IntTensor

class IntTensor(shape: ShapeND, val source: OffsetIntBuffer) : BufferedTensor<Int> (source)

Default BufferedTensor implementation for Int values

Constructors

Link copied to clipboard
constructor(shape: ShapeND, buffer: IntBuffer)
constructor(shape: ShapeND, source: OffsetIntBuffer)

Functions

Link copied to clipboard
open override fun StructureND<Double>.argMax(dim: Int, keepDim: Boolean): IntTensor

Returns the index of maximum value of each row of the input tensor in the given dimension dim.

open override fun StructureND<Int>.argMax(dim: Int, keepDim: Boolean): IntTensor

Returns the index of maximum value of each row of the input tensor in the given dimension dim.

Link copied to clipboard
open override fun StructureND<Double>.argMin(dim: Int, keepDim: Boolean): Tensor<Int>

Returns the index of minimum value of each row of the input tensor in the given dimension dim.

open override fun StructureND<Int>.argMin(dim: Int, keepDim: Boolean): Tensor<Int>

Returns the index of minimum value of each row of the input tensor in the given dimension dim.

Link copied to clipboard

Transforms StructureND of Double to DoubleTensor. Zero copy if possible, but is not guaranteed

Link copied to clipboard
Link copied to clipboard

Create a mutable copy of given StructureND.

Link copied to clipboard
open override fun StructureND<Double>.det(): DoubleTensor

Computes the determinant of a square matrix input, or of each square matrix in a batched input. For more information: https://pytorch.org/docs/stable/linalg.html#torch.linalg.det

Link copied to clipboard
open operator fun StructureND<Double>.div(k: Number): StructureND<Double>

open operator override fun StructureND<Double>.div(arg: StructureND<Double>): DoubleTensor

Each element of the tensor arg is divided by each element of this tensor. The resulting tensor is returned.

open operator override fun StructureND<Double>.div(arg: Double): DoubleTensor

Divide by the scalar arg each element of this tensor returns a new resulting tensor.

open operator override fun StructureND<Double>.div(arg: StructureND<Double>): DoubleTensor

Each element of the tensor arg is divided by each element of this tensor. The resulting tensor is returned.

Link copied to clipboard
open operator override fun Tensor<Double>.divAssign(arg: StructureND<Double>)

Each element of this tensor is divided by each element of the arg tensor.

open operator override fun Tensor<Double>.divAssign(value: Double)

Divides by the scalar value each element of this tensor.

open operator override fun Tensor<Double>.divAssign(arg: StructureND<Double>)

Each element of this tensor is divided by each element of the arg tensor.

Link copied to clipboard
open infix override fun StructureND<Double>.dot(other: StructureND<Double>): DoubleTensor
open infix override fun StructureND<Int>.dot(other: StructureND<Int>): IntTensor

Matrix product of two tensors.

Link copied to clipboard
Link copied to clipboard
infix fun Tensor<Double>.eq(other: Tensor<Double>): Boolean

Compares element-wise two tensors. Comparison of two Double values occurs with 1e-5 precision.

fun Tensor<Double>.eq(other: Tensor<Double>, epsilon: Double): Boolean

Compares element-wise two tensors with a specified precision.

fun Tensor<Int>.eq(other: Tensor<Int>): Boolean

Compares element-wise two int tensors

Link copied to clipboard
open operator override fun get(index: IntArray): Int
Link copied to clipboard
open override fun <F : StructureFeature> getFeature(type: KClass<out F>): F?
Link copied to clipboard
open fun Tensor<Double>.getTensor(first: Int, second: Int): Tensor<Double>
open fun Tensor<Int>.getTensor(first: Int, second: Int): Tensor<Int>

open override fun Tensor<Double>.getTensor(i: Int): DoubleTensor
open override fun Tensor<Int>.getTensor(i: Int): IntTensor

Returns the tensor at index i For more information: https://pytorch.org/cppdocs/notes/tensor_indexing.html

Link copied to clipboard
open override fun StructureND<Double>.inv(): DoubleTensor

Computes the multiplicative inverse matrix of a square matrix input, or of each square matrix in a batched input. Given a square matrix A, return the matrix AInv satisfying A dot AInv == AInv dot A == eye(a.shape[0]). For more information: https://pytorch.org/docs/stable/linalg.html#torch.linalg.inv

Link copied to clipboard
inline override fun StructureND<Double>.map(transform: DoubleField.(Double) -> Double): DoubleTensor

Applies the transform function to each element of the tensor and returns the resulting modified tensor.

inline override fun StructureND<Int>.map(transform: IntRing.(Int) -> Int): IntTensor

Applies the transform function to each element of the tensor and returns the resulting modified tensor.

