As I’m tracking down the source code in aten/src/ATen/native/cuda/PowKernel.cu file, as you see there is a lot of host and device functions that would call some std::pow()
and also global ‘::pow()’ functions. But I’m not sure where are those functions defined? I mean in <cmath>
there is std::pow on the host side, if I remember that correctly. But where are the device side definition? I think it must be overloaded somewhere, right?
So there must be device side explicitly defined and specialized std::pow(). Is it defined inside pytorch or from the compilers? Could you tell where that could be?
Here is the code from PowKernel.cu file:
#ifdef _MSC_VER
// Functions for pow
// pow for at::Half
static inline __host__ __device__ at::Half pow_(at::Half base, at::Half exp) {
return static_cast<at::Half>(std::pow(static_cast<float>(base), static_cast<float>(exp)));
}
...
#else
template <typename Base_type, typename Exp_type>
static inline __host__ __device__ Base_type pow_(Base_type base, Exp_type exp) {
return ::pow(base, exp);
}
Question: where can I find the std::pow()
function and ::pow()
's definitions?