Rate this Page

Template Function torch::stable::parallel_for#

Function Documentation#

template<class F>
inline void torch::stable::parallel_for(const int64_t begin, const int64_t end, const int64_t grain_size, const F &f)#

Stable parallel_for utility.

Provides a stable interface to at::parallel_for for parallel execution. The function f will be called with (begin, end) ranges to process in parallel. grain_size controls the minimum work size per thread for efficient parallelization.

Minimum compatible version: PyTorch 2.10.

Template Parameters:

F – The callable type

Parameters:
  • begin – The start of the iteration range.

  • end – The end of the iteration range (exclusive).

  • grain_size – The minimum number of iterations per thread.

  • f – The function to execute in parallel.