Files
pytorch/caffe2/operators/log1p_op.h
Oleg Khabinov 6145ac07b5 [caffe2] Reintroduce Log1p operator (#55073)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55073

Original diff D27422219 (d92e2520de) was reverted, reintroducing this op again.

Reviewed By: ChunliF

Differential Revision: D27473735

fbshipit-source-id: 1af0281724e9ada699ebf2045d51f65083daf5b4
2021-03-31 22:29:23 -07:00

35 lines
717 B
C++

#ifndef CAFFE2_OPERATORS_LOG1P_OP_H_
#define CAFFE2_OPERATORS_LOG1P_OP_H_
#include <vector>
#include "caffe2/operators/elementwise_ops.h"
#include "caffe2/utils/math.h"
namespace caffe2 {
template <class Context>
struct Log1pFunctor {
template <typename T>
bool operator()(const int N, const T* X, T* Y, Context* context) const {
math::Log1p(N, X, Y, context);
return true;
}
};
template <class Context>
struct Log1pGradientFunctor {
template <typename T>
bool Forward(
const std::vector<int>& X_dims,
const std::vector<int>& dY_dims,
const T* X,
const T* dY,
T* dX,
Context* context) const;
};
} // namespace caffe2
#endif // CAFFE2_OPERATORS_LOG1P_OP_H_