Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
82db4993
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
82db4993
编写于
10月 14, 2022
作者:
W
Wilber
提交者:
GitHub
10月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cherry-pick 46942 (#47015)
上级
84333cf5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
19 addition
and
35 deletion
+19
-35
paddle/fluid/inference/api/analysis_predictor.cc
paddle/fluid/inference/api/analysis_predictor.cc
+8
-6
paddle/fluid/inference/api/paddle_analysis_config.h
paddle/fluid/inference/api/paddle_analysis_config.h
+0
-7
paddle/fluid/inference/api/paddle_inference_api.h
paddle/fluid/inference/api/paddle_inference_api.h
+1
-2
paddle/fluid/pybind/inference_api.cc
paddle/fluid/pybind/inference_api.cc
+0
-7
python/paddle/fluid/inference/__init__.py
python/paddle/fluid/inference/__init__.py
+1
-1
python/paddle/fluid/inference/wrapper.py
python/paddle/fluid/inference/wrapper.py
+2
-3
python/paddle/fluid/tests/unittests/ir/test_convert_to_mixed_precision.py
...uid/tests/unittests/ir/test_convert_to_mixed_precision.py
+5
-6
python/paddle/inference/__init__.py
python/paddle/inference/__init__.py
+2
-3
未找到文件。
paddle/fluid/inference/api/analysis_predictor.cc
浏览文件 @
82db4993
...
@@ -129,17 +129,19 @@ phi::DataType ConvertPrecision(AnalysisConfig::Precision precision) {
...
@@ -129,17 +129,19 @@ phi::DataType ConvertPrecision(AnalysisConfig::Precision precision) {
}
}
}
}
phi
::
Backend
ConvertBackend
(
AnalysisConfig
::
Backend
backend
)
{
phi
::
Backend
ConvertBackend
(
paddle_infer
::
PlaceType
backend
)
{
switch
(
backend
)
{
switch
(
backend
)
{
case
AnalysisConfig
::
Backend
::
kGPU
:
case
paddle_infer
::
PlaceType
::
kGPU
:
// NOTE: phi also support phi::Backend::GPUDNN.
// NOTE: phi also support phi::Backend::GPUDNN.
return
phi
::
Backend
::
GPU
;
return
phi
::
Backend
::
GPU
;
case
AnalysisConfig
::
Backend
::
kNPU
:
case
paddle_infer
::
PlaceType
::
kNPU
:
return
phi
::
Backend
::
NPU
;
return
phi
::
Backend
::
NPU
;
case
AnalysisConfig
::
Backend
::
kXPU
:
case
paddle_infer
::
PlaceType
::
kXPU
:
return
phi
::
Backend
::
XPU
;
return
phi
::
Backend
::
XPU
;
case
AnalysisConfig
::
Backend
::
kCPU
:
case
paddle_infer
::
PlaceType
::
kCPU
:
return
phi
::
Backend
::
CPU
;
return
phi
::
Backend
::
CPU
;
case
paddle_infer
::
PlaceType
::
kIPU
:
return
phi
::
Backend
::
IPU
;
default:
default:
PADDLE_THROW
(
paddle
::
platform
::
errors
::
InvalidArgument
(
PADDLE_THROW
(
paddle
::
platform
::
errors
::
InvalidArgument
(
"Paddle Inference not support backend, we now only support GPU, XPU, "
"Paddle Inference not support backend, we now only support GPU, XPU, "
...
@@ -2320,7 +2322,7 @@ void ConvertToMixedPrecision(const std::string &model_file,
...
@@ -2320,7 +2322,7 @@ void ConvertToMixedPrecision(const std::string &model_file,
const
std
::
string
&
mixed_model_file
,
const
std
::
string
&
mixed_model_file
,
const
std
::
string
&
mixed_params_file
,
const
std
::
string
&
mixed_params_file
,
PrecisionType
mixed_precision
,
PrecisionType
mixed_precision
,
Backend
Type
backend
,
paddle_infer
::
Place
Type
backend
,
bool
keep_io_types
,
bool
keep_io_types
,
std
::
unordered_set
<
std
::
string
>
black_list
)
{
std
::
unordered_set
<
std
::
string
>
black_list
)
{
auto
phi_backend
=
paddle
::
ConvertBackend
(
backend
);
auto
phi_backend
=
paddle
::
ConvertBackend
(
backend
);
...
...
paddle/fluid/inference/api/paddle_analysis_config.h
浏览文件 @
82db4993
...
@@ -170,13 +170,6 @@ struct PD_INFER_DECL AnalysisConfig {
...
@@ -170,13 +170,6 @@ struct PD_INFER_DECL AnalysisConfig {
kBf16
,
///< bf16
kBf16
,
///< bf16
};
};
enum
class
Backend
{
kCPU
=
0
,
kGPU
,
kXPU
,
kNPU
,
};
///
///
/// \brief Set the no-combined model dir path.
/// \brief Set the no-combined model dir path.
///
///
...
...
paddle/fluid/inference/api/paddle_inference_api.h
浏览文件 @
82db4993
...
@@ -47,7 +47,6 @@ namespace paddle_infer {
...
@@ -47,7 +47,6 @@ namespace paddle_infer {
using
PrecisionType
=
paddle
::
AnalysisConfig
::
Precision
;
using
PrecisionType
=
paddle
::
AnalysisConfig
::
Precision
;
using
Config
=
paddle
::
AnalysisConfig
;
using
Config
=
paddle
::
AnalysisConfig
;
using
DistConfig
=
paddle
::
DistConfig
;
using
DistConfig
=
paddle
::
DistConfig
;
using
BackendType
=
paddle
::
AnalysisConfig
::
Backend
;
///
///
/// \class Predictor
/// \class Predictor
...
@@ -198,7 +197,7 @@ PD_INFER_DECL void ConvertToMixedPrecision(
...
@@ -198,7 +197,7 @@ PD_INFER_DECL void ConvertToMixedPrecision(
const
std
::
string
&
mixed_model_file
,
const
std
::
string
&
mixed_model_file
,
const
std
::
string
&
mixed_params_file
,
const
std
::
string
&
mixed_params_file
,
PrecisionType
mixed_precision
,
PrecisionType
mixed_precision
,
Backend
Type
backend
,
Place
Type
backend
,
bool
keep_io_types
=
true
,
bool
keep_io_types
=
true
,
std
::
unordered_set
<
std
::
string
>
black_list
=
{});
std
::
unordered_set
<
std
::
string
>
black_list
=
{});
...
...
paddle/fluid/pybind/inference_api.cc
浏览文件 @
82db4993
...
@@ -616,13 +616,6 @@ void BindAnalysisConfig(py::module *m) {
...
@@ -616,13 +616,6 @@ void BindAnalysisConfig(py::module *m) {
.
value
(
"Bfloat16"
,
AnalysisConfig
::
Precision
::
kBf16
)
.
value
(
"Bfloat16"
,
AnalysisConfig
::
Precision
::
kBf16
)
.
export_values
();
.
export_values
();
py
::
enum_
<
AnalysisConfig
::
Backend
>
(
analysis_config
,
"Backend"
)
.
value
(
"CPU"
,
AnalysisConfig
::
Backend
::
kCPU
)
.
value
(
"GPU"
,
AnalysisConfig
::
Backend
::
kGPU
)
.
value
(
"NPU"
,
AnalysisConfig
::
Backend
::
kNPU
)
.
value
(
"XPU"
,
AnalysisConfig
::
Backend
::
kXPU
)
.
export_values
();
analysis_config
.
def
(
py
::
init
<>
())
analysis_config
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<
const
AnalysisConfig
&>
())
.
def
(
py
::
init
<
const
AnalysisConfig
&>
())
.
def
(
py
::
init
<
const
std
::
string
&>
())
.
def
(
py
::
init
<
const
std
::
string
&>
())
...
...
python/paddle/fluid/inference/__init__.py
浏览文件 @
82db4993
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +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.
from
.wrapper
import
Config
,
DataType
,
PlaceType
,
PrecisionType
,
BackendType
,
Tensor
,
Predictor
from
.wrapper
import
Config
,
DataType
,
PlaceType
,
PrecisionType
,
Tensor
,
Predictor
from
.wrapper
import
convert_to_mixed_precision
from
.wrapper
import
convert_to_mixed_precision
from
..core
import
create_predictor
,
get_version
,
get_num_bytes_of_data_type
,
PredictorPool
,
get_trt_compile_version
,
get_trt_runtime_version
from
..core
import
create_predictor
,
get_version
,
get_num_bytes_of_data_type
,
PredictorPool
,
get_trt_compile_version
,
get_trt_runtime_version
python/paddle/fluid/inference/wrapper.py
浏览文件 @
82db4993
...
@@ -24,7 +24,6 @@ from typing import Set
...
@@ -24,7 +24,6 @@ from typing import Set
DataType
=
PaddleDType
DataType
=
PaddleDType
PlaceType
=
PaddlePlace
PlaceType
=
PaddlePlace
PrecisionType
=
AnalysisConfig
.
Precision
PrecisionType
=
AnalysisConfig
.
Precision
BackendType
=
AnalysisConfig
.
Backend
Config
=
AnalysisConfig
Config
=
AnalysisConfig
Tensor
=
PaddleInferTensor
Tensor
=
PaddleInferTensor
Predictor
=
PaddleInferPredictor
Predictor
=
PaddleInferPredictor
...
@@ -59,7 +58,7 @@ def convert_to_mixed_precision(model_file: str,
...
@@ -59,7 +58,7 @@ def convert_to_mixed_precision(model_file: str,
mixed_model_file
:
str
,
mixed_model_file
:
str
,
mixed_params_file
:
str
,
mixed_params_file
:
str
,
mixed_precision
:
PrecisionType
,
mixed_precision
:
PrecisionType
,
backend
:
Backend
Type
,
backend
:
Place
Type
,
keep_io_types
:
bool
=
True
,
keep_io_types
:
bool
=
True
,
black_list
:
Set
=
set
()):
black_list
:
Set
=
set
()):
'''
'''
...
@@ -71,7 +70,7 @@ def convert_to_mixed_precision(model_file: str,
...
@@ -71,7 +70,7 @@ def convert_to_mixed_precision(model_file: str,
mixed_model_file: The storage path of the converted mixed-precision model.
mixed_model_file: The storage path of the converted mixed-precision model.
mixed_params_file: The storage path of the converted mixed-precision params.
mixed_params_file: The storage path of the converted mixed-precision params.
mixed_precision: The precision, e.g. PrecisionType.Half.
mixed_precision: The precision, e.g. PrecisionType.Half.
backend: The backend, e.g.
Backend
Type.GPU.
backend: The backend, e.g.
Place
Type.GPU.
keep_io_types: Whether the model input and output dtype remains unchanged.
keep_io_types: Whether the model input and output dtype remains unchanged.
black_list: Operators that do not convert precision.
black_list: Operators that do not convert precision.
'''
'''
...
...
python/paddle/fluid/tests/unittests/ir/test_convert_to_mixed_precision.py
浏览文件 @
82db4993
...
@@ -20,7 +20,7 @@ from paddle.vision.models import resnet50
...
@@ -20,7 +20,7 @@ from paddle.vision.models import resnet50
from
paddle.jit
import
to_static
from
paddle.jit
import
to_static
from
paddle.static
import
InputSpec
from
paddle.static
import
InputSpec
from
paddle.inference
import
PrecisionType
,
Backend
Type
from
paddle.inference
import
PrecisionType
,
Place
Type
from
paddle.inference
import
convert_to_mixed_precision
from
paddle.inference
import
convert_to_mixed_precision
...
@@ -38,7 +38,7 @@ class TestConvertToMixedPrecision(unittest.TestCase):
...
@@ -38,7 +38,7 @@ class TestConvertToMixedPrecision(unittest.TestCase):
'resnet50/inference.pdiparams'
,
'resnet50/inference.pdiparams'
,
'mixed/inference.pdmodel'
,
'mixed/inference.pdmodel'
,
'mixed/inference.pdiparams'
,
'mixed/inference.pdiparams'
,
PrecisionType
.
Half
,
Backend
Type
.
GPU
,
True
)
PrecisionType
.
Half
,
Place
Type
.
GPU
,
True
)
def
test_convert_to_fp16_with_fp16_input
(
self
):
def
test_convert_to_fp16_with_fp16_input
(
self
):
model
=
resnet50
(
True
)
model
=
resnet50
(
True
)
...
@@ -49,7 +49,7 @@ class TestConvertToMixedPrecision(unittest.TestCase):
...
@@ -49,7 +49,7 @@ class TestConvertToMixedPrecision(unittest.TestCase):
'resnet50/inference.pdiparams'
,
'resnet50/inference.pdiparams'
,
'mixed1/inference.pdmodel'
,
'mixed1/inference.pdmodel'
,
'mixed1/inference.pdiparams'
,
'mixed1/inference.pdiparams'
,
PrecisionType
.
Half
,
Backend
Type
.
GPU
,
False
)
PrecisionType
.
Half
,
Place
Type
.
GPU
,
False
)
def
test_convert_to_fp16_with_blacklist
(
self
):
def
test_convert_to_fp16_with_blacklist
(
self
):
model
=
resnet50
(
True
)
model
=
resnet50
(
True
)
...
@@ -60,7 +60,7 @@ class TestConvertToMixedPrecision(unittest.TestCase):
...
@@ -60,7 +60,7 @@ class TestConvertToMixedPrecision(unittest.TestCase):
'resnet50/inference.pdiparams'
,
'resnet50/inference.pdiparams'
,
'mixed2/inference.pdmodel'
,
'mixed2/inference.pdmodel'
,
'mixed2/inference.pdiparams'
,
'mixed2/inference.pdiparams'
,
PrecisionType
.
Half
,
Backend
Type
.
GPU
,
False
,
PrecisionType
.
Half
,
Place
Type
.
GPU
,
False
,
set
(
'conv2d'
))
set
(
'conv2d'
))
def
test_convert_to_bf16
(
self
):
def
test_convert_to_bf16
(
self
):
...
@@ -72,8 +72,7 @@ class TestConvertToMixedPrecision(unittest.TestCase):
...
@@ -72,8 +72,7 @@ class TestConvertToMixedPrecision(unittest.TestCase):
'resnet50/inference.pdiparams'
,
'resnet50/inference.pdiparams'
,
'mixed3/inference.pdmodel'
,
'mixed3/inference.pdmodel'
,
'mixed3/inference.pdiparams'
,
'mixed3/inference.pdiparams'
,
PrecisionType
.
Bfloat16
,
BackendType
.
GPU
,
PrecisionType
.
Bfloat16
,
PlaceType
.
GPU
,
True
)
True
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
python/paddle/inference/__init__.py
浏览文件 @
82db4993
...
@@ -16,7 +16,6 @@ from ..fluid.inference import Config # noqa: F401
...
@@ -16,7 +16,6 @@ from ..fluid.inference import Config # noqa: F401
from
..fluid.inference
import
DataType
# noqa: F401
from
..fluid.inference
import
DataType
# noqa: F401
from
..fluid.inference
import
PlaceType
# noqa: F401
from
..fluid.inference
import
PlaceType
# noqa: F401
from
..fluid.inference
import
PrecisionType
# noqa: F401
from
..fluid.inference
import
PrecisionType
# noqa: F401
from
..fluid.inference
import
BackendType
# noqa: F401
from
..fluid.inference
import
Tensor
# noqa: F401
from
..fluid.inference
import
Tensor
# noqa: F401
from
..fluid.inference
import
Predictor
# noqa: F401
from
..fluid.inference
import
Predictor
# noqa: F401
from
..fluid.inference
import
create_predictor
# noqa: F401
from
..fluid.inference
import
create_predictor
# noqa: F401
...
@@ -28,8 +27,8 @@ from ..fluid.inference import get_num_bytes_of_data_type # noqa: F401
...
@@ -28,8 +27,8 @@ from ..fluid.inference import get_num_bytes_of_data_type # noqa: F401
from
..fluid.inference
import
PredictorPool
# noqa: F401
from
..fluid.inference
import
PredictorPool
# noqa: F401
__all__
=
[
# noqa
__all__
=
[
# noqa
'Config'
,
'DataType'
,
'PlaceType'
,
'PrecisionType'
,
'
BackendType'
,
'Tens
or'
,
'Config'
,
'DataType'
,
'PlaceType'
,
'PrecisionType'
,
'
Tensor'
,
'Predict
or'
,
'
Predictor'
,
'
create_predictor'
,
'get_version'
,
'get_trt_compile_version'
,
'create_predictor'
,
'get_version'
,
'get_trt_compile_version'
,
'convert_to_mixed_precision'
,
'get_trt_runtime_version'
,
'convert_to_mixed_precision'
,
'get_trt_runtime_version'
,
'get_num_bytes_of_data_type'
,
'PredictorPool'
'get_num_bytes_of_data_type'
,
'PredictorPool'
]
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录