/usr/local/lib64/python3.6/site-packages/torch/include/ATen
NameSizeModeActions
core/-0755rm
cpu/-0755rm
cuda/-0755rm
cudnn/-0755rm
detail/-0755rm
hip/-0755rm
native/-0755rm
quantized/-0755rm
AccumulateType.h44380644editdlrm
ArrayRef.h440644editdlrm
ATen.h9980644editdlrm
autocast_mode.h67160644editdlrm
Backend.h430644editdlrm
Backtrace.h460644editdlrm
BatchedFallback.h9650644editdlrm
BatchedTensorImpl.h53830644editdlrm
CompositeExplicitAutogradFunctions.h16220644editdlrm
CompositeExplicitAutogradFunctions_inl.h540750644editdlrm
CompositeImplicitAutogradFunctions.h16220644editdlrm
CompositeImplicitAutogradFunctions_inl.h1420820644editdlrm
Config.h7340644editdlrm
Context.h127670644editdlrm
cpp_custom_type_hack.h53260644editdlrm
CPUApplyUtils.h125820644editdlrm
CPUFixedAllocator.h8300644editdlrm
CPUFunctions.h16000644editdlrm
CPUFunctions_inl.h1719240644editdlrm
CPUGeneratorImpl.h14310644editdlrm
CUDAFunctions.h16010644editdlrm
CUDAFunctions_inl.h1856960644editdlrm
CUDAGeneratorImpl.h46950644editdlrm
Device.h420644editdlrm
DeviceGuard.h11340644editdlrm
Dimname.h310644editdlrm
DimVector.h460644editdlrm
Dispatch.h521370644editdlrm
div_rtn.h2040644editdlrm
DLConvertor.h5760644editdlrm
dlpack.h52440644editdlrm
DynamicLibrary.h3690644editdlrm
ExpandUtils.h145060644editdlrm
Formatting.h340644editdlrm
Functions.h8463260644editdlrm
Generator.h460644editdlrm
InferSize.h21430644editdlrm
InitialTensorOptions.h4450644editdlrm
Layout.h420644editdlrm
MapAllocator.h29990644editdlrm
MatrixRef.h30160644editdlrm
MemoryOverlap.h11170644editdlrm
MetaFunctions.h16010644editdlrm
MetaFunctions_inl.h840060644editdlrm
NamedTensor.h350644editdlrm
NamedTensorUtils.h57470644editdlrm
NativeFunctions.h3546510644editdlrm
NativeMetaFunctions.h354450644editdlrm
NumericUtils.h27870644editdlrm
OpaqueTensorImpl.h60800644editdlrm
Operators.h17071990644editdlrm
OpMathType.h4600644editdlrm
Parallel.h48750644editdlrm
ParallelNative.h24430644editdlrm
ParallelNativeTBB.h29340644editdlrm
ParallelOpenMP.h30490644editdlrm
PTThreadPool.h3940644editdlrm
record_function.h240440644editdlrm
RedispatchFunctions.h11128860644editdlrm
RegistrationDeclarations.h5457770644editdlrm
SavedTensorHooks.h3280644editdlrm
Scalar.h440644editdlrm
ScalarOps.h22720644editdlrm
ScalarType.h1290644editdlrm
SequenceNumber.h3730644editdlrm
SmallVector.h470644editdlrm
SparseCsrTensorImpl.h20450644editdlrm
SparseCsrTensorUtils.h5230644editdlrm
SparseTensorImpl.h124170644editdlrm
SparseTensorUtils.h42190644editdlrm
Storage.h430644editdlrm
Tensor.h480644editdlrm
TensorAccessor.h510644editdlrm
TensorGeometry.h18550644editdlrm
TensorIndexing.h219230644editdlrm
TensorIterator.h299620644editdlrm
TensorIteratorInternal.h18620644editdlrm
TensorMeta.h29170644editdlrm
TensorNames.h25190644editdlrm
TensorOperators.h32750644editdlrm
TensorOptions.h490644editdlrm
TensorUtils.h56870644editdlrm
ThreadLocalState.h32890644editdlrm
TracerMode.h55760644editdlrm
TypeDefault.h6800644editdlrm
Utils.h59930644editdlrm
Version.h3400644editdlrm
VmapMode.h9520644editdlrm
VmapTransforms.h76540644editdlrm
WrapDimUtils.h34380644editdlrm
WrapDimUtilsMulti.h7680644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/ATen/CUDAGeneratorImpl.h (4695B)
#pragma once #include #include #include #include #include #include // TODO: this file should be in ATen/cuda, not top level namespace at { /** * Note [CUDA Graph-safe RNG states] * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Strategy: * ~~~~~~~~~ * (It helps to look at * cuda/detail/PhiloxCudaStateRaw.cuh and * cuda/detail/UnpackRaw.cuh * while you read this.) * * A CUDA graph containing multiple RNG ops behaves like a * single giant kernel from the perspective of ops external * to the graph. During graph capture, logic below records * the total of all offset increments that occur in the graphed * region, and records the final total as the offset for the * entire graph. * * When the graph reruns, the logic that reruns it * increments this device's CUDA generator's offset * by that total. * * Meanwhile, within the graph, at capture time, instead of * populating PhiloxCudaStates with the uint64_t offset pulled * directly from the global state, PhiloxCudaState instead * holds a pointer to one-element stream-local int64_t device tensor * holding an initial offset value, and a uint64_t holding an * intra-graph offset. (The intra-graph offset starts from zero * when capture begins.) In each consumer kernel, * at::cuda::philox::unpack computes the offset to use for this kernel * as intra-graph offset + *initial offset. * * When the graph reruns, the logic that reruns it first * fill_s the initial offset tensor with this device's * CUDA generator's current offset. * * The control flow above ensures graphed execution is bitwise * identical to eager execution as long as RNG ops are enqueued * from a single thread, even if RNG ops and graphs containing * RNG ops are enqueued and run simultaneously on multiple streams. * * Usage: * ~~~~~~ * PhiloxCudaState in this file, and unpack() in * cuda/CUDAGraphsUtils.cuh allow non-divergent use of * CUDAGeneratorImpl whether graph capture is underway or not. * * Each PhiloxCudaState instance should be used for one and only one * consumer kernel. * * Example (see e.g. native/cuda/Dropout.cu): * * #include * #include * * __global__ void kernel(..., PhiloxCudaState philox_args) { * auto seeds = at::cuda::philox::unpack(philox_args); * IndexType idx = blockIdx.x * blockDim.x + threadIdx.x; * curandStatePhilox4_32_10_t state; * curand_init(std::get<0>(seeds), // seed * idx, // per-thread subsequence * std::get<1>(seeds), // offset in subsequence * &state); * ... * } * * host_caller(...) { * PhiloxCudaState rng_engine_inputs; * { * // See Note [Acquire lock when using random generators] * std::lock_guard lock(gen->mutex_); * * // gen could be HostState or DevState here! No divergent code needed! * rng_engine_inputs = gen->philox_cuda_state(offset_increment); * } * kernel<<<...>>>(..., rng_engine_inputs); * } * */ struct TORCH_CUDA_CPP_API CUDAGeneratorImpl : public c10::GeneratorImpl { // Constructors CUDAGeneratorImpl(DeviceIndex device_index = -1); ~CUDAGeneratorImpl() = default; // CUDAGeneratorImpl methods std::shared_ptr clone() const; void set_current_seed(uint64_t seed) override; uint64_t current_seed() const override; uint64_t seed() override; void set_state(const c10::TensorImpl& new_state) override; c10::intrusive_ptr get_state() const override; void set_philox_offset_per_thread(uint64_t offset); uint64_t philox_offset_per_thread() const; void capture_prologue(int64_t* offset_extragraph); uint64_t capture_epilogue(); PhiloxCudaState philox_cuda_state(uint64_t increment); // Temporarily accommodates call sites that use philox_engine_inputs. // Allows incremental refactor of call sites to use philox_cuda_state. std::pair philox_engine_inputs(uint64_t increment); static DeviceType device_type(); private: CUDAGeneratorImpl* clone_impl() const override; uint64_t seed_ = default_rng_seed_val; uint64_t philox_offset_per_thread_ = 0; int64_t* offset_extragraph_; uint32_t offset_intragraph_ = 0; bool graph_expects_this_gen_ = false; }; namespace cuda { namespace detail { TORCH_CUDA_CPP_API const Generator& getDefaultCUDAGenerator( DeviceIndex device_index = -1); TORCH_CUDA_CPP_API Generator createCUDAGenerator(DeviceIndex device_index = -1); } // namespace detail } // namespace cuda } // namespace at