Sha256: f2100f0b6412fce85cb0a8503c612d3da2d34461a22443fe3dc18bbf9e6fef50

Contents?: true

Size: 707 Bytes

Versions: 1

Compression:

Stored size: 707 Bytes

Contents

module TensorStream
  class OpenCLBuffer < Buffer
    include ArrayOpsHelper

    attr_accessor :shape, :buffer, :cl_buffer, :op

    def initialize(data_type: , shape:, buffer:, cl_buffer:, op: nil, name: nil)
      @data_type = data_type
      @shape = shape
      @buffer = buffer
      @cl_buffer = cl_buffer
      @name = name
      @op = op
    end

    def to_ruby
      return [] if buffer.empty?
      if shape.empty?
        return buffer[0] != 0 if data_type == :boolean
        return buffer[0]
      end

      result = buffer.reshape(*shape.reverse).to_a
      if data_type == :boolean
        result = process_function_op(result, ->(a, _b) { a != 0 })
      end
      result
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tensor_stream-0.5.0 lib/tensor_stream/evaluator/opencl/opencl_buffer.rb