ReduceOps.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #pragma once
  3. #include <ATen/native/DispatchStub.h>
  4. #include <c10/util/ArrayRef.h>
  5. #include <optional>
  6. namespace c10 {
  7. class Scalar;
  8. }
  9. namespace at {
  10. struct TensorIterator;
  11. class Tensor;
  12. }
  13. namespace at::native {
  14. using reduce_fn = void(*)(TensorIterator &);
  15. DECLARE_DISPATCH(reduce_fn, sum_stub)
  16. DECLARE_DISPATCH(reduce_fn, nansum_stub)
  17. DECLARE_DISPATCH(reduce_fn, prod_stub)
  18. DECLARE_DISPATCH(reduce_fn, mean_stub)
  19. DECLARE_DISPATCH(reduce_fn, and_stub)
  20. DECLARE_DISPATCH(reduce_fn, or_stub)
  21. DECLARE_DISPATCH(reduce_fn, min_values_stub)
  22. DECLARE_DISPATCH(reduce_fn, max_values_stub)
  23. DECLARE_DISPATCH(reduce_fn, argmax_stub)
  24. DECLARE_DISPATCH(reduce_fn, argmin_stub)
  25. DECLARE_DISPATCH(reduce_fn, xor_sum_stub)
  26. using reduce_std_var_function =
  27. void (*)(TensorIterator&, double correction, bool take_sqrt);
  28. DECLARE_DISPATCH(reduce_std_var_function, std_var_stub)
  29. using reduce_norm_fn =
  30. void (*)(Tensor&, const Tensor&, const c10::Scalar&, std::optional<int64_t>);
  31. DECLARE_DISPATCH(reduce_norm_fn, norm_kernel)
  32. using reduce_fn_flag = void(*)(TensorIterator &, const c10::Scalar&);
  33. DECLARE_DISPATCH(reduce_fn_flag, norm_stub)
  34. DECLARE_DISPATCH(reduce_fn_flag, powsum_stub)
  35. using structured_cum_fn = void (*)(const Tensor&, const Tensor&, int64_t);
  36. using cum_fn = void (*)(Tensor&, const Tensor&, int64_t);
  37. DECLARE_DISPATCH(structured_cum_fn, cumsum_stub)
  38. DECLARE_DISPATCH(structured_cum_fn, cumprod_stub)
  39. DECLARE_DISPATCH(cum_fn, logcumsumexp_stub)
  40. DECLARE_DISPATCH(void (*)(const Tensor&, int64_t, bool, Tensor&, Tensor&), aminmax_stub)
  41. DECLARE_DISPATCH(void (*)(const Tensor&, Tensor&, Tensor&), aminmax_allreduce_stub)
  42. // Used in cuda/Normalization.cu
  43. TORCH_API std::tuple<Tensor&,Tensor&> var_mean_out(
  44. Tensor &result1, Tensor &result2, const Tensor &self, IntArrayRef dim,
  45. int64_t correction, bool keepdim);
  46. } // namespace at::native
  47. #else
  48. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  49. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)