remove nets.py in fluid#51717
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
| "glu", | ||
| "scaled_dot_product_attention", | ||
| "img_conv_group", | ||
| ] |
| return out | ||
|
|
||
|
|
||
| def scaled_dot_product_attention( |
There was a problem hiding this comment.
需要明确每条单测的作用,进而确定单测使用到的函数的作用,原则上我们不为某个单测保留函数:
- 如果某个单测核心目的是测试某个其他功能,只是借助到这里的某个函数组网,那么这个函数可以作为依赖保留。例如
simple_img_conv_pool - 如果某个单测的核心目的就是测试这个函数,那么如果函数可以移除的话,单测也相应移除即可。例如
scaled_dot_product_attention。
| with dg.guard(place): | ||
| x_var = dg.to_variable(self.x) | ||
| y_var = fluid.nets.glu(x_var, self.dim) | ||
| y_var = paddle.nn.functional.glu(x_var, self.dim) |
There was a problem hiding this comment.
下面已有一个测试nn.functional.glu 的单测TestGLUV2,这个单测可直接移除
| import paddle.fluid as fluid | ||
| import paddle.fluid.layers as layers | ||
| import paddle.fluid.nets as nets | ||
| import paddle.fluid.tests.unittests.nets as nets |
There was a problem hiding this comment.
这里能否直接用.nets,这样使用会有类似API的感觉,下同。
|
修改好了~ |
| use_double_buffer=False, | ||
| ) | ||
|
|
||
| conv_pool_1 = fluid.nets.simple_img_conv_pool( |
There was a problem hiding this comment.
这个单测,从文件名看是测试执行器的,不应当在这个PR里移除
There was a problem hiding this comment.
我刚提交PR的时候发生冲突,发现这个文件test_async_ssa_graph_executor_mnist.py已经整个被删除了,所以才把这个文件删了来解决冲突的
| keys.stop_gradient = False | ||
|
|
||
| contexts = fluid.nets.scaled_dot_product_attention( | ||
| contexts = nets.scaled_dot_product_attention( |
There was a problem hiding this comment.
这个函数已经在上面移除了,会报错。另外这个单测中,本质是测试这一个api的网络,看起来这个单测可以整体移除掉。
sunzhongkai588
left a comment
There was a problem hiding this comment.
no doc's changes. LGTM



PR types
Others
PR changes
APIs
Description
To clean the code in paddle.fluid, the useless codes should be removed and code still be used should move to a new position.
fluid 目录下的 nets.py 包含较多预定义的简单网络,已基本在1期工作中改成了2.0API组网。只在单测使用,因此将其迁移到单测里提供单测的组网依赖。