Skip to content

Conversation

@annxingyuan
Copy link
Contributor

@annxingyuan annxingyuan commented Sep 10, 2020

Adds modularized StridedSlice kernel to WASM backend. This makes it possible to create a modularized WASM build for the blazeface model.

There is still a lot of logic duplicated between the new kernel and the forwardFunc in the op. I moved a little of it out into slice_util, but I thought it might be best to hold off on the rest until we modularize StridedSlice for a second backend.

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@annxingyuan annxingyuan self-assigned this Sep 10, 2020
Copy link
Collaborator

@lina128 lina128 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 @annxingyuan, @lina128, and @tafsiri)


tfjs-backend-wasm/src/kernels/StridedSlice.ts, line 3 at r1 (raw file):

/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.

2020


tfjs-backend-wasm/src/kernels/StridedSlice.ts, line 114 at r1 (raw file):

  }

  const out = backend.makeOutput(outShape, 'float32');

Hi Ann, just curious, why the large chunk of code is in JS but not in c++?


tfjs-core/src/backends/backend_util.ts, line 40 at r1 (raw file):

import * as slice_util from '../ops/slice_util';
export {slice_util};

Why not export * from '../ops/slice_util' Is there naming conflict?


tfjs-core/src/ops/strided_slice.ts, line 67 at r1 (raw file):

f (strides == null) {
    strides = new Array(begin.length);
  }

This part of the code should be in forward.

Copy link
Contributor Author

@annxingyuan annxingyuan 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 @lina128 and @tafsiri)


tfjs-backend-wasm/src/kernels/StridedSlice.ts, line 3 at r1 (raw file):

Previously, lina128 (Na Li) wrote…

2020

Done.


tfjs-backend-wasm/src/kernels/StridedSlice.ts, line 114 at r1 (raw file):

Previously, lina128 (Na Li) wrote…

Hi Ann, just curious, why the large chunk of code is in JS but not in c++?

The chunk of code above normalizing the begin / end axes? It's cheap to run (despite its length), so keeping it in JS will allow it to be shared between cpu/webgl/wasm kernels.


tfjs-core/src/backends/backend_util.ts, line 40 at r1 (raw file):

Previously, lina128 (Na Li) wrote…

Why not export * from '../ops/slice_util' Is there naming conflict?

Yes, there's a naming conflict with computeOutShape.


tfjs-core/src/ops/strided_slice.ts, line 67 at r1 (raw file):

Previously, lina128 (Na Li) wrote…
f (strides == null) {
    strides = new Array(begin.length);
  }

This part of the code should be in forward.

Done.

@annxingyuan annxingyuan merged commit 0870219 into master Sep 11, 2020
@annxingyuan annxingyuan deleted the wasm_ss branch September 11, 2020 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants