Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NNPA] Fix some bugs for ReduceMin/Max #3038

Merged
merged 2 commits into from
Jan 10, 2025
Merged

Conversation

tungld
Copy link
Collaborator

@tungld tungld commented Jan 9, 2025

Currently, ReduceMin/ReduceMax failed to run on NNPA. This patch is to make them work and produce correct results.

Test program:

module {
  func.func @main_graph(%arg0: tensor<3x2x2xf32> {onnx.name = "x"}) -> (tensor<*xf32> {onnx.name = "y"}) {
   %cst = "onnx.Constant"() {value = dense<[2]> : tensor<1xi64> } : () -> tensor<1xi64>
   %0 ="onnx.ReduceMax"(%arg0, %cst) {keepdims = 1 : si64, noop_with_empty_axes = 0 : si64} : (tensor<3x2x2xf32>, tensor<1xi64>)-> tensor<*xf32>
   "func.return"(%0) : (tensor<*xf32>) -> ()
  }
  "onnx.EntryPoint"() {func = @main_graph} : () -> ()
}

Output using this patch:

python ../utils/RunONNXModel.py -m reducemax.mlir -c "-O3 -march=arch15 -maccel=NNPA" --print-input --print-output
Temporary directory has been created at <TemporaryDirectory '/tmp/tmpxs_l058r'>

Compiling the model ...
  took  0.14967317699847626  seconds.

Loading the compiled model ...
  took  0.0001287180020881351  seconds.

Generating random inputs using seed 42 ...
  - 1st input's shape (3, 2, 2), element type float32. Value ranges [-0.1, 0.1]
  done.

The 1st input x:[3x2x2xfloat32] is:
 [[[-0.02509198  0.09014286]
  [ 0.04639879  0.0197317 ]]

 [[-0.06879627 -0.0688011 ]
  [-0.08838328  0.07323523]]

 [[ 0.020223    0.04161451]
  [-0.0958831   0.09398197]]]

Running inference ...
  1st iteration, 8.331799836014397e-05, seconds
The 1st output y:[3x2x1xfloat32] is:
 [[[ 0.09008789]
  [ 0.04638672]]

 [[-0.06884766]
  [ 0.07324219]]

 [[ 0.04162598]
  [ 0.09399414]]]

@tungld tungld requested a review from hamptonm1 January 9, 2025 05:51
Copy link
Collaborator

@hamptonm1 hamptonm1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tungld
Copy link
Collaborator Author

tungld commented Jan 10, 2025

@jenkins-droid test this please

@tungld tungld merged commit 0183ad9 into onnx:main Jan 10, 2025
7 checks passed
@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #16110 [push] Fix some bugs for Reduce... started at 23:00

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #15137 [push] Fix some bugs for Reduce... started at 23:18

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #16108 [push] Fix some bugs for Reduce... started at 22:00

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #16108 [push] Fix some bugs for Reduce... passed after 1 hr 26 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #16110 [push] Fix some bugs for Reduce... passed after 1 hr 41 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #15137 [push] Fix some bugs for Reduce... passed after 2 hr 30 min

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants