Class: Ikra::Symbolic::ArrayReduceCommand
- Includes:
- ArrayCommand
- Defined in:
- lib/symbolic/visitor.rb,
lib/symbolic/symbolic.rb
Instance Attribute Summary
Attributes included from ArrayCommand
#block, #block_size, #generator_node, #gpu_result_pointer, #input, #keep, #unique_id
Instance Method Summary collapse
- #==(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #execute ⇒ Object
-
#initialize(target, block, block_size: DEFAULT_BLOCK_SIZE, ast: nil, generator_node: nil, command_binding: nil) ⇒ ArrayReduceCommand
constructor
A new instance of ArrayReduceCommand.
-
#input_size ⇒ Object
Returns the number of elements in the input.
- #size ⇒ Object
Methods included from ArrayCommand
#[], #block_def_node, #block_parameter_names, #command_binding, #command_translator_class, #dimensions, #each, #eql?, #externals, #has_previous_result?, #hash, #ikra_type, included, #lexical_externals, #pack, #post_execute, reset_unique_id, #result_type, #set_unique_id, #to_c_type, #to_command, #to_ffi_type, #to_ruby_type, #to_s, #with_index
Methods included from Types::RubyType
#class_id, #eql?, #hash, #inspect, #is_primitive?, #is_union_type?, #should_generate_self_arg?, #to_array_type, #to_c_type, #to_ruby_type, #to_str, #to_union_type
Methods included from ParallelOperations
#&, #*, #+, #-, #/, #<, #<=, #>, #>=, #^, #pcombine, #pmap, #preduce, #pstencil, #pzip, #|
Constructor Details
#initialize(target, block, block_size: DEFAULT_BLOCK_SIZE, ast: nil, generator_node: nil, command_binding: nil) ⇒ ArrayReduceCommand
Returns a new instance of ArrayReduceCommand.
502 503 504 505 506 507 508 509 510 511 512 513 |
# File 'lib/symbolic/symbolic.rb', line 502 def initialize( target, block, block_size: DEFAULT_BLOCK_SIZE, ast: nil, generator_node: nil, command_binding: nil) super(block: block, block_ast: ast, block_size: block_size, keep: keep, generator_node: generator_node, command_binding: command_binding) @input = [ReduceInput.new(command: target.to_command, pattern: :entire)] end |
Instance Method Details
#==(other) ⇒ Object
534 535 536 |
# File 'lib/symbolic/symbolic.rb', line 534 def ==(other) return super(other) && size == other.size end |
#accept(visitor) ⇒ Object
16 17 18 |
# File 'lib/symbolic/visitor.rb', line 16 def accept(visitor) visitor.visit_array_reduce_command(self) end |
#execute ⇒ Object
515 516 517 518 519 520 521 522 523 |
# File 'lib/symbolic/symbolic.rb', line 515 def execute if input.first.command.size == 0 @result = [nil] elsif @input.first.command.size == 1 @result = [input.first.command[0]] else @result = super end end |
#input_size ⇒ Object
Returns the number of elements in the input
530 531 532 |
# File 'lib/symbolic/symbolic.rb', line 530 def input_size return input.first.command.size end |
#size ⇒ Object
525 526 527 |
# File 'lib/symbolic/symbolic.rb', line 525 def size return 1 end |