/
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/MT19937RNGEngine.h
(6410B)
#pragma once // define constants like M_PI and C keywords for MSVC #ifdef _MSC_VER #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #include <math.h> #endif #include <stdint.h> #include <cmath> #include <array> namespace at { constexpr int MERSENNE_STATE_N = 624; constexpr int MERSENNE_STATE_M = 397; constexpr uint32_t MATRIX_A = 0x9908b0df; constexpr uint32_t UMASK = 0x80000000; constexpr uint32_t LMASK = 0x7fffffff; /** * Note [Mt19937 Engine implementation] * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Originally implemented in: * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/MTARCOK/mt19937ar-cok.c * and modified with C++ constructs. Moreover the state array of the engine * has been modified to hold 32 bit uints instead of 64 bits. * * Note that we reimplemented mt19937 instead of using std::mt19937 because, * at::mt19937 turns out to be faster in the pytorch codebase. PyTorch builds with -O2 * by default and following are the benchmark numbers (benchmark code can be found at * https://github.com/syed-ahmed/benchmark-rngs): * * with -O2 * Time to get 100000000 philox randoms with at::uniform_real_distribution = 0.462759s * Time to get 100000000 at::mt19937 randoms with at::uniform_real_distribution = 0.39628s * Time to get 100000000 std::mt19937 randoms with std::uniform_real_distribution = 0.352087s * Time to get 100000000 std::mt19937 randoms with at::uniform_real_distribution = 0.419454s * * std::mt19937 is faster when used in conjunction with std::uniform_real_distribution, * however we can't use std::uniform_real_distribution because of this bug: * http://open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#2524. Plus, even if we used * std::uniform_real_distribution and filtered out the 1's, it is a different algorithm * than what's in pytorch currently and that messes up the tests in tests_distributions.py. * The other option, using std::mt19937 with at::uniform_real_distribution is a tad bit slower * than at::mt19937 with at::uniform_real_distribution and hence, we went with the latter. * * Copyright notice: * A C-program for MT19937, with initialization improved 2002/2/10. * Coded by Takuji Nishimura and Makoto Matsumoto. * This is a faster version by taking Shawn Cokus's optimization, * Matthe Bellew's simplification, Isaku Wada's real version. * * Before using, initialize the state by using init_genrand(seed) * or init_by_array(init_key, key_length). * * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. The names of its contributors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * Any feedback is very welcome. * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) */ /** * mt19937_data_pod is used to get POD data in and out * of mt19937_engine. Used in torch.get_rng_state and * torch.set_rng_state functions. */ struct mt19937_data_pod { uint64_t seed_; int left_; bool seeded_; uint32_t next_; std::array<uint32_t, MERSENNE_STATE_N> state_; }; class mt19937_engine { public: inline explicit mt19937_engine(uint64_t seed = 5489) { init_with_uint32(seed); } inline mt19937_data_pod data() const { return data_; } inline void set_data(mt19937_data_pod data) { data_ = data; } inline uint64_t seed() const { return data_.seed_; } inline bool is_valid() { if ((data_.seeded_ == true) && (data_.left_ > 0 && data_.left_ <= MERSENNE_STATE_N) && (data_.next_ <= MERSENNE_STATE_N)) { return true; } return false; } inline uint32_t operator()() { uint32_t y; if (--(data_.left_) == 0) { next_state(); } y = *(data_.state_.data() + data_.next_++); y ^= (y >> 11); y ^= (y << 7) & 0x9d2c5680; y ^= (y << 15) & 0xefc60000; y ^= (y >> 18); return y; } private: mt19937_data_pod data_; inline void init_with_uint32(uint64_t seed) { data_.seed_ = seed; data_.seeded_ = true; data_.state_[0] = seed & 0xffffffff; for(int j = 1; j < MERSENNE_STATE_N; j++) { data_.state_[j] = (1812433253 * (data_.state_[j-1] ^ (data_.state_[j-1] >> 30)) + j); } data_.left_ = 1; data_.next_ = 0; } inline uint32_t mix_bits(uint32_t u, uint32_t v) { return (u & UMASK) | (v & LMASK); } inline uint32_t twist(uint32_t u, uint32_t v) { return (mix_bits(u,v) >> 1) ^ (v & 1 ? MATRIX_A : 0); } inline void next_state() { uint32_t* p = data_.state_.data(); data_.left_ = MERSENNE_STATE_N; data_.next_ = 0; for(int j = MERSENNE_STATE_N - MERSENNE_STATE_M + 1; --j; p++) { *p = p[MERSENNE_STATE_M] ^ twist(p[0], p[1]); } for(int j = MERSENNE_STATE_M; --j; p++) { *p = p[MERSENNE_STATE_M - MERSENNE_STATE_N] ^ twist(p[0], p[1]); } *p = p[MERSENNE_STATE_M - MERSENNE_STATE_N] ^ twist(p[0], data_.state_[0]); } }; typedef mt19937_engine mt19937; } // namespace at
Save
cmd:
run