Gleethos / neureka

A platform independent tensor library with autograd for the JVM
https://gleethos.github.io/neureka/index.html
MIT License
69 stars 1 forks source link

Failed to convert this tensor from its original layout #10

Closed demkom58 closed 1 year ago

demkom58 commented 1 year ago

Describe the bug IllegalArgumentException thrown with message "Failed to convert this tensor from its original layout 'COLUMN_MAJOR' to target layout 'SYMMETRIC'. Instead this tensor has layout 'UNSPECIFIC'." when trying to dot product transposed tensors.

To Reproduce Code to reproduce the behavior:

Tsr<Double> tX = Tsr.of(Shape.of(2, 1), new double[] {1.0d, 1.0d}).T();
Tsr<Double> tW = Tsr.of(Shape.of(1, 1), new double[] {2.0d});
Tsr<Double> dot = tW.dot(tX);

Additional context Stack trace:

Exception in thread "main" java.lang.IllegalArgumentException: Failed to convert this tensor from its original layout 'COLUMN_MAJOR' to target layout 'SYMMETRIC'. Instead this tensor has layout 'UNSPECIFIC'.
    at neureka.TsrImpl._checkLayoutConversion(TsrImpl.java:657)
    at neureka.TsrImpl._toLayout(TsrImpl.java:594)
    at neureka.TsrImpl.toLayout(TsrImpl.java:761)
    at neureka.backend.main.algorithms.MatMulAlgorithm._prepare(MatMulAlgorithm.java:69)
    at neureka.backend.api.template.algorithms.AbstractFunDeviceAlgorithm.prepare(AbstractFunDeviceAlgorithm.java:81)
    at neureka.backend.api.template.algorithms.AbstractDeviceAlgorithm._prepareForExecution(AbstractDeviceAlgorithm.java:116)
    at neureka.backend.api.template.algorithms.AbstractDeviceAlgorithm.prepareAndExecute(AbstractDeviceAlgorithm.java:100)
    at neureka.backend.api.template.algorithms.AbstractDeviceAlgorithm._deepActivation(AbstractDeviceAlgorithm.java:255)
    at neureka.backend.api.template.algorithms.AbstractDeviceAlgorithm.executeFor(AbstractDeviceAlgorithm.java:91)
    at neureka.backend.main.algorithms.MatMulAlgorithm.lambda$new$8(MatMulAlgorithm.java:36)
    at neureka.backend.api.template.algorithms.AbstractFunDeviceAlgorithm.lambda$execute$3(AbstractFunDeviceAlgorithm.java:240)
    at neureka.backend.main.memory.MemValidator.<init>(MemValidator.java:47)
    at neureka.backend.main.memory.MemValidator.forInputs(MemValidator.java:32)
    at neureka.backend.api.template.algorithms.AbstractFunDeviceAlgorithm.execute(AbstractFunDeviceAlgorithm.java:236)
    at neureka.backend.api.Operation.lambda$execute$1(Operation.java:209)
    at neureka.backend.api.LazyRef.get(LazyRef.java:25)
    at neureka.autograd.GraphNode.<init>(GraphNode.java:122)
    at neureka.backend.api.Operation.execute(Operation.java:230)
    at neureka.math.implementations.FunctionNode.execute(FunctionNode.java:91)
    at neureka.math.Function.lambda$with$2(Function.java:329)
    at neureka.backend.main.memory.MemValidator.<init>(MemValidator.java:47)
    at neureka.backend.main.memory.MemValidator.forInputs(MemValidator.java:32)
    at neureka.math.Function.lambda$with$3(Function.java:329)
    at neureka.math.Function.execute(Function.java:408)
    at neureka.math.Function.execute(Function.java:399)
    at neureka.math.Function.call(Function.java:481)
    at neureka.Tsr.matMul(Tsr.java:2005)
    at neureka.Tsr.dot(Tsr.java:1986)
create-issue-branch[bot] commented 1 year ago

Branch issue-10-Failed_to_convert_this_tensor_from_its_original_layout created!

Gleethos commented 1 year ago

Thank you for the bug report! It looks like there is a bug in the layout validation code as it distrusts a layout which is perfectly valid.

A fixed version will be out soon

Gleethos commented 1 year ago

The fix is out in version 0.20.1

If you find more bugs, issues or even have some feature requests, please feel free to open up issues.

demkom58 commented 1 year ago

Thanks, everything works great! Good job.