Skip to content

Commit

Permalink
Update new python api (#5102)
Browse files Browse the repository at this point in the history
* update doc of new python api

* fix some doc

* update

* update dygraph mode

* modify with review
  • Loading branch information
zyfncg committed Aug 2, 2022
1 parent 2b2d048 commit 35d61ff
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 174 deletions.
Binary file modified docs/dev_guides/api_contributing_guides/code_gen_by_yaml.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 2 additions & 8 deletions docs/dev_guides/api_contributing_guides/new_cpp_op_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -773,13 +773,7 @@ def trace(x, offset=0, axis1=0, axis2=1, name=None):
if in_dygraph_mode():
return _C_ops.final_state_trace( x, offset, axis1, axis2 )

if _in_legacy_dygraph():
return _C_ops.trace(x, 'offset', offset, 'axis1', axis1, 'axis2', axis2)

inputs = {'Input': [x]}
attrs = {'offset': offset, 'axis1': axis1, 'axis2': axis2}
helper = LayerHelper('trace', **locals())

out = helper.create_variable_for_type_inference(dtype=x.dtype)

helper.append_op(
Expand All @@ -794,8 +788,8 @@ def trace(x, offset=0, axis1=0, axis2=1, name=None):

- Python API 实现要点(详见[飞桨API Python 端开发指南](./new_python_api_cn.html)
- 对输入参数进行合法性检查,即 `__check_input(input, offset, axis1, axis2)`
- 添加动态图分支调用,即 `if in_dygraph_mode` 新动态图分支和 `if _in_legacy_dygraph` 旧动态图分支
- 添加静态图分支调用,即dygraph分支后剩余的代码
- 添加动态图分支调用,即 `if in_dygraph_mode` 进入动态图调用分支
- 添加静态图分支调用,即动态图分支后剩余的代码


## 5. 添加单元测试
Expand Down

0 comments on commit 35d61ff

Please sign in to comment.