Skip to content

Instantly share code, notes, and snippets.

@steerapi
Created November 6, 2018 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steerapi/a34e234a2604bf6155a9e0e2d72ac00d to your computer and use it in GitHub Desktop.
Save steerapi/a34e234a2604bf6155a9e0e2d72ac00d to your computer and use it in GitHub Desktop.
var torchjs = require('@idn/torchjs');
var script_module = new torchjs.ScriptModule('resnet18.pt');
var tensor = torchjs.ones([1, 3, 224, 224], false);
const { performance } = require('perf_hooks');
// Comment this out if you don't have cuda
script_module.cuda();
let start, end;
start = performance.now();
let otensor = script_module.forward(tensor);
end = performance.now();
console.log(` gpu: ${end - start} ms`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment