Skip to content

Added minimal support to do some timing of OM Runtime functionality #3095

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

Merged
merged 38 commits into from
Mar 19, 2025

Conversation

AlexandreEichenberger
Copy link
Collaborator

Tried to determine where some of the time is spend when invoking the python runtime. Time printed in seconds.

Timing information is read using indentation, more indented timers are within the following less indented timers.

Test program:

module {
  func.func @main_graph(%arg0: tensor<1x384x30522xf32>, %arg1: tensor<1x384x30522xf32>) -> (tensor<1x384x30522xf32> {onnx.name = "y"}) {
    %0 = "onnx.Add"(%arg0, %arg1) : (tensor<1x384x30522xf32>, tensor<1x384x30522xf32>) -> tensor<1x384x30522xf32>
    return %0 : tensor<1x384x30522xf32>
  }
  "onnx.EntryPoint"() {func = @main_graph} : () -> ()
}

Results when compiling with -O3 for Z using RunONNXModel.py

@OM_DRIVER, process_input, 0.000003
@OM_DRIVER,   tensor_list_create, 0.000000
@OM_DRIVER, tensor_list_create, 0.000000
@OM_DRIVER, inference, 0.003231
@OM_DRIVER,   process_output_types, 0.000002
@OM_DRIVER,   process_output_pyarray, 0.004537
@OM_DRIVER, process_output, 0.004542
@OM_DRIVER,     tensor_destroy_ptr, 0.000085
@OM_DRIVER,     tensor_destroy_struct, 0.000000
@OM_DRIVER,   tensor_list_destroy, 0.000087
@OM_DRIVER, delete_out_lists, 0.000092
@OM_DRIVER,     tensor_destroy_struct, 0.000000
@OM_DRIVER,     tensor_destroy_struct, 0.000000
@OM_DRIVER,   tensor_list_destroy, 0.000003
@OM_DRIVER, delete_in_lists, 0.000005
  2nd iteration, 0.008029167998756748, seconds

where notably a singnificant amount of time is spent in process_output_pyarray, which corresponds to this in onnx-mlir/src/Runtime/python/PyExecutionSessionBase.cpp

outputPyArrays.emplace_back(
        py::array(dtype, shape, omTensorGetDataPtr(omt)));

@AlexandreEichenberger
Copy link
Collaborator Author

Measured overheads of the pyarray creation for 3 different output size and it seems to be linear in the data size

image

Signed-off-by: Alexandre Eichenberger <[email protected]>
@chentong319
Copy link
Collaborator

Did you use the docker env for your measure? Not sure whether the problem is related to the version of python or pybind11, or the combination.

Signed-off-by: Alexandre Eichenberger <[email protected]>
@AlexandreEichenberger
Copy link
Collaborator Author

AlexandreEichenberger commented Mar 14, 2025

It turns out that there is a way when "copying" a C++ data structure to a numpy object that allows the creation of a capsule object that enables python to free objects not allocated by it.

We have to save the pointer of the "allocated" data for the free to works, as sometime the buffer is padded so that the actual data might be a the correct alignment.

The trace below shows that the allocated data is at one address, the data is at another, and when data is freed, it will be effectively the allocated buffer that is freed

Running inference ...
@OM_DRIVER, process_input, 0.004687
@OM_DRIVER,   tensor_list_create, 0.000000
@OM_DRIVER, tensor_list_create, 0.000001
@OM_DRIVER, inference, 0.009955
@OM_DRIVER,   process_output_types, 0.000007
hi alex, preparing free for omTensor with ptr value 0x3ff9397f010 and data ptr 0x3ff93980000
@OM_DRIVER,   process_output_pyarray, 0.000007
@OM_DRIVER, process_output, 0.000020
@OM_DRIVER,     tensor_destroy_struct, 0.000000
@OM_DRIVER,   tensor_list_destroy, 0.000003
@OM_DRIVER, delete_out_lists, 0.000004
@OM_DRIVER,     tensor_destroy_ptr, 0.000095
@OM_DRIVER,     tensor_destroy_struct, 0.000000
@OM_DRIVER,     tensor_destroy_ptr, 0.000139
@OM_DRIVER,     tensor_destroy_struct, 0.000001
@OM_DRIVER,   tensor_list_destroy, 0.000242
@OM_DRIVER, delete_in_lists, 0.000243
  1st iteration, 0.015086764004081488, seconds
Reading reference outputs from check-ref ...
  - 1st output: [1x384x30522xfloat32]
  done.

Verifying value of output_0:[1, 384, 30522] using atol=0.01, rtol=0.05 ...
  correct.

hi alex, freeing omTensor with ptr value 0x3ff9397f010

