copy assignment operator should throw when the backends are different
What commit version of aidge do you use
-
aidge_core: 0.4.0
Problem description
Tensor::operator= was changed to always perform a shallow copy !273 (merged).
It changed the behaviour of this piece of code that use to deep copy values from one backend to another:
x.setBackend("cuda");
x = Array3D<int,2,2,2>{
{
{
{1, 2},
{3, 4}
},
{
{5, 6},
{7, 8}
}
}};
The expected behaviour is to have x on cuda backend when in reality its backend has been updated to cpu with the line below.
If the goal of performing shallow copy only was to avoid hidden errors, allowing every tensor to be copied also create hidden errors.
I think the Tensor::operator= member function should throw an error if backend or dataformat are different.
For now, reversing the two lines does what the user originally expected.