v0.3.0-dev-9 #324
@ -14,9 +14,13 @@ public class RealTensor(
|
|||||||
TensorStrides(shape),
|
TensorStrides(shape),
|
||||||
RealBuffer(buffer)
|
RealBuffer(buffer)
|
||||||
) {
|
) {
|
||||||
override fun item(): Double = buffer[0]
|
override fun item(): Double {
|
||||||
|
check(buffer.size > 0) { "The tensor is empty" }
|
||||||
|
return buffer[0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor> {
|
public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor> {
|
||||||
|
|
||||||
override fun Double.plus(other: RealTensor): RealTensor {
|
override fun Double.plus(other: RealTensor): RealTensor {
|
||||||
@ -116,6 +120,10 @@ public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor
|
|||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun RealTensor.view_as(other: RealTensor): RealTensor {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
override fun RealTensor.abs(): RealTensor {
|
override fun RealTensor.abs(): RealTensor {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public interface TensorAlgebra<T, TensorType : TensorStructure<T>>{
|
|||||||
|
|
||||||
//https://pytorch.org/docs/stable/tensor_view.html
|
//https://pytorch.org/docs/stable/tensor_view.html
|
||||||
public fun TensorType.view(shape: IntArray): TensorType
|
public fun TensorType.view(shape: IntArray): TensorType
|
||||||
|
public fun TensorType.view_as(other: TensorType): TensorType
|
||||||
|
|
||||||
//https://pytorch.org/docs/stable/generated/torch.abs.html
|
//https://pytorch.org/docs/stable/generated/torch.abs.html
|
||||||
public fun TensorType.abs(): TensorType
|
public fun TensorType.abs(): TensorType
|
||||||
|
Loading…
Reference in New Issue
Block a user