| #include "caffe2/operators/log_op.h" |
| |
| #include <string> |
| #include <vector> |
| |
| namespace caffe2 { |
| |
| REGISTER_CPU_OPERATOR( |
| Log, |
| UnaryElementwiseOp<TensorTypes<float>, CPUContext, LogFunctor<CPUContext>>); |
| |
| OPERATOR_SCHEMA(Log) |
| .NumInputs(1) |
| .NumOutputs(1) |
| .AllowInplace({{0, 0}}) |
| .IdenticalTypeAndShape() |
| .SetDoc(R"DOC( |
| Calculates the natural log of the given input tensor, element-wise. This |
| operation can be done in an in-place fashion too, by providing the same input |
| and output blobs. |
| )DOC") |
| .Input(0, "input", "Input tensor") |
| .Output( |
| 0, |
| "output", |
| "The natural log of the input tensor computed " |
| "element-wise") |
| .InheritOnnxSchema("Log"); |
| |
| namespace { |
| |
| class GetLogGradient : public GradientMakerBase { |
| using GradientMakerBase::GradientMakerBase; |
| std::vector<OperatorDef> GetGradientDefs() override { |
| return SingleGradientDef( |
| "Div", |
| "", |
| std::vector<std::string>{GO(0), I(0)}, |
| std::vector<std::string>{GI(0)}); |
| } |
| }; |
| |
| } // namespace |
| |
| REGISTER_GRADIENT(Log, GetLogGradient); |
| |
| } // namespace caffe2 |