Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/relay/op/tensor/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2720,15 +2720,18 @@ bool SplitRel(const Array<Type>& types, int num_inputs, const Attrs& attrs,
}
reporter->Assign(types[1], TupleType(Array<Type>(fields)));
} else {
auto indices = Downcast<Array<ObjectRef>>(param->indices_or_sections);
Array<IndexExpr> indices;
for (auto i : Downcast<Array<Integer>>(param->indices_or_sections)) {
indices.push_back(IntImm(DataType::Int(32), i.as<IntImmNode>()->value));
}
auto begin = IndexExpr(tir::make_zero(DataType::Int(32)));
std::vector<Type> fields;
for (unsigned int i = 0; i < indices.size(); ++i) {
ICHECK(reporter->Assert(Downcast<IndexExpr>(indices[i]) > begin))
ICHECK(reporter->Assert(indices[i] > begin))
<< "indices_or_sections need to be a sorted ascending list";
std::vector<IndexExpr> oshape(data->shape.begin(), data->shape.end());
oshape[axis] = Downcast<IndexExpr>(indices[i]) - begin;
begin = Downcast<IndexExpr>(indices[i]);
oshape[axis] = indices[i] - begin;
begin = indices[i];
auto vec_type = TensorType(oshape, data->dtype);
fields.push_back(vec_type);
}
Expand Down
15 changes: 15 additions & 0 deletions tests/python/relay/test_op_level3.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,21 @@ def verify_split(dshape, indices_or_sections, ret_type, axis=None):
),
axis=1,
)
verify_split(
(d1, d2, d3, d4),
tuple(np.array([2, 4, 7]).astype(np.int64)),
relay.ty.TupleType(
tvm.runtime.convert(
[
relay.ty.TensorType((d1, 2, d3, d4), "float32"),
relay.ty.TensorType((d1, 2, d3, d4), "float32"),
relay.ty.TensorType((d1, 3, d3, d4), "float32"),
relay.ty.TensorType((d1, (d2 - 7), d3, d4), "float32"),
]
)
),
axis=1,
)


def test_full_infer_type():
Expand Down