提交 1f713f68 编写于 作者: Y Yi Wang

in response to comments from Jia-Yi

上级 90a44282
# Design Doc: Layers and Operators
# Design Doc: Functions, Operators, and Layers
In a DL system, we can compose one or more fine grained operators into a coarse grained one. For example, the FC layer can be composed of a multiplication operator and an add operator.
......@@ -20,8 +20,8 @@ Then we can wrap them into operators which are C++ classes and can be created fr
generates
```c++
class mulOp : public OperatorBase {...};
REGISTER_OP(mulOp, "mul");
template <typename T> class mulOp : public OperatorBase {...};
REGISTER_OP(mulOp<float32>, "mul");
```
so that in Python we can create operator mul by:
......@@ -36,12 +36,13 @@ paddle.cpp.create_operator("mul", input=[X1, X2], output=Y)
Also, at the same time, we can compose a coarse level C++ operator class by composing functions `mul` and `add`:
```c++
template <typename T>
class FCOp : public OperatorBase {
public:
void Run(...) {
add(mul(Input("X"), Input("W")), Input("b");
add(mul(Input<T>("X"), Input<T>("W")), Input<T>("b");
}
};
};d
REGISTER_OP(FCOp, "fc");
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册