Class: TensorStream::OpenCLBuffer::LazyBuffer
- Inherits:
-
Object
- Object
- TensorStream::OpenCLBuffer::LazyBuffer
- Defined in:
- lib/tensor_stream/opencl/opencl_buffer.rb
Instance Attribute Summary collapse
-
#data_type ⇒ Object
readonly
Returns the value of attribute data_type.
Instance Method Summary collapse
- #buffer_size_for_type(data_type) ⇒ Object
- #element_size ⇒ Object
-
#initialize(data_type, size) ⇒ LazyBuffer
constructor
A new instance of LazyBuffer.
- #size ⇒ Object
Constructor Details
#initialize(data_type, size) ⇒ LazyBuffer
Returns a new instance of LazyBuffer.
7 8 9 10 |
# File 'lib/tensor_stream/opencl/opencl_buffer.rb', line 7 def initialize(data_type, size) @data_type = data_type @size = size end |
Instance Attribute Details
#data_type ⇒ Object (readonly)
Returns the value of attribute data_type.
5 6 7 |
# File 'lib/tensor_stream/opencl/opencl_buffer.rb', line 5 def data_type @data_type end |
Instance Method Details
#buffer_size_for_type(data_type) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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 ⇒ Object
16 17 18 |
# File 'lib/tensor_stream/opencl/opencl_buffer.rb', line 16 def element_size buffer_size_for_type(@data_type) end |
#size ⇒ Object
12 13 14 |
# File 'lib/tensor_stream/opencl/opencl_buffer.rb', line 12 def size @size end |