Skip to content

Conversation

@guoyu-wang
Copy link
Contributor

Description: [CoreML EP] Add support of Conv operator

Motivation and Context

@guoyu-wang guoyu-wang requested a review from a team as a code owner January 30, 2021 06:46
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());
}
Copy link
Contributor

@skottmckay skottmckay Feb 3, 2021

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

Copy link
Contributor Author

@guoyu-wang guoyu-wang Feb 3, 2021

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

Copy link
Contributor

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)

Copy link
Contributor

@skottmckay skottmckay left a comment

Choose a reason for hiding this comment

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

:shipit:

@guoyu-wang guoyu-wang merged commit 0d35f0e into master Feb 4, 2021
@guoyu-wang guoyu-wang deleted the gwang-msft/coreml_conv_support branch February 4, 2021 08:30
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