torch.get_num_threads
function get_num_threads(): numberReturns the number of threads used for intra-op parallelism.
Intra-op parallelism parallelizes operations within a single tensor operation (e.g., using multiple threads for matrix multiplication). This is typically configured at the BLAS/linear algebra library level in PyTorch.
JavaScript is single-threaded (with Web Workers as an alternative). WebGPU operations are parallelized on the GPU, not through CPU threads.
Returns
number– Always 1 in torch.js (no multi-threading in JavaScript)Examples
// Get intra-op thread count
const threads = torch.get_num_threads();
// torch.js: always 1 (single-threaded)See Also
- PyTorch torch.get_num_threads()
- get_num_interop_threads - Get inter-op thread count