Skip to content

Crash with ONNX Split operator #891

Description

@abcdrm

When I make a ONNX node Split:

node = onnx.helper.make_node(
    "Split",
    inputs=["input"],
    outputs=["output_1", "output_2", "output_3"],
    axis=1
)

The ONNX split doc says that the split input is optional. So I did not use this input.
Then I run this node with ppl.nn.llm, which gives:

[ERROR][2023-11-03 16:34:43.746][reshape_split.cc:51] ERROR: output_count[3] != split point size[2]
[ERROR][2023-11-03 16:34:43.746][kernel.cc:39] Reshape kernel[ppl_anonymous_node_0] failed: invalid value
[ERROR][2023-11-03 16:34:43.746][sequential_scheduler.cc:130] exec kernel[ppl_anonymous_node_0] of type[:Split:13] failed: invalid value
[ERROR][2023-11-03 16:34:43.746][runtime_impl.cc:333] Run() failed: invalid value
[ERROR][2023-11-03 16:34:43.746][pplnn_llm.cc:1213] Run() failed: invalid value

I check the code in pplnn/src/ppl/nn/oputils/onnx/reshape_split.cc

RetCode ReshapeSplit(InputOutputInfo* info, const ir::Attr* arg, const int64_t* split_point) {
    auto param = static_cast<const SplitParam*>(arg);
    auto split_size = info->GetInput<TensorImpl>(1)->GetShape()->GetDim(0);
    const TensorShape& shape = *info->GetInput<TensorImpl>(0)->GetShape();
    int dim_count = shape.GetDimCount();
    uint32_t split_axis = param->axis >= 0 ? param->axis : param->axis + dim_count;

I print info->GetInputCount(), which gives 1, means it has a single input. But split_size accesses info->GetInput<TensorImpl>(1), which is the second input. Plz check this issue.

Also in ppl.nn.llm src/ppl/nn/engines/llm_cuda/ops/onnx/split_op.cc.
Line 59-62:

auto split = info->GetInput<TensorImpl>(1);
if (!split->GetBufferPtr()) {
    return RC_NOT_FOUND;
}

This check seems not work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions