-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[CoreML EP] Add support of Conv operator #6510
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
Conversation
onnxruntime/core/providers/coreml/builders/impl/conv_op_builder.cc
Outdated
Show resolved
Hide resolved
| size_t num_elements = std::accumulate(dimensions.begin(), dimensions.end(), 1, std::multiplies<size_t>()); | ||
| return num_elements * GetElementByteSize(); | ||
| return SafeInt<size_t>(num_elements * GetElementByteSize()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to convert one to a SafeInt prior to doing the calculation. Otherwise you're putting the result of the calculation in the SafeInt and any overflow has already happened.
e.g. SafeInt<size_t>(num_elements) * GetElementByteSize(); #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't num_elements already a size_t? Do we need the SafeInt call here at all? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SafeInt will check if the size_t overflows when num_elements is multiplied by GetElementByteSize(). more likely on a 32-bit system where size_t is smaller.
In reply to: 569776202 [](ancestors = 569776202)
skottmckay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
Description: [CoreML EP] Add support of Conv operator
Motivation and Context