Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
accb132f
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
accb132f
编写于
6月 15, 2019
作者:
S
Sylwester Fraczek
提交者:
Tao Luo
6月 15, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix slim int8 mkldnn multithreading issue (#18009)
上级
5c3cbb58
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
18 addition
and
13 deletion
+18
-13
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+11
-8
python/paddle/fluid/contrib/slim/tests/CMakeLists.txt
python/paddle/fluid/contrib/slim/tests/CMakeLists.txt
+1
-1
python/paddle/fluid/contrib/slim/tests/test_mkldnn_int8_quantization_strategy.py
...trib/slim/tests/test_mkldnn_int8_quantization_strategy.py
+6
-4
未找到文件。
paddle/fluid/pybind/pybind.cc
浏览文件 @
accb132f
...
@@ -44,6 +44,7 @@ limitations under the License. */
...
@@ -44,6 +44,7 @@ limitations under the License. */
#include "paddle/fluid/operators/activation_op.h"
#include "paddle/fluid/operators/activation_op.h"
#include "paddle/fluid/operators/py_func_op.h"
#include "paddle/fluid/operators/py_func_op.h"
#include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h"
#include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h"
#include "paddle/fluid/platform/cpu_helper.h"
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/init.h"
...
@@ -164,6 +165,8 @@ PYBIND11_MODULE(core_noavx, m) {
...
@@ -164,6 +165,8 @@ PYBIND11_MODULE(core_noavx, m) {
BindException
(
&
m
);
BindException
(
&
m
);
m
.
def
(
"set_num_threads"
,
&
platform
::
SetNumThreads
);
m
.
def
(
m
.
def
(
"_append_python_callable_object_and_return_id"
,
"_append_python_callable_object_and_return_id"
,
[](
py
::
object
py_obj
)
->
size_t
{
[](
py
::
object
py_obj
)
->
size_t
{
...
...
python/paddle/fluid/contrib/slim/tests/CMakeLists.txt
浏览文件 @
accb132f
...
@@ -3,7 +3,7 @@ string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}")
...
@@ -3,7 +3,7 @@ string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}")
function
(
inference_analysis_python_api_int8_test target model_dir data_dir filename
)
function
(
inference_analysis_python_api_int8_test target model_dir data_dir filename
)
py_test
(
${
target
}
SRCS
${
filename
}
py_test
(
${
target
}
SRCS
${
filename
}
ENVS
FLAGS_OMP
_NUM_THREADS=
${
CPU_NUM_THREADS_ON_CI
}
ENVS
CPU
_NUM_THREADS=
${
CPU_NUM_THREADS_ON_CI
}
ARGS --infer_model
${
model_dir
}
/model
ARGS --infer_model
${
model_dir
}
/model
--infer_data
${
data_dir
}
/data.bin
--infer_data
${
data_dir
}
/data.bin
--int8_model_save_path int8_models/
${
target
}
--int8_model_save_path int8_models/
${
target
}
...
...
python/paddle/fluid/contrib/slim/tests/test_mkldnn_int8_quantization_strategy.py
浏览文件 @
accb132f
...
@@ -84,8 +84,8 @@ class TestMKLDNNPostTrainingQuantStrategy(unittest.TestCase):
...
@@ -84,8 +84,8 @@ class TestMKLDNNPostTrainingQuantStrategy(unittest.TestCase):
while
step
<
num
:
while
step
<
num
:
fp
.
seek
(
imgs_offset
+
img_size
*
step
)
fp
.
seek
(
imgs_offset
+
img_size
*
step
)
img
=
fp
.
read
(
img_size
)
img
=
fp
.
read
(
img_size
)
img
=
struct
.
unpack_from
(
'{}f'
.
format
(
img_ch
*
img_w
*
img
=
struct
.
unpack_from
(
img_h
),
img
)
'{}f'
.
format
(
img_ch
*
img_w
*
img_h
),
img
)
img
=
np
.
array
(
img
)
img
=
np
.
array
(
img
)
img
.
shape
=
(
img_ch
,
img_w
,
img_h
)
img
.
shape
=
(
img_ch
,
img_w
,
img_h
)
fp
.
seek
(
labels_offset
+
label_size
*
step
)
fp
.
seek
(
labels_offset
+
label_size
*
step
)
...
@@ -137,12 +137,14 @@ class TestMKLDNNPostTrainingQuantStrategy(unittest.TestCase):
...
@@ -137,12 +137,14 @@ class TestMKLDNNPostTrainingQuantStrategy(unittest.TestCase):
images
=
np
.
array
(
images
).
astype
(
'float32'
)
images
=
np
.
array
(
images
).
astype
(
'float32'
)
labels
=
np
.
array
([
x
[
1
]
for
x
in
data
]).
astype
(
"int64"
)
labels
=
np
.
array
([
x
[
1
]
for
x
in
data
]).
astype
(
"int64"
)
labels
=
labels
.
reshape
([
-
1
,
1
])
labels
=
labels
.
reshape
([
-
1
,
1
])
fluid
.
core
.
set_num_threads
(
int
(
os
.
environ
[
'CPU_NUM_THREADS'
]))
out
=
exe
.
run
(
inference_program
,
out
=
exe
.
run
(
inference_program
,
feed
=
{
feed
=
{
feed_target_names
[
0
]:
images
,
feed_target_names
[
0
]:
images
,
feed_target_names
[
1
]:
labels
feed_target_names
[
1
]:
labels
},
},
fetch_list
=
fetch_targets
)
fetch_list
=
fetch_targets
)
fluid
.
core
.
set_num_threads
(
1
)
top1
+=
np
.
sum
(
out
[
1
])
*
len
(
data
)
top1
+=
np
.
sum
(
out
[
1
])
*
len
(
data
)
top5
+=
np
.
sum
(
out
[
2
])
*
len
(
data
)
top5
+=
np
.
sum
(
out
[
2
])
*
len
(
data
)
total_samples
+=
len
(
data
)
total_samples
+=
len
(
data
)
...
@@ -183,8 +185,8 @@ class TestMKLDNNPostTrainingQuantStrategy(unittest.TestCase):
...
@@ -183,8 +185,8 @@ class TestMKLDNNPostTrainingQuantStrategy(unittest.TestCase):
accuracy_diff_threshold
=
test_case_args
.
accuracy_diff_threshold
accuracy_diff_threshold
=
test_case_args
.
accuracy_diff_threshold
_logger
.
info
(
_logger
.
info
(
'FP32 & INT8 prediction run: batch_size {0}, warmup batch size {1}.'
.
'FP32 & INT8 prediction run: batch_size {0}, warmup batch size {1}.'
format
(
batch_size
,
warmup_batch_size
))
.
format
(
batch_size
,
warmup_batch_size
))
#warmup dataset, only use the first batch data
#warmup dataset, only use the first batch data
warmup_reader
=
paddle
.
batch
(
warmup_reader
=
paddle
.
batch
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录