File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
runtime/core/exec_aten/util Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -147,12 +147,17 @@ Error share_tensor_data(
147147 t_dst.nbytes (),
148148 t_src.nbytes ());
149149
150+ // Either the t_src is empty or contains valid data.
150151 ET_CHECK_OR_RETURN_ERROR (
151- t_src.mutable_data_ptr () != nullptr ,
152+ t_src.mutable_data_ptr () != nullptr || t_src. nbytes () == 0 ,
152153 InvalidArgument,
153154 " Source tensor should have data_ptr not being nullptr." );
155+
156+ // Setting data_ptr to nullptr explicitly when t_src is empty.
157+ void * t_src_data_ptr =
158+ t_src.numel () == 0 ? nullptr : t_src.mutable_data_ptr ();
154159 // Assign internal data_ptr as the one in forwarded tensor
155- t_dst.unsafeGetTensorImpl ()->set_data (t_src. mutable_data_ptr () );
160+ t_dst.unsafeGetTensorImpl ()->set_data (t_src_data_ptr );
156161
157162 return Error::Ok;
158163}
You can’t perform that action at this time.
0 commit comments