How to clone a holoscan.core.tensor?

Hi,

I want to cache some of the frames so that later I can send them to a model that takes frames from multiple timestamps as input. However, the frames are referenced by address, and the referenced frames will be released at each execution.

Need your advice on this, thanks!!

Hi Cho.peter

Thanks for your interest in Holoscan SDK and reaching out.
To you question you could do something as

import cupy as cp

# within operator's __init__ or start() method
    self.cached_frames = []
# from within compute (assuming a holoscan.core.Tensor or other tensor-like object was received)

    cupy_tensor = cp.asarray(tensor)               # this references the existing data (does not copy)
    self.cached_frames.append(cupy_tensor.copy())  # cache a copy of the data

Hope that helps