update 2.0 public api in dataset&framework#31985
Merged
XiaoguangHu01 merged 1 commit intoPaddlePaddle:developfrom Apr 27, 2021
zhiboniu:pubapi_dataset_framework
Merged
update 2.0 public api in dataset&framework#31985XiaoguangHu01 merged 1 commit intoPaddlePaddle:developfrom zhiboniu:pubapi_dataset_framework
XiaoguangHu01 merged 1 commit intoPaddlePaddle:developfrom
zhiboniu:pubapi_dataset_framework
Conversation
|
Thanks for your contribution! |
willthefrog
reviewed
Apr 8, 2021
iclementine
reviewed
Apr 23, 2021
iclementine
previously approved these changes
Apr 23, 2021
|
|
||
| from .framework import set_default_dtype #DEFINE_ALIAS | ||
| from .framework import get_default_dtype #DEFINE_ALIAS | ||
| from .framework import set_grad_enabled #DEFINE_ALIAS |
Contributor
There was a problem hiding this comment.
这个paddle/init.py文件怎么没有定义__all__列表呢?
Contributor
Author
There was a problem hiding this comment.
这个文件有一个单独的pr,31985这里只是在paddle.init.py里做了和framework相关的更新。
paddle.init.py的pr:
#32034
phlrain
approved these changes
Apr 26, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR types
Others
PR changes
APIs
Describe
update 2.0 public api in dataset&framework
背景:
对于用户调用api的层级,由于之前没有明确的设计,api开放层级比较随意。影响用户使用中的逻辑和正规感受。
目的:
1)重新整理api开放层级,提升用户使用感受
2)API保留自有特色,同时更好地符合行业规范,降低用户学习成本
3)提高框架api逻辑性,便于后续维护和优化
主要实现方法:
1)__all__内容清晰化,内容逐个列出,一行一个。不再使用 all 的向上传递机制,仅在公开API层级添加 all,其余的 all 列表统一置空
2)不再使用 #DEFINE_ALIAS
3)导入内容清晰化,原则上不再使用 import *, 按需引入需要的API, 每行一个
4)原则上不再使用 from . import module, from .module import submodule时会引入module,避免重复引用
5)添加新的Public API时,需向上寻找到最近的节点添加 import 并加入 all 列表
6)Public API列表由多个公开API层级的 all 列表共同组成,文档抽取以此为准,这些指定层级是:
修改示例展示:
原来写法:
新的写法:
对开发者使用API的影响:
在指定层级推荐方式:(不受影响)
from paddle.nn import CTCLoss
from paddle.nn import Conv2D
非指定层级支持但不推荐:(不受影响)
from paddle.nn.layer.loss import CTCLoss
from paddle.nn.layer.conv import Conv2D
对于import *使用方式不推荐。(非公开层级受影响)
不再支持:(非公开层级)
from paddle.nn.layer import *
from paddle.nn.layer.conv import *
from paddle.nn.initializer.norm import *
from paddle.tensor.math import *
from paddle.optimizer.adam import *
可以支持:(公开层级)
from paddle import *
from paddle.nn import *
from paddle.utils import *
from paddle.optimizer import *
本pr相关修改对api的调用无明显影响