Skip to content

Commit 5b4e763

Browse files
hsharma35facebook-github-bot
authored andcommitted
Allow zero-element tensors for shared inputs. (#13935)
Summary: Pull Request resolved: #13935 Adds support for the case where method inputs are zero-element. Similar to #13623, but adds support for shared input instead. Reviewed By: JacobSzwejbka, DrJessop Differential Revision: D81653487
1 parent c6e52f3 commit 5b4e763

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

runtime/core/exec_aten/util/tensor_util_portable.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ Error share_tensor_data(
147147
t_dst.nbytes(),
148148
t_src.nbytes());
149149

150+
if (t_src.numel() == 0) {
151+
// Note that t_dst is assumed to already be resized.
152+
// If the t_src is empty, no need to update the data_ptr for t_dst.
153+
return Error::Ok;
154+
}
155+
150156
ET_CHECK_OR_RETURN_ERROR(
151157
t_src.mutable_data_ptr() != nullptr,
152158
InvalidArgument,

0 commit comments

Comments
 (0)