Tensor new specification for scalar values
Hello,
I propose the following specification for handling scalar values with Tensor: https://gitlab.eclipse.org/groups/eclipse/aidge/-/wikis/Tensor#scalar-value
The TLDR is:
In order to handle numpy scalar values, we allow a tensor to have a no dimension (nb_dims==0) but a size of 1.
In the case of a Tensor with no values (nullptr), we need to have nbdims==0 and size==0.
This means that a simple check on the number of dimension is not enough to verify if an element is empty or not !
This behavior is required to have the best interroperability with numpy array:
>>> import numpy as np
>>> a = np.array(5)
>>> b = np.array([4])
>>> a.size
1
>>> a.ndim
0
>>> a.shape
()
>>> b.size
1
>>> a.ndim
0
>>> b.shape
(1,)
Also see Python documentation:
- Py Buffer protocol shape: https://docs.python.org/3/c-api/buffer.html#c.Py_buffer.shape
- Numpy Style array: https://docs.python.org/3/c-api/buffer.html#numpy-style-shape-and-strides
Can you @eclipse/aidge please tell me if you agree with this proposition ?