remove fp32 tmp tensor and cast op for initializer.Normal and initializer.Constant #38818
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
Function optimization
PR changes
APIs
Describe
remove fp32 tmp tensor and cast op for initializer.Normal and initializer.Constant
背景:
当参数是 FP16 时,如果需要初始化的 tensor 非常大时,例如 17 个G 大小的 tensor,现有代码是先申请一个临时的 FP32 tensor,进行初始化,然后再cast 成 FP16,拷贝到 FP16 tensor 中。那这个临时的 FP32 tensor 需要 34 G 显存,32G V100上 直接显存 OOM了。通过分析,这些中间变量完全不需要。
PLSC 项目
修改前:
静态图:最大支持 6000万类 FC
动态图:最大支持 6700万类 FC
修改后:
静态图:最大支持 9200万类 FC
动态图:最大支持 8700万类 FC