Skip to content

class OCL(T)
inherits Num::Backend::Storage #

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

Arguments#
Examples#
OCL.new([10, 10], Num::RowMajor, 3.4)
View source

.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

Arguments#
Examples#
OCL.new([10, 10], [10, 1], 3.4)
View source

.new(hostptr : Pointer(T), shape : Array(Int), strides : Array(Int)) #

Initialize an OpenCL storage from a standard library Crystal pointer

Arguments#
Examples#
ptr = Pointer(Int32).malloc(9)
OCL.new(ptr, [3, 3], [3, 1])
View source

.new(shape : Array(Int), order : Num::OrderType) #

Initialize an OpenCL storage from an initial capacity. The data will be filled with zeros

Arguments#
Examples#
OCL.new([100], Num::RowMajor)
View source

.new(shape : Array(Int), strides : Array(Int)) #

Initialize an OpenCL storage from an initial capacity. The data will be filled with zeros

Arguments#
Examples#
OCL.new([100], [1])
View source

Class methods#

.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

a = OCL(Float32).new([10])

# Cannot do
# a.class.new ...

a.class.base(Float64).new([10])
View source

Methods#

#data : LibCL::ClMem #

Data buffer containing the data associated with the parent Tensor

View source

#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

View source

#shape : LibCL::ClMem #

Data buffer containing the shape associated with the parent Tensor

View source

#strides : LibCL::ClMem #

Data buffer containing the strides associated with the parent Tensor

View source

#to_unsafe : LibCL::ClMem #

Returns the underlying OpenCL memory buffer associated with a Tensor

View source

#total_size : Int32 #

Total size of the underlying data buffer. Keeps track of the total size of a buffer if a Tensor has been sliced

View source

#update_metadata(shape : Array(Int32), strides : Array(Int32)) #

View source