Skip to content

Commit

Permalink
Split_indices negative axis added (#1595)
Browse files Browse the repository at this point in the history
  • Loading branch information
PariksheetPinjari909 authored and yzhliu committed Aug 13, 2018
1 parent 60769b7 commit 81b42bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions topi/include/topi/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ inline Array<Tensor> split_sections(const Tensor& x,
int axis,
std::string name = "tensor",
std::string tag = kInjective) {
if (axis < 0) {
axis += static_cast<int>(x->shape.size());
}
CHECK_LT(axis, x->shape.size()) << "axis out of bounds";

auto src_axis_size = static_cast<int>(GetConstInt(x->shape[axis]));

CHECK_GT(num_sections, 0) << "Slice count must be > 0";
Expand Down
1 change: 1 addition & 0 deletions topi/tests/python_cpp/test_topi_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def test_concatenate():

def test_split():
verify_split((2, 12, 3), 3, 1)
verify_split((2, 12, 3), 3, -1)
verify_split((2, 12, 3), [2, 4], 1)
verify_split((10, 12, 24), [5, 7, 9], -1)

Expand Down

0 comments on commit 81b42bc

Please sign in to comment.