Class: Kumi::IR::Loop::Ops::Node

Inherits:
Base::Instruction show all
Defined in:
lib/kumi/ir/loop/ops/node.rb

Class Attribute Summary collapse

Attributes inherited from Base::Instruction

#attributes, #axes, #dtype, #effects, #inputs, #metadata, #opcode, #result

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base::Instruction

#control_effect?, #defs, #effectful?, #io_effect?, #memory_effect?, #normalized_attributes, #printer_attributes, #printer_axes, #printer_dtype, #produces?, #stamp, #state_effect?, #to_print_string, #uses, #validate!, #value_signature, #with_metadata

Constructor Details

#initialize(result: nil, axes: [], dtype: nil, inputs: [], attributes: {}, metadata: {}, effects: Base::Effects::NONE) ⇒ Node

Returns a new instance of Node.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kumi/ir/loop/ops/node.rb', line 17

def initialize(result: nil, axes: [], dtype: nil, inputs: [], attributes: {}, metadata: {}, effects: Base::Effects::NONE)
  axes = Array(axes || []).map(&:to_sym).freeze
  merged_meta = .merge(axes: axes)
  merged_meta = merged_meta.merge(dtype: dtype) if dtype
  super(
    opcode: self.class.opcode_symbol || infer_opcode,
    result: result,
    inputs: inputs,
    attributes: attributes,
    metadata: merged_meta,
    effects: effects
  )
end

Class Attribute Details

.opcode_symbolObject (readonly)

Returns the value of attribute opcode_symbol.



9
10
11
# File 'lib/kumi/ir/loop/ops/node.rb', line 9

def opcode_symbol
  @opcode_symbol
end

Class Method Details

.opcode(value = nil) ⇒ Object



11
12
13
14
# File 'lib/kumi/ir/loop/ops/node.rb', line 11

def opcode(value = nil)
  @opcode_symbol = value if value
  @opcode_symbol
end

Instance Method Details

#to_hObject



31
32
33
# File 'lib/kumi/ir/loop/ops/node.rb', line 31

def to_h
  super.merge(axes: axes, dtype: dtype)
end