Skip to content

k230 compile assertion failure with static single-input PicoDet pre-NMS ONNX #1485

@imHuangke

Description

@imHuangke

Summary

nncase 2.11.0 fails to compile a PicoDet pre-NMS ONNX for k230.

I first removed the common blockers:

  • converted the model to single input
  • fixed the input shape to static [1, 3, 320, 320]
  • cut the graph to a true pre-NMS subgraph
  • verified the final ONNX no longer contains NonMaxSuppression or TopK

After that, nncase still crashes during rewrite/compile with an assertion failure.

Environment

  • OS: Windows
  • Python: 3.10.19
  • nncase: 2.11.0
  • nncase-kpu: 2.11.0
  • onnx: 1.18.0
  • onnxsim: 0.6.2
  • target: k230

The conversion script is a thin wrapper around onnx, onnxsim, and nncase.

Model Information

Original model source:

  • PaddleDetection release/2.9
  • model: picodet_l_320_coco_lcnet

The ONNX used for the final repro has:

  • input: image [1, 3, 320, 320]
  • outputs:
    • Div.1 [1, 2125, 4]
    • Concat.9 [1, 80, 2125]

The final pre-NMS ONNX only contains these ops:

Add, BatchNormalization, Concat, Constant, Conv, Div, GlobalAveragePool, HardSigmoid, HardSwish, MatMul, Mul, Relu, Reshape, Resize, Sigmoid, Softmax, Split, Sqrt, Transpose

Reproduction

Command:

python To_kmodel.py --target k230 --model picodet_l_320_coco_lcnet_pre_nms.onnx --input_width 320 --input_height 320 --ptq_option 0 --dataset_path "img"

The wrapper does:

  1. read ONNX
  2. run onnxsim.simplify(...)
  3. set compile_options.target = "k230"
  4. call compiler.compile()

Error

warn: Nncase.Hosting.PluginLoader[0]
      NNCASE_PLUGIN_PATH is not set.
Process terminated. Assertion Failed
   at Nncase.Passes.RewriteProvider.Rewrite(Expr expr, IEnumerable`1 rules, RunPassContext context)
   at Nncase.CompilerServicesProvider.Rewrite(Expr expr, IEnumerable`1 rules, RunPassContext options)
   at Nncase.CompilerServices.Rewrite(Expr expr, IEnumerable`1 rules, RunPassContext options)
   at Nncase.Passes.DataflowPass.RunCoreAsync(BaseFunction function, RunPassContext options)
   at Nncase.Passes.Pass`2.RunAsync(TInput input, RunPassContext context)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Nncase.Passes.Pass`2.RunAsync(TInput input, RunPassContext context)
   at Nncase.Passes.PassManager.FunctionPassGroup.Runner.RunAsync()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Nncase.Passes.PassManager.FunctionPassGroup.Runner.RunAsync()
   at Nncase.Passes.PassManager.FunctionPassGroup.RunAsync(IRModule module)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Nncase.Passes.PassManager.FunctionPassGroup.RunAsync(IRModule module)
   at Nncase.Passes.PassManager.RunAsync(IRModule module)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Nncase.Passes.PassManager.RunAsync(IRModule module)
   at Nncase.Compiler.Compiler.RunPassAsync(Action`1 register, String name, IProgress`1 progress, CancellationToken token)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Nncase.Compiler.Compiler.RunPassAsync(Action`1 register, String name, IProgress`1 progress, CancellationToken token)
   at Nncase.Compiler.Compiler.CompileAsync(IProgress`1 progress, CancellationToken token)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Nncase.Compiler.Interop.CApi.CompilerCompile(IntPtr compilerHandle)

Notes

  • Earlier attempts with the original PaddleDetection ONNX failed because the model had:
    • two inputs (image, scale_factor)
    • dynamic shape
    • post-process / NMS in graph
  • I removed all of those to isolate the minimal failing graph.
  • So this issue seems to be reproducible on a static, single-input, pre-NMS PicoDet head graph.

Question

Is this a known limitation for PicoDet-style ONNX graphs on nncase 2.11.0 / k230?

If helpful, I can also provide:

  • the minimal ONNX file
  • the simple conversion script
  • exact package list from the environment

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