Skip to content

Conversation

@dsmilkov
Copy link
Contributor

@dsmilkov dsmilkov commented Nov 18, 2019

Implement Padding, needed by almost all models. I added a fast implementation for up to rank-4 tensors, and a generic slow implementation for any rank.

FEATURE


This change is Reviewable

Copy link
Contributor

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


tfjs-backend-wasm/src/cc/kernels/PadV2.cc, line 137 at r1 (raw file):

  typed_memset<T>(out_data, pad_value, out_size);

  for (size_t i = 0; i < in_size; ++i) {

Would we be able to memcopy x_data in the generic case as well by looping over x_shape and paddings?

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


tfjs-backend-wasm/src/cc/kernels/PadV2.cc, line 137 at r1 (raw file):

Previously, annxingyuan (Ann Yuan) wrote…

Would we be able to memcopy x_data in the generic case as well by looping over x_shape and paddings?

Not sure how to do memcpy and work with arbitrary rank. Either way, this slow_pad_nd is a fallback and shouldn't be used by our models which have padding for rank<=4

@dsmilkov dsmilkov merged commit 9fa538d into master Nov 18, 2019
@dsmilkov dsmilkov deleted the pad branch November 18, 2019 15:52
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.

4 participants