Skip to content

Instantly share code, notes, and snippets.

@headius
Created June 8, 2017 05:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/446fc4980bf715bc5b358f1ba881aa80 to your computer and use it in GitHub Desktop.
Save headius/446fc4980bf715bc5b358f1ba881aa80 to your computer and use it in GitHub Desktop.
TensorFlow Ruby binding generated automatically by ffi_gen (via libclang)
# Generated by ffi_gen. Please do not change this file by hand.
require 'ffi'
module TensorFlow
extend FFI::Library
ffi_lib "tensorflow"
def self.attach_function(name, *_)
begin; super; rescue FFI::NotFoundError => e
(class << self; self; end).class_eval { define_method(name) { |*_| raise e } }
end
end
# TensorFlow library. TensorFlow using semantic versioning.
#
# @method tf_version()
# @return [String]
# @scope class
attach_function :tf_version, :TF_Version, [], :string
# The enum values here are identical to corresponding values in types.proto.
#
# <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:tf_data_type).</em>
#
# === Options:
# :float ::
#
# :double ::
#
# :int32 ::
#
# :uint8 ::
# Int32 tensors are always in 'host' memory.
# :int16 ::
#
# :int8 ::
#
# :string ::
#
# :complex64 ::
#
# :complex ::
# Single-precision complex
# :int64 ::
# Old identifier kept for API backwards compatibility
# :bool ::
#
# :qint8 ::
#
# :quint8 ::
# Quantized int8
# :qint32 ::
# Quantized uint8
# :bfloat16 ::
# Quantized int32
# :qint16 ::
# Float32 truncated to 16 bits. Only for cast ops.
# :quint16 ::
# Quantized int16
# :uint16 ::
# Quantized uint16
# :complex128 ::
#
# :half ::
# Double-precision complex
# :resource ::
#
#
# @method _enum_tf_data_type_
# @return [Symbol]
# @scope class
enum :tf_data_type, [
:float, 1,
:double, 2,
:int32, 3,
:uint8, 4,
:int16, 5,
:int8, 6,
:string, 7,
:complex64, 8,
:complex, 8,
:int64, 9,
:bool, 10,
:qint8, 11,
:quint8, 12,
:qint32, 13,
:bfloat16, 14,
:qint16, 15,
:quint16, 16,
:uint16, 17,
:complex128, 18,
:half, 19,
:resource, 20
]
# (eg. TF_STRING) or on failure.
#
# @method tf_data_type_size(dt)
# @param [Symbol from _enum_tf_data_type_] dt
# @return [Integer]
# @scope class
attach_function :tf_data_type_size, :TF_DataTypeSize, [:tf_data_type], :ulong
# corresponding values in error_codes.proto.
#
# <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:tf_code).</em>
#
# === Options:
# :ok ::
#
# :cancelled ::
#
# :unknown ::
#
# :invalid_argument ::
#
# :deadline_exceeded ::
#
# :not_found ::
#
# :already_exists ::
#
# :permission_denied ::
#
# :unauthenticated ::
#
# :resource_exhausted ::
#
# :failed_precondition ::
#
# :aborted ::
#
# :out_of_range ::
#
# :unimplemented ::
#
# :internal ::
#
# :unavailable ::
#
# :data_loss ::
#
#
# @method _enum_tf_code_
# @return [Symbol]
# @scope class
enum :tf_code, [
:ok, 0,
:cancelled, 1,
:unknown, 2,
:invalid_argument, 3,
:deadline_exceeded, 4,
:not_found, 5,
:already_exists, 6,
:permission_denied, 7,
:unauthenticated, 16,
:resource_exhausted, 8,
:failed_precondition, 9,
:aborted, 10,
:out_of_range, 11,
:unimplemented, 12,
:internal, 13,
:unavailable, 14,
:data_loss, 15
]
# else an error code with an associated error message.
class TFStatus < FFI::Struct
layout :dummy, :char
end
# Return a new status object.
#
# @method tf_new_status()
# @return [TFStatus]
# @scope class
attach_function :tf_new_status, :TF_NewStatus, [], TFStatus
# Delete a previously created status object.
#
# @method tf_delete_status(tf_status)
# @param [TFStatus] tf_status
# @return [nil]
# @scope class
attach_function :tf_delete_status, :TF_DeleteStatus, [TFStatus], :void
# A common use is to clear a status: TF_SetStatus(s, TF_OK, "");
#
# @method tf_set_status(s, code, msg)
# @param [TFStatus] s
# @param [Symbol from _enum_tf_code_] code
# @param [String] msg
# @return [nil]
# @scope class
attach_function :tf_set_status, :TF_SetStatus, [TFStatus, :tf_code, :string], :void
# Return the code record in *s.
#
# @method tf_get_code(s)
# @param [TFStatus] s
# @return [Symbol from _enum_tf_code_]
# @scope class
attach_function :tf_get_code, :TF_GetCode, [TFStatus], :tf_code
# TF_OK.
#
# @method tf_message(s)
# @param [TFStatus] s
# @return [String]
# @scope class
attach_function :tf_message, :TF_Message, [TFStatus], :string
# deallocate the block by setting the `data_deallocator` function pointer.
#
# = Fields:
# :data ::
# (FFI::Pointer(*Void))
# :length ::
# (Integer)
# :data_deallocator ::
# (FFI::Pointer(*))
class TFBuffer < FFI::Struct
layout :data, :pointer,
:length, :ulong,
:data_deallocator, :pointer
end
# passing in read-only, input protobufs.
#
# @method tf_new_buffer_from_string(proto, proto_len)
# @param [FFI::Pointer(*Void)] proto
# @param [Integer] proto_len
# @return [TFBuffer]
# @scope class
attach_function :tf_new_buffer_from_string, :TF_NewBufferFromString, [:pointer, :ulong], TFBuffer
# Useful for passing *out* a protobuf.
#
# @method tf_new_buffer()
# @return [TFBuffer]
# @scope class
attach_function :tf_new_buffer, :TF_NewBuffer, [], TFBuffer
# (Not documented)
#
# @method tf_delete_buffer(tf_buffer)
# @param [TFBuffer] tf_buffer
# @return [nil]
# @scope class
attach_function :tf_delete_buffer, :TF_DeleteBuffer, [TFBuffer], :void
# (Not documented)
#
# @method tf_get_buffer(buffer)
# @param [TFBuffer] buffer
# @return [TFBuffer]
# @scope class
attach_function :tf_get_buffer, :TF_GetBuffer, [TFBuffer], TFBuffer.by_value
# facilitate this encoding.
module TFTensorWrappers
# @return [Symbol from _enum_tf_data_type_]
def type()
TensorFlow.tf_tensor_type(self)
end
# @return [Integer]
def byte_size()
TensorFlow.tf_tensor_byte_size(self)
end
# @return [FFI::Pointer(*Void)]
def data()
TensorFlow.tf_tensor_data(self)
end
end
class TFTensor < FFI::Struct
include TFTensorWrappers
layout :dummy, :char
end
# memory managed by something like numpy.
#
# @method tf_new_tensor(tf_data_type, dims, num_dims, data, len, deallocator, deallocator_arg)
# @param [Symbol from _enum_tf_data_type_] tf_data_type
# @param [FFI::Pointer(*Int64T)] dims
# @param [Integer] num_dims
# @param [FFI::Pointer(*Void)] data
# @param [Integer] len
# @param [FFI::Pointer(*)] deallocator
# @param [FFI::Pointer(*Void)] deallocator_arg
# @return [TFTensor]
# @scope class
attach_function :tf_new_tensor, :TF_NewTensor, [:tf_data_type, :pointer, :int, :pointer, :ulong, :pointer, :pointer], TFTensor
# by TF_TensorData with length TF_TensorByteSize.
#
# @method tf_allocate_tensor(tf_data_type, dims, num_dims, len)
# @param [Symbol from _enum_tf_data_type_] tf_data_type
# @param [FFI::Pointer(*Int64T)] dims
# @param [Integer] num_dims
# @param [Integer] len
# @return [TFTensor]
# @scope class
attach_function :tf_allocate_tensor, :TF_AllocateTensor, [:tf_data_type, :pointer, :int, :ulong], TFTensor
# Destroy a tensor.
#
# @method tf_delete_tensor(tf_tensor)
# @param [TFTensor] tf_tensor
# @return [nil]
# @scope class
attach_function :tf_delete_tensor, :TF_DeleteTensor, [TFTensor], :void
# Return the type of a tensor element.
#
# @method tf_tensor_type(tf_tensor)
# @param [TFTensor] tf_tensor
# @return [Symbol from _enum_tf_data_type_]
# @scope class
attach_function :tf_tensor_type, :TF_TensorType, [TFTensor], :tf_data_type
# Return the number of dimensions that the tensor has.
#
# @method tf_num_dims(tf_tensor)
# @param [TFTensor] tf_tensor
# @return [Integer]
# @scope class
attach_function :tf_num_dims, :TF_NumDims, [TFTensor], :int
# REQUIRES: 0 <= dim_index < TF_NumDims(tensor)
#
# @method tf_dim(tensor, dim_index)
# @param [TFTensor] tensor
# @param [Integer] dim_index
# @return [Integer]
# @scope class
attach_function :tf_dim, :TF_Dim, [TFTensor, :int], :long_long
# Return the size of the underlying data in bytes.
#
# @method tf_tensor_byte_size(tf_tensor)
# @param [TFTensor] tf_tensor
# @return [Integer]
# @scope class
attach_function :tf_tensor_byte_size, :TF_TensorByteSize, [TFTensor], :ulong
# Return a pointer to the underlying data buffer.
#
# @method tf_tensor_data(tf_tensor)
# @param [TFTensor] tf_tensor
# @return [FFI::Pointer(*Void)]
# @scope class
attach_function :tf_tensor_data, :TF_TensorData, [TFTensor], :pointer
# Returns an error into `status` otherwise.
#
# @method tf_string_encode(src, src_len, dst, dst_len, status)
# @param [String] src
# @param [Integer] src_len
# @param [String] dst
# @param [Integer] dst_len
# @param [TFStatus] status
# @return [Integer]
# @scope class
attach_function :tf_string_encode, :TF_StringEncode, [:string, :ulong, :string, :ulong, TFStatus], :ulong
# Does not read memory more than `src_len` bytes beyond `src`.
#
# @method tf_string_decode(src, src_len, dst, dst_len, status)
# @param [String] src
# @param [Integer] src_len
# @param [FFI::Pointer(**CharS)] dst
# @param [FFI::Pointer(*SizeT)] dst_len
# @param [TFStatus] status
# @return [Integer]
# @scope class
attach_function :tf_string_decode, :TF_StringDecode, [:string, :ulong, :pointer, :pointer, TFStatus], :ulong
# TF_STRING tensor.
#
# @method tf_string_encoded_size(len)
# @param [Integer] len
# @return [Integer]
# @scope class
attach_function :tf_string_encoded_size, :TF_StringEncodedSize, [:ulong], :ulong
# TF_SessionOptions holds options that can be passed during session creation.
class TFSessionOptions < FFI::Struct
layout :dummy, :char
end
# Return a new options object.
#
# @method tf_new_session_options()
# @return [TFSessionOptions]
# @scope class
attach_function :tf_new_session_options, :TF_NewSessionOptions, [], TFSessionOptions
# host:port
#
# @method tf_set_target(options, target)
# @param [TFSessionOptions] options
# @param [String] target
# @return [nil]
# @scope class
attach_function :tf_set_target, :TF_SetTarget, [TFSessionOptions, :string], :void
# error information in *status.
#
# @method tf_set_config(options, proto, proto_len, status)
# @param [TFSessionOptions] options
# @param [FFI::Pointer(*Void)] proto
# @param [Integer] proto_len
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_set_config, :TF_SetConfig, [TFSessionOptions, :pointer, :ulong, TFStatus], :void
# Destroy an options object.
#
# @method tf_delete_session_options(tf_session_options)
# @param [TFSessionOptions] tf_session_options
# @return [nil]
# @scope class
attach_function :tf_delete_session_options, :TF_DeleteSessionOptions, [TFSessionOptions], :void
# Graphs are thread-safe when used as directed below.
module TFGraphWrappers
# @param [TFOutput] output
# @param [FFI::Pointer(*Int64T)] dims
# @param [Integer] num_dims
# @param [TFStatus] status
# @return [nil]
def set_tensor_shape(output, dims, num_dims, status)
TensorFlow.tf_graph_set_tensor_shape(self, output, dims, num_dims, status)
end
# @param [TFOutput] output
# @param [TFStatus] status
# @return [Integer]
def get_tensor_num_dims(output, status)
TensorFlow.tf_graph_get_tensor_num_dims(self, output, status)
end
# @param [TFOutput] output
# @param [FFI::Pointer(*Int64T)] dims
# @param [Integer] num_dims
# @param [TFStatus] status
# @return [nil]
def get_tensor_shape(output, dims, num_dims, status)
TensorFlow.tf_graph_get_tensor_shape(self, output, dims, num_dims, status)
end
# @param [String] oper_name
# @return [TFOperation]
def operation_by_name(oper_name)
TFOperation.new TensorFlow.tf_graph_operation_by_name(self, oper_name)
end
# @param [FFI::Pointer(*SizeT)] pos
# @return [TFOperation]
def next_operation(pos)
TFOperation.new TensorFlow.tf_graph_next_operation(self, pos)
end
# @param [TFBuffer] output_graph_def
# @param [TFStatus] status
# @return [nil]
def to_graph_def(output_graph_def, status)
TensorFlow.tf_graph_to_graph_def(self, output_graph_def, status)
end
# @param [TFBuffer] graph_def
# @param [FFI::Pointer(*TFImportGraphDefOptions)] options
# @param [FFI::Pointer(*TFOutput)] return_outputs
# @param [Integer] num_return_outputs
# @param [TFStatus] status
# @return [nil]
def import_graph_def_with_return_outputs(graph_def, options, return_outputs, num_return_outputs, status)
TensorFlow.tf_graph_import_graph_def_with_return_outputs(self, graph_def, options, return_outputs, num_return_outputs, status)
end
# @param [TFBuffer] graph_def
# @param [FFI::Pointer(*TFImportGraphDefOptions)] options
# @param [TFStatus] status
# @return [nil]
def import_graph_def(graph_def, options, status)
TensorFlow.tf_graph_import_graph_def(self, graph_def, options, status)
end
end
class TFGraph < FFI::Struct
include TFGraphWrappers
layout :dummy, :char
end
# Return a new graph object.
#
# @method tf_new_graph()
# @return [TFGraph]
# @scope class
attach_function :tf_new_graph, :TF_NewGraph, [], TFGraph
# TFSession's are referencing it.
#
# @method tf_delete_graph(tf_graph)
# @param [TFGraph] tf_graph
# @return [nil]
# @scope class
attach_function :tf_delete_graph, :TF_DeleteGraph, [TFGraph], :void
# Operation being built. The underlying graph must outlive this.
class TFOperationDescription < FFI::Struct
layout :dummy, :char
end
# invalidate old TF_Operation* pointers.
module TFOperationWrappers
# @return [String]
def name()
TensorFlow.tf_operation_name(self)
end
# @return [String]
def op_type()
TensorFlow.tf_operation_op_type(self)
end
# @return [String]
def device()
TensorFlow.tf_operation_device(self)
end
# @return [Integer]
def num_outputs()
TensorFlow.tf_operation_num_outputs(self)
end
# @param [String] arg_name
# @param [TFStatus] status
# @return [Integer]
def output_list_length(arg_name, status)
TensorFlow.tf_operation_output_list_length(self, arg_name, status)
end
# @return [Integer]
def num_inputs()
TensorFlow.tf_operation_num_inputs(self)
end
# @param [String] arg_name
# @param [TFStatus] status
# @return [Integer]
def input_list_length(arg_name, status)
TensorFlow.tf_operation_input_list_length(self, arg_name, status)
end
# @return [Integer]
def num_control_inputs()
TensorFlow.tf_operation_num_control_inputs(self)
end
# @param [FFI::Pointer(**TFOperation)] control_inputs
# @param [Integer] max_control_inputs
# @return [Integer]
def get_control_inputs(control_inputs, max_control_inputs)
TensorFlow.tf_operation_get_control_inputs(self, control_inputs, max_control_inputs)
end
# @return [Integer]
def num_control_outputs()
TensorFlow.tf_operation_num_control_outputs(self)
end
# @param [FFI::Pointer(**TFOperation)] control_outputs
# @param [Integer] max_control_outputs
# @return [Integer]
def get_control_outputs(control_outputs, max_control_outputs)
TensorFlow.tf_operation_get_control_outputs(self, control_outputs, max_control_outputs)
end
# @param [String] attr_name
# @param [TFStatus] status
# @return [TFAttrMetadata]
def get_attr_metadata(attr_name, status)
TensorFlow.tf_operation_get_attr_metadata(self, attr_name, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*Void)] value
# @param [Integer] max_length
# @param [TFStatus] status
# @return [nil]
def get_attr_string(attr_name, value, max_length, status)
TensorFlow.tf_operation_get_attr_string(self, attr_name, value, max_length, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(**Void)] values
# @param [FFI::Pointer(*SizeT)] lengths
# @param [Integer] max_values
# @param [FFI::Pointer(*Void)] storage
# @param [Integer] storage_size
# @param [TFStatus] status
# @return [nil]
def get_attr_string_list(attr_name, values, lengths, max_values, storage, storage_size, status)
TensorFlow.tf_operation_get_attr_string_list(self, attr_name, values, lengths, max_values, storage, storage_size, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*Int64T)] value
# @param [TFStatus] status
# @return [nil]
def get_attr_int(attr_name, value, status)
TensorFlow.tf_operation_get_attr_int(self, attr_name, value, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*Int64T)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
def get_attr_int_list(attr_name, values, max_values, status)
TensorFlow.tf_operation_get_attr_int_list(self, attr_name, values, max_values, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*Float)] value
# @param [TFStatus] status
# @return [nil]
def get_attr_float(attr_name, value, status)
TensorFlow.tf_operation_get_attr_float(self, attr_name, value, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*Float)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
def get_attr_float_list(attr_name, values, max_values, status)
TensorFlow.tf_operation_get_attr_float_list(self, attr_name, values, max_values, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*UChar)] value
# @param [TFStatus] status
# @return [nil]
def get_attr_bool(attr_name, value, status)
TensorFlow.tf_operation_get_attr_bool(self, attr_name, value, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*UChar)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
def get_attr_bool_list(attr_name, values, max_values, status)
TensorFlow.tf_operation_get_attr_bool_list(self, attr_name, values, max_values, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*TFDataType)] value
# @param [TFStatus] status
# @return [nil]
def get_attr_type(attr_name, value, status)
TensorFlow.tf_operation_get_attr_type(self, attr_name, value, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*TFDataType)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
def get_attr_type_list(attr_name, values, max_values, status)
TensorFlow.tf_operation_get_attr_type_list(self, attr_name, values, max_values, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(*Int64T)] value
# @param [Integer] num_dims
# @param [TFStatus] status
# @return [nil]
def get_attr_shape(attr_name, value, num_dims, status)
TensorFlow.tf_operation_get_attr_shape(self, attr_name, value, num_dims, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(**Int64T)] dims
# @param [FFI::Pointer(*Int)] num_dims
# @param [Integer] num_shapes
# @param [FFI::Pointer(*Int64T)] storage
# @param [Integer] storage_size
# @param [TFStatus] status
# @return [nil]
def get_attr_shape_list(attr_name, dims, num_dims, num_shapes, storage, storage_size, status)
TensorFlow.tf_operation_get_attr_shape_list(self, attr_name, dims, num_dims, num_shapes, storage, storage_size, status)
end
# @param [String] attr_name
# @param [TFBuffer] value
# @param [TFStatus] status
# @return [nil]
def get_attr_tensor_shape_proto(attr_name, value, status)
TensorFlow.tf_operation_get_attr_tensor_shape_proto(self, attr_name, value, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(**TFBuffer)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
def get_attr_tensor_shape_proto_list(attr_name, values, max_values, status)
TensorFlow.tf_operation_get_attr_tensor_shape_proto_list(self, attr_name, values, max_values, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(**TFTensor)] value
# @param [TFStatus] status
# @return [nil]
def get_attr_tensor(attr_name, value, status)
TensorFlow.tf_operation_get_attr_tensor(self, attr_name, value, status)
end
# @param [String] attr_name
# @param [FFI::Pointer(**TFTensor)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
def get_attr_tensor_list(attr_name, values, max_values, status)
TensorFlow.tf_operation_get_attr_tensor_list(self, attr_name, values, max_values, status)
end
# @param [String] attr_name
# @param [TFBuffer] output_attr_value
# @param [TFStatus] status
# @return [nil]
def get_attr_value_proto(attr_name, output_attr_value, status)
TensorFlow.tf_operation_get_attr_value_proto(self, attr_name, output_attr_value, status)
end
# @param [TFBuffer] output_node_def
# @param [TFStatus] status
# @return [nil]
def to_node_def(output_node_def, status)
TensorFlow.tf_operation_to_node_def(self, output_node_def, status)
end
end
class TFOperation < FFI::Struct
include TFOperationWrappers
layout :dummy, :char
end
# Represents a specific input of an operation.
#
# = Fields:
# :oper ::
# (TFOperation)
# :index ::
# (Integer) The index of the input within oper.
class TFInput < FFI::Struct
layout :oper, TFOperation,
:index, :int
end
# Represents a specific output of an operation.
#
# = Fields:
# :oper ::
# (TFOperation)
# :index ::
# (Integer) The index of the output within oper.
class TFOutput < FFI::Struct
layout :oper, TFOperation,
:index, :int
end
# is incompatible with the existing shape).
#
# @method tf_graph_set_tensor_shape(graph, output, dims, num_dims, status)
# @param [TFGraph] graph
# @param [TFOutput] output
# @param [FFI::Pointer(*Int64T)] dims
# @param [Integer] num_dims
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_graph_set_tensor_shape, :TF_GraphSetTensorShape, [TFGraph, TFOutput.by_value, :pointer, :int, TFStatus], :void
# * `output` is not in `graph`.
#
# @method tf_graph_get_tensor_num_dims(graph, output, status)
# @param [TFGraph] graph
# @param [TFOutput] output
# @param [TFStatus] status
# @return [Integer]
# @scope class
attach_function :tf_graph_get_tensor_num_dims, :TF_GraphGetTensorNumDims, [TFGraph, TFOutput.by_value, TFStatus], :int
# * `num_dims` does not match the actual number of dimensions.
#
# @method tf_graph_get_tensor_shape(graph, output, dims, num_dims, status)
# @param [TFGraph] graph
# @param [TFOutput] output
# @param [FFI::Pointer(*Int64T)] dims
# @param [Integer] num_dims
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_graph_get_tensor_shape, :TF_GraphGetTensorShape, [TFGraph, TFOutput.by_value, :pointer, :int, TFStatus], :void
# called.
#
# @method tf_new_operation(graph, op_type, oper_name)
# @param [TFGraph] graph
# @param [String] op_type
# @return [TFOperationDescription]
# @scope class
attach_function :tf_new_operation, :TF_NewOperation, [TFGraph, :string, :string], TFOperationDescription
# Specify the device for `desc`. Defaults to empty, meaning unconstrained.
#
# @method tf_set_device(desc, device)
# @param [TFOperationDescription] desc
# @param [String] device
# @return [nil]
# @scope class
attach_function :tf_set_device, :TF_SetDevice, [TFOperationDescription, :string], :void
# For inputs that take a single tensor.
#
# @method tf_add_input(desc, input)
# @param [TFOperationDescription] desc
# @param [TFOutput] input
# @return [nil]
# @scope class
attach_function :tf_add_input, :TF_AddInput, [TFOperationDescription, TFOutput.by_value], :void
# inputs must point to TF_Output(num_inputs).
#
# @method tf_add_input_list(desc, inputs, num_inputs)
# @param [TFOperationDescription] desc
# @param [TFOutput] inputs
# @param [Integer] num_inputs
# @return [nil]
# @scope class
attach_function :tf_add_input_list, :TF_AddInputList, [TFOperationDescription, TFOutput, :int], :void
# Call once per control input to `desc`.
#
# @method tf_add_control_input(desc, input)
# @param [TFOperationDescription] desc
# @param [TFOperation] input
# @return [nil]
# @scope class
attach_function :tf_add_control_input, :TF_AddControlInput, [TFOperationDescription, TFOperation], :void
# subject to change. Primarily intended for internal libraries
#
# @method tf_colocate_with(desc, op)
# @param [TFOperationDescription] desc
# @param [TFOperation] op
# @return [nil]
# @scope class
attach_function :tf_colocate_with, :TF_ColocateWith, [TFOperationDescription, TFOperation], :void
# `value` must point to a string of length `length` bytes.
#
# @method tf_set_attr_string(desc, attr_name, value, length)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(*Void)] value
# @param [Integer] length
# @return [nil]
# @scope class
attach_function :tf_set_attr_string, :TF_SetAttrString, [TFOperationDescription, :string, :pointer, :ulong], :void
# `values(i)` must point to a string of length `lengths(i)` bytes.
#
# @method tf_set_attr_string_list(desc, attr_name, values, lengths, num_values)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(**Void)] values
# @param [FFI::Pointer(*SizeT)] lengths
# @param [Integer] num_values
# @return [nil]
# @scope class
attach_function :tf_set_attr_string_list, :TF_SetAttrStringList, [TFOperationDescription, :string, :pointer, :pointer, :int], :void
# (Not documented)
#
# @method tf_set_attr_int(desc, attr_name, value)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [Integer] value
# @return [nil]
# @scope class
attach_function :tf_set_attr_int, :TF_SetAttrInt, [TFOperationDescription, :string, :long_long], :void
# (Not documented)
#
# @method tf_set_attr_int_list(desc, attr_name, values, num_values)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(*Int64T)] values
# @param [Integer] num_values
# @return [nil]
# @scope class
attach_function :tf_set_attr_int_list, :TF_SetAttrIntList, [TFOperationDescription, :string, :pointer, :int], :void
# (Not documented)
#
# @method tf_set_attr_float(desc, attr_name, value)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [Float] value
# @return [nil]
# @scope class
attach_function :tf_set_attr_float, :TF_SetAttrFloat, [TFOperationDescription, :string, :float], :void
# (Not documented)
#
# @method tf_set_attr_float_list(desc, attr_name, values, num_values)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(*Float)] values
# @param [Integer] num_values
# @return [nil]
# @scope class
attach_function :tf_set_attr_float_list, :TF_SetAttrFloatList, [TFOperationDescription, :string, :pointer, :int], :void
# (Not documented)
#
# @method tf_set_attr_bool(desc, attr_name, value)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [Integer] value
# @return [nil]
# @scope class
attach_function :tf_set_attr_bool, :TF_SetAttrBool, [TFOperationDescription, :string, :uchar], :void
# (Not documented)
#
# @method tf_set_attr_bool_list(desc, attr_name, values, num_values)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(*UChar)] values
# @param [Integer] num_values
# @return [nil]
# @scope class
attach_function :tf_set_attr_bool_list, :TF_SetAttrBoolList, [TFOperationDescription, :string, :pointer, :int], :void
# (Not documented)
#
# @method tf_set_attr_type(desc, attr_name, value)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [Symbol from _enum_tf_data_type_] value
# @return [nil]
# @scope class
attach_function :tf_set_attr_type, :TF_SetAttrType, [TFOperationDescription, :string, :tf_data_type], :void
# (Not documented)
#
# @method tf_set_attr_type_list(desc, attr_name, values, num_values)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(*TFDataType)] values
# @param [Integer] num_values
# @return [nil]
# @scope class
attach_function :tf_set_attr_type_list, :TF_SetAttrTypeList, [TFOperationDescription, :string, :pointer, :int], :void
# >= -1, with -1 meaning "unknown dimension".
#
# @method tf_set_attr_shape(desc, attr_name, dims, num_dims)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(*Int64T)] dims
# @param [Integer] num_dims
# @return [nil]
# @scope class
attach_function :tf_set_attr_shape, :TF_SetAttrShape, [TFOperationDescription, :string, :pointer, :int], :void
# must be >= -1, with -1 meaning "unknown dimension".
#
# @method tf_set_attr_shape_list(desc, attr_name, dims, num_dims, num_shapes)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(**Int64T)] dims
# @param [FFI::Pointer(*Int)] num_dims
# @param [Integer] num_shapes
# @return [nil]
# @scope class
attach_function :tf_set_attr_shape_list, :TF_SetAttrShapeList, [TFOperationDescription, :string, :pointer, :pointer, :int], :void
# binary-serialized TensorShapeProto.
#
# @method tf_set_attr_tensor_shape_proto(desc, attr_name, proto, proto_len, status)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(*Void)] proto
# @param [Integer] proto_len
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_set_attr_tensor_shape_proto, :TF_SetAttrTensorShapeProto, [TFOperationDescription, :string, :pointer, :ulong, TFStatus], :void
# representing a binary-serialized TensorShapeProto.
#
# @method tf_set_attr_tensor_shape_proto_list(desc, attr_name, protos, proto_lens, num_shapes, status)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(**Void)] protos
# @param [FFI::Pointer(*SizeT)] proto_lens
# @param [Integer] num_shapes
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_set_attr_tensor_shape_proto_list, :TF_SetAttrTensorShapeProtoList, [TFOperationDescription, :string, :pointer, :pointer, :int, TFStatus], :void
# (Not documented)
#
# @method tf_set_attr_tensor(desc, attr_name, value, status)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [TFTensor] value
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_set_attr_tensor, :TF_SetAttrTensor, [TFOperationDescription, :string, TFTensor, TFStatus], :void
# (Not documented)
#
# @method tf_set_attr_tensor_list(desc, attr_name, values, num_values, status)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(**TFTensor)] values
# @param [Integer] num_values
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_set_attr_tensor_list, :TF_SetAttrTensorList, [TFOperationDescription, :string, :pointer, :int, TFStatus], :void
# buffer.
#
# @method tf_set_attr_value_proto(desc, attr_name, proto, proto_len, status)
# @param [TFOperationDescription] desc
# @param [String] attr_name
# @param [FFI::Pointer(*Void)] proto
# @param [Integer] proto_len
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_set_attr_value_proto, :TF_SetAttrValueProto, [TFOperationDescription, :string, :pointer, :ulong, TFStatus], :void
# In either case, it deletes `desc`.
#
# @method tf_finish_operation(desc, status)
# @param [TFOperationDescription] desc
# @param [TFStatus] status
# @return [TFOperation]
# @scope class
attach_function :tf_finish_operation, :TF_FinishOperation, [TFOperationDescription, TFStatus], TFOperation
# these are all query functions.
#
# @method tf_operation_name(oper)
# @param [TFOperation] oper
# @return [String]
# @scope class
attach_function :tf_operation_name, :TF_OperationName, [TFOperation], :string
# (Not documented)
#
# @method tf_operation_op_type(oper)
# @param [TFOperation] oper
# @return [String]
# @scope class
attach_function :tf_operation_op_type, :TF_OperationOpType, [TFOperation], :string
# (Not documented)
#
# @method tf_operation_device(oper)
# @param [TFOperation] oper
# @return [String]
# @scope class
attach_function :tf_operation_device, :TF_OperationDevice, [TFOperation], :string
# (Not documented)
#
# @method tf_operation_num_outputs(oper)
# @param [TFOperation] oper
# @return [Integer]
# @scope class
attach_function :tf_operation_num_outputs, :TF_OperationNumOutputs, [TFOperation], :int
# (Not documented)
#
# @method tf_operation_output_type(oper_out)
# @param [TFOutput] oper_out
# @return [Symbol from _enum_tf_data_type_]
# @scope class
attach_function :tf_operation_output_type, :TF_OperationOutputType, [TFOutput.by_value], :tf_data_type
# (Not documented)
#
# @method tf_operation_output_list_length(oper, arg_name, status)
# @param [TFOperation] oper
# @param [String] arg_name
# @param [TFStatus] status
# @return [Integer]
# @scope class
attach_function :tf_operation_output_list_length, :TF_OperationOutputListLength, [TFOperation, :string, TFStatus], :int
# (Not documented)
#
# @method tf_operation_num_inputs(oper)
# @param [TFOperation] oper
# @return [Integer]
# @scope class
attach_function :tf_operation_num_inputs, :TF_OperationNumInputs, [TFOperation], :int
# (Not documented)
#
# @method tf_operation_input_type(oper_in)
# @param [TFInput] oper_in
# @return [Symbol from _enum_tf_data_type_]
# @scope class
attach_function :tf_operation_input_type, :TF_OperationInputType, [TFInput.by_value], :tf_data_type
# (Not documented)
#
# @method tf_operation_input_list_length(oper, arg_name, status)
# @param [TFOperation] oper
# @param [String] arg_name
# @param [TFStatus] status
# @return [Integer]
# @scope class
attach_function :tf_operation_input_list_length, :TF_OperationInputListLength, [TFOperation, :string, TFStatus], :int
# producer.index) to consumer.oper's input (given by consumer.index).
#
# @method tf_operation_input(oper_in)
# @param [TFInput] oper_in
# @return [TFOutput]
# @scope class
attach_function :tf_operation_input, :TF_OperationInput, [TFInput.by_value], TFOutput.by_value
# are added to the graph.
#
# @method tf_operation_output_num_consumers(oper_out)
# @param [TFOutput] oper_out
# @return [Integer]
# @scope class
attach_function :tf_operation_output_num_consumers, :TF_OperationOutputNumConsumers, [TFOutput.by_value], :int
# TF_OperationOutputNumConsumers(oper_out)).
#
# @method tf_operation_output_consumers(oper_out, consumers, max_consumers)
# @param [TFOutput] oper_out
# @param [TFInput] consumers
# @param [Integer] max_consumers
# @return [Integer]
# @scope class
attach_function :tf_operation_output_consumers, :TF_OperationOutputConsumers, [TFOutput.by_value, TFInput, :int], :int
# Get the number of control inputs to an operation.
#
# @method tf_operation_num_control_inputs(oper)
# @param [TFOperation] oper
# @return [Integer]
# @scope class
attach_function :tf_operation_num_control_inputs, :TF_OperationNumControlInputs, [TFOperation], :int
# inputs (should match TF_OperationNumControlInputs(oper)).
#
# @method tf_operation_get_control_inputs(oper, control_inputs, max_control_inputs)
# @param [TFOperation] oper
# @param [FFI::Pointer(**TFOperation)] control_inputs
# @param [Integer] max_control_inputs
# @return [Integer]
# @scope class
attach_function :tf_operation_get_control_inputs, :TF_OperationGetControlInputs, [TFOperation, :pointer, :int], :int
# the graph.
#
# @method tf_operation_num_control_outputs(oper)
# @param [TFOperation] oper
# @return [Integer]
# @scope class
attach_function :tf_operation_num_control_outputs, :TF_OperationNumControlOutputs, [TFOperation], :int
# TF_OperationNumControlOutputs(oper)).
#
# @method tf_operation_get_control_outputs(oper, control_outputs, max_control_outputs)
# @param [TFOperation] oper
# @param [FFI::Pointer(**TFOperation)] control_outputs
# @param [Integer] max_control_outputs
# @return [Integer]
# @scope class
attach_function :tf_operation_get_control_outputs, :TF_OperationGetControlOutputs, [TFOperation, :pointer, :int], :int
# TF_AttrType describes the type of the value of an attribute on an operation.
#
# <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:tf_attr_type).</em>
#
# === Options:
# :string ::
#
# :int ::
#
# :float ::
#
# :bool ::
#
# :type ::
#
# :shape ::
#
# :tensor ::
#
# :placeholder ::
#
# :func ::
#
#
# @method _enum_tf_attr_type_
# @return [Symbol]
# @scope class
enum :tf_attr_type, [
:string, 0,
:int, 1,
:float, 2,
:bool, 3,
:type, 4,
:shape, 5,
:tensor, 6,
:placeholder, 7,
:func, 8
]
# TF_AttrMetadata describes the value of an attribute on an operation.
#
# = Fields:
# :is_list ::
# (Integer) A boolean: 1 if the attribute value is a list, 0 otherwise.
# :list_size ::
# (Integer) Length of the list if is_list is true. Undefined otherwise.
# :type ::
# (Symbol from _enum_tf_attr_type_) Type of the single value stored in the attribute if is_list == 0.
# :total_size ::
# (Integer) (5) Otherwise, total_size is undefined.
class TFAttrMetadata < FFI::Struct
layout :is_list, :uchar,
:list_size, :long_long,
:type, :tf_attr_type,
:total_size, :long_long
end
# Returns metadata about the value of the attribute `attr_name` of `oper`.
#
# @method tf_operation_get_attr_metadata(oper, attr_name, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [TFStatus] status
# @return [TFAttrMetadata]
# @scope class
attach_function :tf_operation_get_attr_metadata, :TF_OperationGetAttrMetadata, [TFOperation, :string, TFStatus], TFAttrMetadata.by_value
# attr_name)).
#
# @method tf_operation_get_attr_string(oper, attr_name, value, max_length, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*Void)] value
# @param [Integer] max_length
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_string, :TF_OperationGetAttrString, [TFOperation, :string, :pointer, :ulong, TFStatus], :void
# Fails if storage_size is too small to hold the requested number of strings.
#
# @method tf_operation_get_attr_string_list(oper, attr_name, values, lengths, max_values, storage, storage_size, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(**Void)] values
# @param [FFI::Pointer(*SizeT)] lengths
# @param [Integer] max_values
# @param [FFI::Pointer(*Void)] storage
# @param [Integer] storage_size
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_string_list, :TF_OperationGetAttrStringList, [TFOperation, :string, :pointer, :pointer, :int, :pointer, :ulong, TFStatus], :void
# (Not documented)
#
# @method tf_operation_get_attr_int(oper, attr_name, value, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*Int64T)] value
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_int, :TF_OperationGetAttrInt, [TFOperation, :string, :pointer, TFStatus], :void
# attr_name)).
#
# @method tf_operation_get_attr_int_list(oper, attr_name, values, max_values, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*Int64T)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_int_list, :TF_OperationGetAttrIntList, [TFOperation, :string, :pointer, :int, TFStatus], :void
# (Not documented)
#
# @method tf_operation_get_attr_float(oper, attr_name, value, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*Float)] value
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_float, :TF_OperationGetAttrFloat, [TFOperation, :string, :pointer, TFStatus], :void
# attr_name)).
#
# @method tf_operation_get_attr_float_list(oper, attr_name, values, max_values, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*Float)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_float_list, :TF_OperationGetAttrFloatList, [TFOperation, :string, :pointer, :int, TFStatus], :void
# (Not documented)
#
# @method tf_operation_get_attr_bool(oper, attr_name, value, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*UChar)] value
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_bool, :TF_OperationGetAttrBool, [TFOperation, :string, :pointer, TFStatus], :void
# attr_name)).
#
# @method tf_operation_get_attr_bool_list(oper, attr_name, values, max_values, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*UChar)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_bool_list, :TF_OperationGetAttrBoolList, [TFOperation, :string, :pointer, :int, TFStatus], :void
# (Not documented)
#
# @method tf_operation_get_attr_type(oper, attr_name, value, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*TFDataType)] value
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_type, :TF_OperationGetAttrType, [TFOperation, :string, :pointer, TFStatus], :void
# attr_name)).
#
# @method tf_operation_get_attr_type_list(oper, attr_name, values, max_values, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*TFDataType)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_type_list, :TF_OperationGetAttrTypeList, [TFOperation, :string, :pointer, :int, TFStatus], :void
# TF_Attr_Meta.size from TF_OperationGetAttrMetadata(oper, attr_name)).
#
# @method tf_operation_get_attr_shape(oper, attr_name, value, num_dims, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(*Int64T)] value
# @param [Integer] num_dims
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_shape, :TF_OperationGetAttrShape, [TFOperation, :string, :pointer, :int, TFStatus], :void
# Fails if storage_size is insufficient to hold the requested shapes.
#
# @method tf_operation_get_attr_shape_list(oper, attr_name, dims, num_dims, num_shapes, storage, storage_size, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(**Int64T)] dims
# @param [FFI::Pointer(*Int)] num_dims
# @param [Integer] num_shapes
# @param [FFI::Pointer(*Int64T)] storage
# @param [Integer] storage_size
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_shape_list, :TF_OperationGetAttrShapeList, [TFOperation, :string, :pointer, :pointer, :int, :pointer, :int, TFStatus], :void
# `attr_name` attribute of `oper`'.
#
# @method tf_operation_get_attr_tensor_shape_proto(oper, attr_name, value, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [TFBuffer] value
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_tensor_shape_proto, :TF_OperationGetAttrTensorShapeProto, [TFOperation, :string, TFBuffer, TFStatus], :void
# TF_OperationGetAttrMetadata(oper, attr_name)).
#
# @method tf_operation_get_attr_tensor_shape_proto_list(oper, attr_name, values, max_values, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(**TFBuffer)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_tensor_shape_proto_list, :TF_OperationGetAttrTensorShapeProtoList, [TFOperation, :string, :pointer, :int, TFStatus], :void
# ownership of (and can deallocate using TF_DeleteTensor).
#
# @method tf_operation_get_attr_tensor(oper, attr_name, value, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(**TFTensor)] value
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_tensor, :TF_OperationGetAttrTensor, [TFOperation, :string, :pointer, TFStatus], :void
# (which can be deleted using TF_DeleteTensor(values(i))).
#
# @method tf_operation_get_attr_tensor_list(oper, attr_name, values, max_values, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [FFI::Pointer(**TFTensor)] values
# @param [Integer] max_values
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_tensor_list, :TF_OperationGetAttrTensorList, [TFOperation, :string, :pointer, :int, TFStatus], :void
# representation of the value of the `attr_name` attr of `oper`.
#
# @method tf_operation_get_attr_value_proto(oper, attr_name, output_attr_value, status)
# @param [TFOperation] oper
# @param [String] attr_name
# @param [TFBuffer] output_attr_value
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_get_attr_value_proto, :TF_OperationGetAttrValueProto, [TFOperation, :string, TFBuffer, TFStatus], :void
# no operation found.
#
# @method tf_graph_operation_by_name(graph, oper_name)
# @param [TFGraph] graph
# @param [String] oper_name
# @return [TFOperation]
# @scope class
attach_function :tf_graph_operation_by_name, :TF_GraphOperationByName, [TFGraph, :string], TFOperation
# }
#
# @method tf_graph_next_operation(graph, pos)
# @param [TFGraph] graph
# @param [FFI::Pointer(*SizeT)] pos
# @return [TFOperation]
# @scope class
attach_function :tf_graph_next_operation, :TF_GraphNextOperation, [TFGraph, :pointer], TFOperation
# May fail on very large graphs in the future.
#
# @method tf_graph_to_graph_def(graph, output_graph_def, status)
# @param [TFGraph] graph
# @param [TFBuffer] output_graph_def
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_graph_to_graph_def, :TF_GraphToGraphDef, [TFGraph, TFBuffer, TFStatus], :void
# TF_GraphImportGraphDef.
module TFImportGraphDefOptionsWrappers
# @param [String] prefix
# @return [nil]
def set_prefix(prefix)
TensorFlow.tf_import_graph_def_options_set_prefix(self, prefix)
end
# @param [String] src_name
# @param [Integer] src_index
# @param [TFOutput] dst
# @return [nil]
def add_input_mapping(src_name, src_index, dst)
TensorFlow.tf_import_graph_def_options_add_input_mapping(self, src_name, src_index, dst)
end
# @param [TFOperation] oper
# @return [nil]
def add_control_dependency(oper)
TensorFlow.tf_import_graph_def_options_add_control_dependency(self, oper)
end
# @param [String] oper_name
# @param [Integer] index
# @return [nil]
def add_return_output(oper_name, index)
TensorFlow.tf_import_graph_def_options_add_return_output(self, oper_name, index)
end
# @return [Integer]
def num_return_outputs()
TensorFlow.tf_import_graph_def_options_num_return_outputs(self)
end
end
class TFImportGraphDefOptions < FFI::Struct
include TFImportGraphDefOptionsWrappers
layout :dummy, :char
end
# (Not documented)
#
# @method tf_new_import_graph_def_options()
# @return [TFImportGraphDefOptions]
# @scope class
attach_function :tf_new_import_graph_def_options, :TF_NewImportGraphDefOptions, [], TFImportGraphDefOptions
# (Not documented)
#
# @method tf_delete_import_graph_def_options(opts)
# @param [TFImportGraphDefOptions] opts
# @return [nil]
# @scope class
attach_function :tf_delete_import_graph_def_options, :TF_DeleteImportGraphDefOptions, [TFImportGraphDefOptions], :void
# be imported into `graph`.
#
# @method tf_import_graph_def_options_set_prefix(opts, prefix)
# @param [TFImportGraphDefOptions] opts
# @param [String] prefix
# @return [nil]
# @scope class
attach_function :tf_import_graph_def_options_set_prefix, :TF_ImportGraphDefOptionsSetPrefix, [TFImportGraphDefOptions, :string], :void
# `dst` references a node already existing in the graph being imported into.
#
# @method tf_import_graph_def_options_add_input_mapping(opts, src_name, src_index, dst)
# @param [TFImportGraphDefOptions] opts
# @param [String] src_name
# @param [Integer] src_index
# @param [TFOutput] dst
# @return [nil]
# @scope class
attach_function :tf_import_graph_def_options_add_input_mapping, :TF_ImportGraphDefOptionsAddInputMapping, [TFImportGraphDefOptions, :string, :int, TFOutput.by_value], :void
# into.
#
# @method tf_graph_import_graph_def_options_remap_control_dependency(opts, src_name, dst)
# @param [TFImportGraphDefOptions] opts
# @param [String] src_name
# @param [TFOperation] dst
# @return [nil]
# @scope class
attach_function :tf_graph_import_graph_def_options_remap_control_dependency, :TF_GraphImportGraphDefOptionsRemapControlDependency, [TFImportGraphDefOptions, :string, TFOperation], :void
# should exist in the graph being imported into.
#
# @method tf_import_graph_def_options_add_control_dependency(opts, oper)
# @param [TFImportGraphDefOptions] opts
# @param [TFOperation] oper
# @return [nil]
# @scope class
attach_function :tf_import_graph_def_options_add_control_dependency, :TF_ImportGraphDefOptionsAddControlDependency, [TFImportGraphDefOptions, TFOperation], :void
# mapping, the corresponding existing tensor in `graph` will be returned.
#
# @method tf_import_graph_def_options_add_return_output(opts, oper_name, index)
# @param [TFImportGraphDefOptions] opts
# @param [String] oper_name
# @param [Integer] index
# @return [nil]
# @scope class
attach_function :tf_import_graph_def_options_add_return_output, :TF_ImportGraphDefOptionsAddReturnOutput, [TFImportGraphDefOptions, :string, :int], :void
# TF_ImportGraphDefOptionsAddReturnOutput().
#
# @method tf_import_graph_def_options_num_return_outputs(opts)
# @param [TFImportGraphDefOptions] opts
# @return [Integer]
# @scope class
attach_function :tf_import_graph_def_options_num_return_outputs, :TF_ImportGraphDefOptionsNumReturnOutputs, [TFImportGraphDefOptions], :int
# `num_return_outputs`. Otherwise it can be null.
#
# @method tf_graph_import_graph_def_with_return_outputs(graph, graph_def, options, return_outputs, num_return_outputs, status)
# @param [TFGraph] graph
# @param [TFBuffer] graph_def
# @param [TFImportGraphDefOptions] options
# @param [TFOutput] return_outputs
# @param [Integer] num_return_outputs
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_graph_import_graph_def_with_return_outputs, :TF_GraphImportGraphDefWithReturnOutputs, [TFGraph, TFBuffer, TFImportGraphDefOptions, TFOutput, :int, TFStatus], :void
# Convenience function for when no return outputs have been added.
#
# @method tf_graph_import_graph_def(graph, graph_def, options, status)
# @param [TFGraph] graph
# @param [TFBuffer] graph_def
# @param [TFImportGraphDefOptions] options
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_graph_import_graph_def, :TF_GraphImportGraphDef, [TFGraph, TFBuffer, TFImportGraphDefOptions, TFStatus], :void
# Note: The following function may fail on very large protos in the future.
#
# @method tf_operation_to_node_def(oper, output_node_def, status)
# @param [TFOperation] oper
# @param [TFBuffer] output_node_def
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_operation_to_node_def, :TF_OperationToNodeDef, [TFOperation, TFBuffer, TFStatus], :void
# (Not documented)
#
# = Fields:
# :ninputs ::
# (Integer) This is the size of cond_inputs, body_inputs, and body_outputs.
# :cond_graph ::
# (TFGraph) variables. The output should be a scalar boolean.
# :cond_inputs ::
# (TFOutput)
# :cond_output ::
# (TFOutput)
# :body_graph ::
# (TFGraph) variables. The outputs are the updated values of the loop variables.
# :body_inputs ::
# (TFOutput)
# :body_outputs ::
# (TFOutput)
# :name ::
# (String) for created operations.
class TFWhileParams < FFI::Struct
layout :ninputs, :int,
:cond_graph, TFGraph,
:cond_inputs, TFOutput,
:cond_output, TFOutput.by_value,
:body_graph, TFGraph,
:body_inputs, TFOutput,
:body_outputs, TFOutput,
:name, :string
end
# possible in the Python API)
#
# @method tf_new_while(g, inputs, ninputs, status)
# @param [TFGraph] g
# @param [TFOutput] inputs
# @param [Integer] ninputs
# @param [TFStatus] status
# @return [TFWhileParams]
# @scope class
attach_function :tf_new_while, :TF_NewWhile, [TFGraph, TFOutput, :int, TFStatus], TFWhileParams.by_value
# TF_NewWhile() call.
#
# @method tf_finish_while(params, status, outputs)
# @param [TFWhileParams] params
# @param [TFStatus] status
# @param [TFOutput] outputs
# @return [nil]
# @scope class
attach_function :tf_finish_while, :TF_FinishWhile, [TFWhileParams, TFStatus, TFOutput], :void
# called after a successful TF_NewWhile() call.
#
# @method tf_abort_while(params)
# @param [TFWhileParams] params
# @return [nil]
# @scope class
attach_function :tf_abort_while, :TF_AbortWhile, [TFWhileParams], :void
# API for driving Graph execution.
module TFSessionWrappers
# @param [TFBuffer] run_options
# @param [TFOutput] inputs
# @param [FFI::Pointer(**TFTensor)] input_values
# @param [Integer] ninputs
# @param [TFOutput] outputs
# @param [FFI::Pointer(**TFTensor)] output_values
# @param [Integer] noutputs
# @param [FFI::Pointer(**TFOperation)] target_opers
# @param [Integer] ntargets
# @param [TFBuffer] run_metadata
# @param [TFStatus] tf_status
# @return [nil]
def run(run_options, inputs, input_values, ninputs, outputs, output_values, noutputs, target_opers, ntargets, run_metadata, tf_status)
TensorFlow.tf_session_run(self, run_options, inputs, input_values, ninputs, outputs, output_values, noutputs, target_opers, ntargets, run_metadata, tf_status)
end
# @param [TFOutput] inputs
# @param [Integer] ninputs
# @param [TFOutput] outputs
# @param [Integer] noutputs
# @param [FFI::Pointer(**TFOperation)] target_opers
# @param [Integer] ntargets
# @param [FFI::Pointer(**CharS)] handle
# @param [TFStatus] tf_status
# @return [nil]
def p_run_setup(inputs, ninputs, outputs, noutputs, target_opers, ntargets, handle, tf_status)
TensorFlow.tf_session_p_run_setup(self, inputs, ninputs, outputs, noutputs, target_opers, ntargets, handle, tf_status)
end
# @param [String] handle
# @param [TFOutput] inputs
# @param [FFI::Pointer(**TFTensor)] input_values
# @param [Integer] ninputs
# @param [TFOutput] outputs
# @param [FFI::Pointer(**TFTensor)] output_values
# @param [Integer] noutputs
# @param [FFI::Pointer(**TFOperation)] target_opers
# @param [Integer] ntargets
# @param [TFStatus] tf_status
# @return [nil]
def p_run(handle, inputs, input_values, ninputs, outputs, output_values, noutputs, target_opers, ntargets, tf_status)
TensorFlow.tf_session_p_run(self, handle, inputs, input_values, ninputs, outputs, output_values, noutputs, target_opers, ntargets, tf_status)
end
end
class TFSession < FFI::Struct
include TFSessionWrappers
layout :dummy, :char
end
# Does not take ownership of opts.
#
# @method tf_new_session(graph, opts, status)
# @param [TFGraph] graph
# @param [TFSessionOptions] opts
# @param [TFStatus] status
# @return [TFSession]
# @scope class
attach_function :tf_new_session, :TF_NewSession, [TFGraph, TFSessionOptions, TFStatus], TFSession
# `meta_graph_def` with the MetaGraphDef of the loaded model.
#
# @method tf_load_session_from_saved_model(session_options, run_options, export_dir, tags, tags_len, graph, meta_graph_def, status)
# @param [TFSessionOptions] session_options
# @param [TFBuffer] run_options
# @param [String] export_dir
# @param [FFI::Pointer(**CharS)] tags
# @param [Integer] tags_len
# @param [TFGraph] graph
# @param [TFBuffer] meta_graph_def
# @param [TFStatus] status
# @return [TFSession]
# @scope class
attach_function :tf_load_session_from_saved_model, :TF_LoadSessionFromSavedModel, [TFSessionOptions, TFBuffer, :string, :pointer, :int, TFGraph, TFBuffer, TFStatus], TFSession
# May not be called after TF_DeleteSession().
#
# @method tf_close_session(tf_session, status)
# @param [TFSession] tf_session
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_close_session, :TF_CloseSession, [TFSession, TFStatus], :void
# corresponding graph).
#
# @method tf_delete_session(tf_session, status)
# @param [TFSession] tf_session
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_delete_session, :TF_DeleteSession, [TFSession, TFStatus], :void
# On failure, output_values() contains NULLs.
#
# @method tf_session_run(session, run_options, inputs, input_values, ninputs, outputs, output_values, noutputs, target_opers, ntargets, run_metadata, tf_status)
# @param [TFSession] session
# @param [TFBuffer] run_options
# @param [TFOutput] inputs
# @param [FFI::Pointer(**TFTensor)] input_values
# @param [Integer] ninputs
# @param [TFOutput] outputs
# @param [FFI::Pointer(**TFTensor)] output_values
# @param [Integer] noutputs
# @param [FFI::Pointer(**TFOperation)] target_opers
# @param [Integer] ntargets
# @param [TFBuffer] run_metadata
# @param [TFStatus] tf_status
# @return [nil]
# @scope class
attach_function :tf_session_run, :TF_SessionRun, [TFSession, TFBuffer, TFOutput, :pointer, :int, TFOutput, :pointer, :int, :pointer, :int, TFBuffer, TFStatus], :void
# NOTE: This is EXPERIMENTAL and subject to change.
#
# @method tf_session_p_run_setup(tf_session, inputs, ninputs, outputs, noutputs, target_opers, ntargets, handle, tf_status)
# @param [TFSession] tf_session
# @param [TFOutput] inputs
# @param [Integer] ninputs
# @param [TFOutput] outputs
# @param [Integer] noutputs
# @param [FFI::Pointer(**TFOperation)] target_opers
# @param [Integer] ntargets
# @param [FFI::Pointer(**CharS)] handle
# @param [TFStatus] tf_status
# @return [nil]
# @scope class
attach_function :tf_session_p_run_setup, :TF_SessionPRunSetup, [TFSession, TFOutput, :int, TFOutput, :int, :pointer, :int, :pointer, TFStatus], :void
# NOTE: This is EXPERIMENTAL and subject to change.
#
# @method tf_session_p_run(tf_session, handle, inputs, input_values, ninputs, outputs, output_values, noutputs, target_opers, ntargets, tf_status)
# @param [TFSession] tf_session
# @param [String] handle
# @param [TFOutput] inputs
# @param [FFI::Pointer(**TFTensor)] input_values
# @param [Integer] ninputs
# @param [TFOutput] outputs
# @param [FFI::Pointer(**TFTensor)] output_values
# @param [Integer] noutputs
# @param [FFI::Pointer(**TFOperation)] target_opers
# @param [Integer] ntargets
# @param [TFStatus] tf_status
# @return [nil]
# @scope class
attach_function :tf_session_p_run, :TF_SessionPRun, [TFSession, :string, TFOutput, :pointer, :int, TFOutput, :pointer, :int, :pointer, :int, TFStatus], :void
# Once called, no more calls to TF_SessionPRun should be made.
#
# @method tf_delete_p_run_handle(handle)
# @param [String] handle
# @return [nil]
# @scope class
attach_function :tf_delete_p_run_handle, :TF_DeletePRunHandle, [:string], :void
# notice.
class TFDeprecatedSession < FFI::Struct
layout :dummy, :char
end
# (Not documented)
#
# @method tf_new_deprecated_session(tf_session_options, status)
# @param [TFSessionOptions] tf_session_options
# @param [TFStatus] status
# @return [TFDeprecatedSession]
# @scope class
attach_function :tf_new_deprecated_session, :TF_NewDeprecatedSession, [TFSessionOptions, TFStatus], TFDeprecatedSession
# (Not documented)
#
# @method tf_close_deprecated_session(tf_deprecated_session, status)
# @param [TFDeprecatedSession] tf_deprecated_session
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_close_deprecated_session, :TF_CloseDeprecatedSession, [TFDeprecatedSession, TFStatus], :void
# (Not documented)
#
# @method tf_delete_deprecated_session(tf_deprecated_session, status)
# @param [TFDeprecatedSession] tf_deprecated_session
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_delete_deprecated_session, :TF_DeleteDeprecatedSession, [TFDeprecatedSession, TFStatus], :void
# (Not documented)
#
# @method tf_reset(opt, containers, ncontainers, status)
# @param [TFSessionOptions] opt
# @param [FFI::Pointer(**CharS)] containers
# @param [Integer] ncontainers
# @param [TFStatus] status
# @return [nil]
# @scope class
attach_function :tf_reset, :TF_Reset, [TFSessionOptions, :pointer, :int, TFStatus], :void
# Prefer use of TF_Session and TF_GraphImportGraphDef over this.
#
# @method tf_extend_graph(tf_deprecated_session, proto, proto_len, tf_status)
# @param [TFDeprecatedSession] tf_deprecated_session
# @param [FFI::Pointer(*Void)] proto
# @param [Integer] proto_len
# @param [TFStatus] tf_status
# @return [nil]
# @scope class
attach_function :tf_extend_graph, :TF_ExtendGraph, [TFDeprecatedSession, :pointer, :ulong, TFStatus], :void
# See TF_SessionRun() above.
#
# @method tf_run(tf_deprecated_session, run_options, input_names, inputs, ninputs, output_names, outputs, noutputs, target_oper_names, ntargets, run_metadata, tf_status)
# @param [TFDeprecatedSession] tf_deprecated_session
# @param [TFBuffer] run_options
# @param [FFI::Pointer(**CharS)] input_names
# @param [FFI::Pointer(**TFTensor)] inputs
# @param [Integer] ninputs
# @param [FFI::Pointer(**CharS)] output_names
# @param [FFI::Pointer(**TFTensor)] outputs
# @param [Integer] noutputs
# @param [FFI::Pointer(**CharS)] target_oper_names
# @param [Integer] ntargets
# @param [TFBuffer] run_metadata
# @param [TFStatus] tf_status
# @return [nil]
# @scope class
attach_function :tf_run, :TF_Run, [TFDeprecatedSession, TFBuffer, :pointer, :pointer, :int, :pointer, :pointer, :int, :pointer, :int, TFBuffer, TFStatus], :void
# See TF_SessionPRunSetup() above.
#
# @method tf_p_run_setup(tf_deprecated_session, input_names, ninputs, output_names, noutputs, target_oper_names, ntargets, handle, tf_status)
# @param [TFDeprecatedSession] tf_deprecated_session
# @param [FFI::Pointer(**CharS)] input_names
# @param [Integer] ninputs
# @param [FFI::Pointer(**CharS)] output_names
# @param [Integer] noutputs
# @param [FFI::Pointer(**CharS)] target_oper_names
# @param [Integer] ntargets
# @param [FFI::Pointer(**CharS)] handle
# @param [TFStatus] tf_status
# @return [nil]
# @scope class
attach_function :tf_p_run_setup, :TF_PRunSetup, [TFDeprecatedSession, :pointer, :int, :pointer, :int, :pointer, :int, :pointer, TFStatus], :void
# See TF_SessionPRun above.
#
# @method tf_p_run(tf_deprecated_session, handle, input_names, inputs, ninputs, output_names, outputs, noutputs, target_oper_names, ntargets, tf_status)
# @param [TFDeprecatedSession] tf_deprecated_session
# @param [String] handle
# @param [FFI::Pointer(**CharS)] input_names
# @param [FFI::Pointer(**TFTensor)] inputs
# @param [Integer] ninputs
# @param [FFI::Pointer(**CharS)] output_names
# @param [FFI::Pointer(**TFTensor)] outputs
# @param [Integer] noutputs
# @param [FFI::Pointer(**CharS)] target_oper_names
# @param [Integer] ntargets
# @param [TFStatus] tf_status
# @return [nil]
# @scope class
attach_function :tf_p_run, :TF_PRun, [TFDeprecatedSession, :string, :pointer, :pointer, :int, :pointer, :pointer, :int, :pointer, :int, TFStatus], :void
# TF_Library holds information about dynamically loaded TensorFlow plugins.
class TFLibrary < FFI::Struct
layout :dummy, :char
end
# On failure, place an error status in status and return NULL.
#
# @method tf_load_library(library_filename, status)
# @param [String] library_filename
# @param [TFStatus] status
# @return [TFLibrary]
# @scope class
attach_function :tf_load_library, :TF_LoadLibrary, [:string, TFStatus], TFLibrary
# ops defined in the library.
#
# @method tf_get_op_list(lib_handle)
# @param [TFLibrary] lib_handle
# @return [TFBuffer]
# @scope class
attach_function :tf_get_op_list, :TF_GetOpList, [TFLibrary], TFBuffer.by_value
# Does NOT unload the library.
#
# @method tf_delete_library_handle(lib_handle)
# @param [TFLibrary] lib_handle
# @return [nil]
# @scope class
attach_function :tf_delete_library_handle, :TF_DeleteLibraryHandle, [TFLibrary], :void
# in this address space.
#
# @method tf_get_all_op_list()
# @return [TFBuffer]
# @scope class
attach_function :tf_get_all_op_list, :TF_GetAllOpList, [], TFBuffer
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment