-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.