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

Add bitwise and compare ops #47

Closed
wants to merge 22 commits into from
Closed

Add bitwise and compare ops #47

wants to merge 22 commits into from

Conversation

xytintel
Copy link
Contributor

e.g. isnan, clamp, clamp_min, clamp_max, bitwise_and, bitwise_or, bitwise_xor, bitwise_not, _local_scalar_dense

q.memcpy(
(void*)value.const_data_ptr<scalar_t>(),
self.const_data_ptr<scalar_t>(),
sizeof(scalar_t));
Copy link
Contributor

Choose a reason for hiding this comment

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

Need synchronize the copy, or the value on host could not be valid.


template <typename opmath_t>
struct ClampMaxFunctor {
opmath_t operator()(opmath_t v) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

AT_DISPATCH_ALL_TYPES_AND2(
kHalf, kBFloat16, iter.dtype(), "clamp_min_xpu", [&]() {
auto lower = min_value.to<scalar_t>();
gpu_kernel(iter, ClampMinFunctor<scalar_t>(lower));
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto, checking opmath.

AT_DISPATCH_ALL_TYPES_AND2(
kHalf, kBFloat16, iter.dtype(), "clamp_max_xpu", [&]() {
auto upper = max_value.to<scalar_t>();
gpu_kernel(iter, ClampMaxFunctor<scalar_t>(upper));
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto, checking opmath.

@xytintel
Copy link
Contributor Author

split pr

@xytintel xytintel closed this Mar 26, 2024
@fengyuan14 fengyuan14 mentioned this pull request Mar 27, 2024
@xytintel xytintel deleted the xyt/bitwise branch April 3, 2024 08:28
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