Skip to content

Commit

Permalink
Handle size-0 output for split (facebookincubator#1011)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebookincubator#1011

For size-0 output tensors, we do not allocate space for the tensor, therefore a nullptr will be passed in.

Reviewed By: frank-wei

Differential Revision: D59128217

fbshipit-source-id: f1c761f37bb91049d9ac6726464c4a4c7881889c
  • Loading branch information
muchulee8 authored and facebook-github-bot committed Jun 28, 2024
1 parent 7d427ca commit a1769f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/aitemplate/backend/common/split_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
throw std::runtime_error("input is NULL!");
}
for (int i = 0; i < real_num_splits; i++) {
if (!outputs[i]) {
if (split_sizes[i] && !outputs[i]) {
throw std::runtime_error("NULL output found at: " + std::to_string(i));
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/unittest/ops/test_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def test_split(self):
self._run_split(input_shape=[2, 0, 4], split_size_or_sections=0, dim=-2)
self._run_split(input_shape=[2, 0, 4], split_size_or_sections=2, dim=-1)
self._run_split(input_shape=[2, 0, 7], split_size_or_sections=[2, 3, 2], dim=-1)
self._run_split(input_shape=[32, 8], split_size_or_sections=[8, 0, 0], dim=-1)

def test_split_with_mask(self):
self._run_split(
Expand Down

0 comments on commit a1769f2

Please sign in to comment.