class OCL(T)

Defined in:

tensor/backends/opencl/impl_allocation.cr
tensor/backends/opencl/impl_data_structure.cr

Constructors

Class Method Summary

Instance Method Summary

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

def self.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]
def self.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

  • shape : Array(Int) - Shape for parent Tensor
  • strides : Array(Int) - Strides for parent Tensor
  • value : T - Value to initially populate the buffer

Examples

OCL.new([10, 10], [10, 1], 3.4)

[View source]
def self.new(hostptr : Pointer(T), shape : Array(Int), strides : Array(Int)) #

Initialize an OpenCL storage from a standard library Crystal pointer

Arguments

  • hostptr : Pointer(T) - Stdlib Crystal pointer containing the Tensors data
  • shape : Array(Int) - Shape for parent Tensor
  • strides : Array(Int) - Strides for parent Tensor

Examples

ptr = Pointer(Int32).malloc(9)
OCL.new(ptr, [3, 3], [3, 1])

[View source]
def self.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]
def self.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 Method Detail

def self.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]

Instance Method Detail

def data : LibCL::ClMem #

Data buffer containing the data associated with the parent Tensor


[View source]
def 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]
def shape : LibCL::ClMem #

Data buffer containing the shape associated with the parent Tensor


[View source]
def strides : LibCL::ClMem #

Data buffer containing the strides associated with the parent Tensor


[View source]
def to_unsafe : LibCL::ClMem #

Returns the underlying OpenCL memory buffer associated with a Tensor


[View source]
def 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]
def update_metadata(shape : Array(Int32), strides : Array(Int32)) #

[View source]