cpp_shape_inference.h revision 6d4956edb02c5a2d0a9bdeb919a4c4c0e55fd882
1/* Copyright 2016 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 THIRD_PARTY_TENSORFLOW_PYTHON_FRAMEWORK_CPP_SHAPE_INFERENCE_H_ 17#define THIRD_PARTY_TENSORFLOW_PYTHON_FRAMEWORK_CPP_SHAPE_INFERENCE_H_ 18 19// Must be included first 20#include "tensorflow/python/lib/core/numpy.h" 21 22#include <vector> 23#include "tensorflow/c/tf_status_helper.h" 24#include "tensorflow/core/platform/types.h" 25 26namespace tensorflow { 27namespace swig { 28 29// Calls the registered C++ shape inference function for <node> (a serialized 30// NodeDef). 31// Should not be called for shape functions that access input tensors; constant 32// input tensor values are not made available, and so the inferred shapes will 33// be less precise than they could be. 34// 35// Returns an error, or OK, in <out_status> according to whether the shape 36// inference was successful. 37// 38// On success, <*output_shapes> is populated with the inferred output shapes (as 39// serialized CppShapeInferenceResult protos). 40// <*output_shapes> must be empty when this function is called. 41// 42// This is temporary code to be used during the migration 43// from python shape inference functions to C++ shape inference functions. 44std::vector<string> RunCppShapeInference( 45 const string& serialized_node_def, 46 const std::vector<string>& input_serialized_shapes, 47 PyObject* input_constant_tensor_values, 48 const std::vector<string>& input_constant_tensor_as_shape_values, 49 TF_Status* out_status); 50 51} // namespace swig 52} // namespace tensorflow 53 54#endif // THIRD_PARTY_TENSORFLOW_PYTHON_FRAMEWORK_CPP_SHAPE_INFERENCE_H_ 55