class OCL(T)
- OCL(T)
- Num::Backend::Storage(T)
- Reference
- Object
Defined in:
tensor/backends/opencl/impl_allocation.crtensor/backends/opencl/impl_data_structure.cr
Constructors
-
.new(shape : Array(Int), order : Num::OrderType, value : T)
Initialize an OpenCL storage from an initial capacity and an initial value, which will fill the buffer
-
.new(shape : Array(Int), strides : Array(Int), value : T)
Initialize an OpenCL storage from an initial capacity and an initial value, which will fill the buffer
-
.new(hostptr : Pointer(T), shape : Array(Int), strides : Array(Int))
Initialize an OpenCL storage from a standard library Crystal pointer
-
.new(shape : Array(Int), order : Num::OrderType)
Initialize an OpenCL storage from an initial capacity.
-
.new(shape : Array(Int), strides : Array(Int))
Initialize an OpenCL storage from an initial capacity.
Class Method Summary
-
.base(dtype : U.class) : OCL(U).class forall U
Return a generic class of a specific generic type, to allow for explicit return types in functions that return a different storage type than the parent Tensor
Instance Method Summary
-
#data : LibCL::ClMem
Data buffer containing the data associated with the parent
Tensor
- #finalize
-
#shape : LibCL::ClMem
Data buffer containing the shape associated with the parent
Tensor
-
#strides : LibCL::ClMem
Data buffer containing the strides associated with the parent
Tensor
-
#to_unsafe : LibCL::ClMem
Returns the underlying OpenCL memory buffer associated with a
Tensor
-
#total_size : Int32
Total size of the underlying data buffer.
- #update_metadata(shape : Array(Int32), strides : Array(Int32))
Instance methods inherited from class Num::Backend::Storage(T)
to_unsafe
to_unsafe,
update_metadata(shape : Array(Int32), strides : Array(Int32))
update_metadata
Constructor methods inherited from class Num::Backend::Storage(T)
new(shape : Array(Int), order : Num::OrderType, value : T)new(shape : Array(Int), strides : Array(Int), value : T)
new(hostptr : Pointer(T), shape : Array(Int), strides : Array(Int))
new(shape : Array(Int), order : Num::OrderType)
new(shape : Array(Int), strides : Array(Int)) new
Constructor Detail
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 theTensor
s 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)
Initialize an OpenCL storage from an initial capacity. The data will be filled with zeros
Arguments
Examples
OCL.new([100], [1])
Class Method Detail
Return a generic class of a specific generic type, to allow for explicit return types in functions that return a different storage type than the parent Tensor
a = OCL(Float32).new([10])
# Cannot do
# a.class.new ...
a.class.base(Float64).new([10])
Instance Method Detail
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