1/* Copyright 2020 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_STATELESS_RANDOM_OPS_V2_H_
17#define TENSORFLOW_CORE_KERNELS_STATELESS_RANDOM_OPS_V2_H_
18
19#include "tensorflow/core/framework/rng_alg.h"
20#include "tensorflow/core/framework/tensor_shape.h"
21
22namespace tensorflow {
23
24inline Status CheckKeyCounterShape(int minimum_counter_size,
25 TensorShape const& key_shape,
26 TensorShape const& counter_shape) {
27 if (!(key_shape.dims() == 1 && key_shape.dim_size(0) == RNG_KEY_SIZE)) {
28 return errors::InvalidArgument(
29 "key must have shape [", RNG_KEY_SIZE, "], not ",
30 key_shape.DebugString(),
31 ". (Note that batched keys are not supported yet.)");
32 }
33 if (!(counter_shape.dims() == 1 &&
34 counter_shape.dim_size(0) >= minimum_counter_size)) {
35 return errors::InvalidArgument(
36 "counter must be a vector with length at least ", minimum_counter_size,
37 "; got shape: ", counter_shape.DebugString(),
38 ". (Note that batched counters are not supported yet.)");
39 }
40 return OkStatus();
41}
42
43} // end namespace tensorflow
44
45#endif // TENSORFLOW_CORE_KERNELS_STATELESS_RANDOM_OPS_V2_H_
46