view release on metacpan or search on metacpan
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
const char* device);
=head2 TF_AddInput
=over 2
For inputs that take a single tensor.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_AddInput(TF_OperationDescription* desc,
TF_Output input);
=head2 TF_AddInputList
=over 2
For inputs that take a list of tensors.
inputs must point to TF_Output[num_inputs].
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_AddInputList(TF_OperationDescription* desc,
const TF_Output* inputs,
int num_inputs);
=head2 TF_AddControlInput
=over 2
Call once per control input to `desc`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_AddControlInput(TF_OperationDescription* desc,
TF_Operation* input);
=head2 TF_ColocateWith
=over 2
Request that `desc` be co-located on the device where `op`
is placed.
Use of this is discouraged since the implementation of device placement is
subject to change. Primarily intended for internal libraries
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_ColocateWith(TF_OperationDescription* desc,
TF_Operation* op);
=head2 TF_SetAttrString
=over 2
`value` must point to a string of length `length` bytes.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrString(TF_OperationDescription* desc,
const char* attr_name,
const void* value, size_t length);
=head2 TF_SetAttrStringList
=over 2
`values` and `lengths` each must have lengths `num_values`.
`values[i]` must point to a string of length `lengths[i]` bytes.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrStringList(TF_OperationDescription* desc,
const char* attr_name,
const void* const* values,
const size_t* lengths,
int num_values);
=head2 TF_SetAttrInt
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrInt(TF_OperationDescription* desc,
const char* attr_name, int64_t value);
=head2 TF_SetAttrIntList
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrIntList(TF_OperationDescription* desc,
const char* attr_name,
const int64_t* values,
int num_values);
=head2 TF_SetAttrFloat
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrFloat(TF_OperationDescription* desc,
const char* attr_name, float value);
=head2 TF_SetAttrFloatList
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrFloatList(TF_OperationDescription* desc,
const char* attr_name,
const float* values,
int num_values);
=head2 TF_SetAttrBool
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrBool(TF_OperationDescription* desc,
const char* attr_name,
unsigned char value);
=head2 TF_SetAttrBoolList
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrBoolList(TF_OperationDescription* desc,
const char* attr_name,
const unsigned char* values,
int num_values);
=head2 TF_SetAttrType
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrType(TF_OperationDescription* desc,
const char* attr_name,
TF_DataType value);
=head2 TF_SetAttrTypeList
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrTypeList(TF_OperationDescription* desc,
const char* attr_name,
const TF_DataType* values,
int num_values);
=head2 TF_SetAttrPlaceholder
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrPlaceholder(TF_OperationDescription* desc,
const char* attr_name,
const char* placeholder);
=head2 TF_SetAttrFuncName
=over 2
Set a 'func' attribute to the specified name.
`value` must point to a string of length `length` bytes.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrFuncName(TF_OperationDescription* desc,
const char* attr_name,
const char* value, size_t length);
=head2 TF_SetAttrShape
=over 2
Set `num_dims` to -1 to represent "unknown rank". Otherwise,
`dims` points to an array of length `num_dims`. `dims[i]` must be
>= -1, with -1 meaning "unknown dimension".
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrShape(TF_OperationDescription* desc,
const char* attr_name,
const int64_t* dims, int num_dims);
=head2 TF_SetAttrShapeList
=over 2
`dims` and `num_dims` must point to arrays of length `num_shapes`.
Set `num_dims[i]` to -1 to represent "unknown rank". Otherwise,
`dims[i]` points to an array of length `num_dims[i]`. `dims[i][j]`
must be >= -1, with -1 meaning "unknown dimension".
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrShapeList(TF_OperationDescription* desc,
const char* attr_name,
const int64_t* const* dims,
const int* num_dims,
int num_shapes);
=head2 TF_SetAttrTensorShapeProto
=over 2
`proto` must point to an array of `proto_len` bytes representing a
binary-serialized TensorShapeProto.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrTensorShapeProto(
TF_OperationDescription* desc, const char* attr_name, const void* proto,
size_t proto_len, TF_Status* status);
=head2 TF_SetAttrTensorShapeProtoList
=over 2
`protos` and `proto_lens` must point to arrays of length `num_shapes`.
`protos[i]` must point to an array of `proto_lens[i]` bytes
representing a binary-serialized TensorShapeProto.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrTensorShapeProtoList(
TF_OperationDescription* desc, const char* attr_name,
const void* const* protos, const size_t* proto_lens, int num_shapes,
TF_Status* status);
=head2 TF_SetAttrTensor
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrTensor(TF_OperationDescription* desc,
const char* attr_name,
TF_Tensor* value,
TF_Status* status);
=head2 TF_SetAttrTensorList
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrTensorList(TF_OperationDescription* desc,
const char* attr_name,
TF_Tensor* const* values,
int num_values,
TF_Status* status);
=head2 TF_SetAttrValueProto
=over 2
`proto` should point to a sequence of bytes of length `proto_len`
representing a binary serialization of an AttrValue protocol
buffer.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetAttrValueProto(TF_OperationDescription* desc,
const char* attr_name,
const void* proto,
size_t proto_len,
TF_Status* status);
=head2 TF_FinishOperationLocked
=over 2
Adds this operation to the graph - see `TF_FinishOperation` for more details.
The lock for `graph` must be held when calling this function.
Unless implementing advanced behavior, like custom gradient functions, you
most likely need to call `TF_FinishOperation` instead.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Operation* TF_FinishOperationLocked(
TF_OperationDescription* desc, TF_Status* status);
=head2 TF_FinishOperation
=over 2
If this function succeeds:
* *status is set to an OK value,
* a TF_Operation is added to the graph,
* a non-null value pointing to the added operation is returned --
this value is valid until the underlying graph is deleted.
Otherwise:
* *status is set to a non-OK value,
* the graph is not modified,
* a null value is returned.
In either case, it deletes `desc`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Operation* TF_FinishOperation(
TF_OperationDescription* desc, TF_Status* status);
=head2 TF_OperationName
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern const char* TF_OperationName(TF_Operation* oper);
=head2 TF_OperationOpType
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=head2 TF_OperationOutputListLength
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationOutputListLength(TF_Operation* oper,
const char* arg_name,
TF_Status* status);
=head2 TF_OperationNumInputs
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationNumInputs(TF_Operation* oper);
=head2 TF_OperationInputType
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_DataType TF_OperationInputType(TF_Input oper_in);
=head2 TF_OperationInputListLength
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationInputListLength(TF_Operation* oper,
const char* arg_name,
TF_Status* status);
=head2 TF_OperationInput
=over 2
In this code:
TF_Output producer = TF_OperationInput(consumer);
There is an edge from producer.oper's output (given by
producer.index) to consumer.oper's input (given by consumer.index).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Output TF_OperationInput(TF_Input oper_in);
=head2 TF_OperationAllInputs
=over 2
Get list of all inputs of a specific operation. `inputs` must point to
an array of length at least `max_inputs` (ideally set to
TF_OperationNumInputs(oper)). Beware that a concurrent
modification of the graph can increase the number of inputs of
an operation.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationAllInputs(TF_Operation* oper,
TF_Output* inputs,
int max_inputs);
=head2 TF_OperationOutputNumConsumers
=over 2
Get the number of current consumers of a specific output of an
operation. Note that this number can change when new operations
are added to the graph.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationOutputNumConsumers(TF_Output oper_out);
=head2 TF_OperationOutputConsumers
=over 2
Get list of all current consumers of a specific output of an
operation. `consumers` must point to an array of length at least
`max_consumers` (ideally set to
TF_OperationOutputNumConsumers(oper_out)). Beware that a concurrent
modification of the graph can increase the number of consumers of
an operation. Returns the number of output consumers (should match
TF_OperationOutputNumConsumers(oper_out)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationOutputConsumers(TF_Output oper_out,
TF_Input* consumers,
int max_consumers);
=head2 TF_OperationNumControlInputs
=over 2
Get the number of control inputs to an operation.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationNumControlInputs(TF_Operation* oper);
=head2 TF_OperationGetControlInputs
=over 2
Get list of all control inputs to an operation. `control_inputs` must
point to an array of length `max_control_inputs` (ideally set to
TF_OperationNumControlInputs(oper)). Returns the number of control
inputs (should match TF_OperationNumControlInputs(oper)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationGetControlInputs(
TF_Operation* oper, TF_Operation** control_inputs, int max_control_inputs);
=head2 TF_OperationNumControlOutputs
=over 2
Get the number of operations that have `*oper` as a control input.
Note that this number can change when new operations are added to
the graph.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationNumControlOutputs(TF_Operation* oper);
=head2 TF_OperationGetControlOutputs
=over 2
Get the list of operations that have `*oper` as a control input.
`control_outputs` must point to an array of length at least
`max_control_outputs` (ideally set to
TF_OperationNumControlOutputs(oper)). Beware that a concurrent
modification of the graph can increase the number of control
outputs. Returns the number of control outputs (should match
TF_OperationNumControlOutputs(oper)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationGetControlOutputs(
TF_Operation* oper, TF_Operation** control_outputs,
int max_control_outputs);
=head2 TF_OperationGetAttrMetadata
=over 2
Returns metadata about the value of the attribute `attr_name` of `oper`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_AttrMetadata TF_OperationGetAttrMetadata(
TF_Operation* oper, const char* attr_name, TF_Status* status);
=head2 TF_OperationGetAttrString
=over 2
Fills in `value` with the value of the attribute `attr_name`. `value` must
point to an array of length at least `max_length` (ideally set to
TF_AttrMetadata.total_size from TF_OperationGetAttrMetadata(oper,
attr_name)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrString(TF_Operation* oper,
const char* attr_name,
void* value,
size_t max_length,
TF_Status* status);
=head2 TF_OperationGetAttrStringList
=over 2
Get the list of strings in the value of the attribute `attr_name`. Fills in
`values` and `lengths`, each of which must point to an array of length at
least `max_values`.
The elements of values will point to addresses in `storage` which must be at
least `storage_size` bytes in length. Ideally, max_values would be set to
TF_AttrMetadata.list_size and `storage` would be at least
TF_AttrMetadata.total_size, obtained from TF_OperationGetAttrMetadata(oper,
attr_name).
Fails if storage_size is too small to hold the requested number of strings.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrStringList(
TF_Operation* oper, const char* attr_name, void** values, size_t* lengths,
int max_values, void* storage, size_t storage_size, TF_Status* status);
=head2 TF_OperationGetAttrInt
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrInt(TF_Operation* oper,
const char* attr_name,
int64_t* value,
TF_Status* status);
=head2 TF_OperationGetAttrIntList
=over 2
Fills in `values` with the value of the attribute `attr_name` of `oper`.
`values` must point to an array of length at least `max_values` (ideally set
TF_AttrMetadata.list_size from TF_OperationGetAttrMetadata(oper,
attr_name)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrIntList(TF_Operation* oper,
const char* attr_name,
int64_t* values,
int max_values,
TF_Status* status);
=head2 TF_OperationGetAttrFloat
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrFloat(TF_Operation* oper,
const char* attr_name,
float* value,
TF_Status* status);
=head2 TF_OperationGetAttrFloatList
=over 2
Fills in `values` with the value of the attribute `attr_name` of `oper`.
`values` must point to an array of length at least `max_values` (ideally set
to TF_AttrMetadata.list_size from TF_OperationGetAttrMetadata(oper,
attr_name)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrFloatList(TF_Operation* oper,
const char* attr_name,
float* values,
int max_values,
TF_Status* status);
=head2 TF_OperationGetAttrBool
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrBool(TF_Operation* oper,
const char* attr_name,
unsigned char* value,
TF_Status* status);
=head2 TF_OperationGetAttrBoolList
=over 2
Fills in `values` with the value of the attribute `attr_name` of `oper`.
`values` must point to an array of length at least `max_values` (ideally set
to TF_AttrMetadata.list_size from TF_OperationGetAttrMetadata(oper,
attr_name)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrBoolList(TF_Operation* oper,
const char* attr_name,
unsigned char* values,
int max_values,
TF_Status* status);
=head2 TF_OperationGetAttrType
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrType(TF_Operation* oper,
const char* attr_name,
TF_DataType* value,
TF_Status* status);
=head2 TF_OperationGetAttrTypeList
=over 2
Fills in `values` with the value of the attribute `attr_name` of `oper`.
`values` must point to an array of length at least `max_values` (ideally set
to TF_AttrMetadata.list_size from TF_OperationGetAttrMetadata(oper,
attr_name)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrTypeList(TF_Operation* oper,
const char* attr_name,
TF_DataType* values,
int max_values,
TF_Status* status);
=head2 TF_OperationGetAttrShape
=over 2
Fills in `value` with the value of the attribute `attr_name` of `oper`.
`values` must point to an array of length at least `num_dims` (ideally set to
TF_Attr_Meta.size from TF_OperationGetAttrMetadata(oper, attr_name)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrShape(TF_Operation* oper,
const char* attr_name,
int64_t* value,
int num_dims,
TF_Status* status);
=head2 TF_OperationGetAttrShapeList
=over 2
Fills in `dims` with the list of shapes in the attribute `attr_name` of
`oper` and `num_dims` with the corresponding number of dimensions. On return,
for every i where `num_dims[i]` > 0, `dims[i]` will be an array of
`num_dims[i]` elements. A value of -1 for `num_dims[i]` indicates that the
i-th shape in the list is unknown.
The elements of `dims` will point to addresses in `storage` which must be
large enough to hold at least `storage_size` int64_ts. Ideally, `num_shapes`
would be set to TF_AttrMetadata.list_size and `storage_size` would be set to
TF_AttrMetadata.total_size from TF_OperationGetAttrMetadata(oper,
attr_name).
Fails if storage_size is insufficient to hold the requested shapes.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrShapeList(
TF_Operation* oper, const char* attr_name, int64_t** dims, int* num_dims,
int num_shapes, int64_t* storage, int storage_size, TF_Status* status);
=head2 TF_OperationGetAttrTensorShapeProto
=over 2
Sets `value` to the binary-serialized TensorShapeProto of the value of
`attr_name` attribute of `oper`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrTensorShapeProto(
TF_Operation* oper, const char* attr_name, TF_Buffer* value,
TF_Status* status);
=head2 TF_OperationGetAttrTensorShapeProtoList
=over 2
Fills in `values` with binary-serialized TensorShapeProto values of the
attribute `attr_name` of `oper`. `values` must point to an array of length at
least `num_values` (ideally set to TF_AttrMetadata.list_size from
TF_OperationGetAttrMetadata(oper, attr_name)).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrTensorShapeProtoList(
TF_Operation* oper, const char* attr_name, TF_Buffer** values,
int max_values, TF_Status* status);
=head2 TF_OperationGetAttrTensor
=over 2
Gets the TF_Tensor valued attribute of `attr_name` of `oper`.
Allocates a new TF_Tensor which the caller is expected to take
ownership of (and can deallocate using TF_DeleteTensor).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrTensor(TF_Operation* oper,
const char* attr_name,
TF_Tensor** value,
TF_Status* status);
=head2 TF_OperationGetAttrTensorList
=over 2
Fills in `values` with the TF_Tensor values of the attribute `attr_name` of
`oper`. `values` must point to an array of TF_Tensor* of length at least
`max_values` (ideally set to TF_AttrMetadata.list_size from
TF_OperationGetAttrMetadata(oper, attr_name)).
The caller takes ownership of all the non-null TF_Tensor* entries in `values`
(which can be deleted using TF_DeleteTensor(values[i])).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrTensorList(TF_Operation* oper,
const char* attr_name,
TF_Tensor** values,
int max_values,
TF_Status* status);
=head2 TF_OperationGetAttrValueProto
=over 2
Sets `output_attr_value` to the binary-serialized AttrValue proto
representation of the value of the `attr_name` attr of `oper`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrValueProto(
TF_Operation* oper, const char* attr_name, TF_Buffer* output_attr_value,
TF_Status* status);
=head2 TF_OperationGetNumAttrs
=over 2
Get the number of attributes the operation has.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationGetNumAttrs(TF_Operation* oper);
=head2 TF_OperationGetAttrNameLength
=over 2
Get the length of the name of the ith attribute, or -1 if there is not an
ith attribute.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_OperationGetAttrNameLength(TF_Operation* oper,
int i);
=head2 TF_OperationGetAttrName
=over 2
Get the name of the ith attribute. output should have the size of
TF_OperationGetAttrNameLength(oper, i).
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationGetAttrName(TF_Operation* oper, int i,
char* output,
TF_Status* status);
=head2 TF_GraphOperationByName
=over 2
Returns the operation in the graph with `oper_name`. Returns nullptr if
no operation found.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Operation* TF_GraphOperationByName(
TF_Graph* graph, const char* oper_name);
=head2 TF_GraphNextOperation
=over 2
Iterate through the operations of a graph. To use:
size_t pos = 0;
TF_Operation* oper;
while ((oper = TF_GraphNextOperation(graph, &pos)) != nullptr) {
DoSomethingWithOperation(oper);
}
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Operation* TF_GraphNextOperation(TF_Graph* graph,
size_t* pos);
=head2 TF_GraphToGraphDef
=over 2
Write out a serialized representation of `graph` (as a GraphDef protocol
message) to `output_graph_def` (allocated by TF_NewBuffer()).
`output_graph_def`'s underlying buffer will be freed when TF_DeleteBuffer()
is called.
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=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
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_GraphImportGraphDef(
TF_Graph* graph, const TF_Buffer* graph_def,
const TF_ImportGraphDefOptions* options, TF_Status* status);
=head2 TF_GraphCopyFunction
=over 2
Adds a copy of function `func` and optionally its gradient function `grad`
to `g`. Once `func`/`grad` is added to `g`, it can be called by creating
an operation using the function's name.
Any changes to `func`/`grad` (including deleting it) done after this method
returns, won't affect the copy of `func`/`grad` in `g`.
If `func` or `grad` are already in `g`, TF_GraphCopyFunction has no
effect on them, but can establish the function->gradient relationship
between them if `func` does not already have a gradient. If `func` already
has a gradient different from `grad`, an error is returned.
`func` must not be null.
If `grad` is null and `func` is not in `g`, `func` is added without a
gradient.
If `grad` is null and `func` is in `g`, TF_GraphCopyFunction is a noop.
`grad` must have appropriate signature as described in the doc of
GradientDef in tensorflow/core/framework/function.proto.
If successful, status is set to OK and `func` and `grad` are added to `g`.
Otherwise, status is set to the encountered error and `g` is unmodified.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_GraphCopyFunction(TF_Graph* g,
const TF_Function* func,
const TF_Function* grad,
TF_Status* status);
=head2 TF_GraphNumFunctions
=over 2
Returns the number of TF_Functions registered in `g`.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_GraphNumFunctions(TF_Graph* g);
=head2 TF_GraphGetFunctions
=over 2
Fills in `funcs` with the TF_Function* registered in `g`.
`funcs` must point to an array of TF_Function* of length at least
`max_func`. In usual usage, max_func should be set to the result of
TF_GraphNumFunctions(g). In this case, all the functions registered in
`g` will be returned. Else, an unspecified subset.
If successful, returns the number of TF_Function* successfully set in
`funcs` and sets status to OK. The caller takes ownership of
all the returned TF_Functions. They must be deleted with TF_DeleteFunction.
On error, returns 0, sets status to the encountered error, and the contents
of funcs will be undefined.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern int TF_GraphGetFunctions(TF_Graph* g, TF_Function** funcs,
int max_func, TF_Status* status);
=head2 TF_OperationToNodeDef
=over 2
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_OperationToNodeDef(TF_Operation* oper,
TF_Buffer* output_node_def,
TF_Status* status);
=head2 TF_NewWhile
=over 2
Creates a TF_WhileParams for creating a while loop in `g`. `inputs` are
outputs that already exist in `g` used as initial values for the loop
variables.
The returned TF_WhileParams will have all fields initialized except
`cond_output`, `body_outputs`, and `name`. The `body_outputs` buffer will be
allocated to size `ninputs`. The caller should build `cond_graph` and
`body_graph` starting from the inputs, and store the final outputs in
`cond_output` and `body_outputs`.
If `status` is OK, the caller must call either TF_FinishWhile or
TF_AbortWhile on the returned TF_WhileParams. If `status` isn't OK, the
returned TF_WhileParams is not valid, and the caller should not call
TF_FinishWhile() or TF_AbortWhile().
Missing functionality (TODO):
- Gradients
- Reference-type inputs
- Directly referencing external tensors from the cond/body graphs (this is
possible in the Python API)
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_WhileParams TF_NewWhile(TF_Graph* g, TF_Output* inputs,
int ninputs,
TF_Status* status);
=head2 TF_FinishWhile
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT void TF_AddGradientsWithPrefix(TF_Graph* g, const char* prefix,
TF_Output* y, int ny,
TF_Output* x, int nx,
TF_Output* dx, TF_Status* status,
TF_Output* dy);
=head2 TF_GraphToFunction
=over 2
Create a TF_Function from a TF_Graph
Params:
fn_body - the graph whose operations (or subset of whose operations) will be
converted to TF_Function.
fn_name - the name of the new TF_Function. Should match the operation
name (OpDef.name) regexp [A-Z][A-Za-z0-9_.\\-/]*.
If `append_hash_to_fn_name` is false, `fn_name` must be distinct
from other function and operation names (at least those
registered in graphs where this function will be used).
append_hash_to_fn_name - Must be 0 or 1. If set to 1, the actual name
of the function will be `fn_name` appended with
'_<hash_of_this_function's_definition>'.
If set to 0, the function's name will be `fn_name`.
num_opers - `num_opers` contains the number of elements in the `opers` array
or a special value of -1 meaning that no array is given.
The distinction between an empty array of operations and no
array of operations is necessary to distinguish the case of
creating a function with no body (e.g. identity or permutation)
and the case of creating a function whose body contains all
the nodes in the graph (except for the automatic skipping, see
below).
opers - Array of operations to become the body of the function or null.
- If no array is given (`num_opers` = -1), all the
operations in `fn_body` will become part of the function
except operations referenced in `inputs`. These operations
must have a single output (these operations are typically
placeholders created for the sole purpose of representing
an input. We can relax this constraint if there are
compelling use cases).
- If an array is given (`num_opers` >= 0), all operations
in it will become part of the function. In particular, no
automatic skipping of dummy input operations is performed.
ninputs - number of elements in `inputs` array
inputs - array of TF_Outputs that specify the inputs to the function.
If `ninputs` is zero (the function takes no inputs), `inputs`
can be null. The names used for function inputs are normalized
names of the operations (usually placeholders) pointed to by
`inputs`. These operation names should start with a letter.
Normalization will convert all letters to lowercase and
non-alphanumeric characters to '_' to make resulting names match
the "[a-z][a-z0-9_]*" pattern for operation argument names.
`inputs` cannot contain the same tensor twice.
noutputs - number of elements in `outputs` array
outputs - array of TF_Outputs that specify the outputs of the function.
If `noutputs` is zero (the function returns no outputs), `outputs`
can be null. `outputs` can contain the same tensor more than once.
output_names - The names of the function's outputs. `output_names` array
must either have the same length as `outputs`
(i.e. `noutputs`) or be null. In the former case,
the names should match the regular expression for ArgDef
names - "[a-z][a-z0-9_]*". In the latter case,
names for outputs will be generated automatically.
opts - various options for the function, e.g. XLA's inlining control.
description - optional human-readable description of this function.
status - Set to OK on success and an appropriate error on failure.
Note that when the same TF_Output is listed as both an input and an output,
the corresponding function's output will equal to this input,
instead of the original node's output.
Callers must also satisfy the following constraints:
- `inputs` cannot refer to TF_Outputs within a control flow context. For
example, one cannot use the output of "switch" node as input.
- `inputs` and `outputs` cannot have reference types. Reference types are
not exposed through C API and are being replaced with Resources. We support
reference types inside function's body to support legacy code. Do not
use them in new code.
- Every node in the function's body must have all of its inputs (including
control inputs). In other words, for every node in the body, each input
must be either listed in `inputs` or must come from another node in
the body. In particular, it is an error to have a control edge going from
a node outside of the body into a node in the body. This applies to control
edges going from nodes referenced in `inputs` to nodes in the body when
the former nodes are not in the body (automatically skipped or not
included in explicitly specified body).
Returns:
On success, a newly created TF_Function instance. It must be deleted by
calling TF_DeleteFunction.
On failure, null.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Function* TF_GraphToFunction(
const TF_Graph* fn_body, const char* fn_name,
unsigned char append_hash_to_fn_name, int num_opers,
const TF_Operation* const* opers, int ninputs, const TF_Output* inputs,
int noutputs, const TF_Output* outputs, const char* const* output_names,
const TF_FunctionOptions* opts, const char* description, TF_Status* status);
=head2 TF_GraphToFunctionWithControlOutputs
=over 2
Similar to TF_GraphToFunction but allows specifying control outputs of the
function.
The arguments of TF_GraphToFunction have the same meaning, but the new
arguments are as follows:
ncontrol_outputs: Number of control outputs of the function.
control_outputs: vector of TF_Operation objects to be marked as control
outputs of the function. Operations marked as control outputs are
guaranteed to execute.
control_output_names: Optional. If not nullptr, vector of strings, one
per control output, with their names to be added to the function's
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
int ncontrol_outputs, const TF_Operation* const* control_outputs,
const char* const* control_output_names, const TF_FunctionOptions* opts,
const char* description, TF_Status* status);
=head2 TF_FunctionName
=over 2
Returns the name of the graph function.
The return value points to memory that is only usable until the next
mutation to *func.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern const char* TF_FunctionName(TF_Function* func);
=head2 TF_FunctionToFunctionDef
=over 2
Write out a serialized representation of `func` (as a FunctionDef protocol
message) to `output_func_def` (allocated by TF_NewBuffer()).
`output_func_def`'s underlying buffer will be freed when TF_DeleteBuffer()
is called.
May fail on very large graphs in the future.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_FunctionToFunctionDef(TF_Function* func,
TF_Buffer* output_func_def,
TF_Status* status);
=head2 TF_FunctionImportFunctionDef
=over 2
Construct and return the function whose FunctionDef representation is
serialized in `proto`. `proto_len` must equal the number of bytes
pointed to by `proto`.
Returns:
On success, a newly created TF_Function instance. It must be deleted by
calling TF_DeleteFunction.
On failure, null.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern TF_Function* TF_FunctionImportFunctionDef(
const void* proto, size_t proto_len, TF_Status* status);
=head2 TF_FunctionSetAttrValueProto
=over 2
Sets function attribute named `attr_name` to value stored in `proto`.
If this attribute is already set to another value, it is overridden.
`proto` should point to a sequence of bytes of length `proto_len`
representing a binary serialization of an AttrValue protocol
buffer.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_FunctionSetAttrValueProto(TF_Function* func,
const char* attr_name,
const void* proto,
size_t proto_len,
TF_Status* status);
=head2 TF_FunctionGetAttrValueProto
=over 2
Sets `output_attr_value` to the binary-serialized AttrValue proto
representation of the value of the `attr_name` attr of `func`.
If `attr_name` attribute is not present, status is set to an error.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_FunctionGetAttrValueProto(
TF_Function* func, const char* attr_name, TF_Buffer* output_attr_value,
TF_Status* status);
=head2 TF_DeleteFunction
=over 2
Frees the memory used by the `func` struct.
TF_DeleteFunction is a noop if `func` is null.
Deleting a function does not remove it from any graphs it was copied to.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_DeleteFunction(TF_Function* func);
=head2 TF_TryEvaluateConstant
=over 2
Attempts to evaluate `output`. This will only be possible if `output` doesn't
depend on any graph inputs (this function is safe to call if this isn't the
case though).
If the evaluation is successful, this function returns true and `output`s
value is returned in `result`. Otherwise returns false. An error status is
returned if something is wrong with the graph or input. Note that this may
return false even if no error status is set.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern unsigned char TF_TryEvaluateConstant(TF_Graph* graph,
TF_Output output,
TF_Tensor** result,
TF_Status* status);
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=head2 TF_ShapeDimSize
=over 2
Returns the `d`th dimension of `shape`. If `shape` has unknown rank,
invoking this function is undefined behavior. Returns -1 if dimension is
unknown.
=back
/* From <tensorflow/c/tf_shape.h> */
TF_CAPI_EXPORT extern int64_t TF_ShapeDimSize(const TF_Shape* shape, int d);
=head2 TF_DeleteShape
=over 2
Deletes `shape`.
=back
/* From <tensorflow/c/tf_shape.h> */
TF_CAPI_EXPORT extern void TF_DeleteShape(TF_Shape* shape);
=head2 TF_NewTensor
=over 2
Return a new tensor that holds the bytes data[0,len-1].
The data will be deallocated by a subsequent call to TF_DeleteTensor via:
(*deallocator)(data, len, deallocator_arg)
Clients must provide a custom deallocator function so they can pass in
memory managed by something like numpy.
May return NULL (and invoke the deallocator) if the provided data buffer
(data, len) is inconsistent with a tensor of the given TF_DataType
and the shape specified by (dima, num_dims).
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern TF_Tensor* TF_NewTensor(
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);
=head2 TF_AllocateTensor
=over 2
Allocate and return a new Tensor.
This function is an alternative to TF_NewTensor and should be used when
memory is allocated to pass the Tensor to the C API. The allocated memory
satisfies TensorFlow's memory alignment preferences and should be preferred
over calling malloc and free.
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/tf_tensor.h> */
TF_CAPI_EXPORT extern TF_Tensor* TF_AllocateTensor(TF_DataType,
const int64_t* dims,
int num_dims, size_t len);
=head2 TF_TensorMaybeMove
=over 2
Deletes `tensor` and returns a new TF_Tensor with the same content if
possible. Returns nullptr and leaves `tensor` untouched if not.
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern TF_Tensor* TF_TensorMaybeMove(TF_Tensor* tensor);
=head2 TF_DeleteTensor
=over 2
Destroy a tensor.
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern void TF_DeleteTensor(TF_Tensor*);
=head2 TF_TensorType
=over 2
Return the type of a tensor element.
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern TF_DataType TF_TensorType(const TF_Tensor*);
=head2 TF_SetShape
=over 2
Set a new shape for the Tensor.
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern void TF_SetShape(TF_Tensor* tensor, const int64_t* dims,
int num_dims);
=head2 TF_NumDims
=over 2
Return the number of dimensions that the tensor has.
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern int TF_NumDims(const TF_Tensor*);
=head2 TF_Dim
=over 2
Return the length of the tensor in the "dim_index" dimension.
REQUIRES: 0 <= dim_index < TF_NumDims(tensor)
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern int64_t TF_Dim(const TF_Tensor* tensor, int dim_index);
=head2 TF_TensorByteSize
=over 2
Return the size of the underlying data in bytes.
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern size_t TF_TensorByteSize(const TF_Tensor*);
=head2 TF_TensorData
=over 2
Return a pointer to the underlying data buffer.
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern void* TF_TensorData(const TF_Tensor*);
=head2 TF_TensorElementCount
=over 2
Returns the number of elements in the tensor.
=back
/* From <tensorflow/c/tf_tensor.h> */
TF_CAPI_EXPORT extern int64_t TF_TensorElementCount(const TF_Tensor* tensor);
=head2 TF_TensorBitcastFrom
=over 2
Copy the internal data representation of `from` to `to`. `new_dims` and
`num_new_dims` specify the new shape of the `to` tensor, `type` specifies its
data type. On success, *status is set to TF_OK and the two tensors share the
same data buffer.
This call requires that the `from` tensor and the given type and shape (dims
and num_dims) are "compatible" (i.e. they occupy the same number of bytes).
Specifically, given from_type_size = TF_DataTypeSize(TF_TensorType(from)):
ShapeElementCount(dims, num_dims) * TF_DataTypeSize(type)
must equal
TF_TensorElementCount(from) * from_type_size
where TF_ShapeElementCount would be the number of elements in a tensor with
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=over 2
=back
/* From <tensorflow/c/tf_tstring.h> */
TF_CAPI_EXPORT extern void TF_StringAssignView(TF_TString *dst, const char *src,
size_t size);
=head2 TF_StringGetDataPointer
=over 2
=back
/* From <tensorflow/c/tf_tstring.h> */
TF_CAPI_EXPORT extern const char *TF_StringGetDataPointer(
const TF_TString *tstr);
=head2 TF_StringGetType
=over 2
=back
/* From <tensorflow/c/tf_tstring.h> */
TF_CAPI_EXPORT extern TF_TString_Type TF_StringGetType(const TF_TString *str);
=head2 TF_StringGetSize
=over 2
=back
/* From <tensorflow/c/tf_tstring.h> */
TF_CAPI_EXPORT extern size_t TF_StringGetSize(const TF_TString *tstr);
=head2 TF_StringGetCapacity
=over 2
=back
/* From <tensorflow/c/tf_tstring.h> */
TF_CAPI_EXPORT extern size_t TF_StringGetCapacity(const TF_TString *str);
=head2 TF_StringDealloc
=over 2
=back
/* From <tensorflow/c/tf_tstring.h> */
TF_CAPI_EXPORT extern void TF_StringDealloc(TF_TString *tstr);
=head2 TF_DataTypeSize
=over 2
TF_DataTypeSize returns the sizeof() for the underlying type corresponding
to the given TF_DataType enum value. Returns 0 for variable length types
(eg. TF_STRING) or on failure.
=back
/* From <tensorflow/c/tf_datatype.h> */
TF_CAPI_EXPORT extern size_t TF_DataTypeSize(TF_DataType dt);
=head2 TF_NewOpDefinitionBuilder
=over 2
Returns a newly allocated op definition builder for the given op name. The
returned builder may be customized with the `TF_OpDefinitionBuilder...`
functions and then registered with TensorFlow with TF_RegisterOpDefinition.
The returned pointer is either freed by a call to TF_RegisterOpDefinition, or
can be manually deleted by TF_DeleteOpDefinitionBuilder if it is never
registered.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern TF_OpDefinitionBuilder* TF_NewOpDefinitionBuilder(
const char* op_name);
=head2 TF_RegisterOpDefinition
=over 2
Registers the given op builder with TensorFlow. Indicates success or
otherwise in the given status.
`builder` is freed whether the op was successfully registered or not. You
must call either this function or TF_DeleteOpDefinitionBuilder to free the
builder, but never both.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_RegisterOpDefinition(
TF_OpDefinitionBuilder* builder, TF_Status* status);
=head2 TF_DeleteOpDefinitionBuilder
=over 2
Frees the given op definition builder. You must call either this function or
TF_RegisterOpDefinition to free the builder, but never both.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_DeleteOpDefinitionBuilder(
TF_OpDefinitionBuilder* builder);
=head2 TF_OpDefinitionBuilderAddAttr
=over 2
Adds an attr to the given TF_OpDefinitionBuilder. The spec has
format "<name>:<type>" or "<name>:<type>=<default>"
where <name> matches regexp [a-zA-Z][a-zA-Z0-9_]*.
By convention, names containing only capital letters are reserved for
attributes whose values can be inferred by the operator implementation if not
supplied by the user. If the attribute name contains characters other than
capital letters, the operator expects the user to provide the attribute value
at operation runtime.
<type> can be:
"string", "int", "float", "bool", "type", "shape", or "tensor"
"numbertype", "realnumbertype", "quantizedtype"
(meaning "type" with a restriction on valid values)
"{int32,int64}" or {realnumbertype,quantizedtype,string}"
(meaning "type" with a restriction containing unions of value types)
"{\"foo\", \"bar\n baz\"}", or "{'foo', 'bar\n baz'}"
(meaning "string" with a restriction on valid values)
"list(string)", ..., "list(tensor)", "list(numbertype)", ...
(meaning lists of the above types)
"int >= 2" (meaning "int" with a restriction on valid values)
"list(string) >= 2", "list(int) >= 2"
(meaning "list(string)" / "list(int)" with length at least 2)
<default>, if included, should use the Proto text format
of <type>. For lists use [a, b, c] format.
Note that any attr specifying the length of an input or output will
get a default minimum of 1 unless the >= # syntax is used.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_OpDefinitionBuilderAddAttr(
TF_OpDefinitionBuilder* builder, const char* attr_spec);
=head2 TF_OpDefinitionBuilderAddInput
=over 2
Adds an input to this TF_OpDefinitionBuilder.
The spec has form "<name>:<type-expr>" or "<name>:Ref(<type-expr>)"
where <name> matches regexp [a-z][a-z0-9_]* and <type-expr> can be:
* For a single tensor: <type>
* For a sequence of tensors with the same type: <number>*<type>
* For a sequence of tensors with different types: <type-list>
Where:
<type> is either one of "float", "int32", "string", ...
or the name of an attr (see TF_OpDefinitionBuilderAddAttr)
with type "type".
<number> is the name of an attr with type "int".
<type-list> is the name of an attr with type "list(type)".
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_OpDefinitionBuilderAddInput(
TF_OpDefinitionBuilder* builder, const char* input_spec);
=head2 TF_OpDefinitionBuilderAddOutput
=over 2
Adds an output to this TF_OpDefinitionBuilder.
The spec has form "<name>:<type-expr>" or "<name>:Ref(<type-expr>)"
where <name> matches regexp [a-z][a-z0-9_]* and <type-expr> can be:
* For a single tensor: <type>
* For a sequence of tensors with the same type: <number>*<type>
* For a sequence of tensors with different types: <type-list>
Where:
<type> is either one of "float", "int32", "string", ...
or the name of an attr (see TF_OpDefinitionBuilderAddAttr)
with type "type".
<number> is the name of an attr with type "int".
<type-list> is the name of an attr with type "list(type)".
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_OpDefinitionBuilderAddOutput(
TF_OpDefinitionBuilder* builder, const char* output_spec);
=head2 TF_OpDefinitionBuilderSetIsCommutative
=over 2
Sets the commutative property for the op built by the given builder.
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_NewWritableFile(const char* filename,
TF_WritableFileHandle** handle,
TF_Status* status);
=head2 TF_CloseWritableFile
=over 2
Closes the given handle and frees its memory. If there was a problem closing
the file, it is indicated by status. Memory is freed in any case.
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_CloseWritableFile(TF_WritableFileHandle* handle,
TF_Status* status);
=head2 TF_SyncWritableFile
=over 2
Syncs content of the handle to the filesystem. Blocks waiting for the
filesystem to indicate that the content has been persisted.
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_SyncWritableFile(TF_WritableFileHandle* handle,
TF_Status* status);
=head2 TF_FlushWritableFile
=over 2
Flush local buffers to the filesystem. If the process terminates after a
successful flush, the contents may still be persisted, since the underlying
filesystem may eventually flush the contents. If the OS or machine crashes
after a successful flush, the contents may or may not be persisted, depending
on the implementation.
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_FlushWritableFile(TF_WritableFileHandle* handle,
TF_Status* status);
=head2 TF_AppendWritableFile
=over 2
Appends the given bytes to the file. Any failure to do so is indicated in
status.
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_AppendWritableFile(TF_WritableFileHandle* handle,
const char* data,
size_t length,
TF_Status* status);
=head2 TF_DeleteFile
=over 2
Deletes the named file and indicates whether successful in *status.
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_DeleteFile(const char* filename,
TF_Status* status);
=head2 TF_StringStreamNext
=over 2
Retrieves the next item from the given TF_StringStream and places a pointer
to it in *result. If no more items are in the list, *result is set to NULL
and false is returned.
Ownership of the items retrieved with this function remains with the library.
Item points are invalidated after a call to TF_StringStreamDone.
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern bool TF_StringStreamNext(TF_StringStream* list,
const char** result);
=head2 TF_StringStreamDone
=over 2
Frees the resources associated with given string list. All pointers returned
by TF_StringStreamNext are invalid after this call.
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_StringStreamDone(TF_StringStream* list);
=head2 TF_GetChildren
=over 2
Retrieves the list of children of the given directory. You can iterate
through the list with TF_StringStreamNext. The caller is responsible for
freeing the list (see TF_StringStreamDone).
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern TF_StringStream* TF_GetChildren(const char* filename,
TF_Status* status);
=head2 TF_GetLocalTempDirectories
=over 2
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=head2 TF_GetGraphDefVersion
=over 2
Returns the graph def version of the given context.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern int TF_GetGraphDefVersion(TF_OpKernelContext* ctx);
=head2 TF_GetOpKernelName
=over 2
Returns the name of the OpKernel.
The returned TF_StringView's underlying string is owned by the OpKernel and
has the same lifetime as the OpKernel.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern TF_StringView TF_GetOpKernelName(TF_OpKernelContext* ctx);
=head2 TF_GetResourceMgrDefaultContainerName
=over 2
Returns the default container of the resource manager in OpKernelContext.
The returned TF_StringView's underlying string is owned by the OpKernel and
has the same lifetime as the OpKernel.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern TF_StringView TF_GetResourceMgrDefaultContainerName(
TF_OpKernelContext* ctx);
=head2 TF_GetOpKernelRequestedInput
=over 2
Returns the name of the requested input at `index` from the OpKernel.
The returned TF_StringView's underlying string is owned by the OpKernel and
has the same lifetime as the OpKernel.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern TF_StringView TF_GetOpKernelRequestedInput(
TF_OpKernelContext* ctx, size_t index);
=head2 TF_OpKernelConstruction_GetAttrSize
=over 2
Get the list_size and total_size of the attribute `attr_name` of `oper`.
list_size - the length of the list.
total_size - total size of the list.
(1) If attr_type == TF_ATTR_STRING
then total_size is the cumulative byte size
of all the strings in the list.
(3) If attr_type == TF_ATTR_SHAPE
then total_size is the number of dimensions
of the shape valued attribute, or -1
if its rank is unknown.
(4) If attr_type == TF_ATTR_SHAPE
then total_size is the cumulative number
of dimensions of all shapes in the list.
(5) Otherwise, total_size is undefined.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrSize(
TF_OpKernelConstruction* ctx, const char* attr_name, int32_t* list_size,
int32_t* total_size, TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrType
=over 2
Interprets the named kernel construction attribute as a TF_DataType and
places it into *val. *status is set to TF_OK.
If the attribute could not be found or could not be interpreted as
TF_DataType, *status is populated with an error.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrType(
TF_OpKernelConstruction* ctx, const char* attr_name, TF_DataType* val,
TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrInt32
=over 2
Interprets the named kernel construction attribute as int32_t and
places it into *val. *status is set to TF_OK.
If the attribute could not be found or could not be interpreted as
int32, *status is populated with an error.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrInt32(
TF_OpKernelConstruction* ctx, const char* attr_name, int32_t* val,
TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrInt64
=over 2
Interprets the named kernel construction attribute as int64_t and
places it into *val. *status is set to TF_OK.
If the attribute could not be found or could not be interpreted as
int64, *status is populated with an error.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrInt64(
TF_OpKernelConstruction* ctx, const char* attr_name, int64_t* val,
TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrFloat
=over 2
Interprets the named kernel construction attribute as float and
places it into *val. *status is set to TF_OK.
If the attribute could not be found or could not be interpreted as
float, *status is populated with an error.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrFloat(
TF_OpKernelConstruction* ctx, const char* attr_name, float* val,
TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrBool
=over 2
Interprets the named kernel construction attribute as bool and
places it into *val. *status is set to TF_OK.
If the attribute could not be found or could not be interpreted as
bool, *status is populated with an error.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrBool(
TF_OpKernelConstruction* ctx, const char* attr_name, TF_Bool* val,
TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrString
=over 2
Interprets the named kernel construction attribute as string and
places it into *val. `val` must
point to an array of length at least `max_length` (ideally set to
total_size from TF_OpKernelConstruction_GetAttrSize(ctx,
attr_name, list_size, total_size)). *status is set to TF_OK.
If the attribute could not be found or could not be interpreted as
string, *status is populated with an error.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrString(
TF_OpKernelConstruction* ctx, const char* attr_name, char* val,
size_t max_length, TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrTensor
=over 2
Interprets the named kernel construction attribute as tensor and places it
into *val. Allocates a new TF_Tensor which the caller is expected to take
ownership of (and can deallocate using TF_DeleteTensor). *status is set to
TF_OK.
If the attribute could not be found or could not be interpreted as
tensor, *status is populated with an error.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrTensor(
TF_OpKernelConstruction* ctx, const char* attr_name, TF_Tensor** val,
TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrTypeList
=over 2
Interprets the named kernel construction attribute as a TF_DataType array and
places it into *vals. *status is set to TF_OK.
`vals` must point to an array of length at least `max_values` (ideally set
to list_size from
TF_OpKernelConstruction_GetAttrSize(ctx, attr_name, list_size,
total_size)).
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrTypeList(
TF_OpKernelConstruction* ctx, const char* attr_name, TF_DataType* vals,
int max_vals, TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrInt32List
=over 2
Interprets the named kernel construction attribute as int32_t array and
places it into *vals. *status is set to TF_OK.
`vals` must point to an array of length at least `max_values` (ideally set
to list_size from
TF_OpKernelConstruction_GetAttrSize(ctx, attr_name, list_size,
total_size)).
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrInt32List(
TF_OpKernelConstruction* ctx, const char* attr_name, int32_t* vals,
int max_vals, TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrInt64List
=over 2
Interprets the named kernel construction attribute as int64_t array and
places it into *vals. *status is set to TF_OK.
`vals` must point to an array of length at least `max_values` (ideally set
to list_size from
TF_OpKernelConstruction_GetAttrSize(ctx, attr_name, list_size,
total_size)).
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrInt64List(
TF_OpKernelConstruction* ctx, const char* attr_name, int64_t* vals,
int max_vals, TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrFloatList
=over 2
Interprets the named kernel construction attribute as float array and
places it into *vals. *status is set to TF_OK.
`vals` must point to an array of length at least `max_values` (ideally set
to list_size from
TF_OpKernelConstruction_GetAttrSize(ctx, attr_name, list_size,
total_size)).
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrFloatList(
TF_OpKernelConstruction* ctx, const char* attr_name, float* vals,
int max_vals, TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrBoolList
=over 2
Interprets the named kernel construction attribute as bool array and
places it into *vals. *status is set to TF_OK.
`vals` must point to an array of length at least `max_values` (ideally set
to list_size from
TF_OpKernelConstruction_GetAttrSize(ctx, attr_name, list_size,
total_size)).
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrBoolList(
TF_OpKernelConstruction* ctx, const char* attr_name, TF_Bool* vals,
int max_vals, TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrStringList
=over 2
Interprets the named kernel construction attribute as string array and fills
in `vals` and `lengths`, each of which must point to an array of length at
least `max_values`. *status is set to TF_OK. The elements of values will
point to addresses in `storage` which must be at least `storage_size` bytes
in length. Ideally, max_values would be set to list_size and `storage` would
be at least total_size, obtained from
TF_OpKernelConstruction_GetAttrSize(ctx, attr_name, list_size,
total_size).
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrStringList(
TF_OpKernelConstruction* ctx, const char* attr_name, char** vals,
size_t* lengths, int max_values, void* storage, size_t storage_size,
TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrTensorList
=over 2
Interprets the named kernel construction attribute as tensor array and places
it into *vals. *status is set to TF_OK.
`vals` must point to an array of length at least `max_values`
(ideally set to list_size from TF_OpKernelConstruction_GetAttrSize(ctx,
attr_name, list_size, total_size)).
The caller takes ownership of all the non-null TF_Tensor* entries in `vals`
(which can be deleted using TF_DeleteTensor(vals[i])).
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrTensorList(
TF_OpKernelConstruction* ctx, const char* attr_name, TF_Tensor** vals,
int max_values, TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrFunction
=over 2
Interprets the named kernel construction attribute as a
tensorflow::NameAttrList and returns the serialized proto as TF_Buffer.
`status` will be set. The caller takes ownership of the returned TF_Buffer
(if not null) and is responsible for managing its lifetime.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern TF_Buffer* TF_OpKernelConstruction_GetAttrFunction(
TF_OpKernelConstruction* ctx, const char* attr_name, TF_Status* status);
=head2 TF_OpKernelConstruction_HasAttr
=over 2
Return true if the kernel construction has the attr_name
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern bool TF_OpKernelConstruction_HasAttr(
TF_OpKernelConstruction* ctx, const char* attr_name, TF_Status* status);
=head2 TF_OpKernelConstruction_GetName
=over 2
Returns the unique operation name for this OpKernel.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern TF_StringView TF_OpKernelConstruction_GetName(
TF_OpKernelConstruction* ctx);
=head2 TF_AllocateOutput
=over 2
Allocates Tensor for output at given index. Caller takes ownership of
returned TF_Tensor and should deallocate it using TF_DeleteTensor(tensor).
This function should be used to allocate outputs inside kernel
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
This interface returns `out` tensor which is updated corresponding to the
variable passed with input index. The caller takes ownership of the `source`
and `dest` tensors and is responsible for freeing them with TF_DeleteTensor.
=back
/* From <tensorflow/c/kernels_experimental.h> */
TF_CAPI_EXPORT extern void TF_GetInputTensorFromVariable(
TF_OpKernelContext* ctx, int input, bool lock_held, bool isVariantType,
bool sparse,
void (*copyFunc)(TF_OpKernelContext* ctx, TF_Tensor* source,
TF_Tensor* dest),
TF_Tensor** out, TF_Status* status);
=head2 TF_OpKernelContext_ForwardRefInputToRefOutput
=over 2
This interface forwards the reference from input to the output tensors
corresponding to the indices provided with `input_index` and `output_index`
=back
/* From <tensorflow/c/kernels_experimental.h> */
TF_CAPI_EXPORT extern void TF_OpKernelContext_ForwardRefInputToRefOutput(
TF_OpKernelContext* ctx, int32_t input_index, int32_t output_index);
=head2 TF_ReleaseVariableInputLockHolder
=over 2
The API releases the opaque lock handle returned with
`TF_MaybeLockVariableInputMutexesInOrder` API
=back
/* From <tensorflow/c/kernels_experimental.h> */
TF_CAPI_EXPORT extern void TF_ReleaseVariableInputLockHolder(
TF_VariableInputLockHolder* lockHolder);
=head2 TF_GetInputByName
=over 2
Allows plugin to get TF_Tensor when passed its input_name
=back
/* From <tensorflow/c/kernels_experimental.h> */
TF_CAPI_EXPORT extern void TF_GetInputByName(TF_OpKernelContext* ctx,
const char* inputName,
TF_Tensor** tensor,
TF_Status* status);
=head2 TF_OpKernelConstruction_GetAttrTensorShape
=over 2
Interprets the named kernel construction attribute as a shape attribute and
fills in `vals` with the size of each dimension. `vals` must point to an
array of length at least `max_values` (ideally set to total_size from
TF_OpKernelConstruction_GetAttrSize(ctx, attr_name, &list_size,
&total_size)).
=back
/* From <tensorflow/c/kernels_experimental.h> */
TF_CAPI_EXPORT extern void TF_OpKernelConstruction_GetAttrTensorShape(
TF_OpKernelConstruction* ctx, const char* attr_name, int64_t* dims,
size_t num_dims, TF_Status* status);
=head2 TF_IsRefInput
=over 2
=back
/* From <tensorflow/c/kernels_experimental.h> */
TF_CAPI_EXPORT extern bool TF_IsRefInput(TF_OpKernelContext* ctx, int i,
TF_Status* status);
=head2 TF_AddNVariant
=over 2
Expose higher level AddN operation for Pluggable vendors to implement
in the plugin for Variant data types. The API takes in the context and a
callback provided by pluggable vendor to do a Binary Add operation on the
tensors unwrapped from the Variant tensors. The caller takes ownership of the
`a`, `b` and `out` tensors and is responsible for freeing them with
TF_DeleteTensor.
=back
/* From <tensorflow/c/kernels_experimental.h> */
TF_CAPI_EXPORT extern void TF_AddNVariant(
TF_OpKernelContext* ctx,
void (*binary_add_func)(TF_OpKernelContext* ctx, TF_Tensor* a, TF_Tensor* b,
TF_Tensor* out),
TF_Status* status);
=head2 TF_ZerosLikeVariant
=over 2
Expose higher level ZerosLike operation for Pluggable vendors to implement
in the plugin for Variant data types. The API takes in the context and a
callback provided by pluggable vendor to do a ZerosLike operation on the
tensors unwrapped from the Variant tensors. The caller takes ownership of the
`input` and `out` tensors and is responsible for freeing them with
TF_DeleteTensor.
=back
/* From <tensorflow/c/kernels_experimental.h> */
TF_CAPI_EXPORT extern void TF_ZerosLikeVariant(
TF_OpKernelContext* ctx,
void (*zeros_like_func)(TF_OpKernelContext* ctx, TF_Tensor* input,
TF_Tensor* out),
TF_Status* status);
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern TFE_Context* TFE_OpGetContext(const TFE_Op* op,
TF_Status* status);
=head2 TFE_OpSetDevice
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetDevice(TFE_Op* op, const char* device_name,
TF_Status* status);
=head2 TFE_OpGetDevice
=over 2
The returned string remains valid throughout the lifetime of 'op'.
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern const char* TFE_OpGetDevice(const TFE_Op* op,
TF_Status* status);
=head2 TFE_OpAddInput
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpAddInput(TFE_Op* op, TFE_TensorHandle* input,
TF_Status* status);
=head2 TFE_OpAddInputList
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpAddInputList(TFE_Op* op,
TFE_TensorHandle** inputs,
int num_inputs,
TF_Status* status);
=head2 TFE_OpGetFlatInputCount
=over 2
Fetches the current number of inputs attached to `op`.
Does not use the operation's definition to determine how many inputs should
be attached. It is intended for use with TFE_OpGetFlatInput to inspect an
already-finalized operation.
Note that TFE_OpGetFlatInputCount and TFE_OpGetFlatInput operate on a flat
sequence of inputs, unlike TFE_OpGetInputLength (for getting the length of a
particular named input list, which may only be part of the op's inputs).
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern int TFE_OpGetFlatInputCount(const TFE_Op* op,
TF_Status* status);
=head2 TFE_OpGetFlatInput
=over 2
Returns a borrowed reference to one of `op`'s inputs. Use
`TFE_TensorHandleCopySharingTensor` to make a new reference.
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern TFE_TensorHandle* TFE_OpGetFlatInput(const TFE_Op* op,
int index,
TF_Status* status);
=head2 TFE_OpGetAttrType
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern TF_AttrType TFE_OpGetAttrType(TFE_Op* op,
const char* attr_name,
unsigned char* is_list,
TF_Status* status);
=head2 TFE_OpNameGetAttrType
=over 2
Get an attribute type given an op name; a fusion of TFE_NewOp and
TFE_OpGetAttrType for use from Python without the overhead of the individual
calls and memory management of TFE_Op.
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern TF_AttrType TFE_OpNameGetAttrType(
TFE_Context* ctx, const char* op_or_function_name, const char* attr_name,
unsigned char* is_list, TF_Status* status);
=head2 TFE_OpSetAttrString
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrString(TFE_Op* op,
const char* attr_name,
const void* value,
size_t length);
=head2 TFE_OpSetAttrInt
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrInt(TFE_Op* op, const char* attr_name,
int64_t value);
=head2 TFE_OpSetAttrFloat
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrFloat(TFE_Op* op, const char* attr_name,
float value);
=head2 TFE_OpSetAttrBool
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrBool(TFE_Op* op, const char* attr_name,
unsigned char value);
=head2 TFE_OpSetAttrType
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrType(TFE_Op* op, const char* attr_name,
TF_DataType value);
=head2 TFE_OpSetAttrShape
=over 2
If the number of dimensions is unknown, `num_dims` must be set to
-1 and `dims` can be null. If a dimension is unknown, the
corresponding entry in the `dims` array must be -1.
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrShape(TFE_Op* op, const char* attr_name,
const int64_t* dims,
const int num_dims,
TF_Status* out_status);
=head2 TFE_OpSetAttrFunction
=over 2
Sets the attribute attr_name to be a function specified by 'function'.
TODO(ashankar,iga): Add this functionality to the C API for graph
construction. Perhaps we want an AttrValueMap equivalent in the C API?
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrFunction(TFE_Op* op,
const char* attr_name,
const TFE_Op* value);
=head2 TFE_OpSetAttrFunctionName
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT void TFE_OpSetAttrFunctionName(TFE_Op* op, const char* attr_name,
const char* data, size_t length);
=head2 TFE_OpSetAttrTensor
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrTensor(TFE_Op* op,
const char* attr_name,
TF_Tensor* tensor,
TF_Status* status);
=head2 TFE_OpSetAttrStringList
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrStringList(TFE_Op* op,
const char* attr_name,
const void* const* values,
const size_t* lengths,
int num_values);
=head2 TFE_OpSetAttrIntList
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrIntList(TFE_Op* op,
const char* attr_name,
const int64_t* values,
int num_values);
=head2 TFE_OpSetAttrFloatList
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrFloatList(TFE_Op* op,
const char* attr_name,
const float* values,
int num_values);
=head2 TFE_OpSetAttrBoolList
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrBoolList(TFE_Op* op,
const char* attr_name,
const unsigned char* values,
int num_values);
=head2 TFE_OpSetAttrTypeList
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrTypeList(TFE_Op* op,
const char* attr_name,
const TF_DataType* values,
int num_values);
=head2 TFE_OpSetAttrShapeList
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrShapeList(
TFE_Op* op, const char* attr_name, const int64_t** dims,
const int* num_dims, int num_values, TF_Status* out_status);
=head2 TFE_OpSetAttrFunctionList
=over 2
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_OpSetAttrFunctionList(TFE_Op* op,
const char* attr_name,
const TFE_Op** value,
int num_values);
=head2 TFE_OpGetInputLength
=over 2
Returns the length (number of tensors) of the input argument `input_name`
found in the provided `op`.
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern int TFE_OpGetInputLength(TFE_Op* op,
const char* input_name,
TF_Status* status);
=head2 TFE_OpGetOutputLength
=over 2
Returns the length (number of tensors) of the output argument `output_name`
found in the provided `op`.
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern int TFE_OpGetOutputLength(TFE_Op* op,
const char* output_name,
TF_Status* status);
=head2 TFE_Execute
=over 2
Execute the operation defined by 'op' and return handles to computed
tensors in `retvals`.
'retvals' must point to a pre-allocated array of TFE_TensorHandle* and
'*num_retvals' should be set to the size of this array. It is an error if
the size of 'retvals' is less than the number of outputs. This call sets
*num_retvals to the number of outputs.
If async execution is enabled, the call may simply enqueue the execution
and return "non-ready" handles in `retvals`. Note that any handles contained
in 'op' should not be mutated till the kernel execution actually finishes.
For sync execution, if any of the inputs to `op` are not ready, this call
will block till they become ready and then return when the kernel execution
is done.
TODO(agarwal): change num_retvals to int from int*.
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_Execute(TFE_Op* op, TFE_TensorHandle** retvals,
int* num_retvals, TF_Status* status);
=head2 TFE_ContextAddFunctionDef
=over 2
Add a function (serialized FunctionDef protocol buffer) to ctx so
that it can be invoked using TFE_Execute.
=back
/* From <tensorflow/c/eager/c_api.h> */
TF_CAPI_EXPORT extern void TFE_ContextAddFunctionDef(
TFE_Context* ctx, const char* serialized_function_def, size_t size,
TF_Status* status);
=head2 TFE_ContextAddFunction
=over 2
Adds a function (created from TF_GraphToFunction or
TF_FunctionImportFunctionDef) to the context, allowing it to be executed with
TFE_Execute by creating an op with the same name as the function.
=back
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=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
Given a Tensor, wrap it with a TensorHandle
Similar to TFE_NewTensorHandle, but includes a pointer to the TFE_Context.
The context should be identical to that of the Tensor.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT TFE_TensorHandle* TFE_NewTensorHandleFromTensor(
TFE_Context* ctx, TF_Tensor* t, TF_Status* status);
=head2 TFE_CreatePackedTensorHandle
=over 2
Create a packed TensorHandle with the given list of TensorHandles.
If `handles` are on the same device, assign the same device to the packed
handle; if `handles` are on different deivces, assign a CompositeDevice to
it.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern TFE_TensorHandle* TFE_CreatePackedTensorHandle(
TFE_Context* ctx, TFE_TensorHandle** handles, int* num_handles,
TF_Status* status);
=head2 TFE_ContextSetSoftDevicePlacement
=over 2
Configure soft device placement policy for the eager executor. Note this
policy is applied to any subsequent op executions.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT void TFE_ContextSetSoftDevicePlacement(TFE_Context* ctx,
unsigned char enable,
TF_Status* status);
=head2 TFE_ContextSetLogDevicePlacement
=over 2
Configure device placement policy logging for the eager executor. Note this
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=over 2
Report error (specified by error_code and error_message) to other tasks in
the cluster.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_ReportErrorToCluster(TFE_Context* ctx,
int error_code,
const char* error_message,
TF_Status* status);
=head2 TFE_GetTaskStates
=over 2
Get task states from the Coordination Service.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_GetTaskStates(TFE_Context* ctx,
const TF_Buffer& tasks,
void* states, TF_Status* status);
=head2 TFE_WaitAtBarrier
=over 2
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_WaitAtBarrier(TFE_Context* ctx,
const char* barrier_id,
int64_t barrier_timeout_in_ms,
TF_Status* status);
=head2 TF_GetNodesToPreserveListSize
=over 2
Get a set of node names that must be preserved. They can not be transformed
or removed during the graph transformation. This includes feed and fetch
nodes, keep_ops, init_ops. Fills in `num_values` and `storage_size`, they
will be used in `TF_GetNodesToPreserveList`.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_GetNodesToPreserveListSize(
const TF_GrapplerItem* item, int* num_values, size_t* storage_size,
TF_Status* status);
=head2 TF_GetNodesToPreserveList
=over 2
Get a set of node names that must be preserved. They can not be transformed
or removed during the graph transformation. This includes feed and fetch
nodes, keep_ops, init_ops. Fills in `values` and `lengths`, each of which
must point to an array of length at least `num_values`.
The elements of values will point to addresses in `storage` which must be at
least `storage_size` bytes in length. `num_values` and `storage` can be
obtained from TF_GetNodesToPreserveSize
Fails if storage_size is too small to hold the requested number of strings.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_GetNodesToPreserveList(
const TF_GrapplerItem* item, char** values, size_t* lengths, int num_values,
void* storage, size_t storage_size, TF_Status* status);
=head2 TF_GetFetchNodesListSize
=over 2
Get a set of node names for fetch nodes. Fills in `values` and `lengths`,
they will be used in `TF_GetFetchNodesList`
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_GetFetchNodesListSize(const TF_GrapplerItem* item,
int* num_values,
size_t* storage_size,
TF_Status* status);
=head2 TF_GetFetchNodesList
=over 2
Get a set of node names for fetch nodes. Fills in `values` and `lengths`,
each of which must point to an array of length at least `num_values`.
The elements of values will point to addresses in `storage` which must be at
least `storage_size` bytes in length. `num_values` and `storage` can be
obtained from TF_GetFetchNodesSize
Fails if storage_size is too small to hold the requested number of strings.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_GetFetchNodesList(const TF_GrapplerItem* item,
char** values, size_t* lengths,
int num_values, void* storage,
size_t storage_size,
TF_Status* status);
=head2 TF_NewGraphProperties
=over 2
Create GraphProperties. The item must outlive the properties.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern TF_GraphProperties* TF_NewGraphProperties(
const TF_GrapplerItem* item);
=head2 TF_DeleteGraphProperties
=over 2
Delete GraphProperties.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_DeleteGraphProperties(
TF_GraphProperties* graph_properties);
=head2 TF_InferStatically
=over 2
Infer tensor shapes through abstract interpretation.
If assume_valid_feeds is true, it can help infer shapes in the fanout of fed
nodes. This may cause incorrectness in graph analyses, but is useful for
simulation or scheduling.
If aggressive_shape_inference is true, nodes are executed on the host to
identify output values when possible and does other aggressive strategies.
This may cause incorrectness in graph analyses, but is useful for simulation
or scheduling.
If include_input_tensor_values is true, the values of constant
tensors will included in the input properties.
If include_output_tensor_values is true, the values of constant tensors will
be included in the output properties.
=back
/* From <tensorflow/c/experimental/grappler/grappler.h> */
TF_CAPI_EXPORT extern void TF_InferStatically(
TF_GraphProperties* graph_properties, TF_Bool assume_valid_feeds,
TF_Bool aggressive_shape_inference, TF_Bool include_input_tensor_values,
TF_Bool include_output_tensor_values, TF_Status* s);
=head2 TF_GetInputPropertiesListSize
=over 2
Get the size of input OpInfo::TensorProperties given node name.
=back
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=head2 TF_GetXlaConstantFoldingDisabled
=over 2
Gets/Sets TF/XLA flag for whether(true) or not(false) to disable constant
folding. This is for testing to ensure that XLA is being tested rather than
Tensorflow's CPU implementation through constant folding.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT unsigned char TF_GetXlaConstantFoldingDisabled();
=head2 TF_SetXlaConstantFoldingDisabled
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT void TF_SetXlaConstantFoldingDisabled(
unsigned char should_enable);
=head2 TF_CreateConfig
=over 2
Create a serialized tensorflow.ConfigProto proto, where:
a) ConfigProto.optimizer_options.global_jit_level is set to ON_1 if
`enable_xla_compilation` is non-zero, and OFF otherwise.
b) ConfigProto.gpu_options.allow_growth is set to `gpu_memory_allow_growth`.
c) ConfigProto.device_count is set to `num_cpu_devices`.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern TF_Buffer* TF_CreateConfig(
unsigned char enable_xla_compilation, unsigned char gpu_memory_allow_growth,
unsigned int num_cpu_devices);
=head2 TF_CreateRunOptions
=over 2
Create a serialized tensorflow.RunOptions proto, where RunOptions.trace_level
is set to FULL_TRACE if `enable_full_trace` is non-zero, and NO_TRACE
otherwise.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern TF_Buffer* TF_CreateRunOptions(
unsigned char enable_full_trace);
=head2 TF_GraphDebugString
=over 2
Returns the graph content in a human-readable format, with length set in
`len`. The format is subject to change in the future.
The returned string is heap-allocated, and caller should call free() on it.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern const char* TF_GraphDebugString(TF_Graph* graph,
size_t* len);
=head2 TF_FunctionDebugString
=over 2
Returns the function content in a human-readable format, with length set in
`len`. The format is subject to change in the future.
The returned string is heap-allocated, and caller should call free() on it.
Do not return const char*, because some foreign language binding
(e.g. swift) cannot then call free() on the returned pointer.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern char* TF_FunctionDebugString(TF_Function* func,
size_t* len);
=head2 TF_DequeueNamedTensor
=over 2
Caller must call TF_DeleteTensor() over the returned tensor. If the queue is
empty, this call is blocked.
Tensors are enqueued via the corresponding TF enqueue op.
TODO(hongm): Add support for `timeout_ms`.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern TF_Tensor* TF_DequeueNamedTensor(TF_Session* session,
int tensor_id,
TF_Status* status);
=head2 TF_EnqueueNamedTensor
=over 2
On success, enqueues `tensor` into a TF-managed FifoQueue given by
`tensor_id`, associated with `session`. There must be a graph node named
"fifo_queue_enqueue_<tensor_id>", to be executed by this API call. It reads
from a placeholder node "arg_tensor_enqueue_<tensor_id>".
`tensor` is still owned by the caller. This call will be blocked if the queue
has reached its capacity, and will be unblocked when the queued tensors again
drop below the capacity due to dequeuing.
Tensors are dequeued via the corresponding TF dequeue op.
TODO(hongm): Add support for `timeout_ms`.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TF_EnqueueNamedTensor(TF_Session* session,
int tensor_id,
TF_Tensor* tensor,
TF_Status* status);
=head2 TF_MakeInternalErrorStatus
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=head2 TF_NewAttrBuilder
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern TF_AttrBuilder* TF_NewAttrBuilder(const char* op_name);
=head2 TF_DeleteAttrBuilder
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TF_DeleteAttrBuilder(TF_AttrBuilder* builder);
=head2 TF_AttrBuilderSetType
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TF_AttrBuilderSetType(TF_AttrBuilder* builder,
const char* attr_name,
TF_DataType value);
=head2 TF_AttrBuilderSetTypeList
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TF_AttrBuilderSetTypeList(TF_AttrBuilder* builder,
const char* attr_name,
const TF_DataType* values,
int num_values);
=head2 TF_AttrBuilderCheckCanRunOnDevice
=over 2
Checks the tensorflow::NodeDef built via the methods above to see if it can
run on device_type.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TF_AttrBuilderCheckCanRunOnDevice(
TF_AttrBuilder* builder, const char* device_type, TF_Status* status);
=head2 TF_GetNumberAttrForOpListInput
=over 2
For argument number input_index, fetch the corresponding number_attr that
needs to be updated with the argument length of the input list.
Returns nullptr if there is any problem like op_name is not found, or the
argument does not support this attribute type.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern const char* TF_GetNumberAttrForOpListInput(
const char* op_name, int input_index, TF_Status* status);
=head2 TF_OpIsStateful
=over 2
Returns 1 if the op is stateful, 0 otherwise. The return value is undefined
if the status is not ok.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern int TF_OpIsStateful(const char* op_type,
TF_Status* status);
=head2 TF_InitMain
=over 2
Platform specific initialization routine. Very few platforms actually require
this to be called.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT void TF_InitMain(const char* usage, int* argc, char*** argv);
=head2 TF_PickUnusedPortOrDie
=over 2
Platform-specific implementation to return an unused port. (This should used
in tests only.)
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT int TF_PickUnusedPortOrDie(void);
=head2 TFE_NewTensorHandleFromScalar
=over 2
Fast path method that makes constructing a single scalar tensor require less
overhead and copies.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern TFE_TensorHandle* TFE_NewTensorHandleFromScalar(
TF_DataType data_type, void* data, size_t len, TF_Status* status);
=head2 TFE_EnableCollectiveOps