From 4c52286c87ee6810a38cbe47ba83f1310704a21f Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Wed, 30 Sep 2020 10:46:27 -0700 Subject: [PATCH] Plumbing SignatureDefParam and TensorSpec through to the C API. PiperOrigin-RevId: 334632559 Change-Id: Ie4b2d1a5fa9de9bb513758286652b3f250d59a2b --- .../c/experimental/saved_model/internal/BUILD | 100 ++++++++++++++++++ .../signature_def_function_metadata.cc | 15 ++- .../internal/signature_def_param.cc | 33 ++++++ .../internal/signature_def_param_list.cc | 33 ++++++ .../internal/signature_def_param_list_type.h | 33 ++++++ .../internal/signature_def_param_type.h | 30 ++++++ .../saved_model/internal/tensor_spec.cc | 32 ++++++ .../saved_model/internal/tensor_spec_type.h | 30 ++++++ .../c/experimental/saved_model/public/BUILD | 21 ++++ .../saved_model/public/c_saved_model_api.h | 3 + .../public/signature_def_function_metadata.h | 15 +++ .../saved_model/public/signature_def_param.h | 44 ++++++++ .../public/signature_def_param_list.h | 44 ++++++++ .../saved_model/public/tensor_spec.h | 46 ++++++++ 14 files changed, 478 insertions(+), 1 deletion(-) create mode 100644 tensorflow/c/experimental/saved_model/internal/signature_def_param.cc create mode 100644 tensorflow/c/experimental/saved_model/internal/signature_def_param_list.cc create mode 100644 tensorflow/c/experimental/saved_model/internal/signature_def_param_list_type.h create mode 100644 tensorflow/c/experimental/saved_model/internal/signature_def_param_type.h create mode 100644 tensorflow/c/experimental/saved_model/internal/tensor_spec.cc create mode 100644 tensorflow/c/experimental/saved_model/internal/tensor_spec_type.h create mode 100644 tensorflow/c/experimental/saved_model/public/signature_def_param.h create mode 100644 tensorflow/c/experimental/saved_model/public/signature_def_param_list.h create mode 100644 tensorflow/c/experimental/saved_model/public/tensor_spec.h diff --git a/tensorflow/c/experimental/saved_model/internal/BUILD b/tensorflow/c/experimental/saved_model/internal/BUILD index 091f5c86967..57c6c053993 100644 --- a/tensorflow/c/experimental/saved_model/internal/BUILD +++ b/tensorflow/c/experimental/saved_model/internal/BUILD @@ -224,6 +224,8 @@ cc_library( ], deps = [ ":signature_def_function_metadata_type", + ":signature_def_param_list", + ":signature_def_param_list_type", "//tensorflow/c:c_api_macros", "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", ], @@ -240,6 +242,104 @@ cc_library( ], ) +cc_library( + name = "signature_def_param", + srcs = [ + "signature_def_param.cc", + ], + hdrs = [ + "//tensorflow/c/experimental/saved_model/public:signature_def_param.h", + ], + copts = tf_copts(), + visibility = [ + "//tensorflow/c/experimental/saved_model/public:__pkg__", + ], + deps = [ + ":signature_def_param_type", + ":tensor_spec", + ":tensor_spec_type", + "//tensorflow/c:c_api_macros", + "//tensorflow/c:tf_shape_internal", + "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", + ], +) + +cc_library( + name = "signature_def_param_type", + hdrs = [ + "signature_def_param_type.h", + ], + deps = [ + "//tensorflow/c:conversion_macros", + "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", + ], +) + +cc_library( + name = "signature_def_param_list", + srcs = [ + "signature_def_param_list.cc", + ], + hdrs = [ + "//tensorflow/c/experimental/saved_model/public:signature_def_param_list.h", + ], + copts = tf_copts(), + visibility = [ + "//tensorflow/c/experimental/saved_model/public:__pkg__", + ], + deps = [ + ":signature_def_param", + ":signature_def_param_list_type", + ":signature_def_param_type", + "//tensorflow/c:c_api_macros", + ], +) + +cc_library( + name = "signature_def_param_list_type", + hdrs = [ + "signature_def_param_list_type.h", + ], + deps = [ + "//tensorflow/c:conversion_macros", + "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", + ], +) + +cc_library( + name = "tensor_spec", + srcs = [ + "tensor_spec.cc", + ], + hdrs = [ + "//tensorflow/c/experimental/saved_model/public:tensor_spec.h", + ], + copts = tf_copts(), + visibility = [ + "//tensorflow/c/experimental/saved_model/public:__pkg__", + ], + deps = [ + ":tensor_spec_type", + "//tensorflow/c:c_api_macros", + "//tensorflow/c:tf_datatype", + "//tensorflow/c:tf_shape", + "//tensorflow/c:tf_shape_internal", + "//tensorflow/c/experimental/saved_model/core:tensor_spec", + ], +) + +cc_library( + name = "tensor_spec_type", + hdrs = [ + "tensor_spec_type.h", + ], + deps = [ + "//tensorflow/c:conversion_macros", + "//tensorflow/c:tf_shape_internal", + "//tensorflow/c/experimental/saved_model/core:tensor_spec", + ], +) + tf_cc_test( name = "saved_model_api_test", size = "small", diff --git a/tensorflow/c/experimental/saved_model/internal/signature_def_function_metadata.cc b/tensorflow/c/experimental/saved_model/internal/signature_def_function_metadata.cc index c5c3616211c..1c547a94155 100644 --- a/tensorflow/c/experimental/saved_model/internal/signature_def_function_metadata.cc +++ b/tensorflow/c/experimental/saved_model/internal/signature_def_function_metadata.cc @@ -16,5 +16,18 @@ limitations under the License. #include "tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h" #include "tensorflow/c/experimental/saved_model/internal/signature_def_function_metadata_type.h" +#include "tensorflow/c/experimental/saved_model/internal/signature_def_param_list_type.h" -// TODO(bmzhao): Add getter functions here as necessary. +extern "C" { + +extern const TF_SignatureDefParamList* TF_SignatureDefFunctionMetadataArgs( + const TF_SignatureDefFunctionMetadata* list) { + return tensorflow::wrap(&tensorflow::unwrap(list)->arguments()); +} + +extern const TF_SignatureDefParamList* TF_SignatureDefFunctionMetadataReturns( + const TF_SignatureDefFunctionMetadata* list) { + return tensorflow::wrap(&tensorflow::unwrap(list)->returns()); +} + +} // end extern "C" diff --git a/tensorflow/c/experimental/saved_model/internal/signature_def_param.cc b/tensorflow/c/experimental/saved_model/internal/signature_def_param.cc new file mode 100644 index 00000000000..ac54f8f5700 --- /dev/null +++ b/tensorflow/c/experimental/saved_model/internal/signature_def_param.cc @@ -0,0 +1,33 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/c/experimental/saved_model/public/signature_def_param.h" + +#include "tensorflow/c/experimental/saved_model/core/signature_def_function_metadata.h" +#include "tensorflow/c/experimental/saved_model/internal/signature_def_param_type.h" +#include "tensorflow/c/experimental/saved_model/internal/tensor_spec_type.h" + +extern "C" { + +extern const char* TF_SignatureDefParamName(const TF_SignatureDefParam* param) { + return tensorflow::unwrap(param)->name().c_str(); +} + +extern const TF_TensorSpec* TF_SignatureDefParamTensorSpec( + const TF_SignatureDefParam* param) { + return tensorflow::wrap(&tensorflow::unwrap(param)->spec()); +} + +} // end extern "C" diff --git a/tensorflow/c/experimental/saved_model/internal/signature_def_param_list.cc b/tensorflow/c/experimental/saved_model/internal/signature_def_param_list.cc new file mode 100644 index 00000000000..328f21635c3 --- /dev/null +++ b/tensorflow/c/experimental/saved_model/internal/signature_def_param_list.cc @@ -0,0 +1,33 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/c/experimental/saved_model/public/signature_def_param_list.h" + +#include "tensorflow/c/experimental/saved_model/internal/signature_def_param_list_type.h" +#include "tensorflow/c/experimental/saved_model/internal/signature_def_param_type.h" + +extern "C" { + +extern size_t TF_SignatureDefParamListSize( + const TF_SignatureDefParamList* list) { + return tensorflow::unwrap(list)->size(); +} + +extern const TF_SignatureDefParam* TF_SignatureDefParamListGet( + const TF_SignatureDefParamList* list, int i) { + return tensorflow::wrap(&tensorflow::unwrap(list)->at(i)); +} + +} // end extern "C" diff --git a/tensorflow/c/experimental/saved_model/internal/signature_def_param_list_type.h b/tensorflow/c/experimental/saved_model/internal/signature_def_param_list_type.h new file mode 100644 index 00000000000..6f535110cee --- /dev/null +++ b/tensorflow/c/experimental/saved_model/internal/signature_def_param_list_type.h @@ -0,0 +1,33 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_SIGNATURE_DEF_PARAM_LIST_TYPE_H_ +#define TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_SIGNATURE_DEF_PARAM_LIST_TYPE_H_ + +#include + +#include "tensorflow/c/conversion_macros.h" +#include "tensorflow/c/experimental/saved_model/core/signature_def_function_metadata.h" + +typedef struct TF_SignatureDefParamList TF_SignatureDefParamList; + +namespace tensorflow { + +DEFINE_CONVERSION_FUNCTIONS(std::vector, + TF_SignatureDefParamList) + +} // namespace tensorflow + +#endif // TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_SIGNATURE_DEF_PARAM_LIST_TYPE_H_ diff --git a/tensorflow/c/experimental/saved_model/internal/signature_def_param_type.h b/tensorflow/c/experimental/saved_model/internal/signature_def_param_type.h new file mode 100644 index 00000000000..fd634bcddb0 --- /dev/null +++ b/tensorflow/c/experimental/saved_model/internal/signature_def_param_type.h @@ -0,0 +1,30 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_SIGNATURE_DEF_PARAM_TYPE_H_ +#define TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_SIGNATURE_DEF_PARAM_TYPE_H_ + +#include "tensorflow/c/conversion_macros.h" +#include "tensorflow/c/experimental/saved_model/core/signature_def_function_metadata.h" + +typedef struct TF_SignatureDefParam TF_SignatureDefParam; + +namespace tensorflow { + +DEFINE_CONVERSION_FUNCTIONS(tensorflow::SignatureDefParam, TF_SignatureDefParam) + +} // namespace tensorflow + +#endif // TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_SIGNATURE_DEF_PARAM_TYPE_H_ diff --git a/tensorflow/c/experimental/saved_model/internal/tensor_spec.cc b/tensorflow/c/experimental/saved_model/internal/tensor_spec.cc new file mode 100644 index 00000000000..f310adef449 --- /dev/null +++ b/tensorflow/c/experimental/saved_model/internal/tensor_spec.cc @@ -0,0 +1,32 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/c/experimental/saved_model/public/tensor_spec.h" + +#include "tensorflow/c/experimental/saved_model/core/tensor_spec.h" +#include "tensorflow/c/experimental/saved_model/internal/tensor_spec_type.h" +#include "tensorflow/c/tf_shape_internal.h" + +extern "C" { + +TF_DataType TF_TensorSpecDataType(const TF_TensorSpec* spec) { + return static_cast(tensorflow::unwrap(spec)->dtype()); +} + +const TF_Shape* TF_TensorSpecShape(const TF_TensorSpec* spec) { + return tensorflow::wrap(&tensorflow::unwrap(spec)->shape()); +} + +} // end extern "C" diff --git a/tensorflow/c/experimental/saved_model/internal/tensor_spec_type.h b/tensorflow/c/experimental/saved_model/internal/tensor_spec_type.h new file mode 100644 index 00000000000..7284c8a8fb2 --- /dev/null +++ b/tensorflow/c/experimental/saved_model/internal/tensor_spec_type.h @@ -0,0 +1,30 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_TENSOR_SPEC_TYPE_H_ +#define TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_TENSOR_SPEC_TYPE_H_ + +#include "tensorflow/c/conversion_macros.h" +#include "tensorflow/c/experimental/saved_model/core/tensor_spec.h" + +typedef struct TF_TensorSpec TF_TensorSpec; + +namespace tensorflow { + +DEFINE_CONVERSION_FUNCTIONS(tensorflow::TensorSpec, TF_TensorSpec) + +} // namespace tensorflow + +#endif // TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_INTERNAL_TENSOR_SPEC_TYPE_H_ diff --git a/tensorflow/c/experimental/saved_model/public/BUILD b/tensorflow/c/experimental/saved_model/public/BUILD index 33c3ce91aef..4198b0e7ee7 100644 --- a/tensorflow/c/experimental/saved_model/public/BUILD +++ b/tensorflow/c/experimental/saved_model/public/BUILD @@ -28,6 +28,9 @@ exports_files( "saved_model_api.h", "signature_def_function.h", "signature_def_function_metadata.h", + "signature_def_param.h", + "signature_def_param_list.h", + "tensor_spec.h", ], visibility = ["//tensorflow/c/experimental/saved_model/internal:__pkg__"], ) @@ -45,6 +48,9 @@ cc_library( ":saved_model_api", ":signature_def_function", ":signature_def_function_metadata", + ":signature_def_param", + ":signature_def_param_list", + ":tensor_spec", ], ) @@ -77,3 +83,18 @@ alias( name = "signature_def_function_metadata", actual = "//tensorflow/c/experimental/saved_model/internal:signature_def_function_metadata", ) + +alias( + name = "signature_def_param", + actual = "//tensorflow/c/experimental/saved_model/internal:signature_def_param", +) + +alias( + name = "signature_def_param_list", + actual = "//tensorflow/c/experimental/saved_model/internal:signature_def_param_list", +) + +alias( + name = "tensor_spec", + actual = "//tensorflow/c/experimental/saved_model/internal:tensor_spec", +) diff --git a/tensorflow/c/experimental/saved_model/public/c_saved_model_api.h b/tensorflow/c/experimental/saved_model/public/c_saved_model_api.h index cedb9de66b8..68f1ece2991 100644 --- a/tensorflow/c/experimental/saved_model/public/c_saved_model_api.h +++ b/tensorflow/c/experimental/saved_model/public/c_saved_model_api.h @@ -23,6 +23,9 @@ limitations under the License. #include "tensorflow/c/experimental/saved_model/public/saved_model_api.h" #include "tensorflow/c/experimental/saved_model/public/signature_def_function.h" #include "tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h" +#include "tensorflow/c/experimental/saved_model/public/signature_def_param.h" +#include "tensorflow/c/experimental/saved_model/public/signature_def_param_list.h" +#include "tensorflow/c/experimental/saved_model/public/tensor_spec.h" // IWYU pragma: end_exports #endif // TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_C_SAVED_MODEL_API_H_ diff --git a/tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h b/tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h index 6f4459732c4..b7a7f67eb19 100644 --- a/tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h +++ b/tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h @@ -16,6 +16,9 @@ limitations under the License. #ifndef TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_SIGNATURE_DEF_FUNCTION_METADATA_H_ #define TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_SIGNATURE_DEF_FUNCTION_METADATA_H_ +#include "tensorflow/c/c_api_macros.h" +#include "tensorflow/c/experimental/saved_model/public/signature_def_param_list.h" + #ifdef __cplusplus extern "C" { #endif // __cplusplus @@ -24,6 +27,18 @@ extern "C" { // SavedModel. typedef struct TF_SignatureDefFunctionMetadata TF_SignatureDefFunctionMetadata; +// Retrieves the arguments of the SignatureDefFunction. The caller is not +// responsible for freeing the returned pointer. +TF_CAPI_EXPORT extern const TF_SignatureDefParamList* +TF_SignatureDefFunctionMetadataArgs( + const TF_SignatureDefFunctionMetadata* list); + +// Retrieves the returns of the SignatureDefFunction. The caller is not +// responsible for freeing the returned pointer. +TF_CAPI_EXPORT extern const TF_SignatureDefParamList* +TF_SignatureDefFunctionMetadataReturns( + const TF_SignatureDefFunctionMetadata* list); + #ifdef __cplusplus } // end extern "C" #endif // __cplusplus diff --git a/tensorflow/c/experimental/saved_model/public/signature_def_param.h b/tensorflow/c/experimental/saved_model/public/signature_def_param.h new file mode 100644 index 00000000000..82993d7fedf --- /dev/null +++ b/tensorflow/c/experimental/saved_model/public/signature_def_param.h @@ -0,0 +1,44 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_SIGNATURE_DEF_PARAM_H_ +#define TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_SIGNATURE_DEF_PARAM_H_ + +#include "tensorflow/c/c_api_macros.h" +#include "tensorflow/c/experimental/saved_model/public/tensor_spec.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// An opaque type that containing metadata of an input/output of a +// TF_SignatureDefFunction loaded from a SavedModel. +typedef struct TF_SignatureDefParam TF_SignatureDefParam; + +// Returns the name of the given parameter. The caller is not responsible for +// freeing the returned char*. +TF_CAPI_EXPORT extern const char* TF_SignatureDefParamName( + const TF_SignatureDefParam* param); + +// Returns the TensorSpec associated with the given parameter. The caller is +// not reponsible for freeing the returned TF_TensorSpec*. +TF_CAPI_EXPORT extern const TF_TensorSpec* TF_SignatureDefParamTensorSpec( + const TF_SignatureDefParam* param); + +#ifdef __cplusplus +} // end extern "C" +#endif // __cplusplus + +#endif // TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_SIGNATURE_DEF_PARAM_H_ diff --git a/tensorflow/c/experimental/saved_model/public/signature_def_param_list.h b/tensorflow/c/experimental/saved_model/public/signature_def_param_list.h new file mode 100644 index 00000000000..0cb3a0d6d33 --- /dev/null +++ b/tensorflow/c/experimental/saved_model/public/signature_def_param_list.h @@ -0,0 +1,44 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_SIGNATURE_DEF_PARAM_LIST_H_ +#define TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_SIGNATURE_DEF_PARAM_LIST_H_ + +#include + +#include "tensorflow/c/c_api_macros.h" +#include "tensorflow/c/experimental/saved_model/public/signature_def_param.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// An opaque type that containing metadata of an input/output of a +// ConcreteFunction loaded from a SavedModel. +typedef struct TF_SignatureDefParamList TF_SignatureDefParamList; + +// Returns the size of `list`. +TF_CAPI_EXPORT extern size_t TF_SignatureDefParamListSize( + const TF_SignatureDefParamList* list); + +// Returns the `i`th TF_SignatureDefParam in the list. +TF_CAPI_EXPORT extern const TF_SignatureDefParam* TF_SignatureDefParamListGet( + const TF_SignatureDefParamList* list, int i); + +#ifdef __cplusplus +} // end extern "C" +#endif // __cplusplus + +#endif // TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_SIGNATURE_DEF_PARAM_LIST_H_ diff --git a/tensorflow/c/experimental/saved_model/public/tensor_spec.h b/tensorflow/c/experimental/saved_model/public/tensor_spec.h new file mode 100644 index 00000000000..82972ef74ef --- /dev/null +++ b/tensorflow/c/experimental/saved_model/public/tensor_spec.h @@ -0,0 +1,46 @@ +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_TENSOR_SPEC_H_ +#define TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_TENSOR_SPEC_H_ + +#include + +#include "tensorflow/c/c_api_macros.h" +#include "tensorflow/c/tf_datatype.h" +#include "tensorflow/c/tf_shape.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// An opaque type corresponding to TensorSpec +typedef struct TF_TensorSpec TF_TensorSpec; + +// Returns the dtype associated with the TensorSpec. +TF_CAPI_EXPORT extern TF_DataType TF_TensorSpecDataType( + const TF_TensorSpec* spec); + +// Returns the shape associated with the TensorSpec. The returned Shape is not +// owned by the caller. Caller must not call TF_DeleteShape on the returned +// shape. +TF_CAPI_EXPORT extern const TF_Shape* TF_TensorSpecShape( + const TF_TensorSpec* spec); + +#ifdef __cplusplus +} // end extern "C" +#endif // __cplusplus + +#endif // TENSORFLOW_C_EXPERIMENTAL_SAVED_MODEL_PUBLIC_TENSOR_SPEC_H_