Replies: 3 comments
-
That's right.
Kwabema's observations from openmv, and mine were similar, at least, for 2D arrays. I noticed gains in flash space only for 3 and 4 dimensions. The nested loops add something like 12-20 bytes per dimension, so it seems to me that setting up the function call for micropython-ulab/code/ndarray.c Line 170 in 38caf84
No, benchmarking on hardware is sorely missing. I would really like to have a standard set of test scripts that could be run on various hardware platforms, but my calls for this were not met with interest in the community. The closest that comes to this is in https://github.com/thiagofe/ulab_samples. If you think that this would be a useful exercise, let us discuss it further! I just don't know how we could entice people to upload their results, or whether there are reasonable hardware emulators, so that we could get the results from virtual environments.
Would you want micropython-ulab/code/ndarray.c Lines 2098 to 2117 in 38caf84 ndarray structure contains static arrays micropython-ulab/code/ndarray.h Lines 143 to 154 in 38caf84 I think this is a very interesting and valuable idea, but given the amount of effort required, I would undertake it only, if there is reasonable interest, and if we can find a way to incrementally implement this. What I mean is that we could begin with a handful of functions (I don't even know, what people use/need), where we explore the implementation, and fix the rest as we go. Would you be OK with that? And on a related note, if I set up a survey, where people could vote for the most used/popular functions, would you be willing to advertise that at |
Beta Was this translation helpful? Give feedback.
-
@v923z Thanks for your detailed reply. I suspected that We use the supplied I do not remember anyone asking for other features to be turned off or on. One person asked for 3D arrays, but it turns out they did not actually need it: they were just confused. So my question was not reflecting a real need, but just what would be possible. I see the issue with the We'd be happy to advertise a survey on Discord, the newsletter, etc. To review our current uses of I tried using github search to find Python code that used the exact word "ulab", but did not succeed. Even |
Beta Was this translation helpful? Give feedback.
-
At the time, I looked at the size of the unix executable, but I don't know the validity of conclusions drawn from that. Even stranger is the fact that for two dimensions, if I get rid of the micropython-ulab/code/ndarray.c Lines 165 to 168 in d072086 function, and simply use m_new0(size_t, ndim) , wherever needed, then the code becomes slightly larger. Similar peculiarities can be observed by changing the number of arguments of specific functions: sometimes more arguments lead to smaller code. Go figure!
There might be quite a few functions that are not particularly popular or used, so switching those off might make sense in your case.
It would not be terribly hard to move to a dynamical number of dimensions, but we don't know the performance hit, and the flash space penalty we would take. As I said, the nested loops as implemented now are rather cheap, both in terms of space, and in execution time. The micropython-ulab/code/ndarray.c Line 170 in d072086
OK, thanks! Then I'll ping you, once I've set up the poll.
You probably still have an older version of micropython-ulab/code/utils/utils.c Line 241 in d072086
Ha! I've also walked into this. Sometimes I'm curious to see what people do with the code, and there is virtually no way of finding that out. |
Beta Was this translation helpful? Give feedback.
-
My understanding of ulab internals is limited, but I have seen the macros that do nested loops over arrays with multiple dimensions, and then found ULAB_HAS_FUNCTION_ITERATOR, which defines the macros as not statically nested (e.g.
BINARY_LOOP
).I thought that setting
ULAB_HAS_FUNCTION_ITERATOR
to 1 on boards where we are getting close to having space problems might help things, but I was worried about the performance effect. To my surprise, on an Adafruit Metro M4 (SAMD51), setting it caused the code to grow larger substantially:ULAB_HAS_FUNCTION_ITERATOR
= 0: firmware size 488820 bytesULAB_HAS_FUNCTION_ITERATOR
= 1: firmware size 497320 bytes (+ 8500 bytes)I don't know why this is. It may be a compilation optimization issue, but that's just a guess.
Assuming the size increase could be fixed, do you have an idea of what kind of performance difference I might expect to see? Have you done any benchmarking on this.
Another question I had was whether setting
ULAB_HAS_FUNCTION_ITERATOR
would allowULAB_MAX_DIMS
to be ignored altogether, because static nested loops would no longer be needed. Or does that not make sense? We have occasionally had users who wanted array support with more dimensions than the default.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions