/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
ATen
/
core
/
/usr/local/lib64/python3.6/site-packages/torch/include/ATen/core
mkdir
upload
Name
Size
Mode
Actions
boxing/
-
0755
rm
dispatch/
-
0755
rm
op_registration/
-
0755
rm
alias_info.h
2986
0644
edit
dl
rm
Array.h
768
0644
edit
dl
rm
ATenGeneral.h
45
0644
edit
dl
rm
ATenOpList.h
246
0644
edit
dl
rm
aten_interned_strings.h
25389
0644
edit
dl
rm
Backtrace.h
59
0644
edit
dl
rm
blob.h
5422
0644
edit
dl
rm
builtin_function.h
3649
0644
edit
dl
rm
DeprecatedTypeProperties.h
3773
0644
edit
dl
rm
DeprecatedTypePropertiesRegistry.h
795
0644
edit
dl
rm
Dict.h
13195
0644
edit
dl
rm
Dict_inl.h
7996
0644
edit
dl
rm
Dimname.h
1188
0644
edit
dl
rm
DimVector.h
247
0644
edit
dl
rm
DistributionsHelper.h
12594
0644
edit
dl
rm
Formatting.h
959
0644
edit
dl
rm
function.h
2145
0644
edit
dl
rm
functional.h
1460
0644
edit
dl
rm
function_schema.h
13577
0644
edit
dl
rm
function_schema_inl.h
9319
0644
edit
dl
rm
Generator.h
4935
0644
edit
dl
rm
grad_mode.h
210
0644
edit
dl
rm
interned_strings.h
25332
0644
edit
dl
rm
interned_strings_class.h
770
0644
edit
dl
rm
ivalue.h
38823
0644
edit
dl
rm
ivalue_inl.h
59963
0644
edit
dl
rm
ivalue_to.h
756
0644
edit
dl
rm
jit_type.h
75971
0644
edit
dl
rm
jit_type_base.h
6508
0644
edit
dl
rm
LegacyTypeDispatch.h
4626
0644
edit
dl
rm
List.h
15667
0644
edit
dl
rm
List_inl.h
11012
0644
edit
dl
rm
Macros.h
44
0644
edit
dl
rm
MT19937RNGEngine.h
6410
0644
edit
dl
rm
NamedTensor.h
5050
0644
edit
dl
rm
operator_name.h
3018
0644
edit
dl
rm
PhiloxRNGEngine.h
6496
0644
edit
dl
rm
PythonModeTLS.h
403
0644
edit
dl
rm
qualified_name.h
4358
0644
edit
dl
rm
QuantizerBase.h
2443
0644
edit
dl
rm
Range.h
418
0644
edit
dl
rm
Reduction.h
461
0644
edit
dl
rm
rref_interface.h
1144
0644
edit
dl
rm
Scalar.h
29
0644
edit
dl
rm
ScalarType.h
33
0644
edit
dl
rm
stack.h
6034
0644
edit
dl
rm
Tensor.h
1756
0644
edit
dl
rm
TensorAccessor.h
10296
0644
edit
dl
rm
TensorBase.h
32767
0644
edit
dl
rm
TensorBody.h
247555
0644
edit
dl
rm
TransformationHelper.h
6911
0644
edit
dl
rm
typeid.h
29
0644
edit
dl
rm
UndefinedTensorImpl.h
42
0644
edit
dl
rm
UnsafeFromTH.h
708
0644
edit
dl
rm
VariableHooksInterface.h
3312
0644
edit
dl
rm
Variadic.h
2257
0644
edit
dl
rm
Vitals.h
2305
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/torch/include/ATen/core/Generator.h
(4935B)
#pragma once #include <stdint.h> #include <mutex> #include <deque> #include <atomic> #include <typeinfo> #include <utility> #include <cstddef> #include <c10/util/Exception.h> #include <c10/util/C++17.h> #include <c10/util/intrusive_ptr.h> #include <c10/core/Device.h> #include <c10/core/DispatchKeySet.h> // For the record I don't think this is a correct pimpl idiom. // Including Impl header in interface header defeats the purpose // because you can't change Impl private members without forcing // everything that included the interface to rebuild. // Impl should be forward-declared in the interface header instead. #include <c10/core/GeneratorImpl.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. */ /** * 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 at { class Tensor; struct TORCH_API Generator { Generator() {} explicit Generator(c10::intrusive_ptr<c10::GeneratorImpl> gen_impl) : impl_(std::move(gen_impl)) { if (impl_.get() == nullptr) { throw std::runtime_error("GeneratorImpl with nullptr is not supported"); } } bool operator==(const Generator& rhs) const { return this->impl_ == rhs.impl_; } bool operator!=(const Generator& rhs) const { return !((*this) == rhs); } bool defined() const { return static_cast<bool>(impl_); } c10::GeneratorImpl* unsafeGetGeneratorImpl() const { return impl_.get(); } c10::GeneratorImpl* unsafeReleaseGeneratorImpl() { return impl_.release(); } const c10::intrusive_ptr<c10::GeneratorImpl>& getIntrusivePtr() const { return impl_; } void set_current_seed(uint64_t seed) { impl_->set_current_seed(seed); } uint64_t current_seed() const { return impl_->current_seed(); } uint64_t seed() { return impl_->seed(); } // Implementation not inlined to prevent cycle reference between // `ATen/core/Generator.h` and `ATen/core/Tensor.h` void set_state(const at::Tensor& new_state); at::Tensor get_state() const; std::mutex& mutex() { return impl_->mutex_; } DispatchKeySet key_set() const { return impl_->key_set(); } Device device() const { return impl_->device(); } inline void set_pyobj(PyObject* pyobj) const noexcept { impl_->set_pyobj(pyobj); } inline PyObject* pyobj() const noexcept { return impl_->pyobj(); } template<typename T> T* get() const { return static_cast<T*>(impl_.get()); } Generator clone() const { return Generator(impl_->clone()); } private: c10::intrusive_ptr<c10::GeneratorImpl> impl_; }; template<class Impl, class... Args> Generator make_generator(Args&&... args) { return Generator(c10::make_intrusive<Impl>(std::forward<Args>(args)...)); } namespace detail { /** * Helper function for checking the validity of new random generator * state. Right now following conditions are checked: * * - The new state tensor must be a torch.ByteTensor * - Data of the new state tensor must be contiguous */ static inline void check_rng_state(const c10::TensorImpl& new_state) { TORCH_CHECK_TYPE( new_state.layout() == kStrided && new_state.device().type() == kCPU && new_state.dtype() == kByte, "RNG state must be a torch.ByteTensor" ); TORCH_CHECK(new_state.is_contiguous(), "RNG state must be contiguous"); } } // namespace detail } // namespace at
Save
cmd:
run