Skip to content

Commit 8a7cac9

Browse files
committed
Added comment
1 parent 9d6b409 commit 8a7cac9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backends/libtorch_c/torch_c.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ extern "C" void torchTensorFromRAITensor(RAI_Tensor *src, void *torch_tensor) {
170170
at::DeviceType device_type = getATenDeviceType(dl_tensor->device.device_type);
171171
at::ScalarType stype = toScalarType(dl_tensor->dtype);
172172
torch::Device device(device_type, dl_tensor->device.device_id);
173+
174+
// Capture the RAI_Tensor to be able to release it once torch is done with
175+
// the tensor that we are about to create (to avoid copying of the blob).
173176
auto free_tensor = [src](void *data) {
174177
RedisAI_TensorFree(src);
175178
};

0 commit comments

Comments
 (0)