/usr/local/lib64/python3.6/site-packages/torch/include/caffe2/operators
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/caffe2/operators/gelu_op.h (1452B)
#ifndef CAFFE2_OPERATORS_GELU_OP_H_
#define CAFFE2_OPERATORS_GELU_OP_H_
#include "caffe2/core/common.h"
#include "caffe2/core/context.h"
#include "caffe2/core/export_caffe2_op_to_c10.h"
#include "caffe2/core/operator.h"
#include "caffe2/operators/elementwise_ops.h"
C10_DECLARE_EXPORT_CAFFE2_OP_TO_C10(Gelu);
namespace caffe2 {
namespace gelu_utils {
constexpr float kFastCoeff = 0.044715f;
} // namespace gelu_utils
template
struct GeluFunctor {
explicit GeluFunctor(OperatorBase& op)
: fast_gelu(op.GetSingleArgument("fast_gelu", false)) {}
template
bool operator()(const int N, const T* X, T* Y, Context* context) const;
const bool fast_gelu;
};
template
struct GeluGradientFunctor {
explicit GeluGradientFunctor(OperatorBase& op)
: fast_gelu(op.GetSingleArgument("fast_gelu", false)) {}
template
bool Forward(
const std::vector& dY_dims,
const std::vector& X_dims,
const T* dY,
const T* X,
T* dX,
Context* context) const;
const bool fast_gelu;
};
template
using GeluOp = UnaryElementwiseWithArgsOp<
TensorTypes,
Context,
GeluFunctor>;
template
using GeluGradientOp = BinaryElementwiseWithArgsOp<
TensorTypes,
Context,
GeluGradientFunctor>;
} // namespace caffe2
#endif // CAFFE2_OPERATORS_GELU_OP_H_