1 /* Copyright 2018 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 #ifndef TENSORFLOW_C_EAGER_C_API_TEST_UTIL_H_ 16 #define TENSORFLOW_C_EAGER_C_API_TEST_UTIL_H_ 17 18 #include "tensorflow/c/eager/c_api.h" 19 20 #include "tensorflow/core/platform/types.h" 21 22 // Return a tensor handle containing a float scalar 23 TFE_TensorHandle* TestScalarTensorHandle(float value); 24 25 // Return a tensor handle containing a int scalar 26 TFE_TensorHandle* TestScalarTensorHandle(int value); 27 28 // Return a tensor handle containing a bool scalar 29 TFE_TensorHandle* TestScalarTensorHandle(bool value); 30 31 // Return a tensor handle containing a 2x2 matrix of doubles 32 TFE_TensorHandle* DoubleTestMatrixTensorHandle(); 33 34 // Return a tensor handle containing a 2x2 matrix of floats 35 TFE_TensorHandle* TestMatrixTensorHandle(); 36 37 // Return a tensor handle containing a 3x2 matrix of doubles 38 TFE_TensorHandle* DoubleTestMatrixTensorHandle3X2(); 39 40 // Return a tensor handle containing a 3x2 matrix of floats 41 TFE_TensorHandle* TestMatrixTensorHandle3X2(); 42 43 // Return a matmul op multiplying `a` by `b`. 44 TFE_Op* MatMulOp(TFE_Context* ctx, TFE_TensorHandle* a, TFE_TensorHandle* b); 45 46 // Return a shape op fetching the shape of `a`. 47 TFE_Op* ShapeOp(TFE_Context* ctx, TFE_TensorHandle* a); 48 49 // Return an 1-D INT32 tensor containing a single value 1. 50 TFE_TensorHandle* TestAxisTensorHandle(); 51 52 // Return an op taking minimum of `input` long `axis` dimension. 53 TFE_Op* MinOp(TFE_Context* ctx, TFE_TensorHandle* input, 54 TFE_TensorHandle* axis); 55 56 // If there is a device of type `device_type`, returns true 57 // and sets 'device_name' accordingly. 58 // `device_type` must be either "GPU" or "TPU". 59 bool GetDeviceName(TFE_Context* ctx, tensorflow::string* device_name, 60 const char* device_type); 61 62 #endif // TENSORFLOW_C_EAGER_C_API_TEST_UTIL_H_ 63