ML::Tensor
Tensor: shape + strides + data buffer Immutable shape, mutable data
Constructors
arange(start : Float32, stop : Float32, step : Float32 = 1.0_f32, device : Device = Tensor.default_device) : Tensor
Arange
linspace(start : Float32, stop : Float32, count : Int32, device : Device = Tensor.default_device) : Tensor
Linspace
new(shape : Shape, dtype : DType = DType::F32, device : Device = Tensor.default_device)
Create empty tensor on GPU
Create from shape tuple
Class methods
Instance methods
buffer
Sourcecontiguous?
Sourcecpu_data
Sourcedevice
Sourcedtype
SourceAppends a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
ndim
Sourceon_cpu?
Sourceon_gpu?
Sourcesafe_cpu_data
Safe CPU data access - converts from GPU if needed, handles empty tensors Returns empty array for empty tensors instead of crashing
shape
Sourcestrides
Sourceto_cpu
Sourceto_cpu!
Sourceto_flat_array
Sourceto_gpu!
Source