Class: Kumi::Core::IRV2::Builder
- Inherits:
-
Object
- Object
- Kumi::Core::IRV2::Builder
- Defined in:
- lib/kumi/core/irv2/builder.rb
Instance Attribute Summary collapse
-
#exports ⇒ Object
readonly
Returns the value of attribute exports.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #align_to(v, target_axes, stamp: nil) ⇒ Object
- #const(lit, stamp: nil) ⇒ Object
- #construct_tuple(*vs, stamp: nil) ⇒ Object
- #dump ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #load_decl(name, stamp: nil) ⇒ Object
- #load_declaration(name, stamp: nil) ⇒ Object
- #load_input(path, stamp: nil) ⇒ Object
- #map(func, *values, stamp: nil) ⇒ Object
- #reduce(func, val, axis, stamp: nil) ⇒ Object
- #select(cond, then_v, else_v, stamp: nil) ⇒ Object
- #store(name, v) ⇒ Object
- #tuple_get(v, index, stamp: nil) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
11 12 13 14 15 |
# File 'lib/kumi/core/irv2/builder.rb', line 11 def initialize @next_id = 0 @values = [] @exports = [] end |
Instance Attribute Details
#exports ⇒ Object (readonly)
Returns the value of attribute exports.
9 10 11 |
# File 'lib/kumi/core/irv2/builder.rb', line 9 def exports @exports end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
9 10 11 |
# File 'lib/kumi/core/irv2/builder.rb', line 9 def values @values end |
Instance Method Details
#align_to(v, target_axes, stamp: nil) ⇒ Object
21 |
# File 'lib/kumi/core/irv2/builder.rb', line 21 def align_to(v, target_axes, stamp: nil) = emit(:AlignTo, [v], { target_axes: Array(target_axes).map(&:to_s) }, stamp: stamp) |
#const(lit, stamp: nil) ⇒ Object
20 |
# File 'lib/kumi/core/irv2/builder.rb', line 20 def const(lit, stamp: nil) = emit(:Const, [lit], {}, stamp: stamp) |
#construct_tuple(*vs, stamp: nil) ⇒ Object
25 |
# File 'lib/kumi/core/irv2/builder.rb', line 25 def construct_tuple(*vs, stamp: nil) = emit(:ConstructTuple, vs, {}, stamp: stamp) |
#dump ⇒ Object
33 34 35 |
# File 'lib/kumi/core/irv2/builder.rb', line 33 def dump [*values.map(&:to_s), *exports.map { |(n, v)| "Store #{n}, %#{v.id}" }].join("\n") end |
#load_decl(name, stamp: nil) ⇒ Object
19 |
# File 'lib/kumi/core/irv2/builder.rb', line 19 def load_decl(name, stamp: nil) = emit(:LoadDecl, [name], {}, stamp: stamp) |
#load_declaration(name, stamp: nil) ⇒ Object
18 |
# File 'lib/kumi/core/irv2/builder.rb', line 18 def load_declaration(name, stamp: nil) = emit(:LoadDeclaration, [name], {}, stamp: stamp) |
#load_input(path, stamp: nil) ⇒ Object
17 |
# File 'lib/kumi/core/irv2/builder.rb', line 17 def load_input(path, stamp: nil) = emit(:LoadInput, [path], {}, stamp: stamp) |
#map(func, *values, stamp: nil) ⇒ Object
23 |
# File 'lib/kumi/core/irv2/builder.rb', line 23 def map(func, *values, stamp: nil) = emit(:Map, values, { fn: func }, stamp: stamp) |
#reduce(func, val, axis, stamp: nil) ⇒ Object
24 |
# File 'lib/kumi/core/irv2/builder.rb', line 24 def reduce(func, val, axis, stamp: nil) = emit(:Reduce, [val], { fn: func, axis: axis.to_s }, stamp: stamp) |
#select(cond, then_v, else_v, stamp: nil) ⇒ Object
22 |
# File 'lib/kumi/core/irv2/builder.rb', line 22 def select(cond, then_v, else_v, stamp: nil) = emit(:Select, [cond, then_v, else_v], {}, stamp: stamp) |
#store(name, v) ⇒ Object
28 29 30 31 |
# File 'lib/kumi/core/irv2/builder.rb', line 28 def store(name, v) (@exports << [name, v] nil) end |
#tuple_get(v, index, stamp: nil) ⇒ Object
26 |
# File 'lib/kumi/core/irv2/builder.rb', line 26 def tuple_get(v, index, stamp: nil) = emit(:TupleGet, [v], { index: index }, stamp: stamp) |