KMP library for tensors #300

Merged
grinisrit merged 215 commits from feature/tensor-algebra into dev 2021-05-08 09:48:04 +03:00
3 changed files with 6 additions and 3 deletions
Showing only changes of commit bd3425e7a5 - Show all commits

View File

@ -12,6 +12,9 @@ public open class BufferedTensor<T>(
public val strides: TensorStrides public val strides: TensorStrides
get() = TensorStrides(shape) get() = TensorStrides(shape)
public val numel: Int
get() = strides.linearSize
override fun get(index: IntArray): T = buffer[bufferStart + strides.offset(index)] override fun get(index: IntArray): T = buffer[bufferStart + strides.offset(index)]
override fun set(index: IntArray, value: T) { override fun set(index: IntArray, value: T) {

View File

@ -1,7 +1,7 @@
package space.kscience.kmath.tensors package space.kscience.kmath.tensors
public class DoubleLinearOpsTensorAlgebra : public class DoubleLinearOpsTensorAlgebra :
LinearOpsTensorAlgebra<Double, DoubleTensor>, LinearOpsTensorAlgebra<Double, DoubleTensor, IntTensor>,
DoubleTensorAlgebra() { DoubleTensorAlgebra() {
override fun DoubleTensor.inv(): DoubleTensor { override fun DoubleTensor.inv(): DoubleTensor {

View File

@ -1,7 +1,7 @@
package space.kscience.kmath.tensors package space.kscience.kmath.tensors
public interface LinearOpsTensorAlgebra<T, TensorType : TensorStructure<T>> : public interface LinearOpsTensorAlgebra<T, TensorType : TensorStructure<T>, IndexTensorType: TensorStructure<Int>> :
TensorPartialDivisionAlgebra<T, TensorType> { TensorPartialDivisionAlgebra<T, TensorType> {
//https://pytorch.org/docs/stable/linalg.html#torch.linalg.inv //https://pytorch.org/docs/stable/linalg.html#torch.linalg.inv
@ -14,7 +14,7 @@ public interface LinearOpsTensorAlgebra<T, TensorType : TensorStructure<T>> :
public fun TensorType.qr(): TensorType public fun TensorType.qr(): TensorType
//https://pytorch.org/docs/stable/generated/torch.lu.html //https://pytorch.org/docs/stable/generated/torch.lu.html
public fun TensorType.lu(): Pair<TensorType, IntTensor> public fun TensorType.lu(): Pair<TensorType, IndexTensorType>
//https://pytorch.org/docs/stable/generated/torch.lu_unpack.html //https://pytorch.org/docs/stable/generated/torch.lu_unpack.html
public fun luPivot(lu: TensorType, pivots: IntTensor): Triple<TensorType, TensorType, TensorType> public fun luPivot(lu: TensorType, pivots: IntTensor): Triple<TensorType, TensorType, TensorType>