Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Add depthToSpace op #1220

Merged
merged 6 commits into from
Aug 29, 2018
Merged

Add depthToSpace op #1220

merged 6 commits into from
Aug 29, 2018

Conversation

jgartman
Copy link
Contributor

@jgartman jgartman commented Aug 12, 2018

Description

Adds depthToSpace to the library
tensorflow/tfjs#329


For repository owners only:

Please remember to apply all applicable tags to your pull request.
Tags: FEATURE, BREAKING, BUG, PERF, DEV, DOC, SECURITY

For more info see: https://github.com/tensorflow/tfjs/blob/master/DEVELOPMENT.md


This change is Reviewable

Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 approvals obtained (waiting on @jgartman)


src/tensor.ts, line 1190 at r1 (raw file):

  }

  depthToSpace(this: Tensor4D, blockSize: number, dataFormat: 'NHwC'|'NCHW'):

capital w?


src/kernels/webgl/depth_to_space_gpu.ts, line 1 at r1 (raw file):

import {GPGPUProgram} from './gpgpu_math';

license at the top here


src/kernels/webgl/depth_to_space_gpu.ts, line 26 at r1 (raw file):

      int offset_h = int(mod(float(h), float(${blockSize})));
      int in_w = w / ${blockSize};
      int offset_w = int(mod(float(w), float(${blockSize})));

can you use imod?


src/ops/array_ops_test.ts, line 3539 at r1 (raw file):

  });

  it('tensor4d, input shape=[1, 4, 2, 2], blockSize=2, format=NCHW', () => {

Just curious, when I run this python code:

x = tf.constant([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], shape=[1, 4, 2, 2])
a = tf.depth_to_space(x, 2, 'NCHW')
print(a)

I get "InvalidArgumentError: Input depth dimension 2 should be divisible by: 4 [Op:DepthToSpace] name: NCHW"

Any idea what's going on there?

Copy link
Contributor Author

@jgartman jgartman left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 approvals obtained (waiting on @jgartman)


src/ops/array_ops_test.ts, line 3539 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

Just curious, when I run this python code:

x = tf.constant([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], shape=[1, 4, 2, 2])
a = tf.depth_to_space(x, 2, 'NCHW')
print(a)

I get "InvalidArgumentError: Input depth dimension 2 should be divisible by: 4 [Op:DepthToSpace] name: NCHW"

Any idea what's going on there?

Can you try:

x = tf.constant([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], shape=[1, 4, 2, 2])
a = tf.depth_to_space(x, 2, data_format='NCHW')
print(a)

Otherwise it will use NCHW as the name of the tensor and use the default data format which is NHWC. I made the same mistake when I was testing and it took me a few minutes to realize what was going on.

Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 7 files at r2, 4 of 4 files at r3.
Reviewable status: 0 of 1 approvals obtained (waiting on @nsthorat)

@nsthorat nsthorat merged commit d3b69a0 into tensorflow:master Aug 29, 2018
@jgartman jgartman deleted the depthToSpace branch October 20, 2018 16:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants