taichi icon indicating copy to clipboard operation
taichi copied to clipboard

Support ndarray deepcopy in C++ wrapper of AOT api

Open ailzhang opened this issue 3 years ago • 3 comments

There're cases where users would want a deepcopy of an ndarray, so we can probably provide this as

auto arr_copy = arr.clone()

in our C++ wrapper. cc: @YuCrazing

ailzhang avatar Oct 24 '22 05:10 ailzhang

What's the intent tho? Do you want an actual deep-copy or just something like np.zeros_like?

PENGUINLIONG avatar Oct 28 '22 13:10 PENGUINLIONG

In my case, I want an actual deep-copy. I would like to copy all data from ndarray A into ndarray B with the least codes. If we have a deep-copy interface, we do not need write codes like this:

auto B = allocate_ndarray(A.shape, A.elem_shape, ...);
memcpy_d2d(B, A);

YuCrazing avatar Oct 31 '22 03:10 YuCrazing

hmm okay. there would be something like a clone.

PENGUINLIONG avatar Oct 31 '22 05:10 PENGUINLIONG