dispatch_utils.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Adapted from
  3. * https://github.com/pytorch/pytorch/blob/v2.0.1/aten/src/ATen/Dispatch.h
  4. */
  5. #include <torch/extension.h>
  6. #define APHRODITE_DISPATCH_CASE_FLOATING_TYPES(...) \
  7. AT_DISPATCH_CASE(at::ScalarType::Float, __VA_ARGS__) \
  8. AT_DISPATCH_CASE(at::ScalarType::Half, __VA_ARGS__) \
  9. AT_DISPATCH_CASE(at::ScalarType::BFloat16, __VA_ARGS__)
  10. #define APHRODITE_DISPATCH_FLOATING_TYPES(TYPE, NAME, ...) \
  11. AT_DISPATCH_SWITCH( \
  12. TYPE, NAME, APHRODITE_DISPATCH_CASE_FLOATING_TYPES(__VA_ARGS__))
  13. #define APHRODITE_DISPATCH_CASE_FLOATING_BYTE_TYPES(...) \
  14. AT_DISPATCH_CASE(at::ScalarType::Float, __VA_ARGS__) \
  15. AT_DISPATCH_CASE(at::ScalarType::Half, __VA_ARGS__) \
  16. AT_DISPATCH_CASE(at::ScalarType::BFloat16, __VA_ARGS__) \
  17. AT_DISPATCH_CASE(at::ScalarType::Byte, __VA_ARGS__)
  18. #define APHRODITE_DISPATCH_FLOATING_BYTE_TYPES(TYPE, NAME, ...) \
  19. AT_DISPATCH_SWITCH( \
  20. TYPE, NAME, APHRODITE_DISPATCH_CASE_FLOATING_BYTE_TYPES(__VA_ARGS__))
  21. #define APHRODITE_DISPATCH_CASE_INTEGRAL_TYPES(...) \
  22. AT_DISPATCH_CASE(at::ScalarType::Byte, __VA_ARGS__) \
  23. AT_DISPATCH_CASE(at::ScalarType::Char, __VA_ARGS__) \
  24. AT_DISPATCH_CASE(at::ScalarType::Short, __VA_ARGS__) \
  25. AT_DISPATCH_CASE(at::ScalarType::Int, __VA_ARGS__) \
  26. AT_DISPATCH_CASE(at::ScalarType::Long, __VA_ARGS__)
  27. #define APHRODITE_DISPATCH_INTEGRAL_TYPES(TYPE, NAME, ...) \
  28. AT_DISPATCH_SWITCH( \
  29. TYPE, NAME, APHRODITE_DISPATCH_CASE_INTEGRAL_TYPES(__VA_ARGS__))