[Tensor] Fix invalid getIdx() method
Context
The Tensor getIdx() method for computing flat index from a coords list is wrong. There were two issues:
- when the coords is 0-rank (i.e. coords == {}) it created a segfault due to an access to an out-of-bound access
- when the coords rank differed from the tensor rank by more than 2 dimensions the computation was incorrect
This MR fixes getIdx() and add unit tests for get()/set()/getIdx() with index or coords.
After adding the first commit (unit tests) here is the output of the unit tests:
unit_testsbuild/unit_tests/tests_aidge_core --rng-seed 0 -c 'Tensor set/get'
/data/Test_Tensor.cpp:337: FAILED:
{Unknown expression after the reported line}
due to a fatal error condition:
SIGSEGV - Segmentation violation signal
===============================================================================
test cases: 5 | 4 passed | 1 failed
assertions: 232 | 231 passed | 1 failed
Segmentation fault
After applying the second patch which fixes the issue, here is the output:
unit_testsbuild/unit_tests/tests_aidge_core --rng-seed 0 -c 'Tensor set/get'
===============================================================================
All tests passed (8009 assertions in 77 test cases)
Modified files
First commit: add unit tests Tensor set/get
to Tensor unit tests (note that with this commit in isolation the unit tests fail.
Second Commit: fix implementation of getIdx()
Third commit: minor change to getStorageIdx()
which did not assert dimensions size before checking coords values.
Detailed major modifications
No major modification.
TODO
No forecasted todo.
Merge request reports
Activity
assigned to @cguillon
requested review from @pineapple
added 149 commits
-
3fd60785...9aad44ea - 146 commits from branch
eclipse/aidge:dev
- da92267d - [Test] Add unit tests for Tensor access by coords
- 12c3e45c - [Tensor] Fix Tensor::getIdx() method
- e44d7267 - [Tensor] Minor change of assertions in getStorageIdx()
Toggle commit list-
3fd60785...9aad44ea - 146 commits from branch
added Fix 🔥🔥 TopicTensor Unit-test labels
enabled an automatic merge when the pipeline for e44d7267 succeeds
mentioned in commit 2ea2cd6b