Calling #min on a tensor results in the following compiler error:
In lib/num/src/tensor/reduction.cr:242:19
242 | Num.min(self, axis, dims)
^---
Error: undefined local variable or method 'axis' for Tensor(Float32, CPU(Float32))
The cause is here, where you can see that the implementation of Tensor#min appears to be erroneously copied from Tensor#min(axis, dims). The latter has two parameters that the former does not, which thus causes the undefined variable error.
Problem description
Calling
#min
on a tensor results in the following compiler error:The cause is here, where you can see that the implementation of
Tensor#min
appears to be erroneously copied fromTensor#min(axis, dims)
. The latter has two parameters that the former does not, which thus causes the undefined variable error.Example
Here we would expected
-1.0
to be output, but the compiler error instead results.Workaround
One can just use
Num.min tensor
instead oftensor.min
, but the latter should probably work also.Proposed Fix
Change the implementation of
Tensor#min
toNum.min self
instead ofNum.min(self, axis, dims)
.