mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 00:57:33 +08:00
[Doc] Change all PaddleLite or Paddle-Lite to Paddle Lite (#929)
* [FlyCV] Bump up FlyCV -> official release 1.0.0 * change PaddleLite or Paddle-Lite to Paddle lite * fix docs * fix doc Co-authored-by: DefTruth <qiustudent_r@163.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
This commit is contained in:
38
examples/application/js/converter/fuseOps.py
Normal file → Executable file
38
examples/application/js/converter/fuseOps.py
Normal file → Executable file
@@ -1,20 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
|
||||
def opListFuse(ops):
|
||||
""" 算子融合 """
|
||||
fuseOpList = [
|
||||
'relu',
|
||||
'relu6',
|
||||
'leaky_relu',
|
||||
'scale',
|
||||
'sigmoid',
|
||||
'hard_sigmoid',
|
||||
'pow',
|
||||
'sqrt',
|
||||
'tanh',
|
||||
'hard_swish',
|
||||
'dropout'
|
||||
'relu', 'relu6', 'leaky_relu', 'scale', 'sigmoid', 'hard_sigmoid',
|
||||
'pow', 'sqrt', 'tanh', 'hard_swish', 'dropout'
|
||||
]
|
||||
|
||||
# 判断op是否为单节点
|
||||
@@ -37,39 +29,41 @@ def opListFuse(ops):
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
for index in reversed(range(len(ops))):
|
||||
if index > 0:
|
||||
op = ops[index]
|
||||
|
||||
# 兼容paddlelite 算子融合字段
|
||||
# 兼容 Paddle Lite 算子融合字段
|
||||
if 'act_type' in op['attrs']:
|
||||
name = op['attrs']['act_type']
|
||||
op['attrs']['fuse_opt'] = {}
|
||||
op['attrs']['fuse_opt'][name] = {}
|
||||
|
||||
if name == 'hard_swish':
|
||||
op['attrs']['fuse_opt'][name]['offset'] = op['attrs']['hard_swish_offset']
|
||||
op['attrs']['fuse_opt'][name]['scale'] = op['attrs']['hard_swish_scale']
|
||||
op['attrs']['fuse_opt'][name]['threshold'] = op['attrs']['hard_swish_threshold']
|
||||
op['attrs']['fuse_opt'][name]['offset'] = op['attrs'][
|
||||
'hard_swish_offset']
|
||||
op['attrs']['fuse_opt'][name]['scale'] = op['attrs'][
|
||||
'hard_swish_scale']
|
||||
op['attrs']['fuse_opt'][name]['threshold'] = op['attrs'][
|
||||
'hard_swish_threshold']
|
||||
|
||||
if name == 'relu6':
|
||||
op['attrs']['fuse_opt'][name]['threshold'] = op['attrs']['fuse_brelu_threshold']
|
||||
op['attrs']['fuse_opt'][name]['threshold'] = op['attrs'][
|
||||
'fuse_brelu_threshold']
|
||||
|
||||
for fuse in fuseOpList:
|
||||
if op['type'] == fuse:
|
||||
prevOp = ops[index - 1]
|
||||
|
||||
if opExistSingleNode(prevOp['outputs']['Out'][0]) and len(prevOp['outputs']['Out']) == 1 :
|
||||
if opExistSingleNode(prevOp['outputs']['Out'][0]) and len(
|
||||
prevOp['outputs']['Out']) == 1:
|
||||
prevOp['attrs']['fuse_opt'] = {}
|
||||
if 'fuse_opt' in op['attrs']:
|
||||
prevOp['attrs']['fuse_opt'] = op['attrs']['fuse_opt']
|
||||
prevOp['attrs']['fuse_opt'] = op['attrs'][
|
||||
'fuse_opt']
|
||||
del op['attrs']['fuse_opt']
|
||||
|
||||
prevOp['attrs']['fuse_opt'][fuse] = op['attrs']
|
||||
prevOp['outputs']['Out'] = op['outputs']['Out']
|
||||
|
||||
del ops[index]
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user