Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wmsofts
Paddle
提交
e5bc2eec
P
Paddle
项目概览
wmsofts
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e5bc2eec
编写于
12月 07, 2022
作者:
Q
Qi Li
提交者:
GitHub
12月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[NPU] add FLAGS_npu_storage_format env to enable npu storage format, test=develop (#48774)
上级
c6a2b0fd
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
36 addition
and
4 deletion
+36
-4
paddle/fluid/platform/flags.cc
paddle/fluid/platform/flags.cc
+12
-0
python/paddle/fluid/dygraph/varbase_patch_methods.py
python/paddle/fluid/dygraph/varbase_patch_methods.py
+6
-1
python/paddle/nn/functional/conv.py
python/paddle/nn/functional/conv.py
+12
-2
python/paddle/nn/layer/norm.py
python/paddle/nn/layer/norm.py
+6
-1
未找到文件。
paddle/fluid/platform/flags.cc
浏览文件 @
e5bc2eec
...
@@ -1041,6 +1041,18 @@ PADDLE_DEFINE_EXPORTED_string(jit_engine_type,
...
@@ -1041,6 +1041,18 @@ PADDLE_DEFINE_EXPORTED_string(jit_engine_type,
"Predictor"
,
"Predictor"
,
"Choose default funciton type in JitLayer."
);
"Choose default funciton type in JitLayer."
);
#ifdef PADDLE_WITH_CUSTOM_DEVICE
/**
* Custom Device NPU related FLAG
* Name: FLAGS_npu_storage_format
* Since Version: 2.5.0
* Value Range: bool, default=false
* Example:
* Note: Enable NPU Storage Format for Ascend910 performance improvement.
*/
PADDLE_DEFINE_EXPORTED_bool
(
npu_storage_format
,
false
,
""
);
#endif
#ifdef PADDLE_WITH_CUDNN_FRONTEND
#ifdef PADDLE_WITH_CUDNN_FRONTEND
/**
/**
* CUDNNv8 related FLAG
* CUDNNv8 related FLAG
...
...
python/paddle/fluid/dygraph/varbase_patch_methods.py
浏览文件 @
e5bc2eec
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
os
import
inspect
import
inspect
import
numpy
as
np
import
numpy
as
np
import
warnings
import
warnings
...
@@ -379,7 +380,11 @@ def monkey_patch_varbase():
...
@@ -379,7 +380,11 @@ def monkey_patch_varbase():
new_ivar
=
self
.
_grad_ivar
()
new_ivar
=
self
.
_grad_ivar
()
# TODO(qili93): temporary for ascned npu performance to be removed along with npu_identity op
# TODO(qili93): temporary for ascned npu performance to be removed along with npu_identity op
if
'npu'
in
get_all_custom_device_type
():
if
(
os
.
environ
.
get
(
'FLAGS_npu_storage_format'
,
None
)
in
[
1
,
'1'
,
True
,
'True'
,
'true'
]
and
'npu'
in
get_all_custom_device_type
()
):
new_ivar
=
paddle
.
incubate
.
_npu_identity
(
x
=
new_ivar
,
format
=-
1
)
new_ivar
=
paddle
.
incubate
.
_npu_identity
(
x
=
new_ivar
,
format
=-
1
)
new_ivar
=
new_ivar
.
_copy_to
(
core
.
CPUPlace
(),
True
)
new_ivar
=
new_ivar
.
_copy_to
(
core
.
CPUPlace
(),
True
)
if
self
.
_grad_ivar
().
type
==
core
.
VarDesc
.
VarType
.
SELECTED_ROWS
:
if
self
.
_grad_ivar
().
type
==
core
.
VarDesc
.
VarType
.
SELECTED_ROWS
:
...
...
python/paddle/nn/functional/conv.py
浏览文件 @
e5bc2eec
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
os
from
paddle
import
_C_ops
,
_legacy_C_ops
,
get_flags
,
in_dynamic_mode
from
paddle
import
_C_ops
,
_legacy_C_ops
,
get_flags
,
in_dynamic_mode
from
paddle.device
import
(
from
paddle.device
import
(
get_all_custom_device_type
,
get_all_custom_device_type
,
...
@@ -149,7 +151,11 @@ def _conv_nd(
...
@@ -149,7 +151,11 @@ def _conv_nd(
new_shape
[
channel_dim
]
=
-
1
new_shape
[
channel_dim
]
=
-
1
bias
=
bias
.
reshape
(
new_shape
)
bias
=
bias
.
reshape
(
new_shape
)
# TODO(qili93): temporary for ascned npu performance to be removed along with npu_identity op
# TODO(qili93): temporary for ascned npu performance to be removed along with npu_identity op
if
'npu'
in
get_all_custom_device_type
():
if
(
os
.
environ
.
get
(
'FLAGS_npu_storage_format'
,
None
)
in
[
1
,
'1'
,
True
,
'True'
,
'true'
]
and
'npu'
in
get_all_custom_device_type
()
):
with
no_grad
():
with
no_grad
():
bias_storage
=
_C_ops
.
npu_identity
(
bias_storage
=
_C_ops
.
npu_identity
(
bias
,
3
bias
,
3
...
@@ -747,7 +753,11 @@ def conv2d(
...
@@ -747,7 +753,11 @@ def conv2d(
+
[
1
for
i
in
range
(
len
(
x
.
shape
)
-
channel_dim
-
1
)],
+
[
1
for
i
in
range
(
len
(
x
.
shape
)
-
channel_dim
-
1
)],
)
)
# TODO(qili93): temporary for ascned npu performance to be removed along with npu_identity op
# TODO(qili93): temporary for ascned npu performance to be removed along with npu_identity op
if
'npu'
in
get_all_custom_device_type
():
if
(
os
.
environ
.
get
(
'FLAGS_npu_storage_format'
,
None
)
in
[
1
,
'1'
,
True
,
'True'
,
'true'
]
and
'npu'
in
get_all_custom_device_type
()
):
with
no_grad
():
with
no_grad
():
bias_storage
=
_C_ops
.
npu_identity
(
bias_storage
=
_C_ops
.
npu_identity
(
bias
,
3
bias
,
3
...
...
python/paddle/nn/layer/norm.py
浏览文件 @
e5bc2eec
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
# TODO: define normalization api
# TODO: define normalization api
import
numbers
import
numbers
import
os
import
warnings
import
warnings
import
numpy
as
np
import
numpy
as
np
...
@@ -681,7 +682,11 @@ class _BatchNormBase(Layer):
...
@@ -681,7 +682,11 @@ class _BatchNormBase(Layer):
self
.
_variance
.
stop_gradient
=
True
self
.
_variance
.
stop_gradient
=
True
# TODO(qili93): temporary for ascned npu performance to be removed along with npu_identity op
# TODO(qili93): temporary for ascned npu performance to be removed along with npu_identity op
if
'npu'
in
get_all_custom_device_type
():
if
(
os
.
environ
.
get
(
'FLAGS_npu_storage_format'
,
None
)
in
[
1
,
'1'
,
True
,
'True'
,
'true'
]
and
'npu'
in
get_all_custom_device_type
()
):
with
no_grad
():
with
no_grad
():
weight_trans
=
_C_ops
.
npu_identity
(
weight_trans
=
_C_ops
.
npu_identity
(
self
.
weight
,
3
self
.
weight
,
3
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录