Link copied to clipboard
inline override fun StructureND<Double>.mapIndexed(transform: DoubleField.(index: IntArray, Double) -> Double): DoubleTensor
inline override fun StructureND<Int>.mapIndexed(transform: IntRing.(index: IntArray, Int) -> Int): IntTensor
Link copied to clipboard
inline fun Tensor<Int>.mapIndexedInPlace(operation: (IntArray, Int) -> Int)
Link copied to clipboard
inline fun Tensor<Double>.mapInPlace(operation: (Double) -> Double)
inline fun Tensor<Int>.mapInPlace(operation: (Int) -> Int)
Link copied to clipboard

Broadcasting Matrix product of two tensors.

Link copied to clipboard
open override fun StructureND<Double>.max(): Double
open override fun StructureND<Int>.max(): Int

Returns the maximum value of all elements in the input tensor or null if there are no values

open override fun StructureND<Double>.max(dim: Int, keepDim: Boolean): DoubleTensor

Returns the maximum value of each row of the input tensor in the given dimension dim.

open override fun StructureND<Int>.max(dim: Int, keepDim: Boolean): IntTensor

Returns the maximum value of each row of the input tensor in the given dimension dim.

Link copied to clipboard
Link copied to clipboard
open override fun StructureND<Double>.min(): Double
open override fun StructureND<Int>.min(): Int

open override fun StructureND<Double>.min(dim: Int, keepDim: Boolean): DoubleTensor

Returns the minimum value of each row of the input tensor in the given dimension dim.

open override fun StructureND<Int>.min(dim: Int, keepDim: Boolean): IntTensor

Returns the minimum value of each row of the input tensor in the given dimension dim.

Link copied to clipboard
open operator override fun StructureND<Double>.minus(arg: StructureND<Double>): DoubleTensor

Each element of the tensor arg is subtracted from each element of this tensor. The resulting tensor is returned.

open operator override fun StructureND<Double>.minus(arg: Double): DoubleTensor

Subtracts the scalar arg from each element of this tensor and returns a new resulting tensor.

open operator override fun StructureND<Double>.minus(arg: StructureND<Double>): DoubleTensor

Each element of the tensor arg is subtracted from each element of this tensor. The resulting tensor is returned.

open operator override fun StructureND<Int>.minus(arg: Int): IntTensor

Subtracts the scalar arg from each element of this tensor and returns a new resulting tensor.

open operator override fun StructureND<Int>.minus(arg: StructureND<Int>): IntTensor

Each element of the tensor arg is subtracted from each element of this tensor. The resulting tensor is returned.

Link copied to clipboard
open operator override fun Tensor<Double>.minusAssign(arg: StructureND<Double>)

Each element of the tensor arg is subtracted from each element of this tensor.

open operator override fun Tensor<Double>.minusAssign(value: Double)

Subtracts the scalar value from each element of this tensor.

open operator override fun Tensor<Double>.minusAssign(arg: StructureND<Double>)

Each element of the tensor arg is subtracted from each element of this tensor.

open operator override fun Tensor<Int>.minusAssign(value: Int)

Subtracts the scalar value from each element of this tensor.

open operator override fun Tensor<Int>.minusAssign(arg: StructureND<Int>)

Each element of the tensor arg is subtracted from each element of this tensor.

Link copied to clipboard
open operator override fun StructureND<Double>.plus(arg: StructureND<Double>): DoubleTensor

Each element of the tensor arg is added to each element of this tensor. The resulting tensor is returned.

open operator override fun StructureND<Double>.plus(arg: Double): DoubleTensor

Adds the scalar arg to each element of this tensor and returns a new resulting tensor.

open operator override fun StructureND<Double>.plus(arg: StructureND<Double>): DoubleTensor

Each element of the tensor arg is added to each element of this tensor. The resulting tensor is returned.

open operator override fun StructureND<Int>.plus(arg: Int): IntTensor

Adds the scalar arg to each element of this tensor and returns a new resulting tensor.

open operator override fun StructureND<Int>.plus(arg: StructureND<Int>): IntTensor

Each element of the tensor arg is added to each element of this tensor. The resulting tensor is returned.

Link copied to clipboard
open operator override fun Tensor<Double>.plusAssign(arg: StructureND<Double>)

Each element of the tensor arg is added to each element of this tensor.

open operator override fun Tensor<Double>.plusAssign(value: Double)

Adds the scalar value to each element of this tensor.

open operator override fun Tensor<Double>.plusAssign(arg: StructureND<Double>)

Each element of the tensor arg is added to each element of this tensor.

open operator override fun Tensor<Int>.plusAssign(value: Int)

Adds the scalar value to each element of this tensor.

open operator override fun Tensor<Int>.plusAssign(arg: StructureND<Int>)

Each element of the tensor arg is added to each element of this tensor.

Link copied to clipboard
open infix fun StructureND<Double>.pow(pow: Number): StructureND<Double>
Link copied to clipboard
inline fun StructureND<Int>.reduceElements(transform: (IntBuffer) -> Int): Int
Link copied to clipboard

