1/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations 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
22namespace 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".
28using StateElementType = int64_t;
29static constexpr DataType STATE_ELEMENT_DTYPE = DT_INT64;
30static constexpr DataType ALGORITHM_DTYPE = STATE_ELEMENT_DTYPE;
31
32using random::PhiloxRandom;
33
34static constexpr int64_t PHILOX_MIN_STATE_SIZE =
35 (PhiloxRandom::ResultType::kElementCount +
36 PhiloxRandom::Key::kElementCount) /
37 2;
38static constexpr int64_t THREEFRY_MIN_STATE_SIZE = 2;
39
40} // end namespace tensorflow
41
42#endif // TENSORFLOW_CORE_KERNELS_STATEFUL_RANDOM_OPS_H_
43