Skip to content

Conversation

@toyxu
Copy link
Contributor

@toyxu toyxu commented Mar 15, 2024

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.

@toyxu
Copy link
Contributor Author

toyxu commented Mar 26, 2024

split pr

@toyxu toyxu closed this Mar 26, 2024
@fengyuan14 fengyuan14 mentioned this pull request Mar 27, 2024
@toyxu toyxu 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.

4 participants