OCL(T)
Inherits Num::Backend::Storage / Reference / Object
Constructors
Initialize an OpenCL storage from an initial capacity and an initial value, which will fill the buffer
Arguments
- shape :
Array(Int)- Shape for parentTensor - order :
Num::OrderType- Memory layout for parentTensor - value :
T- Value to initially populate the buffer
Examples
OCL.new([10, 10], Num::RowMajor, 3.4)
Initialize an OpenCL storage from an initial capacity and an initial value, which will fill the buffer
Arguments
- shape :
Array(Int)- Shape for parentTensor - strides :
Array(Int)- Strides for parentTensor - value :
T- Value to initially populate the buffer
Examples
OCL.new([10, 10], [10, 1], 3.4)
Initialize an OpenCL storage from a standard library Crystal pointer
Arguments
- hostptr :
Pointer(T)- Stdlib Crystal pointer containing theTensors data - shape :
Array(Int)- Shape for parentTensor - strides :
Array(Int)- Strides for parentTensor
Examples
ptr = Pointer(Int32).malloc(9)
OCL.new(ptr, [3, 3], [3, 1])
Initialize an OpenCL storage from an initial capacity. The data will be filled with zeros
Arguments
- shape :
Array(Int)- Shape for parentTensor - order :
Num::OrderType- Memory layout for parentTensor
Examples
OCL.new([100], Num::RowMajor)
Class methods
Instance methods
finalize
Releases the underlying LibCL::ClMem buffers containing the
data for a Tensor, as well as the buffers containing the
shape and strides for the Tensor
total_size
Total size of the underlying data buffer. Keeps track of the total
size of a buffer if a Tensor has been sliced