flat id definition
Tensor exposes two reciprocal functions getIdx and getCoord that convert between tensor coordinates and "flat id".
To this day, the flat id is not formally defined and is implemented as the index of the given data coordinates in the storage associated to the tensor.
Yet, in recommended new tensor design, storage may encompass an area larger than the one exposed by the tensor (for instance, if the tensor is only a view inside a larger tensor). This has three major consequences:
- for a given tensor, its first data (lexicographical order) has a flat id that is >= 0 but not necessarily 0;
- more important: this id may not be computable while data is not actually allocated;
- this id may change in time if storage is reallocated.
No concrete use case of these functions were available so far so this issue went undetected. But now, functions such as computeReceptiveField
are relying on this flat id.
Thus 2 questions are occurring:
- why would this flat id be required (in
computeReceptiveField
for instance) instead of plain coordinates (for efficiency reasons?)?; - shouldn't the flat id definition be modified as follow: 0-based index in the tensor exposed area, in lexicographical order (thus, the first data, lexicographical order, of the tensor would have flat id 0 and the last one (same order) would have, as value, the number of visible data in the tensor, minus 1 (ie the result of
size()
))?