Closed jamesETsmith closed 3 years ago
@jamesETsmith sorry for the slow response.
The challenge with this is that in CTF data is generally distributed on a particular processor grid. The fastest way we typically use to pass existing data into the tensor is to define the processor grid to match the distribution of the existing data, via the tensor constructors that take Idx_Partition
. If local data is laid out in the same manner, it can then simply be copied into the tensors 'data' pointer, which can also be queried via 'get_raw_data()'. I can clarify further how Idx_Partition
this works if this what you need. This can also be used to input a tensor with data only on processor 0.
There are internal mechanisms to create an uninitialized tensor shell (see the init
function in the tensor class in untyped_tensor.cxx and related constructors if you would like to learn more about these) and data can be set instead of allocated by using that, but this interface is not really intended for the user. An internal complication is that CTF does accounting of memory usage based on what it allocated. Depending on the use-case (in particular, do you have in mind passing data just in the sequential setting?) something could be added to pass an existing data pointer this more easily externally.
Question
In the C++ interface of CTF, do you have to ability to initialize a tensor using memory that's been allocated/initialized at an earlier time? I'm thinking something analogous to
Eigen::Map
(see their docs here). I'm working with large arrays and need to avoid copying if possible.Thanks!