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(
147
147
t_dst.nbytes (),
148
148
t_src.nbytes ());
149
149
150
+ // Either the t_src is empty or contains valid data.
150
151
ET_CHECK_OR_RETURN_ERROR (
151
- t_src.mutable_data_ptr () != nullptr ,
152
+ t_src.mutable_data_ptr () != nullptr || t_src. nbytes () == 0 ,
152
153
InvalidArgument,
153
154
" 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 ();
154
159
// 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 );
156
161
157
162
return Error::Ok;
158
163
}
You can’t perform that action at this time.
0 commit comments