AI-TensorFlow-Libtensorflow
view release on metacpan or search on metacpan
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=head2 TF_ImportGraphDefOptionsSetDefaultDevice
=over 2
Set the execution device for nodes in `graph_def`.
Only applies to nodes where a device was not already explicitly specified.
`device` is copied and has no lifetime requirements.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefOptionsSetDefaultDevice(
TF_ImportGraphDefOptions* opts, const char* device);
=head2 TF_ImportGraphDefOptionsSetUniquifyNames
=over 2
Set whether to uniquify imported operation names. If true, imported operation
names will be modified if their name already exists in the graph. If false,
conflicting names will be treated as an error. Note that this option has no
effect if a prefix is set, since the prefix will guarantee all names are
unique. Defaults to false.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefOptionsSetUniquifyNames(
TF_ImportGraphDefOptions* opts, unsigned char uniquify_names);
=head2 TF_ImportGraphDefOptionsSetUniquifyPrefix
=over 2
If true, the specified prefix will be modified if it already exists as an
operation name or prefix in the graph. If false, a conflicting prefix will be
treated as an error. This option has no effect if no prefix is specified.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefOptionsSetUniquifyPrefix(
TF_ImportGraphDefOptions* opts, unsigned char uniquify_prefix);
=head2 TF_ImportGraphDefOptionsAddInputMapping
=over 2
Set any imported nodes with input `src_name:src_index` to have that input
replaced with `dst`. `src_name` refers to a node in the graph to be imported,
`dst` references a node already existing in the graph being imported into.
`src_name` is copied and has no lifetime requirements.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefOptionsAddInputMapping(
TF_ImportGraphDefOptions* opts, const char* src_name, int src_index,
TF_Output dst);
=head2 TF_ImportGraphDefOptionsRemapControlDependency
=over 2
Set any imported nodes with control input `src_name` to have that input
replaced with `dst`. `src_name` refers to a node in the graph to be imported,
`dst` references an operation already existing in the graph being imported
into. `src_name` is copied and has no lifetime requirements.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefOptionsRemapControlDependency(
TF_ImportGraphDefOptions* opts, const char* src_name, TF_Operation* dst);
=head2 TF_ImportGraphDefOptionsAddControlDependency
=over 2
Cause the imported graph to have a control dependency on `oper`. `oper`
should exist in the graph being imported into.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefOptionsAddControlDependency(
TF_ImportGraphDefOptions* opts, TF_Operation* oper);
=head2 TF_ImportGraphDefOptionsAddReturnOutput
=over 2
Add an output in `graph_def` to be returned via the `return_outputs` output
parameter of TF_GraphImportGraphDef(). If the output is remapped via an input
mapping, the corresponding existing tensor in `graph` will be returned.
`oper_name` is copied and has no lifetime requirements.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefOptionsAddReturnOutput(
TF_ImportGraphDefOptions* opts, const char* oper_name, int index);
=head2 TF_ImportGraphDefOptionsNumReturnOutputs
=over 2
Returns the number of return outputs added via
TF_ImportGraphDefOptionsAddReturnOutput().
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_ImportGraphDefOptionsNumReturnOutputs(
const TF_ImportGraphDefOptions* opts);
=head2 TF_ImportGraphDefOptionsAddReturnOperation
=over 2
Add an operation in `graph_def` to be returned via the `return_opers` output
parameter of TF_GraphImportGraphDef(). `oper_name` is copied and has no
lifetime requirements.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefOptionsAddReturnOperation(
TF_ImportGraphDefOptions* opts, const char* oper_name);
=head2 TF_ImportGraphDefOptionsNumReturnOperations
=over 2
Returns the number of return operations added via
TF_ImportGraphDefOptionsAddReturnOperation().
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_ImportGraphDefOptionsNumReturnOperations(
const TF_ImportGraphDefOptions* opts);
=head2 TF_ImportGraphDefResultsReturnOutputs
=over 2
Fetches the return outputs requested via
TF_ImportGraphDefOptionsAddReturnOutput(). The number of fetched outputs is
returned in `num_outputs`. The array of return outputs is returned in
`outputs`. `*outputs` is owned by and has the lifetime of `results`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefResultsReturnOutputs(
TF_ImportGraphDefResults* results, int* num_outputs, TF_Output** outputs);
=head2 TF_ImportGraphDefResultsReturnOperations
=over 2
Fetches the return operations requested via
TF_ImportGraphDefOptionsAddReturnOperation(). The number of fetched
operations is returned in `num_opers`. The array of return operations is
returned in `opers`. `*opers` is owned by and has the lifetime of `results`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefResultsReturnOperations(
TF_ImportGraphDefResults* results, int* num_opers, TF_Operation*** opers);
=head2 TF_ImportGraphDefResultsMissingUnusedInputMappings
=over 2
Fetches any input mappings requested via
TF_ImportGraphDefOptionsAddInputMapping() that didn't appear in the GraphDef
and weren't used as input to any node in the imported graph def. The number
of fetched mappings is returned in `num_missing_unused_input_mappings`. The
array of each mapping's source node name is returned in `src_names`, and the
array of each mapping's source index is returned in `src_indexes`.
`*src_names`, `*src_indexes`, and the memory backing each string in
`src_names` are owned by and have the lifetime of `results`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ImportGraphDefResultsMissingUnusedInputMappings(
TF_ImportGraphDefResults* results, int* num_missing_unused_input_mappings,
const char*** src_names, int** src_indexes);
=head2 TF_DeleteImportGraphDefResults
=over 2
Deletes a results object returned by TF_GraphImportGraphDefWithResults().
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_DeleteImportGraphDefResults(
TF_ImportGraphDefResults* results);
=head2 TF_GraphImportGraphDefWithResults
=over 2
Import the graph serialized in `graph_def` into `graph`. Returns nullptr and
a bad status on error. Otherwise, returns a populated
TF_ImportGraphDefResults instance. The returned instance must be deleted via
TF_DeleteImportGraphDefResults().
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_ImportGraphDefResults*
TF_GraphImportGraphDefWithResults(TF_Graph* graph, const TF_Buffer* graph_def,
const TF_ImportGraphDefOptions* options,
TF_Status* status);
=head2 TF_GraphImportGraphDefWithReturnOutputs
=over 2
Import the graph serialized in `graph_def` into `graph`.
Convenience function for when only return outputs are needed.
`num_return_outputs` must be the number of return outputs added (i.e. the
result of TF_ImportGraphDefOptionsNumReturnOutputs()). If
`num_return_outputs` is non-zero, `return_outputs` must be of length
`num_return_outputs`. Otherwise it can be null.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_GraphImportGraphDefWithReturnOutputs(
TF_Graph* graph, const TF_Buffer* graph_def,
const TF_ImportGraphDefOptions* options, TF_Output* return_outputs,
int num_return_outputs, TF_Status* status);
=head2 TF_GraphImportGraphDef
=over 2
Import the graph serialized in `graph_def` into `graph`.
Convenience function for when no results are needed.
=back
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Buffer TF_GetOpList(TF_Library* lib_handle);
=head2 TF_DeleteLibraryHandle
=over 2
Frees the memory associated with the library handle.
Does NOT unload the library.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_DeleteLibraryHandle(TF_Library* lib_handle);
=head2 TF_GetAllOpList
=over 2
Get the OpList of all OpDefs defined in this address space.
Returns a TF_Buffer, ownership of which is transferred to the caller
(and can be freed using TF_DeleteBuffer).
The data in the buffer will be the serialized OpList proto for ops registered
in this address space.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Buffer* TF_GetAllOpList(void);
=head2 TF_NewApiDefMap
=over 2
Creates a new TF_ApiDefMap instance.
Params:
op_list_buffer - TF_Buffer instance containing serialized OpList
protocol buffer. (See
https://www.tensorflow.org/code/tensorflow/core/framework/op_def.proto
for the OpList proto definition).
status - Set to OK on success and an appropriate error on failure.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_ApiDefMap* TF_NewApiDefMap(TF_Buffer* op_list_buffer,
TF_Status* status);
=head2 TF_DeleteApiDefMap
=over 2
Deallocates a TF_ApiDefMap.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_DeleteApiDefMap(TF_ApiDefMap* apimap);
=head2 TF_ApiDefMapPut
=over 2
Add ApiDefs to the map.
`text` corresponds to a text representation of an ApiDefs protocol message.
(https://www.tensorflow.org/code/tensorflow/core/framework/api_def.proto).
The provided ApiDefs will be merged with existing ones in the map, with
precedence given to the newly added version in case of conflicts with
previous calls to TF_ApiDefMapPut.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ApiDefMapPut(TF_ApiDefMap* api_def_map,
const char* text, size_t text_len,
TF_Status* status);
=head2 TF_ApiDefMapGet
=over 2
Returns a serialized ApiDef protocol buffer for the TensorFlow operation
named `name`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Buffer* TF_ApiDefMapGet(TF_ApiDefMap* api_def_map,
const char* name,
size_t name_len,
TF_Status* status);
=head2 TF_GetAllRegisteredKernels
=over 2
Returns a serialized KernelList protocol buffer containing KernelDefs for all
registered kernels.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Buffer* TF_GetAllRegisteredKernels(TF_Status* status);
=head2 TF_GetRegisteredKernelsForOp
=over 2
Returns a serialized KernelList protocol buffer containing KernelDefs for all
kernels registered for the operation named `name`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Buffer* TF_GetRegisteredKernelsForOp(
const char* name, TF_Status* status);
=head2 TF_UpdateEdge
=over 2
Update edge, switch input/ output in a node
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_UpdateEdge(TF_Graph* graph, TF_Output new_src,
TF_Input dst, TF_Status* status);
=head2 TF_NewServer
=over 2
Creates a new in-process TensorFlow server configured using a serialized
ServerDef protocol buffer provided via `proto` and `proto_len`.
The server will not serve any requests until TF_ServerStart is invoked.
The server will stop serving requests once TF_ServerStop or
TF_DeleteServer is invoked.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Server* TF_NewServer(const void* proto,
size_t proto_len,
TF_Status* status);
=head2 TF_ServerStart
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=over 2
Creates a new TensorHandle from memory residing in the physical device
device_name. Takes ownership of the memory, and will call deleter to release
it after TF no longer needs it or in case of error.
Custom devices must use TFE_NewCustomDeviceTensorHandle instead.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern TFE_TensorHandle* TFE_NewTensorHandleFromDeviceMemory(
TFE_Context* ctx, const char* device_name, TF_DataType, const int64_t* dims,
int num_dims, void* data, size_t len,
void (*deallocator)(void* data, size_t len, void* arg),
void* deallocator_arg, TF_Status* status);
=head2 TFE_HostAddressSpace
=over 2
Retrieves the address space (i.e. job, replia, task) of the local host and
saves it in the buffer.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_HostAddressSpace(TFE_Context* ctx,
TF_Buffer* buf);
=head2 TFE_OpGetAttrs
=over 2
Fetch a reference to `op`'s attributes. The returned reference is only valid
while `op` is alive.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern const TFE_OpAttrs* TFE_OpGetAttrs(const TFE_Op* op);
=head2 TFE_OpAddAttrs
=over 2
Add attributes in `attrs` to `op`.
Does not overwrite or update existing attributes, but adds new ones.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_OpAddAttrs(TFE_Op* op, const TFE_OpAttrs* attrs);
=head2 TFE_OpAttrsSerialize
=over 2
Serialize `attrs` as a tensorflow::NameAttrList protocol buffer (into `buf`),
containing the op name and a map of its attributes.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_OpAttrsSerialize(const TFE_OpAttrs* attrs,
TF_Buffer* buf,
TF_Status* status);
=head2 TFE_OpSetAttrValueProto
=over 2
Set an op's attribute from a serialized AttrValue protocol buffer.
Analogous to TF_SetAttrValueProto for building graph operations.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrValueProto(const TFE_Op* op,
const char* attr_name,
const void* proto,
size_t proto_len,
TF_Status* status);
=head2 TFE_RegisterCustomDevice
=over 2
Registers a custom device for use with eager execution.
Eager operations may be placed on this device, e.g. `with
tf.device("CUSTOM"):` from Python if `device_name` for this call is
"/job:localhost/replica:0/task:0/device:CUSTOM:0".
The custom device defines copy operations for moving TensorHandles on and
off, and an execution operation for named operations. Often execution will
simply wrap op execution on one or more physical devices.
device_info is an opaque caller-defined type stored with the custom device
which is passed to the functions referenced in the TFE_CustomDevice struct
`device` (execute, delete_device, etc.). It can for example contain the
names of wrapped devices.
There are currently no graph semantics implemented for registered custom
devices, so executing tf.functions which contain operations placed on the
custom devices will fail.
`device_name` must not name an existing physical or custom device. It must
follow the format:
/job:<name>/replica:<replica>/task:<task>/device:<type>:<device_num>
If the device is successfully registered, `status` is set to TF_OK. Otherwise
the device is not usable. In case of a bad status, `device.delete_device` is
still called on `device_info` (i.e. the caller does not retain ownership).
This API is highly experimental, and in particular is expected to change when
it starts supporting operations with attributes and when tf.function support
is added.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_RegisterCustomDevice(TFE_Context* ctx,
TFE_CustomDevice device,
const char* device_name,
void* device_info,
TF_Status* status);
=head2 TFE_IsCustomDevice
=over 2
Returns whether `device_name` maps to a registered custom device.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern bool TFE_IsCustomDevice(TFE_Context* ctx,
const char* device_name);
=head2 TFE_NewCustomDeviceTensorHandle
=over 2
Creates a new TensorHandle from memory residing in a custom device. Takes
ownership of the memory pointed to by `tensor_handle_data`, and calls
`methods.deallocator` to release it after TF no longer needs it or in case of
an error.
This call is similar to `TFE_NewTensorHandleFromDeviceMemory`, but supports
custom devices instead of physical devices and does not require blocking
waiting for exact shapes.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern TFE_TensorHandle* TFE_NewCustomDeviceTensorHandle(
TFE_Context*, const char* device_name, TF_DataType, void* data,
TFE_CustomDeviceTensorHandle methods, TF_Status* status);
=head2 TFE_ContextGetFunctionDef
=over 2
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_ContextGetFunctionDef(TFE_Context* ctx,
const char* function_name,
TF_Buffer* buf,
TF_Status* status);
=head2 TFE_AllocateHostTensor
=over 2
Allocate and return a new Tensor on the host.
The caller must set the Tensor values by writing them to the pointer returned
by TF_TensorData with length TF_TensorByteSize.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern TF_Tensor* TFE_AllocateHostTensor(TFE_Context* ctx,
TF_DataType dtype,
const int64_t* dims,
int num_dims,
TF_Status* status);
=head2 TFE_NewTensorHandleFromTensor
=over 2
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
`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*.
( run in 1.097 second using v1.01-cache-2.11-cpan-140bd7fdf52 )