Skip to content

Conversation

@0x45f
Copy link
Contributor

@0x45f 0x45f commented Nov 17, 2021

@paddle-bot-old
Copy link

Thanks for your contribution!

net = SimpleNet()
x = paddle.rand([2, 10])
y = paddle.rand([2, 3])
out = net(x, y)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里也加一下jit.save的导出代码吧,下面方式的case也加一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,440 @@
# 转换原理

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可以加几句概括性的话,简单介绍或引入下面的几个模块内容,比如类似,动转静模块在转换上,主要包括对XXX,XXX的处理.....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# 案例解析


[【基础接口用法】](./basic_usage_cn.html)章节我们介绍了动转静的用法和机制,下面会结合一些具体的模型代码,解答动转静中比较常见的问题。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[基础接口用法](./basic_usage_cn.html)章节我们介绍了动转静的用法和机制,下面会结合一些具体的模型代码,解答动转静中比较常见的问题。
[使用样例](./basic_usage_cn.html)章节我们介绍了动转静的用法和机制,下面会结合一些具体的模型代码,解答动转静中比较常见的问题。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

x_spec = InputSpec(shape=[None, 3], dtype='float32', name='x')

# step 3: @to_static 装饰
static_func = to_static(net.another_func, input_spec=[x_spec])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里最好把 simplenet的class定义也放进来,用户可能不知道anotherfunc怎么定义的

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


在框架内部,动转静模块在转换上主要包括对InputSpec的处理,对函数调用的递归转写,对IfElse、For、While控制语句的转写,以及Layer的Parameters和Buffers变量的转换。下面将从这四个方面介绍动转静模块的转换原理。

## 一、 输入层 InputSpec
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里换一个标题吧,比如设置 Placeholder? 要描述操作的目的,而不是我们提供的API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改为设置 Placeholder 信息

@TCChenlong TCChenlong merged commit ab21e76 into PaddlePaddle:develop Dec 1, 2021
@0x45f 0x45f deleted the dy2stat_refine_docs branch December 2, 2021 02:52
TCChenlong added a commit that referenced this pull request Dec 7, 2021
* Move @to_static pnd into parent dir (#4045)

* Refactor @to_static tutorial doc (#4044)

* Refactor @to_static turial doc

* polish code

* refine content

* refine doc

* fix web link

* polish doc

* fix code style

* Refine dy2stat docs (#4103)

* refine dy2stat docs

* fix index_cn.rst

* fix code review

* modify the explanation for imgs

* change title

* 动转静概述更新 (#4099)

* 动转静概述更新

更新动转静概述章节,补充两个Block,什么是动态图和静态图,什么场景下需要动态图转成静态图

* 动转静概述更新

增加动转静方案示意图

* update style

update style

* update style

* Update index_cn.rst

* 修复格式问题

* update codes

Co-authored-by: Chen Long <[email protected]>

* fix jit (#4128)

* fix jit

* fix jit

* add jit example

* fix style

* fix style

* update to 2.2.1 (#4133)

Co-authored-by: Aurelius84 <[email protected]>
Co-authored-by: 0x45f <[email protected]>
Co-authored-by: moguguo <[email protected]>
Co-authored-by: Chen Long <[email protected]>
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.

3 participants