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

Relation between at::Half and __half #81

Open
SakuraRiven opened this issue Feb 25, 2023 · 0 comments
Open

Relation between at::Half and __half #81

SakuraRiven opened this issue Feb 25, 2023 · 0 comments

Comments

@SakuraRiven
Copy link

Hi, we want to create atomicMax function with __half inputs by following pytorch_scatter/atomics.cuh at master. The detailed codes are

inline __device__ void operator()(at::Half *address, at::Half val) {       \
  unsigned int *address_as_ui =                                            \
      (unsigned int *)((char *)address - ((size_t)address & 2));           \
  unsigned int old = *address_as_ui;                                       \
  unsigned int assumed;                                                    \
                                                                           \
  do {                                                                     \
    assumed = old;                                                         \
    at::Half hsum;                                                         \
    hsum.x = (size_t)address & 2 ? (old >> 16) : (old & 0xffff);           \
    hsum = OP(hsum, val);                                                  \
    old = (size_t)address & 2 ? (old & 0xffff) | (hsum.x << 16)            \
                              : (old & 0xffff0000) | hsum.x;               \
    old = atomicCAS(address_as_ui, assumed, old);                          \
  } while (assumed != old);                                                \
}                                                                          \

When it comes to the __half type, however, we do not how to obtain the hsum.x. Are there some ways to convert as::Half and __half each other?

Also, how could we implement OP as max to deal with __half inputs?

Thanks : )

@SakuraRiven SakuraRiven changed the title Conversion between at::Half and __half Relation between at::Half and __half Feb 25, 2023
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

No branches or pull requests

1 participant