Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
f06abb02
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f06abb02
编写于
11月 19, 2018
作者:
Z
zhangyang0701
提交者:
GitHub
11月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1299 from qnqinan/develop
update FPGA support op and related files, fix
#1296
上级
672caa36
a4f2e07d
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
645 addition
and
8 deletion
+645
-8
src/common/types.cpp
src/common/types.cpp
+5
-1
src/common/types.h
src/common/types.h
+3
-0
src/operators/fusion_conv_add_op.cpp
src/operators/fusion_conv_add_op.cpp
+3
-1
src/operators/fusion_conv_add_relu_op.h
src/operators/fusion_conv_add_relu_op.h
+3
-2
src/operators/fusion_deconv_add_op.cpp
src/operators/fusion_deconv_add_op.cpp
+33
-0
src/operators/fusion_deconv_add_op.h
src/operators/fusion_deconv_add_op.h
+108
-0
src/operators/fusion_deconv_add_relu_op.cpp
src/operators/fusion_deconv_add_relu_op.cpp
+34
-0
src/operators/fusion_deconv_add_relu_op.h
src/operators/fusion_deconv_add_relu_op.h
+110
-0
src/operators/kernel/deconv_add_kernel.h
src/operators/kernel/deconv_add_kernel.h
+39
-0
src/operators/kernel/deconv_add_relu_kernel.h
src/operators/kernel/deconv_add_relu_kernel.h
+39
-0
src/operators/kernel/fpga/V2/conv_add_kernel.cpp
src/operators/kernel/fpga/V2/conv_add_kernel.cpp
+61
-0
src/operators/kernel/fpga/V2/deconv_add_kernel.cpp
src/operators/kernel/fpga/V2/deconv_add_kernel.cpp
+36
-0
src/operators/kernel/fpga/V2/deconv_add_relu_kernel.cpp
src/operators/kernel/fpga/V2/deconv_add_relu_kernel.cpp
+37
-0
src/operators/kernel/fpga/V2/split_kernel.cpp
src/operators/kernel/fpga/V2/split_kernel.cpp
+30
-0
src/operators/kernel/fpga/V2/transpose2_kernel.cpp
src/operators/kernel/fpga/V2/transpose2_kernel.cpp
+36
-0
src/operators/op_param.h
src/operators/op_param.h
+36
-1
src/operators/split_op.cpp
src/operators/split_op.cpp
+4
-1
src/operators/tanh_op.cpp
src/operators/tanh_op.cpp
+1
-1
src/operators/transpose2_op.cpp
src/operators/transpose2_op.cpp
+3
-0
test/CMakeLists.txt
test/CMakeLists.txt
+8
-0
tools/op.cmake
tools/op.cmake
+16
-1
未找到文件。
src/common/types.cpp
浏览文件 @
f06abb02
...
...
@@ -73,6 +73,8 @@ const char *G_OP_TYPE_QUANTIZE = "quantize";
const
char
*
G_OP_TYPE_DEQUANTIZE
=
"dequantize"
;
extern
const
char
*
G_OP_TYPE_TANH
=
"tanh"
;
extern
const
char
*
G_OP_TYPE_FUSION_DECONV_RELU
=
"fusion_deconv_relu"
;
extern
const
char
*
G_OP_TYPE_FUSION_DECONV_ADD
=
"fusion_deconv_add"
;
extern
const
char
*
G_OP_TYPE_FUSION_DECONV_ADD_RELU
=
"fusion_deconv_add_relu"
;
std
::
unordered_map
<
std
::
string
,
std
::
pair
<
std
::
vector
<
std
::
string
>
,
std
::
vector
<
std
::
string
>>>
...
...
@@ -133,5 +135,7 @@ std::unordered_map<
{
G_OP_TYPE_QUANTIZE
,
{{
"X"
},
{
"Out"
,
"OutScale"
}}},
{
G_OP_TYPE_DEQUANTIZE
,
{{
"X"
,
"Scale"
},
{
"Out"
}}},
{
G_OP_TYPE_TANH
,
{{
"X"
},
{
"Out"
}}},
{
G_OP_TYPE_FUSION_DECONV_RELU
,
{{
"Input"
},
{
"Out"
}}}};
{
G_OP_TYPE_FUSION_DECONV_RELU
,
{{
"Input"
},
{
"Out"
}}},
{
G_OP_TYPE_FUSION_DECONV_ADD
,
{{
"Input"
},
{
"Out"
}}},
{
G_OP_TYPE_FUSION_DECONV_ADD_RELU
,
{{
"Input"
},
{
"Out"
}}}};
}
// namespace paddle_mobile
src/common/types.h
浏览文件 @
f06abb02
...
...
@@ -142,6 +142,9 @@ extern const char *G_OP_TYPE_DEQUANTIZE;
extern
const
char
*
G_OP_TYPE_TANH
;
extern
const
char
*
G_OP_TYPE_FUSION_DECONV_RELU
;
extern
const
char
*
G_OP_TYPE_FUSION_DECONV_ADD
;
extern
const
char
*
G_OP_TYPE_FUSION_DECONV_ADD_RELU
;
extern
std
::
unordered_map
<
std
::
string
,
std
::
pair
<
std
::
vector
<
std
::
string
>
,
std
::
vector
<
std
::
string
>>>
op_input_output_key
;
...
...
src/operators/fusion_conv_add_op.cpp
浏览文件 @
f06abb02
...
...
@@ -61,5 +61,7 @@ REGISTER_OPERATOR_MALI_GPU(fusion_conv_add, ops::FusionConvAddOp);
#ifdef PADDLE_MOBILE_CL
REGISTER_OPERATOR_CL
(
fusion_conv_add
,
ops
::
FusionConvAddOp
);
#endif
#ifdef PADDLE_MOBILE_FPGA
REGISTER_OPERATOR_FPGA
(
fusion_conv_add
,
ops
::
FusionConvAddOp
);
#endif
#endif
src/operators/fusion_conv_add_relu_op.h
浏览文件 @
f06abb02
...
...
@@ -29,8 +29,9 @@ namespace operators {
class
FusionConvAddReluOpMatcher
:
public
framework
::
FusionOpMatcher
{
public:
FusionConvAddReluOpMatcher
()
{
// node_ = framework::Node(G_OP_TYPE_FUSION_CONV_ADD);
// node_ > std::make_shared<framework::Node>(G_OP_TYPE_RELU);
node_
=
framework
::
Node
(
G_OP_TYPE_CONV
);
node_
>
std
::
make_shared
<
framework
::
Node
>
(
G_OP_TYPE_ELEMENTWISE_ADD
)
>
std
::
make_shared
<
framework
::
Node
>
(
G_OP_TYPE_RELU
);
}
void
FolderNodes
(
...
...
src/operators/fusion_deconv_add_op.cpp
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_DECONVADD_OP
#include "operators/fusion_deconv_add_op.h"
namespace
paddle_mobile
{
namespace
operators
{}
}
// namespace paddle_mobile
namespace
ops
=
paddle_mobile
::
operators
;
REGISTER_FUSION_MATCHER
(
fusion_deconv_add
,
ops
::
FusionDeconvAddMatcher
);
#ifdef PADDLE_MOBILE_CPU
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
#endif
#ifdef PADDLE_MOBILE_FPGA
REGISTER_OPERATOR_FPGA
(
fusion_deconv_add
,
ops
::
FusionDeconvAddOp
);
#endif
#endif
src/operators/fusion_deconv_add_op.h
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_DECONVADD_OP
#pragma once
#include <string>
#include <vector>
#include "framework/operator.h"
#include "framework/program/program-optimize/fusion_op_register.h"
#include "operators/kernel/deconv_add_kernel.h"
namespace
paddle_mobile
{
namespace
operators
{
using
std
::
string
;
using
std
::
vector
;
class
FusionDeconvAddMatcher
:
public
framework
::
FusionOpMatcher
{
public:
FusionDeconvAddMatcher
()
{
node_
=
framework
::
Node
(
G_OP_TYPE_CONV_TRANSPOSE
);
node_
>
std
::
make_shared
<
framework
::
Node
>
(
G_OP_TYPE_ELEMENTWISE_ADD
);
}
void
FolderNodes
(
framework
::
Node
*
node
,
std
::
vector
<
std
::
shared_ptr
<
framework
::
Node
>>
*
removed_nodes
)
{
node
->
Folder
(
node_
.
Depth
(),
Type
(),
{{
G_OP_TYPE_ELEMENTWISE_ADD
,
{{
"Y"
,
"Y"
}}}},
removed_nodes
);
}
std
::
string
Type
()
{
return
G_OP_TYPE_FUSION_DECONV_ADD
;
}
};
template
<
typename
DeviceType
,
typename
T
>
class
FusionDeconvAddOp
:
public
framework
::
OperatorWithKernel
<
DeviceType
,
FusionDeconvAddParam
<
DeviceType
>
,
operators
::
DeconvAddKernel
<
DeviceType
,
T
>>
{
public:
FusionDeconvAddOp
(
const
string
&
type
,
const
VariableNameMap
&
inputs
,
const
VariableNameMap
&
outputs
,
const
framework
::
AttributeMap
&
attrs
,
std
::
shared_ptr
<
framework
::
Scope
>
scope
)
:
framework
::
OperatorWithKernel
<
DeviceType
,
FusionDeconvAddParam
<
DeviceType
>
,
operators
::
DeconvAddKernel
<
DeviceType
,
T
>>
(
type
,
inputs
,
outputs
,
attrs
,
scope
)
{}
void
InferShape
()
const
{
auto
input
=
this
->
param_
.
Input
();
auto
in_dims
=
input
->
dims
();
auto
filter
=
this
->
param_
.
Filter
();
auto
filter_dims
=
filter
->
dims
();
std
::
vector
<
int
>
strides
=
this
->
param_
.
Strides
();
std
::
vector
<
int
>
paddings
=
this
->
param_
.
Paddings
();
std
::
vector
<
int
>
dilations
=
this
->
param_
.
Dilations
();
int
groups
=
this
->
param_
.
Groups
();
PADDLE_MOBILE_ENFORCE
(
in_dims
.
size
()
==
4
||
in_dims
.
size
()
==
5
,
"ConvTransposeOp intput should be 4-D or 5-D tensor."
);
PADDLE_MOBILE_ENFORCE
(
in_dims
.
size
()
==
filter_dims
.
size
(),
"ConvTransposeOp input dimension and filter dimension "
"should be the same."
);
PADDLE_MOBILE_ENFORCE
(
in_dims
.
size
()
-
strides
.
size
()
==
2U
,
"ConvTransposeOp input dimension and strides dimension should "
"be consistent."
);
PADDLE_MOBILE_ENFORCE
(
paddings
.
size
()
==
strides
.
size
(),
"ConvTransposeOp paddings dimension and strides "
"dimension should be the same."
);
PADDLE_MOBILE_ENFORCE
(
paddings
.
size
()
==
dilations
.
size
(),
"ConvTransposeOp paddings dimension and dilations "
"dimension should be the same."
);
PADDLE_MOBILE_ENFORCE
(
in_dims
[
1
]
==
filter_dims
[
0
],
"In ConvTransposeOp, The number of input channels should "
"be equal to the number of filter's channels."
);
std
::
vector
<
int64_t
>
output_shape
({
in_dims
[
0
],
filter_dims
[
1
]
*
groups
});
for
(
size_t
i
=
0
;
i
<
strides
.
size
();
++
i
)
{
auto
filter_extent
=
dilations
[
i
]
*
(
filter_dims
[
i
+
2
]
-
1
)
+
1
;
output_shape
.
push_back
((
in_dims
[
i
+
2
]
-
1
)
*
strides
[
i
]
-
2
*
paddings
[
i
]
+
filter_extent
);
}
this
->
param_
.
Output
()
->
Resize
(
framework
::
make_ddim
(
output_shape
));
}
protected:
};
}
// namespace operators
}
// namespace paddle_mobile
#endif // FUSION_DECONV_ADD_OP
src/operators/fusion_deconv_add_relu_op.cpp
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_DECONVADDRELU_OP
#include "operators/fusion_deconv_add_relu_op.h"
namespace
paddle_mobile
{
namespace
operators
{}
}
// namespace paddle_mobile
namespace
ops
=
paddle_mobile
::
operators
;
REGISTER_FUSION_MATCHER
(
fusion_deconv_add_relu
,
ops
::
FusionDeconvAddReluMatcher
);
#ifdef PADDLE_MOBILE_CPU
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
#endif
#ifdef PADDLE_MOBILE_FPGA
REGISTER_OPERATOR_FPGA
(
fusion_deconv_add_relu
,
ops
::
FusionDeconvAddReluOp
);
#endif
#endif
src/operators/fusion_deconv_add_relu_op.h
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_DECONVADDRELU_OP
#pragma once
#include <string>
#include <vector>
#include "framework/operator.h"
#include "framework/program/program-optimize/fusion_op_register.h"
#include "operators/kernel/deconv_add_relu_kernel.h"
namespace
paddle_mobile
{
namespace
operators
{
using
std
::
string
;
using
std
::
vector
;
class
FusionDeconvAddReluMatcher
:
public
framework
::
FusionOpMatcher
{
public:
FusionDeconvAddReluMatcher
()
{
node_
=
framework
::
Node
(
G_OP_TYPE_CONV_TRANSPOSE
);
node_
>
std
::
make_shared
<
framework
::
Node
>
(
G_OP_TYPE_ELEMENTWISE_ADD
)
>
std
::
make_shared
<
framework
::
Node
>
(
G_OP_TYPE_RELU
);
}
void
FolderNodes
(
framework
::
Node
*
node
,
std
::
vector
<
std
::
shared_ptr
<
framework
::
Node
>>
*
removed_nodes
)
{
node
->
Folder
(
node_
.
Depth
(),
Type
(),
{{
G_OP_TYPE_ELEMENTWISE_ADD
,
{{
"Y"
,
"Y"
}}}},
removed_nodes
);
}
std
::
string
Type
()
{
return
G_OP_TYPE_FUSION_DECONV_ADD_RELU
;
}
};
template
<
typename
DeviceType
,
typename
T
>
class
FusionDeconvAddReluOp
:
public
framework
::
OperatorWithKernel
<
DeviceType
,
FusionDeconvAddReluParam
<
DeviceType
>
,
operators
::
DeconvAddReluKernel
<
DeviceType
,
T
>>
{
public:
FusionDeconvAddReluOp
(
const
string
&
type
,
const
VariableNameMap
&
inputs
,
const
VariableNameMap
&
outputs
,
const
framework
::
AttributeMap
&
attrs
,
std
::
shared_ptr
<
framework
::
Scope
>
scope
)
:
framework
::
OperatorWithKernel
<
DeviceType
,
FusionDeconvAddReluParam
<
DeviceType
>
,
operators
::
DeconvAddReluKernel
<
DeviceType
,
T
>>
(
type
,
inputs
,
outputs
,
attrs
,
scope
)
{}
void
InferShape
()
const
{
auto
input
=
this
->
param_
.
Input
();
auto
in_dims
=
input
->
dims
();
auto
filter
=
this
->
param_
.
Filter
();
auto
filter_dims
=
filter
->
dims
();
std
::
vector
<
int
>
strides
=
this
->
param_
.
Strides
();
std
::
vector
<
int
>
paddings
=
this
->
param_
.
Paddings
();
std
::
vector
<
int
>
dilations
=
this
->
param_
.
Dilations
();
int
groups
=
this
->
param_
.
Groups
();
PADDLE_MOBILE_ENFORCE
(
in_dims
.
size
()
==
4
||
in_dims
.
size
()
==
5
,
"ConvTransposeOp intput should be 4-D or 5-D tensor."
);
PADDLE_MOBILE_ENFORCE
(
in_dims
.
size
()
==
filter_dims
.
size
(),
"ConvTransposeOp input dimension and filter dimension "
"should be the same."
);
PADDLE_MOBILE_ENFORCE
(
in_dims
.
size
()
-
strides
.
size
()
==
2U
,
"ConvTransposeOp input dimension and strides dimension should "
"be consistent."
);
PADDLE_MOBILE_ENFORCE
(
paddings
.
size
()
==
strides
.
size
(),
"ConvTransposeOp paddings dimension and strides "
"dimension should be the same."
);
PADDLE_MOBILE_ENFORCE
(
paddings
.
size
()
==
dilations
.
size
(),
"ConvTransposeOp paddings dimension and dilations "
"dimension should be the same."
);
PADDLE_MOBILE_ENFORCE
(
in_dims
[
1
]
==
filter_dims
[
0
],
"In ConvTransposeOp, The number of input channels should "
"be equal to the number of filter's channels."
);
std
::
vector
<
int64_t
>
output_shape
({
in_dims
[
0
],
filter_dims
[
1
]
*
groups
});
for
(
size_t
i
=
0
;
i
<
strides
.
size
();
++
i
)
{
auto
filter_extent
=
dilations
[
i
]
*
(
filter_dims
[
i
+
2
]
-
1
)
+
1
;
output_shape
.
push_back
((
in_dims
[
i
+
2
]
-
1
)
*
strides
[
i
]
-
2
*
paddings
[
i
]
+
filter_extent
);
}
this
->
param_
.
Output
()
->
Resize
(
framework
::
make_ddim
(
output_shape
));
}
protected:
};
}
// namespace operators
}
// namespace paddle_mobile
#endif // FUSION_DECONV_ADD_RELU_OP
src/operators/kernel/deconv_add_kernel.h
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_DECONVADD_OP
#pragma once
#include "framework/operator.h"
#include "operators/op_param.h"
namespace
paddle_mobile
{
namespace
operators
{
using
framework
::
OpKernelBase
;
template
<
typename
DeviceType
,
typename
T
>
class
DeconvAddKernel
:
public
OpKernelBase
<
DeviceType
,
FusionDeconvAddParam
<
DeviceType
>>
{
public:
void
Compute
(
const
FusionDeconvAddParam
<
DeviceType
>
&
param
);
bool
Init
(
FusionDeconvAddParam
<
DeviceType
>
*
param
);
};
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/kernel/deconv_add_relu_kernel.h
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_DECONVADDRELU_OP
#pragma once
#include "framework/operator.h"
#include "operators/op_param.h"
namespace
paddle_mobile
{
namespace
operators
{
using
framework
::
OpKernelBase
;
template
<
typename
DeviceType
,
typename
T
>
class
DeconvAddReluKernel
:
public
OpKernelBase
<
DeviceType
,
FusionDeconvAddReluParam
<
DeviceType
>>
{
public:
void
Compute
(
const
FusionDeconvAddReluParam
<
DeviceType
>
&
param
);
bool
Init
(
FusionDeconvAddReluParam
<
DeviceType
>
*
param
);
};
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/kernel/fpga/V2/conv_add_kernel.cpp
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_CONVADD_OP
#include "operators/kernel/conv_add_kernel.h"
namespace
paddle_mobile
{
namespace
operators
{
template
<
>
bool
ConvAddKernel
<
FPGA
,
float
>::
Init
(
FusionConvAddParam
<
FPGA
>
*
param
)
{
bool
relu_enabled
=
false
;
auto
input
=
const_cast
<
Tensor
*>
(
param
->
Input
());
const
Tensor
*
bias
=
param
->
Bias
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
auto
filter
=
const_cast
<
Tensor
*>
(
param
->
Filter
());
auto
out
=
param
->
Output
();
PADDLE_MOBILE_ENFORCE
(
out
->
dims
()[
1
]
==
bias
->
dims
()[
0
],
"Output channel should be equal to bias number"
);
int
channel
=
out
->
dims
()[
1
];
auto
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
// NOLINT
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
bs_ptr
[
i
+
channel
]
=
1
;
bs_ptr
[
i
]
=
bias_ptr
[
i
];
}
fpga
::
format_conv_data
(
filter
,
out
,
bs_ptr
,
param
->
Groups
());
fpga
::
SplitConvArgs
conv_arg
=
{
0
};
fpga
::
fill_split_arg
(
&
conv_arg
,
input
,
out
,
filter
,
relu_enabled
,
param
->
Groups
(),
param
->
Strides
()[
0
],
param
->
Strides
()[
1
],
param
->
Paddings
()[
0
],
param
->
Paddings
()[
1
],
bs_ptr
);
param
->
SetFpgaArgs
(
conv_arg
);
return
true
;
}
template
<
>
void
ConvAddKernel
<
FPGA
,
float
>::
Compute
(
const
FusionConvAddParam
<
FPGA
>
&
param
)
{
fpga
::
ComputeFpgaConv
(
param
.
FpgaArgs
());
}
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/kernel/fpga/V2/deconv_add_kernel.cpp
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_DECONVADD_OP
#include "operators/kernel/deconv_add_kernel.h"
#include "framework/operator.h"
#include "operators/op_param.h"
namespace
paddle_mobile
{
namespace
operators
{
template
<
>
bool
DeconvAddKernel
<
FPGA
,
float
>::
Init
(
FusionDeconvAddParam
<
FPGA
>
*
param
)
{
return
true
;
}
template
<
>
void
DeconvAddKernel
<
FPGA
,
float
>::
Compute
(
const
FusionDeconvAddParam
<
FPGA
>
&
param
)
{}
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/kernel/fpga/V2/deconv_add_relu_kernel.cpp
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef FUSION_DECONVADDRELU_OP
#include "operators/kernel/deconv_add_relu_kernel.h"
#include "framework/operator.h"
#include "operators/op_param.h"
namespace
paddle_mobile
{
namespace
operators
{
template
<
>
bool
DeconvAddReluKernel
<
FPGA
,
float
>::
Init
(
FusionDeconvAddReluParam
<
FPGA
>
*
param
)
{
return
true
;
}
template
<
>
void
DeconvAddReluKernel
<
FPGA
,
float
>::
Compute
(
const
FusionDeconvAddReluParam
<
FPGA
>
&
param
)
{}
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/kernel/fpga/V2/split_kernel.cpp
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef SPLIT_OP
#include "operators/kernel/split_kernel.h"
namespace
paddle_mobile
{
namespace
operators
{
template
<
>
bool
SplitKernel
<
FPGA
,
float
>::
Init
(
SplitParam
<
FPGA
>*
param
)
{
return
true
;
}
template
<
>
void
SplitKernel
<
FPGA
,
float
>::
Compute
(
const
SplitParam
<
FPGA
>&
param
)
{}
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/kernel/fpga/V2/transpose2_kernel.cpp
0 → 100644
浏览文件 @
f06abb02
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef TRANSPOSE2_OP
#include "operators/kernel/transpose2_kernel.h"
#include "operators/kernel/central-arm-func/transpose2_arm_func.h"
namespace
paddle_mobile
{
namespace
operators
{
template
<
>
bool
Transpose2Kernel
<
FPGA
,
float
>::
Init
(
Transpose2Param
<
FPGA
>
*
param
)
{
return
true
;
}
template
<
>
void
Transpose2Kernel
<
FPGA
,
float
>::
Compute
(
const
Transpose2Param
<
FPGA
>
&
param
)
{
// Transpose2Compute<float>(param);
}
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/op_param.h
浏览文件 @
f06abb02
...
...
@@ -2221,7 +2221,10 @@ class ConvTransposeParam : public OpParam {
const
Scope
&
scope
)
{
filter_
=
FilterFrom
<
GType
>
(
inputs
,
scope
);
input_
=
InputFrom
<
GType
>
(
inputs
,
scope
);
output_
=
OutputFrom
<
GType
>
(
outputs
,
scope
);
// output_ = OutputFrom<GType>(outputs, scope);
if
(
outputs
.
count
(
"Output"
))
{
output_
=
OpParam
::
OutputFrom
<
GType
>
(
outputs
,
scope
);
}
strides_
=
GetAttr
<
vector
<
int
>>
(
"strides"
,
attrs
);
paddings_
=
GetAttr
<
vector
<
int
>>
(
"paddings"
,
attrs
);
dilations_
=
GetAttr
<
vector
<
int
>>
(
"dilations"
,
attrs
);
...
...
@@ -2262,6 +2265,38 @@ class ConvTransposeParam : public OpParam {
#endif
};
#endif
#ifdef FUSION_DECONVADD_OP
template
<
typename
Dtype
>
class
FusionDeconvAddParam
:
public
ConvTransposeParam
<
Dtype
>
{
typedef
typename
DtypeTensorTrait
<
Dtype
>::
gtype
GType
;
typedef
typename
DtypeTensorTrait
<
Dtype
>::
rtype
RType
;
public:
FusionDeconvAddParam
(
const
VariableNameMap
&
inputs
,
const
VariableNameMap
&
outputs
,
const
AttributeMap
&
attrs
,
const
Scope
&
scope
)
:
ConvTransposeParam
<
Dtype
>
(
inputs
,
outputs
,
attrs
,
scope
)
{
bias_
=
OpParam
::
InputYFrom
<
GType
>
(
inputs
,
scope
);
axis_
=
OpParam
::
GetAttr
<
int
>
(
"axis"
,
attrs
);
output_
=
OpParam
::
OutFrom
<
GType
>
(
outputs
,
scope
);
}
RType
*
Bias
()
const
{
return
bias_
;
}
const
int
&
Axis
()
const
{
return
axis_
;
}
RType
*
Output
()
const
{
return
output_
;
}
protected:
RType
*
bias_
;
int
axis_
;
RType
*
output_
;
};
#endif
#ifdef FUSION_DECONVADDRELU_OP
template
<
typename
Dtype
>
using
FusionDeconvAddReluParam
=
FusionDeconvAddParam
<
Dtype
>
;
#endif
#ifdef FUSION_DECONVRELU_OP
template
<
typename
Dtype
>
...
...
src/operators/split_op.cpp
浏览文件 @
f06abb02
...
...
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. */
#ifdef SPLIT_OP
#include "operators/split_op.h"
#include <vector>
namespace
paddle_mobile
{
namespace
operators
{
...
...
@@ -83,5 +83,8 @@ namespace ops = paddle_mobile::operators;
#ifdef PADDLE_MOBILE_CPU
REGISTER_OPERATOR_CPU
(
split
,
ops
::
SplitOp
);
#endif
#ifdef PADDLE_MOBILE_FPGA
REGISTER_OPERATOR_FPGA
(
split
,
ops
::
SplitOp
);
#endif
#endif // SPLIT_OP
src/operators/tanh_op.cpp
浏览文件 @
f06abb02
...
...
@@ -29,7 +29,7 @@ void TanhOp<DeviceType, T>::InferShape() const {
namespace
ops
=
paddle_mobile
::
operators
;
#ifdef PADDLE_MOBILE_FPGA
REGISTER_OPERATOR_FPGA
(
T
anh
,
ops
::
TanhOp
);
REGISTER_OPERATOR_FPGA
(
t
anh
,
ops
::
TanhOp
);
#endif
#endif
src/operators/transpose2_op.cpp
浏览文件 @
f06abb02
...
...
@@ -60,5 +60,8 @@ namespace ops = paddle_mobile::operators;
#ifdef PADDLE_MOBILE_CPU
REGISTER_OPERATOR_CPU
(
transpose2
,
ops
::
Transpose2Op
);
#endif
#ifdef PADDLE_MOBILE_FPGA
REGISTER_OPERATOR_FPGA
(
transpose2
,
ops
::
Transpose2Op
);
#endif
#endif // TRANSPOSE_OP
test/CMakeLists.txt
浏览文件 @
f06abb02
...
...
@@ -66,6 +66,10 @@ list(FIND NET "FPGA_NET_V1" CON)
if
(
CON GREATER -1
)
ADD_EXECUTABLE
(
test-resnet50 fpga/test_resnet50.cpp test_helper.h test_include.h executor_for_test.h
)
target_link_libraries
(
test-resnet50 paddle-mobile
)
ADD_EXECUTABLE
(
test-densebox net/test_densebox_combine.cpp test_helper.h test_include.h executor_for_test.h
)
target_link_libraries
(
test-densebox paddle-mobile
)
set
(
FOUND_MATCH ON
)
endif
()
...
...
@@ -76,6 +80,10 @@ if (CON GREATER -1)
ADD_EXECUTABLE
(
test-pe fpga/test_pe.cpp
)
target_link_libraries
(
test-pe paddle-mobile
)
ADD_EXECUTABLE
(
test-densebox net/test_densebox_combine.cpp test_helper.h test_include.h executor_for_test.h
)
target_link_libraries
(
test-densebox paddle-mobile
)
set
(
FOUND_MATCH ON
)
endif
()
...
...
tools/op.cmake
浏览文件 @
f06abb02
...
...
@@ -127,6 +127,8 @@ endif()
list
(
FIND NET
"FPGA_NET_V2"
CON
)
if
(
CON GREATER -1
)
message
(
"FPGA_NET_V2 enabled"
)
set
(
FEED_OP ON
)
set
(
FUSION_CONVADDRELU_OP ON
)
set
(
FUSION_ELEMENTWISEADDRELU_OP ON
)
set
(
FUSION_FC_OP ON
)
set
(
POOL_OP ON
)
...
...
@@ -135,9 +137,16 @@ if (CON GREATER -1)
set
(
FUSION_CONVBN_OP ON
)
set
(
CONV_TRANSPOSE_OP ON
)
set
(
FUSION_DECONVRELU_OP ON
)
set
(
SLICE_OP ON
)
#
set(SLICE_OP ON)
set
(
TANH_OP ON
)
set
(
ELEMENTWISEADD_OP ON
)
set
(
TRANSPOSE2_OP ON
)
set
(
FUSION_CONVADD_OP ON
)
set
(
SPLIT_OP ON
)
set
(
FUSION_DECONVADD_OP ON
)
set
(
FUSION_DECONVADDRELU_OP ON
)
set
(
FOUND_MATCH ON
)
endif
()
...
...
@@ -452,4 +461,10 @@ if (TANH_OP)
endif
()
if
(
FUSION_DECONVRELU_OP
)
add_definitions
(
-DFUSION_DECONVRELU_OP
)
endif
()
if
(
FUSION_DECONVADD_OP
)
add_definitions
(
-DFUSION_DECONVADD_OP
)
endif
()
if
(
FUSION_DECONVADDRELU_OP
)
add_definitions
(
-DFUSION_DECONVADDRELU_OP
)
endif
()
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录