Skip to content

Add int32_t as required type to some operators #7192

Merged
skottmckay merged 3 commits intomasterfrom
skottmckay/AddInt32AsRequiredTypeToSomeOps
Apr 1, 2021
Merged

Add int32_t as required type to some operators #7192
skottmckay merged 3 commits intomasterfrom
skottmckay/AddInt32AsRequiredTypeToSomeOps

Conversation

@skottmckay
Copy link
Contributor

Description:
Updates to some operators to always support int32 and int64 based on testing of Android package build config with a minimal build using global type reduction.

If an operator can be used for shape manipulation (int64) it is frequently used for indices manipulation (int32 or int64), so we enable both types for that set of ops.

  • e.g. BERT models like MobileBERT take int32 indices as input
  • Scatter/Gather ops utilize indices

This allows us to avoid having to specify int32 and int64 in the global list of types, which would mean they're unnecessarily enabled for all operators.

DequantizeLinear also needs to special casing of int32. In that case just make all three types required for simplicity.

Misc. fix to python bindings to exclude call that fails in a minimal build.

Motivation and Context
Avoid having to support int32_t and int64_t for all ops when using global type reduction

…testing of Android package build config with a minimal build.

If an operator can be used for shape manipulation (int64) it is frequently used for indices manipulation (int32), so we enable both types for that set of ops.
  - e.g. BERT models take indices as input
  - Scatter/Gather ops utilize indices

Misc. fix to python bindings to exclude call that fails in a minimal build.
@skottmckay skottmckay requested a review from edgchen1 March 31, 2021 03:21
@skottmckay skottmckay requested a review from a team as a code owner March 31, 2021 03:21
ORT_SPECIFY_OP_KERNEL_ARG_REQUIRED_TYPES_ALL_OPSETS(
kCpuExecutionProvider, kOnnxDomain, Gather, Input, 1, int64_t);
}
kCpuExecutionProvider, kOnnxDomain, Gather, Input, 1, int32_t, int64_t);
Copy link
Contributor

Choose a reason for hiding this comment

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

int32_t, int64_t [](start = 58, length = 16)

if the default and required types are the same, there's not really a reason to have the type reduction here at all. but it's fine to clean that up later too

Copy link
Contributor

Choose a reason for hiding this comment

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

same comment for Slice input 1


In reply to: 605087765 [](ancestors = 605087765)

OrtPybindThrowIfError(sess->FilterEnabledOptimizers(disabled_optimizer_names));
}
#else
ORT_UNUSED_PARAMETER(disabled_optimizer_names);
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be useful to print a warning that disabled optimizer names will be ignored if any are provided?

Copy link
Contributor

@edgchen1 edgchen1 left a comment

Choose a reason for hiding this comment

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

:shipit:

@skottmckay skottmckay merged commit 329fd03 into master Apr 1, 2021
@skottmckay skottmckay deleted the skottmckay/AddInt32AsRequiredTypeToSomeOps branch April 1, 2021 09:32
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