AI-TensorFlow-Libtensorflow
view release on metacpan or search on metacpan
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=head2 TF_GetOutputPropertiesList
=over 2
Get a list of output OpInfo::TensorProperties given node name.
Return the serialized list `properties`.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_GetOutputPropertiesList(
TF_GraphProperties* graph_properties, const char* name,
TF_Buffer** properties, int num_values, TF_Status* status);
=head2 TF_NewFunctionLibraryDefinition
=over 2
Create NewFunctionLibraryDefinition.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern TF_FunctionLibraryDefinition*
TF_NewFunctionLibraryDefinition(const TF_Buffer* graph_buf, TF_Status* status);
=head2 TF_DeleteFunctionLibraryDefinition
=over 2
Delete NewFunctionLibraryDefinition.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_DeleteFunctionLibraryDefinition(
TF_FunctionLibraryDefinition* fn_lib);
=head2 TF_LookUpOpDef
=over 2
Shorthand for calling LookUp to get the OpDef from FunctionLibraryDefinition
given op name. The returned OpDef is represented by TF_Buffer.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_LookUpOpDef(TF_FunctionLibraryDefinition* fn_lib,
const char* name, TF_Buffer* buf,
TF_Status* s);
=head2 TF_TensorSpecDataType
=over 2
Returns the dtype associated with the TensorSpec.
=back
/* From <tensorflow/c/experimental/saved_model/public/tensor_spec.h> */
TF_CAPI_EXPORT extern TF_DataType TF_TensorSpecDataType(
const TF_TensorSpec* spec);
=head2 TF_TensorSpecShape
=over 2
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.
=back
/* From <tensorflow/c/experimental/saved_model/public/tensor_spec.h> */
TF_CAPI_EXPORT extern const TF_Shape* TF_TensorSpecShape(
const TF_TensorSpec* spec);
=head2 TF_InitPlugin
=over 2
/// Initializes a TensorFlow plugin.
///
/// Must be implemented by the plugin DSO. It is called by TensorFlow runtime.
///
/// Filesystem plugins can be loaded on demand by users via
/// `Env::LoadLibrary` or during TensorFlow's startup if they are on certain
/// paths (although this has a security risk if two plugins register for the
/// same filesystem and the malicious one loads before the legimitate one -
/// but we consider this to be something that users should care about and
/// manage themselves). In both of these cases, core TensorFlow looks for
/// the `TF_InitPlugin` symbol and calls this function.
///
/// For every filesystem URI scheme that this plugin supports, the plugin must
/// add one `TF_FilesystemPluginInfo` entry in `plugin_info->ops` and call
/// `TF_SetFilesystemVersionMetadata` for that entry.
///
/// Plugins must also initialize `plugin_info->plugin_memory_allocate` and
/// `plugin_info->plugin_memory_free` to ensure memory allocated by plugin is
/// freed in a compatible way.
=back
/* From <tensorflow/c/experimental/filesystem/filesystem_interface.h> */
TF_CAPI_EXPORT extern void TF_InitPlugin(TF_FilesystemPluginInfo* plugin_info);
=head2 TF_LoadSavedModel
=over 2
Load a SavedModel from `dirname`. We expect the SavedModel to contain a
single Metagraph (as for those exported from TF2's `tf.saved_model.save`).
Params:
dirname - A directory filepath that the SavedModel is at.
ctx - A TFE_Context containing optional load/TF runtime options.
`ctx` must outlive the returned TF_SavedModel pointer.
status - Set to OK on success and an appropriate error on failure.
Returns:
If status is not OK, returns nullptr. Otherwise, returns a newly created
TF_SavedModel instance. It must be deleted by calling TF_DeleteSavedModel.
=back
/* From <tensorflow/c/experimental/saved_model/public/saved_model_api.h> */
TF_CAPI_EXPORT extern TF_SavedModel* TF_LoadSavedModel(const char* dirname,
TFE_Context* ctx,
TF_Status* status);
=head2 TF_LoadSavedModelWithTags
=over 2
Load a SavedModel from `dirname`.
Params:
dirname - A directory filepath that the SavedModel is at.
ctx - A TFE_Context containing optional load/TF runtime options.
`ctx` must outlive the returned TF_SavedModel pointer.
tags - char* array of SavedModel tags. We will load the metagraph matching
the tags.
tags_len - number of elements in the `tags` array.
status - Set to OK on success and an appropriate error on failure.
Returns:
If status is not OK, returns nullptr. Otherwise, returns a newly created
TF_SavedModel instance. It must be deleted by calling TF_DeleteSavedModel.
=back
/* From <tensorflow/c/experimental/saved_model/public/saved_model_api.h> */
TF_CAPI_EXPORT extern TF_SavedModel* TF_LoadSavedModelWithTags(
const char* dirname, TFE_Context* ctx, const char* const* tags,
int tags_len, TF_Status* status);
=head2 TF_DeleteSavedModel
=over 2
Deletes a TF_SavedModel, and frees any resources owned by it.
=back
/* From <tensorflow/c/experimental/saved_model/public/saved_model_api.h> */
TF_CAPI_EXPORT extern void TF_DeleteSavedModel(TF_SavedModel* model);
=head2 TF_GetSavedModelConcreteFunction
=over 2
Retrieve a function from the TF2 SavedModel via function path.
Params:
model - The TF2 SavedModel to load a function from.
function_path - A string containing the path from the root saved python
object to a tf.function method.
TODO(bmzhao): Add a detailed example of this with a
python tf.module before moving this out of experimental.
status - Set to OK on success and an appropriate error on failure.
Returns:
If status is not OK, returns nullptr. Otherwise, returns a
TF_ConcreteFunction instance. The lifetime of this instance is
"conceptually" bound to `model`. Once `model` is deleted, all
`TF_ConcreteFunctions` retrieved from it are invalid, and have been deleted.
=back
/* From <tensorflow/c/experimental/saved_model/public/saved_model_api.h> */
TF_CAPI_EXPORT extern TF_ConcreteFunction* TF_GetSavedModelConcreteFunction(
TF_SavedModel* model, const char* function_path, TF_Status* status);
=head2 TF_GetSavedModelSignatureDefFunction
=over 2
Retrieve a function from the TF SavedModel via a SignatureDef key.
Params:
model - The SavedModel to load a function from.
signature_def_key - The string key of the SignatureDef map of a SavedModel:
https://github.com/tensorflow/tensorflow/blob/69b08900b1e991d84bce31f3b404f5ed768f339f/tensorflow/core/protobuf/meta_graph.proto#L89
status - Set to OK on success and an appropriate error on failure.
Returns:
If status is not OK, returns nullptr. Otherwise, returns a
TF_SignatureDefFunction instance. Once `model` is deleted, all
`TF_SignatureDefFunctions` retrieved from it are invalid, and have been
deleted.
=back
/* From <tensorflow/c/experimental/saved_model/public/saved_model_api.h> */
TF_CAPI_EXPORT extern TF_SignatureDefFunction*
TF_GetSavedModelSignatureDefFunction(TF_SavedModel* model,
const char* signature_def_key,
TF_Status* status);
=head2 TF_ConcreteFunctionGetMetadata
=over 2
Returns FunctionMetadata associated with `func`. Metadata's lifetime is
bound to `func`, which is bound to the TF_SavedModel it was loaded from.
=back
/* From <tensorflow/c/experimental/saved_model/public/concrete_function.h> */
TF_CAPI_EXPORT extern TF_FunctionMetadata* TF_ConcreteFunctionGetMetadata(
TF_ConcreteFunction* func);
=head2 TF_ConcreteFunctionMakeCallOp
=over 2
Returns a TFE_Op suitable for executing this function. Caller must provide
all function inputs in `inputs`, and must not add any additional inputs on
the returned op. (i.e. don't call TFE_OpAddInput or TFE_OpAddInputList).
The caller is responsible for deleting the returned TFE_Op. If op
construction fails, `status` will be non-OK and the returned pointer will be
null.
TODO(bmzhao): Remove this function in a subsequent change; Design + implement
a Function Execution interface for ConcreteFunction that accepts a tagged
union of types (tensorflow::Value). This effectively requires moving much of
the implementation of function.py/def_function.py to C++, and exposing a
high-level API here. A strawman for what this interface could look like:
TF_Value* TF_ExecuteFunction(TFE_Context*, TF_ConcreteFunction*, TF_Value*
inputs, int num_inputs, TF_Status* status);
=back
/* From <tensorflow/c/experimental/saved_model/public/concrete_function.h> */
TF_CAPI_EXPORT extern TFE_Op* TF_ConcreteFunctionMakeCallOp(
TF_ConcreteFunction* func, TFE_TensorHandle** inputs, int num_inputs,
TF_Status* status);
=head2 TF_SignatureDefParamName
=over 2
Returns the name of the given parameter. The caller is not responsible for
freeing the returned char*.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_param.h> */
TF_CAPI_EXPORT extern const char* TF_SignatureDefParamName(
const TF_SignatureDefParam* param);
=head2 TF_SignatureDefParamTensorSpec
=over 2
Returns the TensorSpec associated with the given parameter. The caller is
not reponsible for freeing the returned TF_TensorSpec*.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_param.h> */
TF_CAPI_EXPORT extern const TF_TensorSpec* TF_SignatureDefParamTensorSpec(
const TF_SignatureDefParam* param);
=head2 TF_SignatureDefFunctionGetMetadata
=over 2
Returns FunctionMetadata associated with `func`. Metadata's lifetime is
bound to `func`, which is bound to the TF_SavedModel it was loaded from.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_function.h> */
TF_CAPI_EXPORT extern TF_SignatureDefFunctionMetadata*
TF_SignatureDefFunctionGetMetadata(TF_SignatureDefFunction* func);
=head2 TF_SignatureDefFunctionMakeCallOp
=over 2
Returns a TFE_Op suitable for executing this function. Caller must provide
all function inputs in `inputs`, and must not add any additional inputs on
the returned op. (i.e. don't call TFE_OpAddInput or TFE_OpAddInputList).
The caller is responsible for deleting the returned TFE_Op. If op
construction fails, `status` will be non-OK and the returned pointer will be
null.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_function.h> */
TF_CAPI_EXPORT extern TFE_Op* TF_SignatureDefFunctionMakeCallOp(
TF_SignatureDefFunction* func, TFE_TensorHandle** inputs, int num_inputs,
TF_Status* status);
=head2 TF_ConcreteFunctionListSize
=over 2
Returns the size of `list`.
=back
/* From <tensorflow/c/experimental/saved_model/public/concrete_function_list.h> */
TF_CAPI_EXPORT extern size_t TF_ConcreteFunctionListSize(
TF_ConcreteFunctionList* list);
=head2 TF_ConcreteFunctionListGet
=over 2
Returns the `i`th TF_ConcreteFunction in the list.
=back
/* From <tensorflow/c/experimental/saved_model/public/concrete_function_list.h> */
TF_CAPI_EXPORT extern TF_ConcreteFunction* TF_ConcreteFunctionListGet(
TF_ConcreteFunctionList* list, int i);
=head2 TF_DeleteConcreteFunctionList
=over 2
Deletes `list`.
=back
/* From <tensorflow/c/experimental/saved_model/public/concrete_function_list.h> */
TF_CAPI_EXPORT extern void TF_DeleteConcreteFunctionList(
TF_ConcreteFunctionList* list);
=head2 TF_SignatureDefParamListSize
=over 2
Returns the size of `list`.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_param_list.h> */
TF_CAPI_EXPORT extern size_t TF_SignatureDefParamListSize(
const TF_SignatureDefParamList* list);
=head2 TF_SignatureDefParamListGet
=over 2
Returns the `i`th TF_SignatureDefParam in the list.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_param_list.h> */
TF_CAPI_EXPORT extern const TF_SignatureDefParam* TF_SignatureDefParamListGet(
const TF_SignatureDefParamList* list, int i);
=head2 TF_SignatureDefFunctionMetadataArgs
=over 2
Retrieves the arguments of the SignatureDefFunction. The caller is not
responsible for freeing the returned pointer.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h> */
TF_CAPI_EXPORT extern const TF_SignatureDefParamList*
TF_SignatureDefFunctionMetadataArgs(
const TF_SignatureDefFunctionMetadata* list);
=head2 TF_SignatureDefFunctionMetadataReturns
=over 2
Retrieves the returns of the SignatureDefFunction. The caller is not
responsible for freeing the returned pointer.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h> */
TF_CAPI_EXPORT extern const TF_SignatureDefParamList*
TF_SignatureDefFunctionMetadataReturns(
const TF_SignatureDefFunctionMetadata* list);
=head2 TF_EnableXLACompilation
=over 2
When `enable` is true, set
tensorflow.ConfigProto.OptimizerOptions.global_jit_level to ON_1, and also
set XLA flag values to prepare for XLA compilation. Otherwise set
global_jit_level to OFF.
This and the next API are syntax sugar over TF_SetConfig(), and is used by
clients that cannot read/write the tensorflow.ConfigProto proto.
TODO: Migrate to TF_CreateConfig() below.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TF_EnableXLACompilation(TF_SessionOptions* options,
unsigned char enable);
=head2 TF_SetXlaEnableLazyCompilation
=over 2
Set XLA's internal BuildXlaOpsPassFlags.tf_xla_enable_lazy_compilation to the
value of 'enabled'. Also returns the original value of that flag.
Use in tests to allow XLA to fallback to TF classic. This has global effect.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT unsigned char TF_SetXlaEnableLazyCompilation(
unsigned char enable);
=head2 TF_SetTfXlaCpuGlobalJit
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT unsigned char TF_SetTfXlaCpuGlobalJit(unsigned char enable);
=head2 TF_SetXlaAutoJitMode
=over 2
Sets XLA's auto jit mode according to the specified string, which is parsed
as if passed in XLA_FLAGS. This has global effect.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT void TF_SetXlaAutoJitMode(const char* mode);
=head2 TF_GetXlaAutoJitEnabled
( run in 0.788 second using v1.01-cache-2.11-cpan-39bf76dae61 )