elementwise_mul_op.cc 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License. */

#include "paddle/operators/elementwise_mul_op.h"
16
#include "paddle/operators/elementwise_op.h"
17 18 19 20

namespace paddle {
namespace operators {

G
gongweibao 已提交
21
class ElementwiseMulOpMaker : public ElementwiseOpMaker {
22
 public:
G
gongweibao 已提交
23 24 25
  ElementwiseMulOpMaker(framework::OpProto* proto,
                        framework::OpAttrChecker* op_checker)
      : ElementwiseOpMaker(proto, op_checker) {
K
kexinzhao 已提交
26
    SetComment("Mul", "$Out = X \\odot\\ Y$");
G
gongweibao 已提交
27
    AddComment(comment_);
28 29 30 31 32 33 34
  }
};

}  // namespace operators
}  // namespace paddle

namespace ops = paddle::operators;
G
gongweibao 已提交
35 36
REGISTER_OP(elementwise_mul, ops::ElementwiseOp, ops::ElementwiseMulOpMaker,
            elementwise_mul_grad, ops::ElementwiseOpGrad);
37 38
REGISTER_OP_CPU_KERNEL(
    elementwise_mul,
39
    ops::ElementwiseMulKernel<paddle::platform::CPUPlace, float>,
D
Dong Zhihong 已提交
40 41 42
    ops::ElementwiseMulKernel<paddle::platform::CPUPlace, double>,
    ops::ElementwiseMulKernel<paddle::platform::CPUPlace, int>,
    ops::ElementwiseMulKernel<paddle::platform::CPUPlace, int64_t>);
43 44
REGISTER_OP_CPU_KERNEL(
    elementwise_mul_grad,
45
    ops::ElementwiseMulGradKernel<paddle::platform::CPUPlace, float>,
D
Dong Zhihong 已提交
46 47 48
    ops::ElementwiseMulGradKernel<paddle::platform::CPUPlace, double>,
    ops::ElementwiseMulGradKernel<paddle::platform::CPUPlace, int>,
    ops::ElementwiseMulGradKernel<paddle::platform::CPUPlace, int64_t>);