Above, we can see the 2 different addresses for alloc and data, and we can see that the data is freed after verification (as the python driver, here CheckONNX.py keep the numpy array live until after the verification is performed.

Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
@AlexandreEichenberger
Copy link
Collaborator Author

Results of the timing:

@OM_DRIVER, process_input, 0.000008
@OM_DRIVER,   tensor_list_create, 0.000000
@OM_DRIVER, tensor_list_create, 0.000001
@OM_DRIVER, inference, 0.003783
@OM_DRIVER,   process_output_types, 0.000007
@OM_DRIVER,   process_output_pyarray, 0.000005
@OM_DRIVER, process_output, 0.000020
@OM_DRIVER,     tensor_destroy_struct, 0.000000
@OM_DRIVER,   tensor_list_destroy, 0.000003
@OM_DRIVER, delete_out_lists, 0.000005
@OM_DRIVER,     tensor_destroy_struct, 0.000000
@OM_DRIVER,     tensor_destroy_struct, 0.000000
@OM_DRIVER,   tensor_list_destroy, 0.000005
@OM_DRIVER, delete_in_lists, 0.000006
  1st iteration, 0.0039923149888636544, seconds

we see now that inference takes 0.003783 s, and model takes 0.0039923149888636544. So now 94% of the time is spent in the inference, when driving it from python. Before it was less than 50%... obviously skewed by the fact that this was a single node operation. Nevertheless, we can now see that the "copy" is removed as the overheads are so much lowered, and the log above shows that the freeing of the data was done in the proper location within the python program using the provided lambda function by the C++ runtime.

@AlexandreEichenberger
Copy link
Collaborator Author

Did you use the docker env for your measure? Not sure whether the problem is related to the version of python or pybind11, or the combination.

I think it was due to the copy operation within the py::array as moving to a scheme that does not require the copying removed the issue. Thanks for the good suggestion.

Signed-off-by: Alexandre Eichenberger <[email protected]>
Copy link
Collaborator

@chentong319 chentong319 left a comment

Choose a reason for hiding this comment

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

LGTM!

@AlexandreEichenberger
Copy link
Collaborator Author

@Sunny-Anand let me know if you want to merge this now or in a bit.

It removes a copy for the outputs of a model when using in a python environment.

My tests cover usages using the RunONNXModel.py scripts and the backend tests. I verified the results for one model on a Z arch using NNPA, as there are alignments "tricks" that we do for NNPA buffers that we don't otherwise do.

I let you the final go ahead/wait choice.

@Sunny-Anand
Copy link
Collaborator

@AlexandreEichenberger, let's merge this improvement in the main. Thanks for improving it, it's essential for those performance benchmark measurements.

Copy link
Collaborator

@tungld tungld left a comment

Choose a reason for hiding this comment

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

LGTM!

#define TIMING_PRINT(_var_name) \
if (_var_name##_nest_level >= 0) { /* was started at least once */ \
int l = _var_name##_nest_level <= 5 ? _var_name##_nest_level : 5; \
fprintf(stderr, "@OM_DRIVER, %s%s, %ld.%06ld\n", timing_nest_strings[l], \
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can avoid using timing_nest_string by using %* to print out "" l times, e.g.

fprintf(stderr, "@OM_DRIVER, %*s%s, %ld.%06ld\n", l, "",
           #_var_name, (long int)_var_name.tv_sec, (long int)_var_name.tv_usec);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will give this pattern a try.

*
* @param tensor pointer to the OMTensor
* @return pointer to the allocated memory buffer of the OMTensor,
* This should only be used when needing needing to create
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two needing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tx, added some additional comments on the difference between data and allocated pointers.

Signed-off-by: Alexandre Eichenberger <[email protected]>
@AlexandreEichenberger AlexandreEichenberger merged commit 694d5f1 into onnx:main Mar 19, 2025
7 checks passed
@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #16394 [push] Added minimal support to... started at 10:32

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #16392 [push] Added minimal support to... started at 09:32

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #15375 [push] Added minimal support to... started at 10:44

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #16392 [push] Added minimal support to... passed after 1 hr 20 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #16394 [push] Added minimal support to... passed after 1 hr 30 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #15375 [push] Added minimal support to... passed after 2 hr 25 min

tungld pushed a commit to brnorris03/onnx-mlir that referenced this pull request May 9, 2025
jorickert added a commit that referenced this pull request May 19, 2025
* update float types, tosa, other misc changes

Signed-off-by: Boyana Norris <[email protected]>

* fix buildOnnxToTosaPaddingConstOp

Signed-off-by: Boyana Norris <[email protected]>

* fix lit tests (wip)

Signed-off-by: Boyana Norris <[email protected]>

* updte doc

Signed-off-by: Boyana Norris <[email protected]>

* use stablehlo tagged version

Signed-off-by: Boyana Norris <[email protected]>

* fixed more lit tests

Signed-off-by: Boyana Norris <[email protected]>

* fix .clang-format

Signed-off-by: Boyana Norris <[email protected]>

* fix lit (wip)

Signed-off-by: Boyana Norris <[email protected]>

* revert .clang-format change

Signed-off-by: Boyana Norris <[email protected]>

* fix lit tests

Signed-off-by: Boyana Norris <[email protected]>

* fix formatting

Signed-off-by: Boyana Norris <[email protected]>

* lit tests pass (except jni -- not tested)

Signed-off-by: Boyana Norris <[email protected]>

* manually fix formatting; can't get clang-format to do it on any of my machines

Signed-off-by: Boyana Norris <[email protected]>

* revert lit test changes unrelated to update

Signed-off-by: Boyana Norris <[email protected]>

* update llvm and stablhlo shas, misc minor updates

Signed-off-by: Boyana Norris <[email protected]>

* remove non-existent passes

Signed-off-by: Boyana Norris <[email protected]>

* lit updates (wip)

Signed-off-by: Tung D. Le <[email protected]>

* Bump Upsample to Opset 10 and change the opset versioning to allow to skip over opset versions if a newer, backwards compatible one exists. (#3065)

* Bump Upsample to Opset 10

This is a non-functional change, the only difference is that Upsample was marked as deprecated with Opset 10

Signed-off-by: Rickert, Jonas <[email protected]>

* Use a map of the available opset versions in onnx to select the node opset to use.

Introduces a new built-time generated map that contains all versions of an operation as defined by onnx.
To determine the opset version for a node/op:
1.	Determine the latest valid opset version. This is the newest version in this opset-version-map that is older or equal to the current graph opset.
2.	Select the newest version from the versions supported by onnx-mlir that is equal or newer to the latest valid opset version. This allows it to skip over opset versions, that have a newer backwards compatible version.
Example:
	Versions in onnx and supported by onnx-mlir: [3, 5].
	Graph opset version to node version: 3 -> 3, 4 -> 3, 5 -> 5

	Versions in onnx: [7, 9, 10]. Version 10 is backwards compatible to version 9.
	Version supported by onnx-mlir: [7, 10].
	Graph opset version to node version: 7 -> 7, 8 -> 7, 9 -> 10, 10 -> 10

Signed-off-by: Rickert, Jonas <[email protected]>

---------

Signed-off-by: Rickert, Jonas <[email protected]>

* Improve scripts (#3089)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Bump various ops to opset 21, adding int4/uint4 and 8 bit float support. (#3064)

* Add support for TensorProto::UINT4/INT4

Signed-off-by: Rickert, Jonas <[email protected]>

* Upgrade onnx.Cast to opset 21

Signed-off-by: Rickert, Jonas <[email protected]>

* Bump various ops to opset 21.

These are all backwards compatibel version bumps, only adding support for int/uint4.

Bumped ops:
Flatten
Identity
If
Loop
Pad
Reshape
Scan
Shape
Size
Squeeze
Transpose
Unsqueeze

Signed-off-by: Rickert, Jonas <[email protected]>

---------

Signed-off-by: Rickert, Jonas <[email protected]>

* Added minimal support to do some timing of OM Runtime functionality (#3095)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* adding __errno_location call for mvs (#3099)

Signed-off-by: Christopher Munoz <[email protected]>

* Rewriting pattern to remove WhereOp and EqualOp.  (#3094)

Remove ONNXWhereOp and ONNXEqualOp into newly created ConcatOp.

---------

Signed-off-by: Haruki Imai <[email protected]>

* Enable NNPA saturation by default and change the option to --nnpa-disable-saturation (#3101)

* Enable NNPA saturation by default and change the option to --nnpa-disable-saturation

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* removing weak attribute of errorno (#3103)

Signed-off-by: Christopher Munoz <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Fix the custom build link for docs/Docker.md (#3104)

Signed-off-by: JiQiu <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Python driver for torch model (#3093)

* implementation

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

* test

Signed-off-by: Chen Tong <[email protected]>

* py format

Signed-off-by: Chen Tong <[email protected]>

* torch.compile

Signed-off-by: Chen Tong <[email protected]>

* refine

Signed-off-by: Chen Tong <[email protected]>

* add debug

Signed-off-by: Chen Tong <[email protected]>

* respond

Signed-off-by: Chen Tong <[email protected]>

* response

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* implement (#3108)

Signed-off-by: Chen Tong <[email protected]>

* Followups for torch model driver (#3106)

* simplify

Signed-off-by: Chen Tong <[email protected]>

* complete

Signed-off-by: Chen Tong <[email protected]>

* fix

Signed-off-by: Chen Tong <[email protected]>

* fix

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>

* Fix an error in ZHighConstantPropagation for QuantizedStick (#3112)

Signed-off-by: Tung D. Le <[email protected]>

* Add z17 for -march (#3113)

* done

Signed-off-by: Tong Chen <[email protected]>

* convert

Signed-off-by: Tong Chen <[email protected]>

* fix

Signed-off-by: Tong Chen <[email protected]>

* format

Signed-off-by: Tong Chen <[email protected]>

---------

Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Tong Chen <[email protected]>

* Decompose Hardswish into simpler ONNX ops (#3107)

* Decompose and lower Hardswish

Signed-off-by: Kumarappan <[email protected]>

* Providing the decomposition as compile time option with krnl dialect lowering as default

Signed-off-by: Kumarappan <[email protected]>

---------

Signed-off-by: Kumarappan <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Reorder relu to maxpool optimization pass in ONNX dialect (#3109)

* Reorder Relu and maxpool optimization

Signed-off-by: Arkar-Hema <[email protected]>

* Swap Relu and maxpool only when Relu is not a consumer of conv

Signed-off-by: Arkar-Hema <[email protected]>

---------

Signed-off-by: Arkar-Hema <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Move onnx.Constant before the root op when fusing onnx ops (#3119)

Signed-off-by: Tung D. Le <[email protected]>

* Support QLinearMatMul on CPU (#3117)

* Support QLinearMatMul on CPU

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* Update black-format-check.yml (#3118)

Signed-off-by: Andreas Fehlner <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Merge nested concat Ops optimization pass in ONNX dialect (#3111)

* Merging nested concat ops

Signed-off-by: Arkar-Hema <[email protected]>

---------

Signed-off-by: Arkar-Hema <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Enhance shape inference for ONNX Reshape (#3122)

* Add a special case in shape inference for reshape

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* update zdnn1.1.2 (#3130)

Signed-off-by: Sunny Anand <[email protected]>

* Updating supported ops on NNPA md for z17.  (#3120)

* starting to update new z17 NNPA ops

Signed-off-by: Christopher Munoz <[email protected]>

---------

Signed-off-by: Christopher Munoz <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* fix CVE-2025-32434 (#3135)

Signed-off-by: Sunny Anand <[email protected]>

* Fuse consecutive clips pattern (#3132)

* Fuse consecutive clips pattern

Signed-off-by: Kumarappan <[email protected]>


---------

Signed-off-by: Kumarappan <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Replace deprecated applyPatternsAndFoldGreedily with applyPatternsGreedily. This functions also folds by default, so it is an NFC

Signed-off-by: Rickert, Jonas <[email protected]>

* Fix clang-format

Signed-off-by: Rickert, Jonas <[email protected]>

* Replace bufferization::createOwnershipBasedBufferDeallocationPass with mlir::createConvertBufferizationToMemRefPass

Signed-off-by: Rickert, Jonas <[email protected]>

* Update onnx-to-tosa reshape lit test

Signed-off-by: Rickert, Jonas <[email protected]>

* Move gemm_to_fc tests to gemm_to_matmul

Signed-off-by: Rickert, Jonas <[email protected]>

* Change tosaBuilder::mul function signature to make clear that the shift is an int8

Signed-off-by: Rickert, Jonas <[email protected]>

* Disable buffer_loop_hoisting test as it gets completly optimized away

Signed-off-by: Rickert, Jonas <[email protected]>

* Guard against dynamic dim in result

Signed-off-by: Rickert, Jonas <[email protected]>

* Use resize operaton input and output type to calculate the border, instead of using the calculated numerator/denominator

Signed-off-by: Rickert, Jonas <[email protected]>

* Guard against linear interpolation of integer types

Signed-off-by: Rickert, Jonas <[email protected]>

* Add test for disallowed onnx.Resize on its with linear interpolation to tosa

Signed-off-by: Rickert, Jonas <[email protected]>

* Add 'Pure' annotation to some krnl ops and recreate documentation

Signed-off-by: Rickert, Jonas <[email protected]>

* Build stablehlo with static libs

Signed-off-by: Rickert, Jonas <[email protected]>

* Disable memref.prefetch since it does not work with the new bufferization

Signed-off-by: Tung D. Le <[email protected]>

* Conv add const where the constant is a scalar (#3145)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* added support for Celu op (#3139)

Signed-off-by: logeshwaranmcw <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>

* Fix some warnings related to stickification for NNPA (#3147)

Signed-off-by: Tung D. Le <[email protected]>

* Removing duplicate file (#3146)

Signed-off-by: Christopher Munoz <[email protected]>

* migrated instance/group normalization from decompose to canonicalize (#3148)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Fusion of Matmul add covering the stacked/unstacked/bcast1/bcast23 patterns (#3140)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Support --march=native (#3134)

* changes

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

* linkage

Signed-off-by: Chen Tong <[email protected]>

* lib

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>

* fix another error on s390x

Signed-off-by: Tung D. Le <[email protected]>

* lower Ub to LLVM since vector.shape_cast is lowered to UB

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Boyana Norris <[email protected]>
Signed-off-by: Tung D. Le <[email protected]>
Signed-off-by: Rickert, Jonas <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Christopher Munoz <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: JiQiu <[email protected]>
Signed-off-by: Chen Tong <[email protected]>
Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Kumarappan <[email protected]>
Signed-off-by: Arkar-Hema <[email protected]>
Signed-off-by: Andreas Fehlner <[email protected]>
Signed-off-by: Sunny Anand <[email protected]>
Signed-off-by: logeshwaranmcw <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>
Co-authored-by: Jonas Rickert <[email protected]>
Co-authored-by: Christopher Munoz <[email protected]>
Co-authored-by: Haruki Imai <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>
Co-authored-by: qjivy <[email protected]>
Co-authored-by: Tong Chen <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: kumarappan-cmyk <[email protected]>
Co-authored-by: Arkar-Hema <[email protected]>
Co-authored-by: Andreas Fehlner <[email protected]>
Co-authored-by: logeshwaranmcw <[email protected]>
jorickert added a commit to Xilinx/onnx-mlir that referenced this pull request Jun 26, 2025
LLVM update 43d71ba (onnx#3086)

* update float types, tosa, other misc changes

Signed-off-by: Boyana Norris <[email protected]>

* fix buildOnnxToTosaPaddingConstOp

Signed-off-by: Boyana Norris <[email protected]>

* fix lit tests (wip)

Signed-off-by: Boyana Norris <[email protected]>

* updte doc

Signed-off-by: Boyana Norris <[email protected]>

* use stablehlo tagged version

Signed-off-by: Boyana Norris <[email protected]>

* fixed more lit tests

Signed-off-by: Boyana Norris <[email protected]>

* fix .clang-format

Signed-off-by: Boyana Norris <[email protected]>

* fix lit (wip)

Signed-off-by: Boyana Norris <[email protected]>

* revert .clang-format change

Signed-off-by: Boyana Norris <[email protected]>

* fix lit tests

Signed-off-by: Boyana Norris <[email protected]>

* fix formatting

Signed-off-by: Boyana Norris <[email protected]>

* lit tests pass (except jni -- not tested)

Signed-off-by: Boyana Norris <[email protected]>

* manually fix formatting; can't get clang-format to do it on any of my machines

Signed-off-by: Boyana Norris <[email protected]>

* revert lit test changes unrelated to update

Signed-off-by: Boyana Norris <[email protected]>

* update llvm and stablhlo shas, misc minor updates

Signed-off-by: Boyana Norris <[email protected]>

* remove non-existent passes

Signed-off-by: Boyana Norris <[email protected]>

* lit updates (wip)

Signed-off-by: Tung D. Le <[email protected]>

* Bump Upsample to Opset 10 and change the opset versioning to allow to skip over opset versions if a newer, backwards compatible one exists. (onnx#3065)

* Bump Upsample to Opset 10

This is a non-functional change, the only difference is that Upsample was marked as deprecated with Opset 10

Signed-off-by: Rickert, Jonas <[email protected]>

* Use a map of the available opset versions in onnx to select the node opset to use.

Introduces a new built-time generated map that contains all versions of an operation as defined by onnx.
To determine the opset version for a node/op:
1.	Determine the latest valid opset version. This is the newest version in this opset-version-map that is older or equal to the current graph opset.
2.	Select the newest version from the versions supported by onnx-mlir that is equal or newer to the latest valid opset version. This allows it to skip over opset versions, that have a newer backwards compatible version.
Example:
	Versions in onnx and supported by onnx-mlir: [3, 5].
	Graph opset version to node version: 3 -> 3, 4 -> 3, 5 -> 5

	Versions in onnx: [7, 9, 10]. Version 10 is backwards compatible to version 9.
	Version supported by onnx-mlir: [7, 10].
	Graph opset version to node version: 7 -> 7, 8 -> 7, 9 -> 10, 10 -> 10

Signed-off-by: Rickert, Jonas <[email protected]>

---------

Signed-off-by: Rickert, Jonas <[email protected]>

* Improve scripts (onnx#3089)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Bump various ops to opset 21, adding int4/uint4 and 8 bit float support. (onnx#3064)

* Add support for TensorProto::UINT4/INT4

Signed-off-by: Rickert, Jonas <[email protected]>

* Upgrade onnx.Cast to opset 21

Signed-off-by: Rickert, Jonas <[email protected]>

* Bump various ops to opset 21.

These are all backwards compatibel version bumps, only adding support for int/uint4.

Bumped ops:
Flatten
Identity
If
Loop
Pad
Reshape
Scan
Shape
Size
Squeeze
Transpose
Unsqueeze

Signed-off-by: Rickert, Jonas <[email protected]>

---------

Signed-off-by: Rickert, Jonas <[email protected]>

* Added minimal support to do some timing of OM Runtime functionality (onnx#3095)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* adding __errno_location call for mvs (onnx#3099)

Signed-off-by: Christopher Munoz <[email protected]>

* Rewriting pattern to remove WhereOp and EqualOp.  (onnx#3094)

Remove ONNXWhereOp and ONNXEqualOp into newly created ConcatOp.

---------

Signed-off-by: Haruki Imai <[email protected]>

* Enable NNPA saturation by default and change the option to --nnpa-disable-saturation (onnx#3101)

* Enable NNPA saturation by default and change the option to --nnpa-disable-saturation

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* removing weak attribute of errorno (onnx#3103)

Signed-off-by: Christopher Munoz <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Fix the custom build link for docs/Docker.md (onnx#3104)

Signed-off-by: JiQiu <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Python driver for torch model (onnx#3093)

* implementation

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

* test

Signed-off-by: Chen Tong <[email protected]>

* py format

Signed-off-by: Chen Tong <[email protected]>

* torch.compile

Signed-off-by: Chen Tong <[email protected]>

* refine

Signed-off-by: Chen Tong <[email protected]>

* add debug

Signed-off-by: Chen Tong <[email protected]>

* respond

Signed-off-by: Chen Tong <[email protected]>

* response

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* implement (onnx#3108)

Signed-off-by: Chen Tong <[email protected]>

* Followups for torch model driver (onnx#3106)

* simplify

Signed-off-by: Chen Tong <[email protected]>

* complete

Signed-off-by: Chen Tong <[email protected]>

* fix

Signed-off-by: Chen Tong <[email protected]>

* fix

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>

* Fix an error in ZHighConstantPropagation for QuantizedStick (onnx#3112)

Signed-off-by: Tung D. Le <[email protected]>

* Add z17 for -march (onnx#3113)

* done

Signed-off-by: Tong Chen <[email protected]>

* convert

Signed-off-by: Tong Chen <[email protected]>

* fix

Signed-off-by: Tong Chen <[email protected]>

* format

Signed-off-by: Tong Chen <[email protected]>

---------

Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Tong Chen <[email protected]>

* Decompose Hardswish into simpler ONNX ops (onnx#3107)

* Decompose and lower Hardswish

Signed-off-by: Kumarappan <[email protected]>

* Providing the decomposition as compile time option with krnl dialect lowering as default

Signed-off-by: Kumarappan <[email protected]>

---------

Signed-off-by: Kumarappan <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Reorder relu to maxpool optimization pass in ONNX dialect (onnx#3109)

* Reorder Relu and maxpool optimization

Signed-off-by: Arkar-Hema <[email protected]>

* Swap Relu and maxpool only when Relu is not a consumer of conv

Signed-off-by: Arkar-Hema <[email protected]>

---------

Signed-off-by: Arkar-Hema <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Move onnx.Constant before the root op when fusing onnx ops (onnx#3119)

Signed-off-by: Tung D. Le <[email protected]>

* Support QLinearMatMul on CPU (onnx#3117)

* Support QLinearMatMul on CPU

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* Update black-format-check.yml (onnx#3118)

Signed-off-by: Andreas Fehlner <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Merge nested concat Ops optimization pass in ONNX dialect (onnx#3111)

* Merging nested concat ops

Signed-off-by: Arkar-Hema <[email protected]>

---------

Signed-off-by: Arkar-Hema <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Enhance shape inference for ONNX Reshape (onnx#3122)

* Add a special case in shape inference for reshape

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* update zdnn1.1.2 (onnx#3130)

Signed-off-by: Sunny Anand <[email protected]>

* Updating supported ops on NNPA md for z17.  (onnx#3120)

* starting to update new z17 NNPA ops

Signed-off-by: Christopher Munoz <[email protected]>

---------

Signed-off-by: Christopher Munoz <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* fix CVE-2025-32434 (onnx#3135)

Signed-off-by: Sunny Anand <[email protected]>

* Fuse consecutive clips pattern (onnx#3132)

* Fuse consecutive clips pattern

Signed-off-by: Kumarappan <[email protected]>

---------

Signed-off-by: Kumarappan <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Replace deprecated applyPatternsAndFoldGreedily with applyPatternsGreedily. This functions also folds by default, so it is an NFC

Signed-off-by: Rickert, Jonas <[email protected]>

* Fix clang-format

Signed-off-by: Rickert, Jonas <[email protected]>

* Replace bufferization::createOwnershipBasedBufferDeallocationPass with mlir::createConvertBufferizationToMemRefPass

Signed-off-by: Rickert, Jonas <[email protected]>

* Update onnx-to-tosa reshape lit test

Signed-off-by: Rickert, Jonas <[email protected]>

* Move gemm_to_fc tests to gemm_to_matmul

Signed-off-by: Rickert, Jonas <[email protected]>

* Change tosaBuilder::mul function signature to make clear that the shift is an int8

Signed-off-by: Rickert, Jonas <[email protected]>

* Disable buffer_loop_hoisting test as it gets completly optimized away

Signed-off-by: Rickert, Jonas <[email protected]>

* Guard against dynamic dim in result

Signed-off-by: Rickert, Jonas <[email protected]>

* Use resize operaton input and output type to calculate the border, instead of using the calculated numerator/denominator

Signed-off-by: Rickert, Jonas <[email protected]>

* Guard against linear interpolation of integer types

Signed-off-by: Rickert, Jonas <[email protected]>

* Add test for disallowed onnx.Resize on its with linear interpolation to tosa

Signed-off-by: Rickert, Jonas <[email protected]>

* Add 'Pure' annotation to some krnl ops and recreate documentation

Signed-off-by: Rickert, Jonas <[email protected]>

* Build stablehlo with static libs

Signed-off-by: Rickert, Jonas <[email protected]>

* Disable memref.prefetch since it does not work with the new bufferization

Signed-off-by: Tung D. Le <[email protected]>

* Conv add const where the constant is a scalar (onnx#3145)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* added support for Celu op (onnx#3139)

Signed-off-by: logeshwaranmcw <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>

* Fix some warnings related to stickification for NNPA (onnx#3147)

Signed-off-by: Tung D. Le <[email protected]>

* Removing duplicate file (onnx#3146)

Signed-off-by: Christopher Munoz <[email protected]>

* migrated instance/group normalization from decompose to canonicalize (onnx#3148)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Fusion of Matmul add covering the stacked/unstacked/bcast1/bcast23 patterns (onnx#3140)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Support --march=native (onnx#3134)

* changes

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

* linkage

Signed-off-by: Chen Tong <[email protected]>

* lib

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>

* fix another error on s390x

Signed-off-by: Tung D. Le <[email protected]>

* lower Ub to LLVM since vector.shape_cast is lowered to UB

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Boyana Norris <[email protected]>
Signed-off-by: Tung D. Le <[email protected]>
Signed-off-by: Rickert, Jonas <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Christopher Munoz <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: JiQiu <[email protected]>
Signed-off-by: Chen Tong <[email protected]>
Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Kumarappan <[email protected]>
Signed-off-by: Arkar-Hema <[email protected]>
Signed-off-by: Andreas Fehlner <[email protected]>
Signed-off-by: Sunny Anand <[email protected]>
Signed-off-by: logeshwaranmcw <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>
Co-authored-by: Jonas Rickert <[email protected]>
Co-authored-by: Christopher Munoz <[email protected]>
Co-authored-by: Haruki Imai <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>
Co-authored-by: qjivy <[email protected]>
Co-authored-by: Tong Chen <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: kumarappan-cmyk <[email protected]>
Co-authored-by: Arkar-Hema <[email protected]>
Co-authored-by: Andreas Fehlner <[email protected]>
Co-authored-by: logeshwaranmcw <[email protected]>
jorickert added a commit to Xilinx/onnx-mlir that referenced this pull request Jul 1, 2025
AMD changes: Update lowering and tests for onnx->tosa conversions that are not upstream

Partial cherry-pick of f03b287

LLVM update 43d71ba (onnx#3086)

* update float types, tosa, other misc changes

Signed-off-by: Boyana Norris <[email protected]>

* fix buildOnnxToTosaPaddingConstOp

Signed-off-by: Boyana Norris <[email protected]>

* fix lit tests (wip)

Signed-off-by: Boyana Norris <[email protected]>

* updte doc

Signed-off-by: Boyana Norris <[email protected]>

* use stablehlo tagged version

Signed-off-by: Boyana Norris <[email protected]>

* fixed more lit tests

Signed-off-by: Boyana Norris <[email protected]>

* fix .clang-format

Signed-off-by: Boyana Norris <[email protected]>

* fix lit (wip)

Signed-off-by: Boyana Norris <[email protected]>

* revert .clang-format change

Signed-off-by: Boyana Norris <[email protected]>

* fix lit tests

Signed-off-by: Boyana Norris <[email protected]>

* fix formatting

Signed-off-by: Boyana Norris <[email protected]>

* lit tests pass (except jni -- not tested)

Signed-off-by: Boyana Norris <[email protected]>

* manually fix formatting; can't get clang-format to do it on any of my machines

Signed-off-by: Boyana Norris <[email protected]>

* revert lit test changes unrelated to update

Signed-off-by: Boyana Norris <[email protected]>

* update llvm and stablhlo shas, misc minor updates

Signed-off-by: Boyana Norris <[email protected]>

* remove non-existent passes

Signed-off-by: Boyana Norris <[email protected]>

* lit updates (wip)

Signed-off-by: Tung D. Le <[email protected]>

* Bump Upsample to Opset 10 and change the opset versioning to allow to skip over opset versions if a newer, backwards compatible one exists. (onnx#3065)

* Bump Upsample to Opset 10

This is a non-functional change, the only difference is that Upsample was marked as deprecated with Opset 10

Signed-off-by: Rickert, Jonas <[email protected]>

* Use a map of the available opset versions in onnx to select the node opset to use.

Introduces a new built-time generated map that contains all versions of an operation as defined by onnx.
To determine the opset version for a node/op:
1.	Determine the latest valid opset version. This is the newest version in this opset-version-map that is older or equal to the current graph opset.
2.	Select the newest version from the versions supported by onnx-mlir that is equal or newer to the latest valid opset version. This allows it to skip over opset versions, that have a newer backwards compatible version.
Example:
	Versions in onnx and supported by onnx-mlir: [3, 5].
	Graph opset version to node version: 3 -> 3, 4 -> 3, 5 -> 5

	Versions in onnx: [7, 9, 10]. Version 10 is backwards compatible to version 9.
	Version supported by onnx-mlir: [7, 10].
	Graph opset version to node version: 7 -> 7, 8 -> 7, 9 -> 10, 10 -> 10

Signed-off-by: Rickert, Jonas <[email protected]>

---------

Signed-off-by: Rickert, Jonas <[email protected]>

* Improve scripts (onnx#3089)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Bump various ops to opset 21, adding int4/uint4 and 8 bit float support. (onnx#3064)

* Add support for TensorProto::UINT4/INT4

Signed-off-by: Rickert, Jonas <[email protected]>

* Upgrade onnx.Cast to opset 21

Signed-off-by: Rickert, Jonas <[email protected]>

* Bump various ops to opset 21.

These are all backwards compatibel version bumps, only adding support for int/uint4.

Bumped ops:
Flatten
Identity
If
Loop
Pad
Reshape
Scan
Shape
Size
Squeeze
Transpose
Unsqueeze

Signed-off-by: Rickert, Jonas <[email protected]>

---------

Signed-off-by: Rickert, Jonas <[email protected]>

* Added minimal support to do some timing of OM Runtime functionality (onnx#3095)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* adding __errno_location call for mvs (onnx#3099)

Signed-off-by: Christopher Munoz <[email protected]>

* Rewriting pattern to remove WhereOp and EqualOp.  (onnx#3094)

Remove ONNXWhereOp and ONNXEqualOp into newly created ConcatOp.

---------

Signed-off-by: Haruki Imai <[email protected]>

* Enable NNPA saturation by default and change the option to --nnpa-disable-saturation (onnx#3101)

* Enable NNPA saturation by default and change the option to --nnpa-disable-saturation

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* removing weak attribute of errorno (onnx#3103)

Signed-off-by: Christopher Munoz <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Fix the custom build link for docs/Docker.md (onnx#3104)

Signed-off-by: JiQiu <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Python driver for torch model (onnx#3093)

* implementation

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

* test

Signed-off-by: Chen Tong <[email protected]>

* py format

Signed-off-by: Chen Tong <[email protected]>

* torch.compile

Signed-off-by: Chen Tong <[email protected]>

* refine

Signed-off-by: Chen Tong <[email protected]>

* add debug

Signed-off-by: Chen Tong <[email protected]>

* respond

Signed-off-by: Chen Tong <[email protected]>

* response

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* implement (onnx#3108)

Signed-off-by: Chen Tong <[email protected]>

* Followups for torch model driver (onnx#3106)

* simplify

Signed-off-by: Chen Tong <[email protected]>

* complete

Signed-off-by: Chen Tong <[email protected]>

* fix

Signed-off-by: Chen Tong <[email protected]>

* fix

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>

* Fix an error in ZHighConstantPropagation for QuantizedStick (onnx#3112)

Signed-off-by: Tung D. Le <[email protected]>

* Add z17 for -march (onnx#3113)

* done

Signed-off-by: Tong Chen <[email protected]>

* convert

Signed-off-by: Tong Chen <[email protected]>

* fix

Signed-off-by: Tong Chen <[email protected]>

* format

Signed-off-by: Tong Chen <[email protected]>

---------

Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Tong Chen <[email protected]>

* Decompose Hardswish into simpler ONNX ops (onnx#3107)

* Decompose and lower Hardswish

Signed-off-by: Kumarappan <[email protected]>

* Providing the decomposition as compile time option with krnl dialect lowering as default

Signed-off-by: Kumarappan <[email protected]>

---------

Signed-off-by: Kumarappan <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Reorder relu to maxpool optimization pass in ONNX dialect (onnx#3109)

* Reorder Relu and maxpool optimization

Signed-off-by: Arkar-Hema <[email protected]>

* Swap Relu and maxpool only when Relu is not a consumer of conv

Signed-off-by: Arkar-Hema <[email protected]>

---------

Signed-off-by: Arkar-Hema <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Move onnx.Constant before the root op when fusing onnx ops (onnx#3119)

Signed-off-by: Tung D. Le <[email protected]>

* Support QLinearMatMul on CPU (onnx#3117)

* Support QLinearMatMul on CPU

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* Update black-format-check.yml (onnx#3118)

Signed-off-by: Andreas Fehlner <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Merge nested concat Ops optimization pass in ONNX dialect (onnx#3111)

* Merging nested concat ops

Signed-off-by: Arkar-Hema <[email protected]>

---------

Signed-off-by: Arkar-Hema <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Enhance shape inference for ONNX Reshape (onnx#3122)

* Add a special case in shape inference for reshape

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* update zdnn1.1.2 (onnx#3130)

Signed-off-by: Sunny Anand <[email protected]>

* Updating supported ops on NNPA md for z17.  (onnx#3120)

* starting to update new z17 NNPA ops

Signed-off-by: Christopher Munoz <[email protected]>

---------

Signed-off-by: Christopher Munoz <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* fix CVE-2025-32434 (onnx#3135)

Signed-off-by: Sunny Anand <[email protected]>

* Fuse consecutive clips pattern (onnx#3132)

* Fuse consecutive clips pattern

Signed-off-by: Kumarappan <[email protected]>

---------

Signed-off-by: Kumarappan <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Replace deprecated applyPatternsAndFoldGreedily with applyPatternsGreedily. This functions also folds by default, so it is an NFC

Signed-off-by: Rickert, Jonas <[email protected]>

* Fix clang-format

Signed-off-by: Rickert, Jonas <[email protected]>

* Replace bufferization::createOwnershipBasedBufferDeallocationPass with mlir::createConvertBufferizationToMemRefPass

Signed-off-by: Rickert, Jonas <[email protected]>

* Update onnx-to-tosa reshape lit test

Signed-off-by: Rickert, Jonas <[email protected]>

* Move gemm_to_fc tests to gemm_to_matmul

Signed-off-by: Rickert, Jonas <[email protected]>

* Change tosaBuilder::mul function signature to make clear that the shift is an int8

Signed-off-by: Rickert, Jonas <[email protected]>

* Disable buffer_loop_hoisting test as it gets completly optimized away

Signed-off-by: Rickert, Jonas <[email protected]>

* Guard against dynamic dim in result

Signed-off-by: Rickert, Jonas <[email protected]>

* Use resize operaton input and output type to calculate the border, instead of using the calculated numerator/denominator

Signed-off-by: Rickert, Jonas <[email protected]>

* Guard against linear interpolation of integer types

Signed-off-by: Rickert, Jonas <[email protected]>

* Add test for disallowed onnx.Resize on its with linear interpolation to tosa

Signed-off-by: Rickert, Jonas <[email protected]>

* Add 'Pure' annotation to some krnl ops and recreate documentation

Signed-off-by: Rickert, Jonas <[email protected]>

* Build stablehlo with static libs

Signed-off-by: Rickert, Jonas <[email protected]>

* Disable memref.prefetch since it does not work with the new bufferization

Signed-off-by: Tung D. Le <[email protected]>

* Conv add const where the constant is a scalar (onnx#3145)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* added support for Celu op (onnx#3139)

Signed-off-by: logeshwaranmcw <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>

* Fix some warnings related to stickification for NNPA (onnx#3147)

Signed-off-by: Tung D. Le <[email protected]>

* Removing duplicate file (onnx#3146)

Signed-off-by: Christopher Munoz <[email protected]>

* migrated instance/group normalization from decompose to canonicalize (onnx#3148)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Fusion of Matmul add covering the stacked/unstacked/bcast1/bcast23 patterns (onnx#3140)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Support --march=native (onnx#3134)

* changes

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

* linkage

Signed-off-by: Chen Tong <[email protected]>

* lib

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>

* fix another error on s390x

Signed-off-by: Tung D. Le <[email protected]>

* lower Ub to LLVM since vector.shape_cast is lowered to UB

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Boyana Norris <[email protected]>
Signed-off-by: Tung D. Le <[email protected]>
Signed-off-by: Rickert, Jonas <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Christopher Munoz <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: JiQiu <[email protected]>
Signed-off-by: Chen Tong <[email protected]>
Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Kumarappan <[email protected]>
Signed-off-by: Arkar-Hema <[email protected]>
Signed-off-by: Andreas Fehlner <[email protected]>
Signed-off-by: Sunny Anand <[email protected]>
Signed-off-by: logeshwaranmcw <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>
Co-authored-by: Jonas Rickert <[email protected]>
Co-authored-by: Christopher Munoz <[email protected]>
Co-authored-by: Haruki Imai <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>
Co-authored-by: qjivy <[email protected]>
Co-authored-by: Tong Chen <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: kumarappan-cmyk <[email protected]>
Co-authored-by: Arkar-Hema <[email protected]>
Co-authored-by: Andreas Fehlner <[email protected]>
Co-authored-by: logeshwaranmcw <[email protected]>
Signed-off-by: Jonas Rickert <[email protected]>
jorickert added a commit to Xilinx/onnx-mlir that referenced this pull request Jul 1, 2025
AMD changes: Update lowering and tests for onnx->tosa conversions that are not upstream

Partial cherry-pick of f03b287

LLVM update 43d71ba (onnx#3086)

* update float types, tosa, other misc changes

Signed-off-by: Boyana Norris <[email protected]>

* fix buildOnnxToTosaPaddingConstOp

Signed-off-by: Boyana Norris <[email protected]>

* fix lit tests (wip)

Signed-off-by: Boyana Norris <[email protected]>

* updte doc

Signed-off-by: Boyana Norris <[email protected]>

* use stablehlo tagged version

Signed-off-by: Boyana Norris <[email protected]>

* fixed more lit tests

Signed-off-by: Boyana Norris <[email protected]>

* fix .clang-format

Signed-off-by: Boyana Norris <[email protected]>

* fix lit (wip)

Signed-off-by: Boyana Norris <[email protected]>

* revert .clang-format change

Signed-off-by: Boyana Norris <[email protected]>

* fix lit tests

Signed-off-by: Boyana Norris <[email protected]>

* fix formatting

Signed-off-by: Boyana Norris <[email protected]>

* lit tests pass (except jni -- not tested)

Signed-off-by: Boyana Norris <[email protected]>

* manually fix formatting; can't get clang-format to do it on any of my machines

Signed-off-by: Boyana Norris <[email protected]>

* revert lit test changes unrelated to update

Signed-off-by: Boyana Norris <[email protected]>

* update llvm and stablhlo shas, misc minor updates

Signed-off-by: Boyana Norris <[email protected]>

* remove non-existent passes

Signed-off-by: Boyana Norris <[email protected]>

* lit updates (wip)

Signed-off-by: Tung D. Le <[email protected]>

* Bump Upsample to Opset 10 and change the opset versioning to allow to skip over opset versions if a newer, backwards compatible one exists. (onnx#3065)

* Bump Upsample to Opset 10

This is a non-functional change, the only difference is that Upsample was marked as deprecated with Opset 10

Signed-off-by: Rickert, Jonas <[email protected]>

* Use a map of the available opset versions in onnx to select the node opset to use.

Introduces a new built-time generated map that contains all versions of an operation as defined by onnx.
To determine the opset version for a node/op:
1.	Determine the latest valid opset version. This is the newest version in this opset-version-map that is older or equal to the current graph opset.
2.	Select the newest version from the versions supported by onnx-mlir that is equal or newer to the latest valid opset version. This allows it to skip over opset versions, that have a newer backwards compatible version.
Example:
	Versions in onnx and supported by onnx-mlir: [3, 5].
	Graph opset version to node version: 3 -> 3, 4 -> 3, 5 -> 5

	Versions in onnx: [7, 9, 10]. Version 10 is backwards compatible to version 9.
	Version supported by onnx-mlir: [7, 10].
	Graph opset version to node version: 7 -> 7, 8 -> 7, 9 -> 10, 10 -> 10

Signed-off-by: Rickert, Jonas <[email protected]>

---------

Signed-off-by: Rickert, Jonas <[email protected]>

* Improve scripts (onnx#3089)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Bump various ops to opset 21, adding int4/uint4 and 8 bit float support. (onnx#3064)

* Add support for TensorProto::UINT4/INT4

Signed-off-by: Rickert, Jonas <[email protected]>

* Upgrade onnx.Cast to opset 21

Signed-off-by: Rickert, Jonas <[email protected]>

* Bump various ops to opset 21.

These are all backwards compatibel version bumps, only adding support for int/uint4.

Bumped ops:
Flatten
Identity
If
Loop
Pad
Reshape
Scan
Shape
Size
Squeeze
Transpose
Unsqueeze

Signed-off-by: Rickert, Jonas <[email protected]>

---------

Signed-off-by: Rickert, Jonas <[email protected]>

* Added minimal support to do some timing of OM Runtime functionality (onnx#3095)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* adding __errno_location call for mvs (onnx#3099)

Signed-off-by: Christopher Munoz <[email protected]>

* Rewriting pattern to remove WhereOp and EqualOp.  (onnx#3094)

Remove ONNXWhereOp and ONNXEqualOp into newly created ConcatOp.

---------

Signed-off-by: Haruki Imai <[email protected]>

* Enable NNPA saturation by default and change the option to --nnpa-disable-saturation (onnx#3101)

* Enable NNPA saturation by default and change the option to --nnpa-disable-saturation

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* removing weak attribute of errorno (onnx#3103)

Signed-off-by: Christopher Munoz <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Fix the custom build link for docs/Docker.md (onnx#3104)

Signed-off-by: JiQiu <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Python driver for torch model (onnx#3093)

* implementation

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

* test

Signed-off-by: Chen Tong <[email protected]>

* py format

Signed-off-by: Chen Tong <[email protected]>

* torch.compile

Signed-off-by: Chen Tong <[email protected]>

* refine

Signed-off-by: Chen Tong <[email protected]>

* add debug

Signed-off-by: Chen Tong <[email protected]>

* respond

Signed-off-by: Chen Tong <[email protected]>

* response

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* implement (onnx#3108)

Signed-off-by: Chen Tong <[email protected]>

* Followups for torch model driver (onnx#3106)

* simplify

Signed-off-by: Chen Tong <[email protected]>

* complete

Signed-off-by: Chen Tong <[email protected]>

* fix

Signed-off-by: Chen Tong <[email protected]>

* fix

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>

* Fix an error in ZHighConstantPropagation for QuantizedStick (onnx#3112)

Signed-off-by: Tung D. Le <[email protected]>

* Add z17 for -march (onnx#3113)

* done

Signed-off-by: Tong Chen <[email protected]>

* convert

Signed-off-by: Tong Chen <[email protected]>

* fix

Signed-off-by: Tong Chen <[email protected]>

* format

Signed-off-by: Tong Chen <[email protected]>

---------

Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Tong Chen <[email protected]>

* Decompose Hardswish into simpler ONNX ops (onnx#3107)

* Decompose and lower Hardswish

Signed-off-by: Kumarappan <[email protected]>

* Providing the decomposition as compile time option with krnl dialect lowering as default

Signed-off-by: Kumarappan <[email protected]>

---------

Signed-off-by: Kumarappan <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Reorder relu to maxpool optimization pass in ONNX dialect (onnx#3109)

* Reorder Relu and maxpool optimization

Signed-off-by: Arkar-Hema <[email protected]>

* Swap Relu and maxpool only when Relu is not a consumer of conv

Signed-off-by: Arkar-Hema <[email protected]>

---------

Signed-off-by: Arkar-Hema <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Move onnx.Constant before the root op when fusing onnx ops (onnx#3119)

Signed-off-by: Tung D. Le <[email protected]>

* Support QLinearMatMul on CPU (onnx#3117)

* Support QLinearMatMul on CPU

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* Update black-format-check.yml (onnx#3118)

Signed-off-by: Andreas Fehlner <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Merge nested concat Ops optimization pass in ONNX dialect (onnx#3111)

* Merging nested concat ops

Signed-off-by: Arkar-Hema <[email protected]>

---------

Signed-off-by: Arkar-Hema <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Enhance shape inference for ONNX Reshape (onnx#3122)

* Add a special case in shape inference for reshape

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Tung D. Le <[email protected]>

* update zdnn1.1.2 (onnx#3130)

Signed-off-by: Sunny Anand <[email protected]>

* Updating supported ops on NNPA md for z17.  (onnx#3120)

* starting to update new z17 NNPA ops

Signed-off-by: Christopher Munoz <[email protected]>

---------

Signed-off-by: Christopher Munoz <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* fix CVE-2025-32434 (onnx#3135)

Signed-off-by: Sunny Anand <[email protected]>

* Fuse consecutive clips pattern (onnx#3132)

* Fuse consecutive clips pattern

Signed-off-by: Kumarappan <[email protected]>

---------

Signed-off-by: Kumarappan <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>

* Replace deprecated applyPatternsAndFoldGreedily with applyPatternsGreedily. This functions also folds by default, so it is an NFC

Signed-off-by: Rickert, Jonas <[email protected]>

* Fix clang-format

Signed-off-by: Rickert, Jonas <[email protected]>

* Replace bufferization::createOwnershipBasedBufferDeallocationPass with mlir::createConvertBufferizationToMemRefPass

Signed-off-by: Rickert, Jonas <[email protected]>

* Update onnx-to-tosa reshape lit test

Signed-off-by: Rickert, Jonas <[email protected]>

* Move gemm_to_fc tests to gemm_to_matmul

Signed-off-by: Rickert, Jonas <[email protected]>

* Change tosaBuilder::mul function signature to make clear that the shift is an int8

Signed-off-by: Rickert, Jonas <[email protected]>

* Disable buffer_loop_hoisting test as it gets completly optimized away

Signed-off-by: Rickert, Jonas <[email protected]>

* Guard against dynamic dim in result

Signed-off-by: Rickert, Jonas <[email protected]>

* Use resize operaton input and output type to calculate the border, instead of using the calculated numerator/denominator

Signed-off-by: Rickert, Jonas <[email protected]>

* Guard against linear interpolation of integer types

Signed-off-by: Rickert, Jonas <[email protected]>

* Add test for disallowed onnx.Resize on its with linear interpolation to tosa

Signed-off-by: Rickert, Jonas <[email protected]>

* Add 'Pure' annotation to some krnl ops and recreate documentation

Signed-off-by: Rickert, Jonas <[email protected]>

* Build stablehlo with static libs

Signed-off-by: Rickert, Jonas <[email protected]>

* Disable memref.prefetch since it does not work with the new bufferization

Signed-off-by: Tung D. Le <[email protected]>

* Conv add const where the constant is a scalar (onnx#3145)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* added support for Celu op (onnx#3139)

Signed-off-by: logeshwaranmcw <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>

* Fix some warnings related to stickification for NNPA (onnx#3147)

Signed-off-by: Tung D. Le <[email protected]>

* Removing duplicate file (onnx#3146)

Signed-off-by: Christopher Munoz <[email protected]>

* migrated instance/group normalization from decompose to canonicalize (onnx#3148)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Fusion of Matmul add covering the stacked/unstacked/bcast1/bcast23 patterns (onnx#3140)

Signed-off-by: Alexandre Eichenberger <[email protected]>

* Support --march=native (onnx#3134)

* changes

Signed-off-by: Chen Tong <[email protected]>

* format

Signed-off-by: Chen Tong <[email protected]>

* linkage

Signed-off-by: Chen Tong <[email protected]>

* lib

Signed-off-by: Chen Tong <[email protected]>

---------

Signed-off-by: Chen Tong <[email protected]>

* fix another error on s390x

Signed-off-by: Tung D. Le <[email protected]>

* lower Ub to LLVM since vector.shape_cast is lowered to UB

Signed-off-by: Tung D. Le <[email protected]>

---------

Signed-off-by: Boyana Norris <[email protected]>
Signed-off-by: Tung D. Le <[email protected]>
Signed-off-by: Rickert, Jonas <[email protected]>
Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Christopher Munoz <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: JiQiu <[email protected]>
Signed-off-by: Chen Tong <[email protected]>
Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Kumarappan <[email protected]>
Signed-off-by: Arkar-Hema <[email protected]>
Signed-off-by: Andreas Fehlner <[email protected]>
Signed-off-by: Sunny Anand <[email protected]>
Signed-off-by: logeshwaranmcw <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>
Co-authored-by: Jonas Rickert <[email protected]>
Co-authored-by: Christopher Munoz <[email protected]>
Co-authored-by: Haruki Imai <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>
Co-authored-by: qjivy <[email protected]>
Co-authored-by: Tong Chen <[email protected]>
Co-authored-by: Sunny Anand <[email protected]>
Co-authored-by: kumarappan-cmyk <[email protected]>
Co-authored-by: Arkar-Hema <[email protected]>
Co-authored-by: Andreas Fehlner <[email protected]>
Co-authored-by: logeshwaranmcw <[email protected]>
Signed-off-by: Jonas Rickert <[email protected]>
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.

5 participants