• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 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_PYTHON_EAGER_PYWRAP_TENSOR_H_
16 #define TENSORFLOW_PYTHON_EAGER_PYWRAP_TENSOR_H_
17 
18 #include "tensorflow/c/eager/c_api.h"
19 #include "tensorflow/core/framework/types.pb.h"
20 #include "tensorflow/core/platform/types.h"
21 #include "tensorflow/python/lib/core/numpy.h"
22 
23 bool EagerTensor_CheckExact(const PyObject* o);
24 tensorflow::int64 PyEagerTensor_ID(const PyObject* tensor);
25 tensorflow::DataType PyEagerTensor_Dtype(const PyObject* tensor);
26 tensorflow::int64 PyEagerTensor_NumElements(const PyObject* tensor);
27 
28 namespace tensorflow {
29 bool IsCompatible(int desired_dtype, TF_DataType returned_dtype);
30 TFE_TensorHandle* ConvertToEagerTensor(PyObject* value, PyObject* dtype);
31 
32 // TODO(nareshmodi): Move EagerCast and ReadVariableOp (which use the C API to
33 // execute TFE Ops) to a separate common library.
34 TFE_TensorHandle* EagerCast(TFE_Context* ctx, TFE_TensorHandle* handle,
35                             TF_DataType src_type_enum,
36                             TF_DataType dst_type_enum, TF_Status* out_status);
37 }
38 
39 #endif  // TENSORFLOW_PYTHON_EAGER_PYWRAP_TENSOR_H_
40