onnx / onnx-mlir

Representation and Reference Lowering of ONNX Models in MLIR Compiler Infrastructure
Apache License 2.0
760 stars 319 forks source link

bidaf-9.onnx from onnx model zoo fails to compile #2770

Closed cjvolzka closed 7 months ago

cjvolzka commented 7 months ago

The bidaf-9.onnx model fails to compile with latest commit. I get the same error compiling for CPU or NNPA.

onnx-mlir version

podman run --rm -it onnxmlir/onnx-mlir:latest --version
onnx-mlir version 0.4.2, onnx version 1.15.0 (https://github.com/onnx/onnx-mlir.git e4d788dc0352be7331a6f3cdbab853b4a63c0631)
LLVM version 19.0.0git (https://github.com/llvm/llvm-project.git a4ca07f13b560b4f6fa5459eef7159e4f9ee9a6b)
Optimized build with assertions.
Default target: s390x-ibm-linux
Host CPU: z16

Error when attempting to compile for NNPA (I get the same error attempting CPU)

podman run --rm -it --workdir=/workdir -v $(pwd):/workdir:z onnxmlir/onnx-mlir:latest --O3 --EmitLib --mtriple=s390x-ibm-loz --mcpu=z16 --maccel=NNPA --onnx-op-stats TXT ./bidaf-9.onnx 
Operations encountered:
-----------------------
   func.func               , 1
   func.return             , 1
   onnx.Abs                , 1
   onnx.Add                , 12
   onnx.ArgMax             , 1
   onnx.Cast               , 3
   onnx.CategoryMapper     , 4
   onnx.Ceil               , 1
   onnx.Clip               , 1
   onnx.Compress           , 1
   onnx.Concat             , 13
   onnx.Constant           , 26
   onnx.Dim                , 7
   onnx.Expand             , 7
   onnx.Gather             , 4
   onnx.Greater            , 1
   onnx.Hardmax            , 1
   onnx.Max                , 2
   onnx.Mul                , 10
   onnx.NoValue            , 1
   onnx.ReduceMaxV13       , 3
   onnx.ReduceSumV11       , 4
   onnx.Relu               , 2
   onnx.Reshape            , 14
   onnx.Scan               , 1
   onnx.Slice              , 7
   onnx.Squeeze            , 12
   onnx.Sub                , 1
   onnx.Sum                , 1
   onnx.Transpose          , 16
   onnx.Unsqueeze          , 8
   onnx.Where              , 2
   onnx.Yield              , 1
  zhigh.Add                , 5
  zhigh.Conv2D             , 2
  zhigh.LSTM               , 5
  zhigh.Log                , 2
  zhigh.MatMul             , 12
  zhigh.Mul                , 4
  zhigh.Relu               , 4
  zhigh.Sigmoid            , 4
  zhigh.Softmax            , 5
  zhigh.Stick              , 19
  zhigh.StickifiedConstant , 41
  zhigh.Sub                , 4
  zhigh.Unstick            , 19
loc("onnx.CategoryMapper"("CategoryMapper_5")): error: expected result type to be 'memref<1x1x1x16x!krnl.string, strided<[256, 256, 256, 1]>>' or a rank-reduced version. (mismatch of result layout) 
tungld commented 7 months ago

@cjvolzka PR #2774 would fix the issue here, in the sense that the model would be compiled successfully.

But I heard from @negiyas that this model currently works with static inputs only, say we need to compile the model with --shapeInformation.