Added tensor constructors and get_raw_data to work with pointers of p…#202
Added tensor constructors and get_raw_data to work with pointers of p…#202sohailreddy wants to merge 3 commits intoserizba:masterfrom
Conversation
|
Hi @sohailrreddy, great work! Definitely something interesting and required by many of us! I think that with your changes now it would be better if the old Thanks! |
…y. Now also return the size of the raw pointer Committer: Sohail Reddy <sredd001@fiu.edu>
|
Hi @serizba , Great point!! I updated the Let me know what you think! |
|
Good work! Sorry for not attending this earlier. I will fix the conflicts myself and merge it. This is required. |
|
Thanks for taking care of this @serizba |
|
Hello, I'm a newbuy in C++ and I have a question: can I create cppflow::tensor from 2-dimensional vector or array? I've tried but it dropped me What am I doing wrong? |
|
It won't work with multi-dimensional vector/array as inputs. You would need to create a single vector containing all the elements of the multi-dim. vector (or tensor) and then pass the pointer to this raw data, along with the length of each dimension to the cppflow::tensor() constructor. std::vector<int64_t> shape{2,3};
std::vector<int64_t> long_vector(6); // Length should be product of all dims
auto b = cppflow::tensor(long_vector.data(), shape); |
|
I've tried this, but it thorws an error P.S. Full code: P.P.S. As I think, these lines have to work while cppflow::tensor(long_vector.data(), shape). But I don't know why they don't work |
Since most scientific computing codes don't use std::vector and use their own containers, new tensor constructor and get_raw_data functions were added to work with pointers of primitive types.