Skip to content

BatchNormalization should be an optional operation #187

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
pyu10055 opened this issue Jun 24, 2021 · 3 comments · Fixed by #638
Closed

BatchNormalization should be an optional operation #187

pyu10055 opened this issue Jun 24, 2021 · 3 comments · Fixed by #638
Labels

Comments

@pyu10055
Copy link
Collaborator

BatchNormalization usually are optimized away for inference (fused into conv2d op filter and bias), for example TFLite does not have this op, for compatibility purpose we shall move this op to optional section of the spec.

@wchao1115
Copy link
Collaborator

wchao1115 commented Jun 28, 2021

BatchNorm is actually fully supported as a native operation in DirectML. It is true that for performance benefit it is often fused with the preceding convolution and following relu activation. However, those are framework choices to make. The WebNN implementer can also choose to apply that same fusion at the backend through the graph compilation step. But again, it is not a requirement that this fusion must be made at all time. A backend implementation should be allowed to treat BatchNorm as a standalone operation, or fuse it with just the following relu, etc. I think it's still an implementation choice.

@pyu10055
Copy link
Collaborator Author

pyu10055 commented Jul 8, 2021

Thanks, @wchao1115. Given that TF Lite does not have this op, would it be ok to mark it as optional in the spec? It's fine if the DirectML implementation includes it by default. It would be nice if the spec focuses first on what's common to all the major ML frameworks.

@wchao1115
Copy link
Collaborator

wchao1115 commented Jul 11, 2021

For the implementation that lacks native support for this operation, it can be entirely implemented by compositing other operations as illustrated in the note section of the batchNormalization operation spec. I don't think we can define this operation as optional because it'll break the user's expectation.

inexorabletash added a commit to inexorabletash/webnn that referenced this issue Apr 5, 2024
Many complex operations in the spec are given decompositions, showing
how the operation could be replaced through the use of more primitive
operations. This text is repeated in many places. Improve this in two
ways:

* Use Bikeshed's Text Macro[1] to reduce the repetition.

* Streamline the text, and make it explicit that if the underlying
  platform doesn't support an operation, WebNN API implementations can
  use the decomposition as a guide to emulate it.

The macro [EMULATED] is used at the end of an intro sentence since
there are variations - some of the decompositions are grouped, and
some make assumptions (e.g. activation functions, layouts, etc).

If we assume that implementations must implement all operations in the
spec, either via the underlying platform or emulation, this fixes webmachinelearning#187

[1] https://speced.github.io/bikeshed/#metadata-text-macro
inexorabletash added a commit to inexorabletash/webnn that referenced this issue Apr 5, 2024
Many complex operations in the spec are given decompositions, showing
how the operation could be replaced through the use of more primitive
operations. This text is repeated in many places. Improve this in two
ways:

* Use Bikeshed's Text Macro[1] to reduce the repetition.

* Streamline the text, and make it explicit that if the underlying
  platform doesn't support an operation, WebNN API implementations can
  use the decomposition as a guide to emulate it.

The macro [EMULATED] is used at the end of an intro sentence since
there are variations - some of the decompositions are grouped, and
some make assumptions (e.g. activation functions, layouts, etc).

If we assume that implementations must implement all operations in the
spec, either via the underlying platform or emulation, this fixes webmachinelearning#187

[1] https://speced.github.io/bikeshed/#metadata-text-macro
@fdwr fdwr closed this as completed in #638 Apr 16, 2024
fdwr pushed a commit that referenced this issue Apr 16, 2024
…638)

Many complex operations in the spec are given decompositions, showing
how the operation could be replaced through the use of more primitive
operations. This text is repeated in many places. Improve this in two
ways:

* Use Bikeshed's Text Macro[1] to reduce the repetition.

* Streamline the text, and make it explicit that if the underlying
  platform doesn't support an operation, WebNN API implementations can
  use the decomposition as a guide to emulate it.

The macro [EMULATED] is used at the end of an intro sentence since
there are variations - some of the decompositions are grouped, and
some make assumptions (e.g. activation functions, layouts, etc).

If we assume that implementations must implement all operations in the
spec, either via the underlying platform or emulation, this fixes #187

[1] https://speced.github.io/bikeshed/#metadata-text-macro
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants