Skip to content
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

[wasm] Add MaxPoolWithArgmax kernel #7673

Merged
merged 5 commits into from
May 11, 2023

Conversation

chunnienc
Copy link
Collaborator

Quick implementation based on existing pool3d library. Will look into utilizing xnnpack in the future.

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

@chunnienc chunnienc marked this pull request as ready for review May 9, 2023 00:08
Copy link
Member

@mattsoulanille mattsoulanille left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +104 to +123
switch (dtype) {
case DType::float32:
MaxPoolWithArgmaxImpl(x_info.f32(), pooled_info.f32_write(),
indexes_info.i32_write(), include_batch_index,
pool_info);
break;
case DType::int32:
MaxPoolWithArgmaxImpl(x_info.i32(), pooled_info.i32_write(),
indexes_info.i32_write(), include_batch_index,
pool_info);
break;
case DType::boolean:
MaxPoolWithArgmaxImpl(x_info.b(), pooled_info.b_write(),
indexes_info.i32_write(), include_batch_index,
pool_info);
break;
default:
util::warn("MaxPoolWithArgmax for tensor id failed. Unknown dtype %d",
x_id, dtype);
}
Copy link
Member

Choose a reason for hiding this comment

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

I sort of wonder if this dtype switch could be a macro, but that would probably be unreadable and prone to bugs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, and that's part of the wasm-backend productionization work. Currently tensor type check in wasm kernels are not comprehensive and rely on switch branches everywhere. I will replace all of them with some type introspection in the future and correctly throw errors when unsupported. But before that I'd just use the old fashion so I can better find out where needs to be fixed when applying large scale changes.

@chunnienc chunnienc merged commit cf72ac0 into tensorflow:master May 11, 2023
@chunnienc chunnienc deleted the wasm-maxpoolargmax branch May 11, 2023 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants