AI-TensorFlow-Libtensorflow

 view release on metacpan or  search on metacpan

lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod  view on Meta::CPAN


  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
       OpDef.

=back

  /* From <tensorflow/c/c_api.h> */
  TF_CAPI_EXPORT extern TF_Function* TF_GraphToFunctionWithControlOutputs(
      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,
      int ncontrol_outputs, const TF_Operation* const* control_outputs,

lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod  view on Meta::CPAN

  Returns the `i`th TF_SignatureDefParam in the list.

=back

  /* From <tensorflow/c/experimental/saved_model/public/signature_def_param_list.h> */
  TF_CAPI_EXPORT extern const TF_SignatureDefParam* TF_SignatureDefParamListGet(
      const TF_SignatureDefParamList* list, int i);

=head2 TF_SignatureDefFunctionMetadataArgs

=over 2

  Retrieves the arguments of the SignatureDefFunction. The caller is not
  responsible for freeing the returned pointer.

=back

  /* From <tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h> */
  TF_CAPI_EXPORT extern const TF_SignatureDefParamList*
  TF_SignatureDefFunctionMetadataArgs(
      const TF_SignatureDefFunctionMetadata* list);

=head2 TF_SignatureDefFunctionMetadataReturns

=over 2

  Retrieves the returns of the SignatureDefFunction. The caller is not
  responsible for freeing the returned pointer.

=back

  /* From <tensorflow/c/experimental/saved_model/public/signature_def_function_metadata.h> */
  TF_CAPI_EXPORT extern const TF_SignatureDefParamList*
  TF_SignatureDefFunctionMetadataReturns(
      const TF_SignatureDefFunctionMetadata* list);

=head2 TF_EnableXLACompilation

=over 2

  When `enable` is true, set
  tensorflow.ConfigProto.OptimizerOptions.global_jit_level to ON_1, and also
  set XLA flag values to prepare for XLA compilation. Otherwise set
  global_jit_level to OFF.
  
  This and the next API are syntax sugar over TF_SetConfig(), and is used by
  clients that cannot read/write the tensorflow.ConfigProto proto.
  TODO: Migrate to TF_CreateConfig() below.

=back

  /* From <tensorflow/c/c_api_experimental.h> */
  TF_CAPI_EXPORT extern void TF_EnableXLACompilation(TF_SessionOptions* options,
                                                     unsigned char enable);

=head2 TF_SetXlaEnableLazyCompilation

=over 2

  Set XLA's internal BuildXlaOpsPassFlags.tf_xla_enable_lazy_compilation to the
  value of 'enabled'. Also returns the original value of that flag.
  
  Use in tests to allow XLA to fallback to TF classic. This has global effect.

=back

  /* From <tensorflow/c/c_api_experimental.h> */
  TF_CAPI_EXPORT unsigned char TF_SetXlaEnableLazyCompilation(
      unsigned char enable);

=head2 TF_SetTfXlaCpuGlobalJit

=over 2

=back

  /* From <tensorflow/c/c_api_experimental.h> */
  TF_CAPI_EXPORT unsigned char TF_SetTfXlaCpuGlobalJit(unsigned char enable);

=head2 TF_SetXlaAutoJitMode

=over 2

  Sets XLA's auto jit mode according to the specified string, which is parsed
  as if passed in XLA_FLAGS. This has global effect.

=back

  /* From <tensorflow/c/c_api_experimental.h> */
  TF_CAPI_EXPORT void TF_SetXlaAutoJitMode(const char* mode);

=head2 TF_GetXlaAutoJitEnabled

=over 2

  Returns whether the single GPU or general XLA auto jit optimizations are
  enabled through MarkForCompilationPassFlags.

=back

  /* From <tensorflow/c/c_api_experimental.h> */
  TF_CAPI_EXPORT unsigned char TF_GetXlaAutoJitEnabled();

=head2 TF_SetXlaMinClusterSize

=over 2

  Sets XLA's minimum cluster size. This has global effect.

=back

  /* From <tensorflow/c/c_api_experimental.h> */
  TF_CAPI_EXPORT void TF_SetXlaMinClusterSize(int size);

=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.



( run in 1.285 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )