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

Fix squeeze and concat when all tensors are 0 sized #1199

Merged
merged 9 commits into from
Aug 1, 2018
Merged

Conversation

dsmilkov
Copy link
Contributor

@dsmilkov dsmilkov commented Aug 1, 2018

  • Make sure squeeze() on zero-sized tensors works.
  • Make sure concat(inputs) where all inputs are zero-sized works.

Both changes are motivated by bugs showing up on ssd_mobilenet_v2_coco

BUG


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.

Reviewed 8 of 8 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @dsmilkov, @nsthorat, and @pyu10055)


src/tensor_test.ts, line 945 at r1 (raw file):

    const a = tf.tensor3d([], [0, 1, 0]);
    const res = tf.squeeze(a);
    expect(res.shape).toEqual([0, 0]);

this is so weird lol

Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r1.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @dsmilkov and @pyu10055)


src/ops/concat_util.ts, line 42 at r1 (raw file):

export function computeOutShape(shapes: number[][], axis: number): number[] {
  const outputShape = shapes[0].slice();

do you need to make sure the shapes have the same rank?

Copy link
Contributor Author

@dsmilkov dsmilkov 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: :shipit: complete! 1 of 1 approvals obtained (waiting on @dsmilkov)


src/tensor_test.ts, line 945 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

this is so weird lol

I know.. but caused exception on coco_ssd model, so we have to fix it :)


src/ops/concat_util.ts, line 42 at r1 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

do you need to make sure the shapes have the same rank?

The check I removed was redundant since the assertParams() method above does the validation, which we call before we call this method.

Copy link
Collaborator

@pyu10055 pyu10055 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: :shipit: complete! 1 of 1 approvals obtained

@tensorflow tensorflow deleted a comment from googlebot Aug 1, 2018
@dsmilkov dsmilkov merged commit 95bae20 into master Aug 1, 2018
@dsmilkov dsmilkov deleted the zero-shape branch August 1, 2018 22:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants