/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
c10
/
core
/
/usr/local/lib64/python3.6/site-packages/torch/include/c10/core
mkdir
upload
Name
Size
Mode
Actions
impl/
-
0755
rm
Allocator.h
8725
0644
edit
dl
rm
AutogradState.h
994
0644
edit
dl
rm
Backend.h
8487
0644
edit
dl
rm
CompileTimeFunctionPointer.h
1677
0644
edit
dl
rm
CopyBytes.h
1229
0644
edit
dl
rm
CPUAllocator.h
2267
0644
edit
dl
rm
DefaultDtype.h
394
0644
edit
dl
rm
DefaultTensorOptions.h
1032
0644
edit
dl
rm
Device.h
5396
0644
edit
dl
rm
DeviceGuard.h
7555
0644
edit
dl
rm
DeviceType.h
2994
0644
edit
dl
rm
DispatchKey.h
18069
0644
edit
dl
rm
DispatchKeySet.h
12951
0644
edit
dl
rm
Event.h
4169
0644
edit
dl
rm
GeneratorImpl.h
3713
0644
edit
dl
rm
GradMode.h
1261
0644
edit
dl
rm
InferenceMode.h
3471
0644
edit
dl
rm
Layout.h
1225
0644
edit
dl
rm
MemoryFormat.h
8571
0644
edit
dl
rm
OptionalRef.h
521
0644
edit
dl
rm
QEngine.h
861
0644
edit
dl
rm
QScheme.h
1562
0644
edit
dl
rm
Scalar.h
6019
0644
edit
dl
rm
ScalarType.h
17073
0644
edit
dl
rm
ScalarTypeToTypeMeta.h
1365
0644
edit
dl
rm
Storage.h
4369
0644
edit
dl
rm
StorageImpl.h
5610
0644
edit
dl
rm
Stream.h
7373
0644
edit
dl
rm
StreamGuard.h
6315
0644
edit
dl
rm
TensorImpl.h
96152
0644
edit
dl
rm
TensorOptions.h
27593
0644
edit
dl
rm
thread_pool.h
2992
0644
edit
dl
rm
UndefinedTensorImpl.h
911
0644
edit
dl
rm
WrapDimMinimal.h
805
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/torch/include/c10/core/GeneratorImpl.h
(3713B)
#pragma once #include <stdint.h> #include <atomic> #include <deque> #include <mutex> #include <typeinfo> #include <utility> #include <c10/core/Device.h> #include <c10/core/DispatchKeySet.h> #include <c10/core/TensorImpl.h> #include <c10/util/C++17.h> #include <c10/util/Exception.h> #include <c10/util/intrusive_ptr.h> #include <c10/util/python_stub.h> /** * Note [Generator] * ~~~~~~~~~~~~~~~~ * A Pseudo Random Number Generator (PRNG) is an engine that uses an algorithm * to generate a seemingly random sequence of numbers, that may be later be used * in creating a random distribution. Such an engine almost always maintains a * state and requires a seed to start off the creation of random numbers. Often * times, users have found it beneficial to be able to explicitly create, * retain, and destroy PRNG states and also be able to have control over the * seed value. * * A Generator in ATen gives users the ability to read, write and modify a PRNG * engine. For instance, it does so by letting users seed a PRNG engine, fork * the state of the engine, etc. * * By default, there is one generator per device, and a device's generator is * lazily created. A user can use the torch.Generator() api to create their own * generator. Currently torch.Generator() can only create a CPUGeneratorImpl. */ /** * Note [Acquire lock when using random generators] * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Generator and its derived classes are NOT thread-safe. Please note that most * of the places where we have inserted locking for generators are historically * based, and we haven't actually checked that everything is truly thread safe * (and it probably isn't). Please use the public mutex_ when using any methods * from these classes, except for the read-only methods. You can learn about the * usage by looking into the unittests (aten/src/ATen/cpu_generator_test.cpp) * and other places where we have used lock_guard. * * TODO: Look into changing the threading semantics of Generators in ATen (e.g., * making them non-thread safe and instead making the generator state * splittable, to accommodate forks into other threads). */ namespace c10 { // The default seed is selected to be a large number // with good distribution of 0s and 1s in bit representation constexpr uint64_t default_rng_seed_val = 67280421310721; struct C10_API GeneratorImpl : public c10::intrusive_ptr_target { // Constructors GeneratorImpl(Device device_in, DispatchKeySet key_set); // Delete all copy and move assignment in favor of clone() // method GeneratorImpl(const GeneratorImpl& other) = delete; GeneratorImpl(GeneratorImpl&& other) = delete; GeneratorImpl& operator=(const GeneratorImpl& other) = delete; virtual ~GeneratorImpl() = default; c10::intrusive_ptr<GeneratorImpl> clone() const; // Common methods for all generators virtual void set_current_seed(uint64_t seed) = 0; virtual uint64_t current_seed() const = 0; virtual uint64_t seed() = 0; virtual void set_state(const c10::TensorImpl& new_state) = 0; virtual c10::intrusive_ptr<c10::TensorImpl> get_state() const = 0; Device device() const; // See Note [Acquire lock when using random generators] std::mutex mutex_; DispatchKeySet key_set() const { return key_set_; } inline void set_pyobj(PyObject* pyobj) noexcept { pyobj_ = pyobj; } inline PyObject* pyobj() const noexcept { return pyobj_; } protected: Device device_; DispatchKeySet key_set_; PyObject* pyobj_ = nullptr; virtual GeneratorImpl* clone_impl() const = 0; }; namespace detail { TORCH_API uint64_t getNonDeterministicRandom(bool is_cuda = false); } // namespace detail } // namespace c10
Save
cmd:
run