DenseTensorDataFactory

Low level DenseTensorDataFactory factories.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun <T : DType, V> fromByteArray(data: ByteArray, dtype: T): TensorData<T, V>

Creates a tensor from byte array data for various data types.

open override fun <T : DType, V> fromByteArray(shape: Shape, dtype: KClass<T>, data: ByteArray): TensorData<T, V>
Link copied to clipboard
fun <T : DType, V> fromFloatArray(data: FloatArray, dtype: T): TensorData<T, V>

Creates a tensor from float array with specified data type (overloaded version).

fun <T : DType> fromFloatArray(shape: Shape, data: FloatArray, dtype: T): TensorData<T, Float>
open override fun <T : DType, V> fromFloatArray(shape: Shape, dtype: KClass<T>, data: FloatArray): TensorData<T, V>
Link copied to clipboard
fun <T : DType, V> fromIntArray(data: IntArray, dtype: T): TensorData<T, V>

Creates a tensor from int array with specified data type.

open override fun <T : DType, V> fromIntArray(shape: Shape, dtype: KClass<T>, data: IntArray): TensorData<T, V>
Link copied to clipboard
fun <T : DType> full(shape: Shape, value: Number, dtype: T): TensorData<T, *>

Creates a tensor filled with a constant value for the specified dtype.

open override fun <T : DType, V> full(shape: Shape, dtype: KClass<T>, value: Number): TensorData<T, V>
Link copied to clipboard
open override fun <T : DType, V> init(shape: Shape, dtype: KClass<T>, generator: (indices: IntArray) -> V): TensorData<T, V>
Link copied to clipboard
fun <T : DType, V> matrix(vararg rows: Array<V>): TensorData<T, V>

Creates a matrix tensor from multiple rows of values.

Link copied to clipboard
open override fun <T : DType, V> ones(shape: Shape, dtype: KClass<T>): TensorData<T, V>
Link copied to clipboard
fun <T : DType> randn(shape: Shape, mean: Float = 0.0f, std: Float = 1.0f, dtype: T, random: Random = Random.Default): TensorData<T, *>

Creates a tensor filled with random values from normal distribution.

open override fun <T : DType, V> randn(shape: Shape, dtype: KClass<T>, mean: Float, std: Float, random: Random): TensorData<T, V>
Link copied to clipboard
open override fun <T : DType, V> randomInit(shape: Shape, dtype: KClass<T>, generator: (random: Random) -> V, random: Random): TensorData<T, V>
Link copied to clipboard
fun <T : DType, V> randomInt(shape: Shape, dtype: T, random: Random, generator: (size: Int, random: Random) -> V): TensorData<T, *>

Creates a tensor filled with random values from uniform distribution [0, 1) for floating point types or [0, maxValue) for integer types.

Link copied to clipboard
fun <T : DType, V> scalar(value: V): TensorData<T, V>

Creates a scalar tensor from a single value.

Link copied to clipboard
open override fun <T : DType, V> uniform(shape: Shape, dtype: KClass<T>, min: Float, max: Float, random: Random): TensorData<T, V>
Link copied to clipboard
fun <T : DType, V> vector(values: Array<V>): TensorData<T, V>

Creates a vector tensor from an array of values.

Link copied to clipboard
open override fun <T : DType, V> wrapByteArray(shape: Shape, dtype: KClass<T>, data: ByteArray): TensorData<T, V>

Wraps a ByteArray without copying. The caller must ensure the array is not mutated while the returned TensorData is in use. Default implementation falls back to fromByteArray (which copies).

Link copied to clipboard
open override fun <T : DType, V> wrapFloatArray(shape: Shape, dtype: KClass<T>, data: FloatArray): TensorData<T, V>

Wraps a FloatArray without copying. The caller must ensure the array is not mutated while the returned TensorData is in use. Default implementation falls back to fromFloatArray (which copies).

Link copied to clipboard
open override fun <T : DType, V> wrapIntArray(shape: Shape, dtype: KClass<T>, data: IntArray): TensorData<T, V>

Wraps an IntArray without copying. The caller must ensure the array is not mutated while the returned TensorData is in use. Default implementation falls back to fromIntArray (which copies).

Link copied to clipboard
open override fun <T : DType, V> zeros(shape: Shape, dtype: KClass<T>): TensorData<T, V>