class TensorStream::OpenCLBuffer::LazyBuffer

Attributes

data_type[R]

Public Class Methods

new(data_type, size) click to toggle source
# File lib/tensor_stream/opencl/opencl_buffer.rb, line 7
def initialize(data_type, size)
  @data_type = data_type
  @size = size
end

Public Instance Methods

buffer_size_for_type(data_type) click to toggle source
# File lib/tensor_stream/opencl/opencl_buffer.rb, line 20
def buffer_size_for_type(data_type)
  case data_type
  when :float, :float32, :float16
    4
  when :float64
    8
  when :int, :int32, :int64, :uint64, :uint32 # NArray does not have 64 bit int types
    4
  when :int16, :uint16
    2
  when :uint8, :int8
    1
  when :boolean
    1
  when :string
    1
  when :unknown
    nil
  else
    raise "unsupported type #{data_type}"
  end
end
element_size() click to toggle source
# File lib/tensor_stream/opencl/opencl_buffer.rb, line 16
def element_size
  buffer_size_for_type(@data_type)
end
size() click to toggle source
# File lib/tensor_stream/opencl/opencl_buffer.rb, line 12
def size
  @size
end