Implementation of tensor with variable sizes
votientu opened this issue · comments
Hello,
I really love the Fastor project, the time performance is sufficient for N-Dimensional array computation.
Can I ask first how the Tensor is implemented ? Is it an array, vector or a pointer to array, etc... ?
Is it possible to consider the variable sizes Tensor ? In some problems, we know only the sizes in runtime.
size_t height = 416; // the height and width of image are supposed to change in runtime
size_t width = 416;
float data[height*width*3];
Fastor::Tensor<float, height, width, 3> image(data);
I can give a hand if you can show me where to start.
Regards,
Not a maintainer, just a user, but this isn't a restriction of Fastor. To my, I think fairly extensive, knowledge non-type template parameters, the things you put into angled brackets, have to be constexpr
, so what you're asking isn't possible on the language level. Obviously, this doesn't mean that you cannot implement "dynamic tensors" that act like std::vector
, but that's an entirely different problem.
Fastor tensors are stack allocated. There is an unpublished dynamic sized tensor fork of Fastor. Making tensors dynamically allocated requires fundamental changes in Fastor and I am afraid there is no simple solution to this.
Thanks