This repository was archived by the owner on Oct 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
Add maxPooling3d layer & averagePooling3d layer #555
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Jun 6, 2019
dsmilkov
pushed a commit
to tensorflow/tfjs-core
that referenced
this pull request
Aug 8, 2019
This PR adds `avgPool3d` op & `maxPool3d` op with CPU and WebGL implementation, supports inference and gradient. The APIs align with TensorFlow’s Python API [tf.nn.avg_pool3d](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/avg_pool3d) and [tf.nn.max_pool3d](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/max_pool3d). The `avgPool3d` & `maxPool3d` ops support `tf.layers.averagePooling3d` & `tf.layers.maxPooling3d` (feature requested in [tensorflow/tfjs#1035](tensorflow/tfjs#1035)). As a checklist, features in this PR: * Add `tf.avgPool3d` to ops * Add `tf.maxPool3d` to ops * Add `avgPool3d` kernel to handle `tf.avgPool3d`’s prediction * Add `maxPool3d` kernel to handle `tf.maxPool3d`’s prediction * Add private helper `pool3d` function in CPU kernel as the implementation of `avgPool3d` kernel and `maxPool3d` kernel in CPU end * Add `Pool3DProgram` in WebGL kernel as the implementation of `avgPool3d` kernel and `maxPool3d` kernel in GPU end * Add `avgPool3dBackprop` kernel to handle `tf.avgPool3d`’s gradient * Add `avgPool3dBackprop` CPU kernel implementation * Add `AvgPool3DBackpropProgram` as the implementation of `avgPool3dBackprop` WebGL kernel * Add `maxPool3dBackprop` kernel to handle `tf.maxPool3d`’s gradient * Add `maxPool3dBackprop` CPU kernel implementation * Add a private helper function `maxPool3dPositions` for maxPool3dBackprop in CPU kernel * Add `MaxPool3DBackpropProgram` as the implementation of `maxPool3dBackprop` WebGL kernel * Integrate WebGL end’s `maxPool3dPositions` helper function into Pool3DProgram * Add a `computePool3DInfo` util function to compute operation information for `avgPool3d` & `maxPool3d` * Make check function `eitherStridesOrDilationsAreOne` support 3D input * Add 14 unit tests for `avgPool3d` (one test case failed in nodejs env as TF Backend doesn’t support `NUMBER` pad mode) * Add 7 unit tests for `avgPool3dBackprop` * Add 13 unit tests for `maxPool3d` (one test case failed in nodejs env as TF Backend doesn’t support `NUMBER` pad mode) * Add 10 unit tests for `maxPool3dBackprop` * Add 8 unit tests for util function `computePool3DInfo` * Export `Tensor5D `type * Add jsdocs and executable examples for website api documentation I built a local website, if everything goes well, the `avgPool3d` and `maxPool3d` APIs would lie in `Operations/Convolution` section and look like the screen shot below: <img width="1184" alt="Screen Shot 2019-06-06 at 1 32 30 AM" src="https://user-images.githubusercontent.com/7977100/59018883-c13c3400-87fb-11e9-8f36-316edab35231.png"> **Relative PRs:** * Make nodejs kernel support avgPool3d & maxPool3d [tensorflow/tfjs-node#256](tensorflow/tfjs-node#256) * Add averagePooling3d layer & maxPooling3d layer [tensorflow/tfjs-layers#555](tensorflow/tfjs-layers#555) * Add avgPool3d & maxPool3d ops for graph model [tensorflow/tfjs-converter#375](tensorflow/tfjs-converter#375) **Reference:** * [tf.nn.avg_pool3d TensorFlow Python API](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/avg_pool3d) * [tf.nn.max_pool3d TensorFlow Python API](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/max_pool3d) --- To see the logs from the Cloud Build CI, please join either our [discussion](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs) or [announcement](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs-announce) mailing list. FEATURE
caisq
approved these changes
Aug 15, 2019
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.
Thanks, @syt123450
Will merge as soon as the tests pass.
Thanks for the review @caisq ! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds
averagePooling3d
layer &maxPooling3d
layer(feature requested in tensorflow/tfjs#1035).Features in this PR:
pool3d
function to compute 3D poolingpool3d
functionPooling3DLayerArgs
interfacePooling3D
classMaxPooling3D
classAveragePooling3D
classaveragePooling3d
layeraveragePooling3d
layermaxPooling3d
layermaxPooling3d
layerNote:
This PR depends on PR tensorflow/tfjs-core#1778, which adds
maxPool3d
op,avgPool3d
op, and exportsTensor5D
type.Reference:
To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.
This change is