Skip to content
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

Merged
merged 3 commits into from
Oct 12, 2018
Merged

Update new_op_cn.md #136

merged 3 commits into from
Oct 12, 2018

Conversation

tink2123
Copy link
Collaborator

fix #132

@shanyi15 shanyi15 requested review from jetfuel and sneaxiy and removed request for jetfuel October 11, 2018 06:52
@shanyi15
Copy link
Contributor

请问是否有预览呢@tink2123

@shanyi15
Copy link
Contributor

这篇文档可能还有些其他的格式问题(看现在官网0.15.0的文档),这次一起检查好了更新一下吧

@tink2123
Copy link
Collaborator Author

@shanyi15 好的~那我现在统一调整一下这篇的格式

@@ -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.
Copy link
Collaborator

@sneaxiy sneaxiy Oct 11, 2018

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."

@@ -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,导致潜在的错误。
Copy link
Collaborator

@sneaxiy sneaxiy Oct 11, 2018

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,导致潜在的错误。

@tink2123
Copy link
Collaborator Author

tink2123 commented Oct 11, 2018

完成内容修正与格式调整,预览效果如下:
default

@shanyi15
Copy link
Contributor

image
这里项目符号和数字只保留一个就好~

Copy link
Contributor

@shanyi15 shanyi15 left a 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

@tink2123 tink2123 merged commit 17bbcc9 into develop Oct 12, 2018
@tink2123 tink2123 deleted the tink2123-patch-1 branch October 12, 2018 09:35
RichardWooSJTU pushed a commit to RichardWooSJTU/docs that referenced this pull request Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

《如何写新的operator》更新
3 participants