Class: TensorStream::DynamicStitch

Inherits:
Operation show all
Defined in:
lib/tensor_stream/dynamic_stitch.rb

Overview

Defines a TensorStream controlflow op

Instance Attribute Summary collapse

Attributes inherited from Operation

#breakpoint, #consumers, #data_type, #device, #inputs, #is_const, #name, #operation, #options, #outputs, #rank, #shape

Attributes inherited from Tensor

#data_type, #given_name, #graph, #internal, #is_const, #name, #native_buffer, #op, #outputs, #rank, #shape, #source, #value

Instance Method Summary collapse

Methods inherited from Operation

#const_value, #container_buffer, #infer_const, #inspect, #op, #set_input, #set_name, #set_option, #to_h, #to_math, #to_s

Methods included from OpHelper

#_op, #cons, #format_source, #fp_type?, #i_cons, #i_op, #i_var, #int_type?, #reduced_shape, #shape_eval, #shape_full_specified, #shapes_fully_specified_and_equal

Methods inherited from Tensor

#auto_math, #breakpoint!, cast_dtype, #collect, #consumers, detect_type, #device, #dtype, #eval, #first, #inspect, #internal?, #print!, reset_counters, #to_a, #to_f, #to_h, #to_i, #to_math, #to_s

Methods included from TensorMixins

#!=, #%, #*, #**, #+, #-, #-@, #/, #<, #<=, #==, #>, #>=, #[], #and, #cast, #ceil, #dot, #floor, #log, #matmul, #reduce, #reshape, #round, #var, #zero?

Constructor Details

#initialize(flow_type, inputs, ops = nil, options = {}) ⇒ DynamicStitch

Returns a new instance of DynamicStitch.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/tensor_stream/dynamic_stitch.rb', line 6

def initialize(flow_type, inputs, ops = nil, options = {})
  setup_initial_state(options)

  @operation = :"flow_#{flow_type}"
  @options = options.merge(n: inputs[0].size)
  @inputs = inputs.flatten(1).map { |i| TensorStream.convert_to_tensor(i) }.map { |i| i ? i.op : nil }

  @consumers = Set.new
  @data_type = Tensor.detect_type(inputs[1])
  @name = [@graph.get_name_scope, options[:name] || set_name].compact.join("/")
  @ops = ops
  @shape = TensorShape.new(nil)
  @graph.add_node(self)
end

Instance Attribute Details

#opsObject

Returns the value of attribute ops.



4
5
6
# File 'lib/tensor_stream/dynamic_stitch.rb', line 4

def ops
  @ops
end

Instance Method Details

#runObject



25
26
27
# File 'lib/tensor_stream/dynamic_stitch.rb', line 25

def run
  eval
end

#set_data_type(_passed_data_type) ⇒ Object



21
22
23
# File 'lib/tensor_stream/dynamic_stitch.rb', line 21

def set_data_type(_passed_data_type)
  :unknown
end