1 | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved. |
2 | |
3 | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | you may not use this file except in compliance with the License. |
5 | You may obtain a copy of the License at |
6 | |
7 | http://www.apache.org/licenses/LICENSE-2.0 |
8 | |
9 | Unless required by applicable law or agreed to in writing, software |
10 | distributed under the License is distributed on an "AS IS" BASIS, |
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | See the License for the specific language governing permissions and |
13 | limitations under the License. |
14 | ==============================================================================*/ |
15 | |
16 | #ifndef TENSORFLOW_CORE_KERNELS_STATEFUL_RANDOM_OPS_H_ |
17 | #define TENSORFLOW_CORE_KERNELS_STATEFUL_RANDOM_OPS_H_ |
18 | |
19 | #include "tensorflow/core/framework/types.h" |
20 | #include "tensorflow/core/lib/random/philox_random.h" |
21 | |
22 | namespace tensorflow { |
23 | |
24 | // 'Variable' doesn't support uint32 or uint64 yet (due to reasons explained |
25 | // in b/111604096 and cl/171681867), so we use signed int here. We choose int64 |
26 | // instead of int32 because `VarHandleOp` doesn't support int32 on GPU, and |
27 | // because of the "int32 problem". |
28 | using StateElementType = int64_t; |
29 | static constexpr DataType STATE_ELEMENT_DTYPE = DT_INT64; |
30 | static constexpr DataType ALGORITHM_DTYPE = STATE_ELEMENT_DTYPE; |
31 | |
32 | using random::PhiloxRandom; |
33 | |
34 | static constexpr int64_t PHILOX_MIN_STATE_SIZE = |
35 | (PhiloxRandom::ResultType::kElementCount + |
36 | PhiloxRandom::Key::kElementCount) / |
37 | 2; |
38 | static constexpr int64_t THREEFRY_MIN_STATE_SIZE = 2; |
39 | |
40 | } // end namespace tensorflow |
41 | |
42 | #endif // TENSORFLOW_CORE_KERNELS_STATEFUL_RANDOM_OPS_H_ |
43 | |