Skip to content

Commit 8bf98b1

Browse files
hsharma35facebook-github-bot
authored andcommitted
Allow zero-element tensors for shared inputs. (pytorch#13935)
Summary: Adds support for the case where method inputs are zero-element. Similar to pytorch#13623, but adds support for shared input instead. Differential Revision: D81653487
1 parent f9ce98f commit 8bf98b1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

runtime/core/exec_aten/util/tensor_util_portable.cpp

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

150+
if (t_src.numel() == 0) {
151+
// If the tensor is empty, we don't need to do anything.
152+
return Error::Ok;
153+
}
154+
150155
ET_CHECK_OR_RETURN_ERROR(
151156
t_src.mutable_data_ptr() != nullptr,
152157
InvalidArgument,

0 commit comments

Comments
 (0)