view release on metacpan or search on metacpan
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
TF_Graph* graph, const char* op_type, const char* oper_name);
=head2 TF_SetDevice
=over 2
Specify the device for `desc`. Defaults to empty, meaning unconstrained.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SetDevice(TF_OperationDescription* desc,
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
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
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
=over 2
Builds the while loop specified by `params` and returns the output tensors of
the while loop in `outputs`. `outputs` should be allocated to size
`params.ninputs`.
`params` is no longer valid once this returns.
Either this or TF_AbortWhile() must be called after a successful
TF_NewWhile() call.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_FinishWhile(const TF_WhileParams* params,
TF_Status* status,
TF_Output* outputs);
=head2 TF_AbortWhile
=over 2
Frees `params`s resources without building a while loop. `params` is no
longer valid after this returns. Either this or TF_FinishWhile() must be
called after a successful TF_NewWhile() call.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_AbortWhile(const TF_WhileParams* params);
=head2 TF_AddGradients
=over 2
Adds operations to compute the partial derivatives of sum of `y`s w.r.t `x`s,
i.e., d(y_1 + y_2 + ...)/dx_1, d(y_1 + y_2 + ...)/dx_2...
`dx` are used as initial gradients (which represent the symbolic partial
derivatives of some loss function `L` w.r.t. `y`).
`dx` must be nullptr or have size `ny`.
If `dx` is nullptr, the implementation will use dx of `OnesLike` for all
shapes in `y`.
The partial derivatives are returned in `dy`. `dy` should be allocated to
size `nx`.
Gradient nodes are automatically named under the "gradients/" prefix. To
guarantee name uniqueness, subsequent calls to the same graph will
append an incremental tag to the prefix: "gradients_1/", "gradients_2/", ...
See TF_AddGradientsWithPrefix, which provides a means to specify a custom
name prefix for operations added to a graph to compute the gradients.
WARNING: This function does not yet support all the gradients that python
supports. See
https://www.tensorflow.org/code/tensorflow/cc/gradients/README.md
for instructions on how to add C++ more gradients.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT void TF_AddGradients(TF_Graph* g, TF_Output* y, int ny,
TF_Output* x, int nx, TF_Output* dx,
TF_Status* status, TF_Output* dy);
=head2 TF_AddGradientsWithPrefix
=over 2
Adds operations to compute the partial derivatives of sum of `y`s w.r.t `x`s,
i.e., d(y_1 + y_2 + ...)/dx_1, d(y_1 + y_2 + ...)/dx_2...
This is a variant of TF_AddGradients that allows to caller to pass a custom
name prefix to the operations added to a graph to compute the gradients.
`dx` are used as initial gradients (which represent the symbolic partial
derivatives of some loss function `L` w.r.t. `y`).
`dx` must be nullptr or have size `ny`.
If `dx` is nullptr, the implementation will use dx of `OnesLike` for all
shapes in `y`.
The partial derivatives are returned in `dy`. `dy` should be allocated to
size `nx`.
`prefix` names the scope into which all gradients operations are being added.
`prefix` must be unique within the provided graph otherwise this operation
will fail. If `prefix` is nullptr, the default prefixing behaviour takes
place, see TF_AddGradients for more details.
WARNING: This function does not yet support all the gradients that python
supports. See
https://www.tensorflow.org/code/tensorflow/cc/gradients/README.md
for instructions on how to add C++ more gradients.
=back
/* 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.
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_DeleteSession(TF_Session*, TF_Status* status);
=head2 TF_SessionRun
=over 2
Run the graph associated with the session starting with the supplied inputs
(inputs[0,ninputs-1] with corresponding values in input_values[0,ninputs-1]).
Any NULL and non-NULL value combinations for (`run_options`,
`run_metadata`) are valid.
- `run_options` may be NULL, in which case it will be ignored; or
non-NULL, in which case it must point to a `TF_Buffer` containing the
serialized representation of a `RunOptions` protocol buffer.
- `run_metadata` may be NULL, in which case it will be ignored; or
non-NULL, in which case it must point to an empty, freshly allocated
`TF_Buffer` that may be updated to contain the serialized representation
of a `RunMetadata` protocol buffer.
The caller retains ownership of `input_values` (which can be deleted using
TF_DeleteTensor). The caller also retains ownership of `run_options` and/or
`run_metadata` (when not NULL) and should manually call TF_DeleteBuffer on
them.
On success, the tensors corresponding to outputs[0,noutputs-1] are placed in
output_values[]. Ownership of the elements of output_values[] is transferred
to the caller, which must eventually call TF_DeleteTensor on them.
On failure, output_values[] contains NULLs.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SessionRun(
TF_Session* session,
// RunOptions
const TF_Buffer* run_options,
// Input tensors
const TF_Output* inputs, TF_Tensor* const* input_values, int ninputs,
// Output tensors
const TF_Output* outputs, TF_Tensor** output_values, int noutputs,
// Target operations
const TF_Operation* const* target_opers, int ntargets,
// RunMetadata
TF_Buffer* run_metadata,
// Output status
TF_Status*);
=head2 TF_SessionPRunSetup
=over 2
Set up the graph with the intended feeds (inputs) and fetches (outputs) for a
sequence of partial run calls.
On success, returns a handle that is used for subsequent PRun calls. The
handle should be deleted with TF_DeletePRunHandle when it is no longer
needed.
On failure, out_status contains a tensorflow::Status with an error
message. *handle is set to nullptr.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SessionPRunSetup(
TF_Session*,
// Input names
const TF_Output* inputs, int ninputs,
// Output names
const TF_Output* outputs, int noutputs,
// Target operations
const TF_Operation* const* target_opers, int ntargets,
// Output handle
const char** handle,
// Output status
TF_Status*);
=head2 TF_SessionPRun
=over 2
Continue to run the graph with additional feeds and fetches. The
execution state is uniquely identified by the handle.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_SessionPRun(
TF_Session*, const char* handle,
// Input tensors
const TF_Output* inputs, TF_Tensor* const* input_values, int ninputs,
// Output tensors
const TF_Output* outputs, TF_Tensor** output_values, int noutputs,
// Target operations
const TF_Operation* const* target_opers, int ntargets,
// Output status
TF_Status*);
=head2 TF_DeletePRunHandle
=over 2
Deletes a handle allocated by TF_SessionPRunSetup.
Once called, no more calls to TF_SessionPRun should be made.
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_DeletePRunHandle(const char* handle);
=head2 TF_NewDeprecatedSession
=over 2
=back
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=back
/* From <tensorflow/c/c_api.h> */
TF_CAPI_EXPORT extern void TF_RegisterFilesystemPlugin(
const char* plugin_filename, TF_Status* status);
=head2 TF_NewShape
=over 2
Return a new, unknown rank shape object. The caller is responsible for
calling TF_DeleteShape to deallocate and destroy the returned shape.
=back
/* From <tensorflow/c/tf_shape.h> */
TF_CAPI_EXPORT extern TF_Shape* TF_NewShape();
=head2 TF_ShapeDims
=over 2
Returns the rank of `shape`. If `shape` has unknown rank, returns -1.
=back
/* From <tensorflow/c/tf_shape.h> */
TF_CAPI_EXPORT extern int TF_ShapeDims(const TF_Shape* shape);
=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*);
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=head2 TF_OpDefinitionBuilderSetShapeInferenceFunction
=over 2
Sets the shape inference function for the op.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_OpDefinitionBuilderSetShapeInferenceFunction(
TF_OpDefinitionBuilder* builder,
void (*shape_inference_func)(TF_ShapeInferenceContext* ctx,
TF_Status* status));
=head2 TF_ShapeInferenceContextNumInputs
=over 2
Returns the number of inputs in the given shape inference context.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern int64_t TF_ShapeInferenceContextNumInputs(
TF_ShapeInferenceContext* ctx);
=head2 TF_NewShapeHandle
=over 2
Returns a newly allocated shape handle. The shapes represented by these
handles may be queried or mutated with the corresponding
TF_ShapeInferenceContext... functions.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern TF_ShapeHandle* TF_NewShapeHandle();
=head2 TF_ShapeInferenceContextGetInput
=over 2
Places the ith input of the given shape inference context into the given
shape handle, or returns a status other than TF_OK indicating why the input
could not be retrieved
(for example, if i < 0 || i >= TF_ShapeInferenceContextNumInputs(ctx)).
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_ShapeInferenceContextGetInput(
TF_ShapeInferenceContext* ctx, int i, TF_ShapeHandle* handle,
TF_Status* status);
=head2 TF_ShapeInferenceContextSetOutput
=over 2
Places the given shape handle into the `i`th output position of the given
context. Internally, the shape handle is copied; the caller may subsequently
delete `handle`.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT
extern void TF_ShapeInferenceContextSetOutput(TF_ShapeInferenceContext* ctx,
int i, TF_ShapeHandle* handle,
TF_Status* status);
=head2 TF_ShapeInferenceContextScalar
=over 2
Returns a newly-allocated scalar shape handle. The returned handle should
be freed with TF_DeleteShapeHandle.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern TF_ShapeHandle* TF_ShapeInferenceContextScalar(
TF_ShapeInferenceContext* ctx);
=head2 TF_ShapeInferenceContextVectorFromSize
=over 2
Returns a newly-allocate shape handle representing a vector of the given
size. The returned handle should be freed with TF_DeleteShapeHandle.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern TF_ShapeHandle* TF_ShapeInferenceContextVectorFromSize(
TF_ShapeInferenceContext* ctx, size_t size);
=head2 TF_NewDimensionHandle
=over 2
Returns a newly allocated dimension handle. It must be freed with
TF_DeleteDimensionHandle.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern TF_DimensionHandle* TF_NewDimensionHandle();
=head2 TF_ShapeInferenceContext_GetAttrType
=over 2
Interprets the named shape inference context 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
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=over 2
If <handle> has rank <rank>, or its rank is unknown, return OK and return the
shape with asserted rank in <*result>. Otherwise an error is placed into
`status`.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_ShapeInferenceContextWithRank(
TF_ShapeInferenceContext* ctx, TF_ShapeHandle* handle, int64_t rank,
TF_ShapeHandle* result, TF_Status* status);
=head2 TF_ShapeInferenceContextWithRankAtLeast
=over 2
If <handle> has rank at least <rank>, or its rank is unknown, return OK and
return the shape with asserted rank in <*result>. Otherwise an error is
placed into `status`.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_ShapeInferenceContextWithRankAtLeast(
TF_ShapeInferenceContext* ctx, TF_ShapeHandle* handle, int64_t rank,
TF_ShapeHandle* result, TF_Status* status);
=head2 TF_ShapeInferenceContextWithRankAtMost
=over 2
If <handle> has rank at most <rank>, or its rank is unknown, return OK and
return the shape with asserted rank in <*result>. Otherwise an error is
placed into `status`.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_ShapeInferenceContextWithRankAtMost(
TF_ShapeInferenceContext* ctx, TF_ShapeHandle* handle, int64_t rank,
TF_ShapeHandle* result, TF_Status* status);
=head2 TF_ShapeInferenceContextDim
=over 2
Places a handle to the ith dimension of the given shape into *result.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_ShapeInferenceContextDim(
TF_ShapeInferenceContext* ctx, TF_ShapeHandle* shape_handle, int64_t i,
TF_DimensionHandle* result);
=head2 TF_ShapeInferenceContextSubshape
=over 2
Returns in <*result> a sub-shape of <shape_handle>, with dimensions
[start:end]. <start> and <end> can be negative, to index from the end of the
shape. <start> and <end> are set to the rank of <shape_handle> if > rank of
<shape_handle>.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_ShapeInferenceContextSubshape(
TF_ShapeInferenceContext* ctx, TF_ShapeHandle* shape_handle, int64_t start,
int64_t end, TF_ShapeHandle* result, TF_Status* status);
=head2 TF_ShapeInferenceContextSetUnknownShape
=over 2
Places an unknown shape in all outputs for the given inference context. Used
for shape inference functions with ops whose output shapes are unknown.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_ShapeInferenceContextSetUnknownShape(
TF_ShapeInferenceContext* ctx, TF_Status* status);
=head2 TF_DimensionHandleValueKnown
=over 2
Returns whether the given handle represents a known dimension.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern int TF_DimensionHandleValueKnown(
TF_DimensionHandle* dim_handle);
=head2 TF_DimensionHandleValue
=over 2
Returns the value of the given dimension.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern int64_t TF_DimensionHandleValue(
TF_DimensionHandle* dim_handle);
=head2 TF_ShapeInferenceContextConcatenateShapes
=over 2
Returns in <*result> the result of appending the dimensions of <second> to
those of <first>.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_ShapeInferenceContextConcatenateShapes(
TF_ShapeInferenceContext* ctx, TF_ShapeHandle* first,
TF_ShapeHandle* second, TF_ShapeHandle* result, TF_Status* status);
=head2 TF_DeleteShapeHandle
=over 2
Frees the given shape handle.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_DeleteShapeHandle(TF_ShapeHandle* handle);
=head2 TF_DeleteDimensionHandle
=over 2
Frees the given dimension handle.
=back
/* From <tensorflow/c/ops.h> */
TF_CAPI_EXPORT extern void TF_DeleteDimensionHandle(TF_DimensionHandle* handle);
=head2 TF_CreateDir
=over 2
Creates the specified directory. Typical status code are:
* TF_OK - successfully created the directory
* TF_ALREADY_EXISTS - directory already exists
* TF_PERMISSION_DENIED - dirname is not writable
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_CreateDir(const char* dirname, TF_Status* status);
=head2 TF_DeleteDir
=over 2
Deletes the specified directory. Typical status codes are:
* TF_OK - successfully deleted the directory
* TF_FAILED_PRECONDITION - the directory is not empty
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_DeleteDir(const char* dirname, TF_Status* status);
=head2 TF_DeleteRecursively
=over 2
Deletes the specified directory and all subdirectories and files underneath
it. This is accomplished by traversing the directory tree rooted at dirname
and deleting entries as they are encountered.
If dirname itself is not readable or does not exist, *undeleted_dir_count is
set to 1, *undeleted_file_count is set to 0 and an appropriate status (e.g.
TF_NOT_FOUND) is returned.
If dirname and all its descendants were successfully deleted, TF_OK is
returned and both error counters are set to zero.
Otherwise, while traversing the tree, undeleted_file_count and
undeleted_dir_count are updated if an entry of the corresponding type could
not be deleted. The returned error status represents the reason that any one
of these entries could not be deleted.
Typical status codes:
* TF_OK - dirname exists and we were able to delete everything underneath
* TF_NOT_FOUND - dirname doesn't exist
* TF_PERMISSION_DENIED - dirname or some descendant is not writable
* TF_UNIMPLEMENTED - some underlying functions (like Delete) are not
implemented
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_DeleteRecursively(const char* dirname,
int64_t* undeleted_file_count,
int64_t* undeleted_dir_count,
TF_Status* status);
=head2 TF_FileStat
=over 2
Obtains statistics for the given path. If status is TF_OK, *stats is
updated, otherwise it is not touched.
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_FileStat(const char* filename,
TF_FileStatistics* stats,
TF_Status* status);
=head2 TF_NewWritableFile
=over 2
Creates or truncates the given filename and returns a handle to be used for
appending data to the file. If status is TF_OK, *handle is updated and the
caller is responsible for freeing it (see TF_CloseWritableFile).
=back
/* From <tensorflow/c/env.h> */
TF_CAPI_EXPORT extern void TF_NewWritableFile(const char* filename,
TF_WritableFileHandle** handle,
TF_Status* status);
=head2 TF_CloseWritableFile
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_KernelBuilder_Label(
TF_KernelBuilder* kernel_builder, const char* label);
=head2 TF_RegisterKernelBuilder
=over 2
Register the given kernel builder with the TensorFlow runtime. If
registration fails, the given status will be populated.
This call takes ownership of the `builder` pointer.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_RegisterKernelBuilder(const char* kernel_name,
TF_KernelBuilder* builder,
TF_Status* status);
=head2 TF_RegisterKernelBuilderWithKernelDef
=over 2
Register the given kernel builder with the TensorFlow runtime. If
registration fails, the given status will be populated.
This method is the same as TF_RegisterKernelBuilder except it takes in a
serialized KernelDef, and uses it for registration, instead of building a new
one. Users can choose to not provide a serialized KernelDef and in that case
it's identical to TF_RegisterKernelBuilder.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_RegisterKernelBuilderWithKernelDef(
const char* serialized_kernel_def, const char* name,
TF_KernelBuilder* builder, TF_Status* status);
=head2 TF_DeleteKernelBuilder
=over 2
Deletes the given TF_KernelBuilder. This should be called only if the kernel
builder is not registered with TensorFlow via TF_RegisterKernelBuilder.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_DeleteKernelBuilder(TF_KernelBuilder* builder);
=head2 TF_GetStream
=over 2
TF_GetStream returns the SP_Stream available in ctx.
This function returns a stream only for devices registered using the
StreamExecutor C API
(tensorflow/c/experimental/stream_executor/stream_executor.h). It will return
nullptr and set error status in all other cases.
Experimental: this function doesn't have compatibility guarantees and subject
to change at any time.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern SP_Stream TF_GetStream(TF_OpKernelContext* ctx,
TF_Status* status);
=head2 TF_NumInputs
=over 2
TF_NumInputs returns the number of inputs available in ctx.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern int TF_NumInputs(TF_OpKernelContext* ctx);
=head2 TF_NumOutputs
=over 2
TF_NumOutputs returns the number of outputs to be placed in *ctx by the
kernel.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern int TF_NumOutputs(TF_OpKernelContext* ctx);
=head2 TF_GetInput
=over 2
Retrieves the ith input from ctx. If TF_GetCode(status) is TF_OK, *tensor is
populated and its ownership is passed to the caller. In any other case,
*tensor is not modified.
If i < 0 or i >= TF_NumInputs(ctx), *status is set to TF_OUT_OF_RANGE.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_GetInput(TF_OpKernelContext* ctx, int i,
TF_Tensor** tensor, TF_Status* status);
=head2 TF_InputRange
=over 2
Retrieves the start and stop indices, given the input name. Equivalent to
OpKernel::InputRange(). `args` will contain the result indices and status.
=back
/* From <tensorflow/c/kernels.h> */
TF_CAPI_EXPORT extern void TF_InputRange(TF_OpKernelContext* ctx,
const char* name,
TF_InputRange_Args* args);
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
This call may not block for execution of ops enqueued concurrently with this
call.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_ExecutorWaitForAllPendingNodes(
TFE_Executor*, TF_Status* status);
=head2 TFE_ExecutorClearError
=over 2
When an error happens, any pending operations are discarded, and newly issued
ops return an error. This call clears the error state and re-enables
execution of newly issued ops.
Note that outputs of discarded ops remain in a corrupt state and should not
be used for future calls.
TODO(agarwal): mark the affected handles and raise errors if they are used.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_ExecutorClearError(TFE_Executor*);
=head2 TFE_ContextSetExecutorForThread
=over 2
Sets a custom Executor for the current thread. All nodes created by this
thread will be added to this Executor. It will override the current executor.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_ContextSetExecutorForThread(TFE_Context*,
TFE_Executor*);
=head2 TFE_ContextGetExecutorForThread
=over 2
Returns the Executor for the current thread.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern TFE_Executor* TFE_ContextGetExecutorForThread(
TFE_Context*);
=head2 TFE_ContextUpdateServerDef
=over 2
Update an existing context with a new set of servers defined in a ServerDef
proto. Servers can be added to and removed from the list of remote workers
in the context. A New set of servers identified by the ServerDef must be up
when the context is updated.
This API is for experimental usage and may be subject to change.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_ContextUpdateServerDef(TFE_Context* ctx,
int keep_alive_secs,
const void* proto,
size_t proto_len,
TF_Status* status);
=head2 TFE_ContextCheckAlive
=over 2
Checks whether a remote worker is alive or not. This will return true even if
the context doesn't exist on the remote worker.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern bool TFE_ContextCheckAlive(TFE_Context* ctx,
const char* worker_name,
TF_Status* status);
=head2 TFE_ContextAsyncWait
=over 2
Sync pending nodes in local executors (including the context default executor
and thread executors) and streaming requests to remote executors, and get the
combined status.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_ContextAsyncWait(TFE_Context* ctx,
TF_Status* status);
=head2 TFE_TensorHandleDevicePointer
=over 2
This function will block till the operation that produces `h` has
completed. This is only valid on local TFE_TensorHandles. The pointer
returned will be on the device in which the TFE_TensorHandle resides (so e.g.
for a GPU tensor this will return a pointer to GPU memory). The pointer is
only guaranteed to be valid until TFE_DeleteTensorHandle is called on this
TensorHandle. Only supports POD data types.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void* TFE_TensorHandleDevicePointer(TFE_TensorHandle*,
TF_Status*);
=head2 TFE_TensorHandleDeviceMemorySize
=over 2
This function will block till the operation that produces `h` has
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
/* 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
policy is applied to any subsequent op executions.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT void TFE_ContextSetLogDevicePlacement(TFE_Context* ctx,
unsigned char enable,
TF_Status* status);
=head2 TFE_ContextSetRunEagerOpAsFunction
=over 2
Enables running eager ops as function.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT void TFE_ContextSetRunEagerOpAsFunction(TFE_Context* ctx,
unsigned char enable,
TF_Status* status);
=head2 TFE_ContextSetJitCompileRewrite
=over 2
Enables rewrite jit_compile functions.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT void TFE_ContextSetJitCompileRewrite(TFE_Context* ctx,
unsigned char enable,
TF_Status* status);
=head2 TFE_TensorHandleDeviceType
=over 2
Returns the device type of the operation that produced `h`.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern const char* TFE_TensorHandleDeviceType(
TFE_TensorHandle* h, TF_Status* status);
=head2 TFE_TensorHandleDeviceID
=over 2
Returns the device ID of the operation that produced `h`.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern int TFE_TensorHandleDeviceID(TFE_TensorHandle* h,
TF_Status* status);
=head2 TFE_TensorHandleGetStatus
=over 2
Returns the status for the tensor handle. In TFRT, a tensor handle can carry
error info if error happens. If so, the status will be set with the error
info. If not, status will be set as OK.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_TensorHandleGetStatus(TFE_TensorHandle* h,
TF_Status* status);
=head2 TFE_GetExecutedOpNames
=over 2
Get a comma-separated list of op names executed in graph functions dispatched
to `ctx`. This feature is currently only enabled for TFRT debug builds, for
performance and simplicity reasons.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_GetExecutedOpNames(TFE_Context* ctx,
TF_Buffer* buf,
TF_Status* status);
=head2 TFE_SetLogicalCpuDevices
=over 2
Set logical devices to the context's device manager.
If logical devices are already configured at context initialization
through TFE_ContextOptions, this method should not be called.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_SetLogicalCpuDevices(TFE_Context* ctx,
int num_cpus,
const char* prefix,
TF_Status* status);
=head2 TFE_InsertConfigKeyValue
=over 2
Set configuration key and value using coordination service.
If coordination service is enabled, the key-value will be stored on the
leader and become accessible to all workers in the cluster.
Currently, a config key can only be set with one value, and subsequently
setting the same key will lead to errors.
Note that the key-values are only expected to be used for cluster
configuration data, and should not be used for storing a large amount of data
or being accessed very frequently.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_InsertConfigKeyValue(TFE_Context* ctx,
const char* key,
const char* value,
TF_Status* status);
=head2 TFE_GetConfigKeyValue
=over 2
Get configuration key and value using coordination service.
The config key must be set before getting its value. Getting value of
non-existing config keys will result in errors.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_GetConfigKeyValue(TFE_Context* ctx,
const char* key,
TF_Buffer* value_buf,
TF_Status* status);
=head2 TFE_DeleteConfigKeyValue
=over 2
Delete configuration key-value. If `key` is a directory, recursively clean up
all key-values under the path specified by `key`.
=back
/* From <tensorflow/c/eager/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_DeleteConfigKeyValue(TFE_Context* ctx,
const char* key,
TF_Status* status);
=head2 TFE_ReportErrorToCluster
=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
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
Returns:
If status is not OK, returns nullptr. Otherwise, returns a
TF_ConcreteFunction instance. The lifetime of this instance is
"conceptually" bound to `model`. Once `model` is deleted, all
`TF_ConcreteFunctions` retrieved from it are invalid, and have been deleted.
=back
/* From <tensorflow/c/experimental/saved_model/public/saved_model_api.h> */
TF_CAPI_EXPORT extern TF_ConcreteFunction* TF_GetSavedModelConcreteFunction(
TF_SavedModel* model, const char* function_path, TF_Status* status);
=head2 TF_GetSavedModelSignatureDefFunction
=over 2
Retrieve a function from the TF SavedModel via a SignatureDef key.
Params:
model - The SavedModel to load a function from.
signature_def_key - The string key of the SignatureDef map of a SavedModel:
https://github.com/tensorflow/tensorflow/blob/69b08900b1e991d84bce31f3b404f5ed768f339f/tensorflow/core/protobuf/meta_graph.proto#L89
status - Set to OK on success and an appropriate error on failure.
Returns:
If status is not OK, returns nullptr. Otherwise, returns a
TF_SignatureDefFunction instance. Once `model` is deleted, all
`TF_SignatureDefFunctions` retrieved from it are invalid, and have been
deleted.
=back
/* From <tensorflow/c/experimental/saved_model/public/saved_model_api.h> */
TF_CAPI_EXPORT extern TF_SignatureDefFunction*
TF_GetSavedModelSignatureDefFunction(TF_SavedModel* model,
const char* signature_def_key,
TF_Status* status);
=head2 TF_ConcreteFunctionGetMetadata
=over 2
Returns FunctionMetadata associated with `func`. Metadata's lifetime is
bound to `func`, which is bound to the TF_SavedModel it was loaded from.
=back
/* From <tensorflow/c/experimental/saved_model/public/concrete_function.h> */
TF_CAPI_EXPORT extern TF_FunctionMetadata* TF_ConcreteFunctionGetMetadata(
TF_ConcreteFunction* func);
=head2 TF_ConcreteFunctionMakeCallOp
=over 2
Returns a TFE_Op suitable for executing this function. Caller must provide
all function inputs in `inputs`, and must not add any additional inputs on
the returned op. (i.e. don't call TFE_OpAddInput or TFE_OpAddInputList).
The caller is responsible for deleting the returned TFE_Op. If op
construction fails, `status` will be non-OK and the returned pointer will be
null.
TODO(bmzhao): Remove this function in a subsequent change; Design + implement
a Function Execution interface for ConcreteFunction that accepts a tagged
union of types (tensorflow::Value). This effectively requires moving much of
the implementation of function.py/def_function.py to C++, and exposing a
high-level API here. A strawman for what this interface could look like:
TF_Value* TF_ExecuteFunction(TFE_Context*, TF_ConcreteFunction*, TF_Value*
inputs, int num_inputs, TF_Status* status);
=back
/* From <tensorflow/c/experimental/saved_model/public/concrete_function.h> */
TF_CAPI_EXPORT extern TFE_Op* TF_ConcreteFunctionMakeCallOp(
TF_ConcreteFunction* func, TFE_TensorHandle** inputs, int num_inputs,
TF_Status* status);
=head2 TF_SignatureDefParamName
=over 2
Returns the name of the given parameter. The caller is not responsible for
freeing the returned char*.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_param.h> */
TF_CAPI_EXPORT extern const char* TF_SignatureDefParamName(
const TF_SignatureDefParam* param);
=head2 TF_SignatureDefParamTensorSpec
=over 2
Returns the TensorSpec associated with the given parameter. The caller is
not reponsible for freeing the returned TF_TensorSpec*.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_param.h> */
TF_CAPI_EXPORT extern const TF_TensorSpec* TF_SignatureDefParamTensorSpec(
const TF_SignatureDefParam* param);
=head2 TF_SignatureDefFunctionGetMetadata
=over 2
Returns FunctionMetadata associated with `func`. Metadata's lifetime is
bound to `func`, which is bound to the TF_SavedModel it was loaded from.
=back
/* From <tensorflow/c/experimental/saved_model/public/signature_def_function.h> */
TF_CAPI_EXPORT extern TF_SignatureDefFunctionMetadata*
TF_SignatureDefFunctionGetMetadata(TF_SignatureDefFunction* func);
=head2 TF_SignatureDefFunctionMakeCallOp
=over 2
Returns a TFE_Op suitable for executing this function. Caller must provide
all function inputs in `inputs`, and must not add any additional inputs on
the returned op. (i.e. don't call TFE_OpAddInput or TFE_OpAddInputList).
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> */
TF_CAPI_EXPORT extern void TF_MakeInternalErrorStatus(TF_Status* status,
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
=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
=over 2
Specify the server_def that enables collective ops.
This is different to the above function in that it doesn't create remote
contexts, and remotely executing ops is not possible. It just enables
communication for collective ops.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_EnableCollectiveOps(TFE_Context* ctx,
const void* proto,
size_t proto_len,
TF_Status* status);
=head2 TFE_AbortCollectiveOps
=over 2
Aborts all ongoing collectives with the specified status. After abortion,
subsequent collectives will error with this status immediately. To reset the
collectives, create a new EagerContext.
This is intended to be used when a peer failure is detected.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_AbortCollectiveOps(TFE_Context* ctx,
TF_Status* status);
=head2 TFE_CollectiveOpsCheckPeerHealth
=over 2
Checks the health of collective ops peers. Explicit health check is needed in
multi worker collective ops to detect failures in the cluster. If a peer is
down, collective ops may hang.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TFE_CollectiveOpsCheckPeerHealth(
TFE_Context* ctx, const char* task, int64_t timeout_in_ms,
TF_Status* status);
=head2 TF_NewShapeAndTypeList
=over 2
API for manipulating TF_ShapeAndTypeList objects.
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern TF_ShapeAndTypeList* TF_NewShapeAndTypeList(
int num_shapes);
=head2 TF_ShapeAndTypeListSetShape
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TF_ShapeAndTypeListSetShape(
TF_ShapeAndTypeList* shape_list, int index, const int64_t* dims,
int num_dims);
=head2 TF_ShapeAndTypeListSetUnknownShape
=over 2
=back
/* From <tensorflow/c/c_api_experimental.h> */
TF_CAPI_EXPORT extern void TF_ShapeAndTypeListSetUnknownShape(
TF_ShapeAndTypeList* shape_list, int index);
=head2 TF_ShapeAndTypeListSetDtype