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

Add ReduceMean onnx operation #2049

Merged
merged 2 commits into from
Apr 13, 2024

Conversation

gabotechs
Copy link
Contributor

This PR adds support for the "ReduceMean" onnx operation based on https://onnx.ai/onnx/operators/onnx__ReduceMean.html#reducemean-13

The onnx model that I'm trying to load was generated with https://github.com/huggingface/optimum, and that tool generates the version 13 of the "ReduceMean" operation, so I have implemented a version compatible with 13 and below.

There do is a new version 18 with different inputs (axes comes as a second input rather than a named attribute), but I have not seen a clear path for switching between the different versions of an operation in order to provide different implementations.

A clean way I can imagine of doing is would be to split candle-onnx/src/eval.rs into one file per operation, implement all the versions of an operation in each file, and heavily reuse code across versions of the same operation. That would also allow to colocate tests and implementations. It sounds like a big change though...


I have also gathered a list of onnx operations that are missing and are needed for my use-case:

Still missing

Sqrt
Range
Greater
Less
Log
Min
Where

Incomplete implementation

ConstantOfShape -> should take "value" attribute into account for selecting the correct DType

@LaurentMazare LaurentMazare merged commit e6d412b into huggingface:main Apr 13, 2024
10 checks passed
@LaurentMazare
Copy link
Collaborator

Thanks!

@gabotechs gabotechs deleted the add-reduce-mean-onnx-op branch April 20, 2024 16:24
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.

2 participants