Builds tensor from rows of the input tensor.

Link copied to clipboard
open operator override fun set(index: IntArray, value: Int)
Link copied to clipboard
open override fun StructureND<Double>.sum(): Double
open override fun StructureND<Int>.sum(): Int

open override fun StructureND<Double>.sum(dim: Int, keepDim: Boolean): DoubleTensor

Returns the sum of each row of the input tensor in the given dimension dim.

open override fun StructureND<Int>.sum(dim: Int, keepDim: Boolean): IntTensor

Returns the sum of each row of the input tensor in the given dimension dim.

Link copied to clipboard
open operator fun StructureND<Double>.times(k: Number): StructureND<Double>

open operator override fun StructureND<Double>.times(arg: StructureND<Double>): DoubleTensor

Each element of the tensor arg is multiplied by each element of this tensor. The resulting tensor is returned.

open operator override fun StructureND<Double>.times(arg: Double): DoubleTensor

Multiplies the scalar arg by each element of this tensor and returns a new resulting tensor.

open operator override fun StructureND<Double>.times(arg: StructureND<Double>): DoubleTensor

Each element of the tensor arg is multiplied by each element of this tensor. The resulting tensor is returned.

open operator override fun StructureND<Int>.times(arg: Int): IntTensor

Multiplies the scalar arg by each element of this tensor and returns a new resulting tensor.

open operator override fun StructureND<Int>.times(arg: StructureND<Int>): IntTensor

Each element of the tensor arg is multiplied by each element of this tensor. The resulting tensor is returned.

Link copied to clipboard
open operator override fun Tensor<Double>.timesAssign(arg: StructureND<Double>)

Each element of the tensor arg is multiplied by each element of this tensor.

open operator override fun Tensor<Double>.timesAssign(value: Double)

Multiplies the scalar value by each element of this tensor.

open operator override fun Tensor<Double>.timesAssign(arg: StructureND<Double>)

Each element of the tensor arg is multiplied by each element of this tensor.

open operator override fun Tensor<Int>.timesAssign(value: Int)

Multiplies the scalar value by each element of this tensor.

open operator override fun Tensor<Int>.timesAssign(arg: StructureND<Int>)

Each element of the tensor arg is multiplied by each element of this tensor.

Link copied to clipboard
Link copied to clipboard
open override fun StructureND<Double>.transposed(i: Int, j: Int): Tensor<Double>

Returns a tensor that is a transposed version of this tensor. The given dimensions i and j are swapped. For more information: https://pytorch.org/docs/stable/generated/torch.transpose.html

open override fun StructureND<Int>.transposed(i: Int, j: Int): Tensor<Int>

Returns a tensor that is a transposed version of this tensor. The given dimensions i and j are swapped. For more information: https://pytorch.org/docs/stable/generated/torch.transpose.html

Link copied to clipboard
open operator override fun StructureND<Double>.unaryMinus(): DoubleTensor
open operator override fun StructureND<Int>.unaryMinus(): IntTensor

Numerical negative, element-wise.

Link copied to clipboard
open operator fun StructureND<Int>.unaryPlus(): StructureND<Int>
Link copied to clipboard
open override fun StructureND<Double>.value(): Double
open override fun StructureND<Int>.value(): Int

Returns a single tensor value of unit dimension. The tensor shape must be equal to 1.

Link copied to clipboard
open override fun StructureND<Double>.valueOrNull(): Double?
open override fun StructureND<Int>.valueOrNull(): Int?

Returns a single tensor value of unit dimension if tensor shape equals to 1.

Link copied to clipboard
open override fun Tensor<Double>.view(shape: ShapeND): DoubleTensor
open override fun Tensor<Int>.view(shape: ShapeND): IntTensor

Returns a new tensor with the same data as the self tensor but of a different shape. The returned tensor shares the same data and must have the same number of elements, but may have a different size For more information: https://pytorch.org/docs/stable/tensor_view.html

Link copied to clipboard
open override fun Tensor<Double>.viewAs(other: StructureND<Double>): DoubleTensor

View this tensor as the same size as other. this.viewAs(other) is equivalent to this.view(other.shape). For more information: https://pytorch.org/cppdocs/notes/tensor_indexing.html

open override fun Tensor<Int>.viewAs(other: StructureND<Int>): IntTensor

View this tensor as the same size as other. this.viewAs(other) is equivalent to this.view(other.shape). For more information: https://pytorch.org/cppdocs/notes/tensor_indexing.html

Properties

Link copied to clipboard
open val dimension: Int
Link copied to clipboard
open override val indices: Strides

Buffer strides based on RowStrides implementation

Link copied to clipboard

Number of elements in tensor

Link copied to clipboard
open override val shape: ShapeND
Link copied to clipboard
open override val source: OffsetIntBuffer