torch.profiler.Profiler
class Profilernew Profiler(options: ProfilerOptions = {})
Constructor Parameters
optionsProfilerOptionsoptional- Configuration options for profiling
Profiler for tracking and analyzing operation execution.
Records profiling events during execution and provides statistics and reporting.
Use with profile() function for automatic context management, or manually
with start() and stop().
Examples
// Automatic context management
const profiler = await profile(async () => {
const x = torch.randn([1000, 1000]);
const y = x.matmul(x.t());
});
console.log(profiler.key_averages().table());
// Manual management
const profiler = new Profiler({ record_shapes: true });
profiler.start();
const result = torch.tensor([1, 2, 3]).sum();
await profiler.stop();
console.log(profiler.get_events());