Revision 3141686451b4439d0d6c5f6ee1789feec121fa5e authored by Gregory Chanan on 11 October 2016, 16:43:09 UTC, committed by Gregory Chanan on 08 November 2016, 21:01:05 UTC
Does as much math as possible in accreal to try to suss out why CudaHalfTensor fails.
1 parent e3d7d12
Raw File
Sqrt.cu
#include "THCUNN.h"
#include "THCHalf.h"
#include "THCHalfAutoNumerics.cuh"

template <typename T>
struct sqrtupdateOutput_functor
{
  const T bias;

  sqrtupdateOutput_functor(T bias_)
    : bias(bias_)
  {}

  __device__ void operator()(T *output, const T *input) const
  {
    *output = sqrt(*input + bias);
  }
};

template <typename T>
struct sqrtupdateGradInput_functor
{
  sqrtupdateGradInput_functor() {}

  __device__ void operator()(T *gradInput, const T *output, const T *gradOutput) const
  {
    *gradInput = (THCNumerics<T>::eq(*output,ScalarConvert<float, T>::to(0.0f))) ? ScalarConvert<float, T>::to(0.0f) : ((ScalarConvert<float, T>::to(0.5f) * *gradOutput) / *output);
  }
};

#include "generic/Sqrt.cu"
#include "THCGenerateFloatTypes.h"
back to top