-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update new_op_cn.md #136
Update new_op_cn.md #136
Conversation
请问是否有预览呢@tink2123 |
这篇文档可能还有些其他的格式问题(看现在官网0.15.0的文档),这次一起检查好了更新一下吧 |
@shanyi15 好的~那我现在统一调整一下这篇的格式 |
doc/fluid/dev/new_op_cn.md
Outdated
@@ -150,8 +150,9 @@ class MulOp : public framework::OperatorWithKernel { | |||
|
|||
protected: | |||
void InferShape(const framework::InferShapeContext &ctx) const override { | |||
auto dim0 = ctx.Input<Tensor>("X")->dims(); | |||
auto dim1 = ctx.Input<Tensor>("Y")->dims(); | |||
//never use Input or Output if you want a to get a LoDTensor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it to be "never use Input<Tensor> or Output<Tensor> if you want a to get a LoDTensor."
doc/fluid/dev/new_op_cn.md
Outdated
@@ -201,16 +202,18 @@ MulOp(const std::string &type, const framework::VariableNameMap &inputs, | |||
- 与`InferShapeContext`相比,`ExecutionContext`增加了设备类型,同样可获取到输入输出和属性参数。 | |||
- `Compute`函数里实现`OpKernel`的具体计算逻辑。 | |||
|
|||
Op的输入和输出可分别通过ExecutionContext::Input()和ExecutionContext::Output()获得。注意:若op的输入/输出的变量类型是LoDTensor(fluid默认所有的Tensor默认都是LoDTensor类型),请写成ExecutionContext::Input()和ExecutionContext::Output(),不要写ExecutionContext::Input()和ExecutionContext::Output()。因为若实际的变量类型为SelectedRows,Input()和Output()方法会将SelectedRows类型特化为Tensor,导致潜在的错误。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Op的输入和输出可分别通过ExecutionContext::Input<T>()和ExecutionContext::Output<T>()获得。注意:若op的输入/输出的变量类型是LoDTensor(fluid默认所有的Tensor默认都是LoDTensor类型),请写成ExecutionContext::Input<LoDTensor>()和ExecutionContext::Output<LoDTensor>(),不要写ExecutionContext::Input<Tensor>()和ExecutionContext::Output<Tensor>()。因为若实际的变量类型为SelectedRows,Input<Tensor>()和Output<Tensor>()方法会将SelectedRows类型特化为Tensor,导致潜在的错误。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
辛苦cherrypick到1.0.0
fix #132