Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
fc882c7b
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
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看板
未验证
提交
fc882c7b
编写于
11月 29, 2022
作者:
G
gem5
提交者:
GitHub
11月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support rsqrt op. (#48223)
上级
c0d31dac
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
28 deletion
+45
-28
paddle/fluid/inference/api/analysis_predictor.cc
paddle/fluid/inference/api/analysis_predictor.cc
+1
-0
paddle/fluid/inference/tensorrt/convert/CMakeLists.txt
paddle/fluid/inference/tensorrt/convert/CMakeLists.txt
+0
-0
paddle/fluid/inference/tensorrt/convert/unary_op.cc
paddle/fluid/inference/tensorrt/convert/unary_op.cc
+37
-22
paddle/fluid/inference/tensorrt/op_teller.cc
paddle/fluid/inference/tensorrt/op_teller.cc
+2
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_unary.py
...id/tests/unittests/ir/inference/test_trt_convert_unary.py
+5
-6
未找到文件。
paddle/fluid/inference/api/analysis_predictor.cc
100644 → 100755
浏览文件 @
fc882c7b
...
...
@@ -2246,6 +2246,7 @@ USE_TRT_CONVERTER(flatten_contiguous_range);
USE_TRT_CONVERTER
(
matmul
);
USE_TRT_CONVERTER
(
matmul_v2
);
USE_TRT_CONVERTER
(
bmm
);
USE_TRT_CONVERTER
(
rsqrt
);
USE_TRT_CONVERTER
(
conv2d
);
USE_TRT_CONVERTER
(
relu
);
USE_TRT_CONVERTER
(
exp
);
...
...
paddle/fluid/inference/tensorrt/convert/CMakeLists.txt
100644 → 100755
浏览文件 @
fc882c7b
文件模式从 100644 更改为 100755
paddle/fluid/inference/tensorrt/convert/unary_op.cc
浏览文件 @
fc882c7b
...
...
@@ -52,38 +52,47 @@ class UnaryOpConverter : public OpConverter {
nvinfer1
::
ITensor
*
input_tensor
=
engine_
->
GetITensor
(
op_desc
.
Input
(
"X"
)[
0
]);
auto
op_pair
=
ops
.
find
(
op_type_
);
nvinfer1
::
IUnaryLayer
*
layer
=
TRT_ENGINE_ADD_LAYER
(
engine_
,
Unary
,
*
input_tensor
,
op_pair
->
second
);
nvinfer1
::
IUnaryLayer
*
layer
=
nullptr
;
for
(
auto
trt_op
:
op_pair
->
second
)
{
layer
=
TRT_ENGINE_ADD_LAYER
(
engine_
,
Unary
,
*
input_tensor
,
trt_op
);
input_tensor
=
layer
->
getOutput
(
0
);
}
auto
output_name
=
op_desc
.
Output
(
"Out"
)[
0
];
RreplenishLayerAndOutput
(
layer
,
op_type_
,
{
output_name
},
test_mode
);
}
protected:
std
::
string
op_type_
;
static
const
std
::
unordered_map
<
std
::
string
,
nvinfer1
::
UnaryOperation
>
ops
;
static
const
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
nvinfer1
::
UnaryOperation
>>
ops
;
};
const
std
::
unordered_map
<
std
::
string
,
nvinfer1
::
UnaryOperation
>
const
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
nvinfer1
::
UnaryOperation
>
>
UnaryOpConverter
::
ops
=
{
{
"exp"
,
nvinfer1
::
UnaryOperation
::
kEXP
},
{
"log"
,
nvinfer1
::
UnaryOperation
::
kLOG
},
{
"sqrt"
,
nvinfer1
::
UnaryOperation
::
kSQRT
},
{
"abs"
,
nvinfer1
::
UnaryOperation
::
kABS
},
{
"sin"
,
nvinfer1
::
UnaryOperation
::
kSIN
},
{
"cos"
,
nvinfer1
::
UnaryOperation
::
kCOS
},
{
"tan"
,
nvinfer1
::
UnaryOperation
::
kTAN
},
{
"sinh"
,
nvinfer1
::
UnaryOperation
::
kSINH
},
{
"cosh"
,
nvinfer1
::
UnaryOperation
::
kCOSH
},
{
"asin"
,
nvinfer1
::
UnaryOperation
::
kASIN
},
{
"acos"
,
nvinfer1
::
UnaryOperation
::
kACOS
},
{
"atan"
,
nvinfer1
::
UnaryOperation
::
kATAN
},
{
"asinh"
,
nvinfer1
::
UnaryOperation
::
kASINH
},
{
"atanh"
,
nvinfer1
::
UnaryOperation
::
kATANH
},
{
"ceil"
,
nvinfer1
::
UnaryOperation
::
kCEIL
},
{
"floor"
,
nvinfer1
::
UnaryOperation
::
kFLOOR
},
{
"reciprocal"
,
nvinfer1
::
UnaryOperation
::
kRECIP
},
{
"exp"
,
{
nvinfer1
::
UnaryOperation
::
kEXP
}},
{
"log"
,
{
nvinfer1
::
UnaryOperation
::
kLOG
}},
{
"sqrt"
,
{
nvinfer1
::
UnaryOperation
::
kSQRT
}},
{
"abs"
,
{
nvinfer1
::
UnaryOperation
::
kABS
}},
{
"sin"
,
{
nvinfer1
::
UnaryOperation
::
kSIN
}},
{
"cos"
,
{
nvinfer1
::
UnaryOperation
::
kCOS
}},
{
"tan"
,
{
nvinfer1
::
UnaryOperation
::
kTAN
}},
{
"sinh"
,
{
nvinfer1
::
UnaryOperation
::
kSINH
}},
{
"cosh"
,
{
nvinfer1
::
UnaryOperation
::
kCOSH
}},
{
"asin"
,
{
nvinfer1
::
UnaryOperation
::
kASIN
}},
{
"acos"
,
{
nvinfer1
::
UnaryOperation
::
kACOS
}},
{
"atan"
,
{
nvinfer1
::
UnaryOperation
::
kATAN
}},
{
"asinh"
,
{
nvinfer1
::
UnaryOperation
::
kASINH
}},
{
"atanh"
,
{
nvinfer1
::
UnaryOperation
::
kATANH
}},
{
"ceil"
,
{
nvinfer1
::
UnaryOperation
::
kCEIL
}},
{
"floor"
,
{
nvinfer1
::
UnaryOperation
::
kFLOOR
}},
{
"rsqrt"
,
{
nvinfer1
::
UnaryOperation
::
kSQRT
,
nvinfer1
::
UnaryOperation
::
kRECIP
}},
{
"reciprocal"
,
{
nvinfer1
::
UnaryOperation
::
kRECIP
}},
#if IS_TRT_VERSION_GE(7000)
{
"erf"
,
nvinfer1
::
UnaryOperation
::
kERF
},
{
"erf"
,
{
nvinfer1
::
UnaryOperation
::
kERF
}
},
#endif
};
...
...
@@ -153,6 +162,11 @@ class FloorOpConverter : public UnaryOpConverter {
public:
FloorOpConverter
()
{
op_type_
=
"floor"
;
}
};
class
RsqrtOpConverter
:
public
UnaryOpConverter
{
public:
RsqrtOpConverter
()
{
op_type_
=
"rsqrt"
;
}
};
class
ReciprocalOpConverter
:
public
UnaryOpConverter
{
public:
ReciprocalOpConverter
()
{
op_type_
=
"reciprocal"
;
}
...
...
@@ -184,6 +198,7 @@ REGISTER_TRT_OP_CONVERTER(asinh, AsinhOpConverter);
REGISTER_TRT_OP_CONVERTER
(
atanh
,
AtanhOpConverter
);
REGISTER_TRT_OP_CONVERTER
(
ceil
,
CeilOpConverter
);
REGISTER_TRT_OP_CONVERTER
(
floor
,
FloorOpConverter
);
REGISTER_TRT_OP_CONVERTER
(
rsqrt
,
RsqrtOpConverter
);
REGISTER_TRT_OP_CONVERTER
(
reciprocal
,
ReciprocalOpConverter
);
#if IS_TRT_VERSION_GE(7000)
REGISTER_TRT_OP_CONVERTER
(
erf
,
ErfOpConverter
);
...
...
paddle/fluid/inference/tensorrt/op_teller.cc
100644 → 100755
浏览文件 @
fc882c7b
...
...
@@ -2310,6 +2310,7 @@ struct SimpleOpTypeSetTeller : public Teller {
"atanh"
,
"ceil"
,
"floor"
,
"rsqrt"
,
"reciprocal"
,
"erf"
,
"softmax"
,
...
...
@@ -2438,6 +2439,7 @@ struct SimpleOpTypeSetTeller : public Teller {
"atanh"
,
"ceil"
,
"floor"
,
"rsqrt"
,
"reciprocal"
,
"erf"
,
"softmax"
,
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_unary.py
浏览文件 @
fc882c7b
...
...
@@ -31,16 +31,14 @@ class TrtConvertActivationTest(TrtLayerAutoScanTest):
self
.
trt_param
.
workspace_size
=
1073741824
def
generate_input1
(
dims
,
batch
,
attrs
:
List
[
Dict
[
str
,
Any
]]):
if
dims
==
1
:
return
np
.
random
.
random
([
32
]).
astype
(
np
.
float32
)
elif
dims
==
2
:
if
dims
==
2
:
return
np
.
random
.
random
([
3
,
32
]).
astype
(
np
.
float32
)
elif
dims
==
3
:
return
np
.
random
.
random
([
3
,
32
,
32
]).
astype
(
np
.
float32
)
else
:
return
np
.
random
.
random
([
batch
,
3
,
32
,
32
]).
astype
(
np
.
float32
)
for
dims
in
[
1
,
2
,
3
,
4
]:
for
dims
in
[
2
,
3
,
4
]:
for
batch
in
[
1
,
4
]:
for
op_type
in
[
"exp"
,
...
...
@@ -59,6 +57,7 @@ class TrtConvertActivationTest(TrtLayerAutoScanTest):
"atanh"
,
"ceil"
,
"floor"
,
"rsqrt"
,
"reciprocal"
,
]:
self
.
dims
=
dims
...
...
@@ -135,7 +134,7 @@ class TrtConvertActivationTest(TrtLayerAutoScanTest):
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
False
),
1e-
5
),
1e-
4
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
False
...
...
@@ -146,7 +145,7 @@ class TrtConvertActivationTest(TrtLayerAutoScanTest):
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
True
),
1e-
5
),
1e-
4
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
True
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录