v923z / micropython-ulab

a numpy-like fast vector module for micropython, circuitpython, and their derivatives
https://micropython-ulab.readthedocs.io/en/latest
MIT License
432 stars 117 forks source link

[BUG] Memory corruption with ulab.numpy.dot #574

Closed jepler closed 1 year ago

jepler commented 1 year ago

Describe the bug

Adafruit CircuitPython 8.0.0-beta.6 on 2022-12-21; Adafruit ItsyBitsy M4 Express with samd51g19
>>> ulab.__version__
'6.0.2-2D-c'

as well as "unix circuitpython" with the same ulab version

To Reproduce

import ulab.numpy as np
coeff = np.ones((6,6))
values = np.ones(6) 
# next line prints array([6.0]) in ulab while python3 prints [6. 6. 6. 6. 6. 6.] 
print(np.dot(values, coeff))
# eventually causes crash!
while True: x = np.dot(values, coeff)

Expected behavior Would like behavior to match standard Python & not hardfault

Additional context Is an output array of wrong size being allocated?

jepler commented 1 year ago

[I changed the example so it tries to state more clearly that the shape of the result of dot is different]