Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
极客李华
Paddle
提交
0914ff97
P
Paddle
项目概览
极客李华
/
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,发现更多精彩内容 >>
未验证
提交
0914ff97
编写于
7月 07, 2021
作者:
W
Wilber
提交者:
GitHub
7月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix reshape trt condition (#34007)
上级
cb73feea
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
60 addition
and
18 deletion
+60
-18
paddle/fluid/inference/goapi/README.md
paddle/fluid/inference/goapi/README.md
+3
-3
paddle/fluid/inference/tensorrt/op_teller.cc
paddle/fluid/inference/tensorrt/op_teller.cc
+8
-7
python/paddle/fluid/tests/unittests/ir/inference/inference_pass_test.py
...fluid/tests/unittests/ir/inference/inference_pass_test.py
+2
-5
python/paddle/fluid/tests/unittests/ir/inference/test_trt_yolo_box_op.py
...luid/tests/unittests/ir/inference/test_trt_yolo_box_op.py
+47
-3
未找到文件。
paddle/fluid/inference/goapi/README.md
浏览文件 @
0914ff97
...
...
@@ -11,8 +11,8 @@ Paddle Inference golang API 基于 [capi](../capi_exp) 和 cgo 实现,需要
2.
使用
`go get`
获取golang paddle api
```
# 此处使用上一步记录的CommitId,假设为
76e5724
COMMITID=
76e5724
# 此处使用上一步记录的CommitId,假设为
0722297
COMMITID=
0722297
go get -d -v github.com/paddlepaddle/paddle/paddle/fluid/inference/goapi@${COMMITID}
```
...
...
@@ -28,7 +28,7 @@ go1.15新增了`GOMODCACHE`环境变量,`go get`默认会将代码下载到`GO
```
bash
eval
$(
go
env
|
grep
GOMODCACHE
)
# 按需修改最后的goapi版本号
cd
${
GOMODCACHE
}
/github.com/paddlepaddle/paddle/paddle/fluid/inference/goapi
\@
v0.0.0-20210
517084506-76e5724c16a5
/
cd
${
GOMODCACHE
}
/github.com/paddlepaddle/paddle/paddle/fluid/inference/goapi
\@
v0.0.0-20210
623023452-0722297d9b8c
/
ln
-s
${
PADDLE_C_DOWNLOAD_DIR
}
/paddle_inference_c_install_dir paddle_inference_c
```
...
...
paddle/fluid/inference/tensorrt/op_teller.cc
浏览文件 @
0914ff97
...
...
@@ -692,15 +692,16 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
if
(
op_type
==
"reshape"
||
op_type
==
"reshape2"
)
{
if
(
!
desc
.
HasAttr
(
"shape"
))
{
return
false
;
// Paddle-TRT does not support the input tensors: Shape and ShapeTensor
}
else
if
(
desc
.
Input
(
"Shape"
).
size
()
>=
1
||
desc
.
Input
(
"ShapeTensor"
).
size
()
>=
1
)
{
}
// Paddle-TRT does not support the input tensors: Shape and ShapeTensor
if
(
desc
.
Input
(
"Shape"
).
size
()
>=
1
||
desc
.
Input
(
"ShapeTensor"
).
size
()
>=
1
)
{
return
false
;
}
else
{
std
::
vector
<
int
>
shape
=
BOOST_GET_CONST
(
std
::
vector
<
int
>
,
desc
.
GetAttr
(
"shape"
));
if
(
shape
.
size
()
>=
nvinfer1
::
Dims
::
MAX_DIMS
)
return
false
;
}
std
::
vector
<
int
>
shape
=
BOOST_GET_CONST
(
std
::
vector
<
int
>
,
desc
.
GetAttr
(
"shape"
));
if
(
shape
.
size
()
>=
nvinfer1
::
Dims
::
MAX_DIMS
)
return
false
;
if
(
!
with_dynamic_shape
&&
shape
[
0
]
==
-
1
)
return
false
;
}
if
(
op_type
==
"reduce_sum"
)
{
...
...
python/paddle/fluid/tests/unittests/ir/inference/inference_pass_test.py
浏览文件 @
0914ff97
...
...
@@ -72,9 +72,7 @@ class InferencePassTest(unittest.TestCase):
feeded_var_names
=
list
(
self
.
feeds
.
keys
()),
target_vars
=
self
.
fetch_list
,
executor
=
executor
,
main_program
=
program
,
model_filename
=
"model"
,
params_filename
=
"params"
)
main_program
=
program
)
return
outs
...
...
@@ -111,8 +109,7 @@ class InferencePassTest(unittest.TestCase):
'''
Return a new object of AnalysisConfig.
'''
config
=
AnalysisConfig
(
os
.
path
.
join
(
self
.
path
,
"model"
),
os
.
path
.
join
(
self
.
path
,
"params"
))
config
=
AnalysisConfig
(
self
.
path
)
config
.
disable_gpu
()
config
.
switch_specify_input_names
(
True
)
config
.
switch_ir_optim
(
True
)
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_yolo_box_op.py
浏览文件 @
0914ff97
...
...
@@ -32,8 +32,6 @@ class TRTYoloBoxTest(InferencePassTest):
image_size
=
fluid
.
data
(
name
=
'image_size'
,
shape
=
[
self
.
bs
,
2
],
dtype
=
'int32'
)
boxes
,
scores
=
self
.
append_yolobox
(
image
,
image_size
)
scores
=
fluid
.
layers
.
reshape
(
scores
,
(
self
.
bs
,
-
1
))
out
=
fluid
.
layers
.
batch_norm
(
scores
,
is_test
=
True
)
self
.
feeds
=
{
'image'
:
np
.
random
.
random
(
image_shape
).
astype
(
'float32'
),
...
...
@@ -43,7 +41,7 @@ class TRTYoloBoxTest(InferencePassTest):
self
.
enable_trt
=
True
self
.
trt_parameters
=
TRTYoloBoxTest
.
TensorRTParam
(
1
<<
30
,
self
.
bs
,
1
,
AnalysisConfig
.
Precision
.
Float32
,
False
,
False
)
self
.
fetch_list
=
[
out
,
boxes
]
self
.
fetch_list
=
[
scores
,
boxes
]
def
set_params
(
self
):
self
.
bs
=
4
...
...
@@ -72,5 +70,51 @@ class TRTYoloBoxTest(InferencePassTest):
PassVersionChecker
.
IsCompatible
(
'tensorrt_subgraph_pass'
))
class
TRTYoloBoxFP16Test
(
InferencePassTest
):
def
setUp
(
self
):
self
.
set_params
()
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
image_shape
=
[
self
.
bs
,
self
.
channel
,
self
.
height
,
self
.
width
]
image
=
fluid
.
data
(
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
image_size
=
fluid
.
data
(
name
=
'image_size'
,
shape
=
[
self
.
bs
,
2
],
dtype
=
'int32'
)
boxes
,
scores
=
self
.
append_yolobox
(
image
,
image_size
)
self
.
feeds
=
{
'image'
:
np
.
random
.
random
(
image_shape
).
astype
(
'float32'
),
'image_size'
:
np
.
array
([[
416
,
416
]]).
astype
(
'int32'
),
}
self
.
enable_trt
=
True
self
.
trt_parameters
=
TRTYoloBoxFP16Test
.
TensorRTParam
(
1
<<
30
,
self
.
bs
,
1
,
AnalysisConfig
.
Precision
.
Half
,
False
,
False
)
self
.
fetch_list
=
[
scores
,
boxes
]
def
set_params
(
self
):
self
.
bs
=
1
self
.
height
=
13
self
.
width
=
13
self
.
class_num
=
1
self
.
anchors
=
[
106
,
148
,
92
,
300
,
197
,
334
]
self
.
channel
=
18
self
.
conf_thresh
=
.
05
self
.
downsample_ratio
=
32
def
append_yolobox
(
self
,
image
,
image_size
):
return
fluid
.
layers
.
yolo_box
(
x
=
image
,
img_size
=
image_size
,
class_num
=
self
.
class_num
,
anchors
=
self
.
anchors
,
conf_thresh
=
self
.
conf_thresh
,
downsample_ratio
=
self
.
downsample_ratio
)
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
use_gpu
=
True
self
.
check_output_with_option
(
use_gpu
,
flatten
=
True
,
rtol
=
1e-1
)
self
.
assertTrue
(
PassVersionChecker
.
IsCompatible
(
'tensorrt_subgraph_pass'
))
if
__name__
==
"__main__"
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录