-
Notifications
You must be signed in to change notification settings - Fork 297
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
fix dynamic shape inference in DepthToSpace #880
Conversation
Signed-off-by: Dom Miketa <[email protected]>
Signed-off-by: Dom Miketa <[email protected]>
@@ -40,7 +40,8 @@ def _common(cls, node, **kwargs): | |||
if mode == "CRD": | |||
# need native computation | |||
bsize = attrs.get("blocksize") | |||
batch, channel, height, width = x.shape | |||
x_shape = tf.shape(x) |
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.
First, thanks very much for making the contribution! If you don't mind, please consider use the utility method tf_shape, which takes care of both fully defined and dynamic shapes, and provides slight optimization for static shape.
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 for the suggestion, switched to tf_shape.
test/backend/test_dynamic_shape.py
Outdated
def test_depth_to_space(self): | ||
b,c,h,w = shape = [2, 48, 5, 6] |
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 code looks fine. Please run yapf as described in https://github.com/onnx/onnx-tensorflow#code-standard to keep the code format and style consistent. Thanks.
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.
Thank you for pointing out that document, done on both files.
c9ac540
to
fff017b
Compare
Signed-off-by: Dom Miketa <[email protected]>
Signed-off-by: Dom Miketa <[email protected]>
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.
LGTM!
Nets using DepthToSpace are currently incompatible with dynamic axes. It's enough to switch from
x.shape
totf.shape(x)
along with manual unrolling of the resulting 4-dimensional tensor (as one is not allowed to directly iterate over a tf.Tensor).Related to #543 and #771
Edit: Added a unittest. It's my first one and my second PR ever, so fingers crossed..!