Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
5533eddb
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
338
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看板
提交
5533eddb
编写于
9月 16, 2020
作者:
J
Jiansong Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove/edit some comments.
上级
143c7e5e
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
37 addition
and
116 deletion
+37
-116
lite/api/CMakeLists.txt
lite/api/CMakeLists.txt
+3
-3
lite/backends/imagination_nna/imgdnn_manager.h
lite/backends/imagination_nna/imgdnn_manager.h
+7
-0
lite/kernels/imagination_nna/bridges/CMakeLists.txt
lite/kernels/imagination_nna/bridges/CMakeLists.txt
+0
-56
lite/kernels/imagination_nna/bridges/batch_norm_op.cc
lite/kernels/imagination_nna/bridges/batch_norm_op.cc
+2
-13
lite/kernels/imagination_nna/bridges/graph.cc
lite/kernels/imagination_nna/bridges/graph.cc
+1
-1
lite/kernels/imagination_nna/bridges/graph.h
lite/kernels/imagination_nna/bridges/graph.h
+15
-20
lite/kernels/imagination_nna/bridges/paddle_use_bridges.h
lite/kernels/imagination_nna/bridges/paddle_use_bridges.h
+0
-1
lite/kernels/imagination_nna/bridges/pool_op.cc
lite/kernels/imagination_nna/bridges/pool_op.cc
+5
-8
lite/kernels/imagination_nna/bridges/utility.cc
lite/kernels/imagination_nna/bridges/utility.cc
+0
-2
lite/kernels/imagination_nna/subgraph_compute.cc
lite/kernels/imagination_nna/subgraph_compute.cc
+3
-11
tools/codestyle/clang_format.hook
tools/codestyle/clang_format.hook
+1
-1
未找到文件。
lite/api/CMakeLists.txt
浏览文件 @
5533eddb
...
@@ -87,7 +87,7 @@ else()
...
@@ -87,7 +87,7 @@ else()
target_link_libraries
(
paddle_light_api_shared
${
rknpu_builder_libs
}
${
rknpu_runtime_libs
}
)
target_link_libraries
(
paddle_light_api_shared
${
rknpu_builder_libs
}
${
rknpu_runtime_libs
}
)
endif
()
endif
()
if
(
LITE_WITH_IMAGINATION_NNA
)
if
(
LITE_WITH_IMAGINATION_NNA
)
# Need to add IMG IMAGINATION_NNA runtime libs (lib
hiai
.so) dependency
# Need to add IMG IMAGINATION_NNA runtime libs (lib
imgdnn.so, libnnasession
.so) dependency
#target_link_libraries(paddle_light_api_shared ${nna_builder_libs} ${nna_runtime_libs})
#target_link_libraries(paddle_light_api_shared ${nna_builder_libs} ${nna_runtime_libs})
endif
()
endif
()
endif
()
endif
()
...
@@ -123,8 +123,8 @@ if(LITE_WITH_RKNPU)
...
@@ -123,8 +123,8 @@ if(LITE_WITH_RKNPU)
endif
()
endif
()
if
(
LITE_WITH_IMAGINATION_NNA
)
if
(
LITE_WITH_IMAGINATION_NNA
)
set
(
light_api_deps
${
light_api_deps
}
${
nna_deps
}
)
set
(
light_api_deps
${
light_api_deps
}
${
imagination_
nna_deps
}
)
set
(
cxx_api_deps
${
cxx_api_deps
}
${
nna_deps
}
)
set
(
cxx_api_deps
${
cxx_api_deps
}
${
imagination_
nna_deps
}
)
endif
()
endif
()
if
(
LITE_WITH_HUAWEI_ASCEND_NPU
)
if
(
LITE_WITH_HUAWEI_ASCEND_NPU
)
...
...
lite/backends/imagination_nna/imgdnn_manager.h
浏览文件 @
5533eddb
...
@@ -222,6 +222,13 @@ class ImgdnnManager {
...
@@ -222,6 +222,13 @@ class ImgdnnManager {
return
desc
;
return
desc
;
}
}
imgdnn_tensor_descriptor
getTensorDescriptor
(
imgdnn_tensor
tensor
)
{
imgdnn_tensor_descriptor
desc
;
err_
=
imgdnnGetTensorDescriptor
(
tensor
,
&
desc
);
ASSERT
(
err_
!=
IMGDNN_SUCCESS
,
"GetTensorDescriptors failed!"
);
return
desc
;
}
size_t
getDescriptorSize
(
const
imgdnn_tensor_descriptor
*
const
descriptor
)
{
size_t
getDescriptorSize
(
const
imgdnn_tensor_descriptor
*
const
descriptor
)
{
size_t
size
=
imgdnnGetDescriptorSize
(
descriptor
,
&
err_
);
size_t
size
=
imgdnnGetDescriptorSize
(
descriptor
,
&
err_
);
ASSERT
(
err_
!=
IMGDNN_SUCCESS
,
"GetDescriptorSize failed!"
);
ASSERT
(
err_
!=
IMGDNN_SUCCESS
,
"GetDescriptorSize failed!"
);
...
...
lite/kernels/imagination_nna/bridges/CMakeLists.txt
浏览文件 @
5533eddb
...
@@ -9,37 +9,8 @@ set(imagination_nna_subgraph_bridge_deps subgraph_bridge_registry subgraph_bridg
...
@@ -9,37 +9,8 @@ set(imagination_nna_subgraph_bridge_deps subgraph_bridge_registry subgraph_bridg
lite_cc_library
(
subgraph_bridge_fc_op_imagination_nna SRCS fc_op.cc DEPS
${
imagination_nna_subgraph_bridge_deps
}
)
lite_cc_library
(
subgraph_bridge_fc_op_imagination_nna SRCS fc_op.cc DEPS
${
imagination_nna_subgraph_bridge_deps
}
)
lite_cc_library
(
subgraph_bridge_conv_op_imagination_nna SRCS conv_op.cc DEPS
${
imagination_nna_subgraph_bridge_deps
}
)
lite_cc_library
(
subgraph_bridge_conv_op_imagination_nna SRCS conv_op.cc DEPS
${
imagination_nna_subgraph_bridge_deps
}
)
#lite_cc_library(subgraph_bridge_matmul_op_imagination_nna SRCS matmul_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_mul_op_imagination_nna SRCS mul_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
lite_cc_library
(
subgraph_bridge_act_op_imagination_nna SRCS act_op.cc DEPS
${
imagination_nna_subgraph_bridge_deps
}
)
lite_cc_library
(
subgraph_bridge_act_op_imagination_nna SRCS act_op.cc DEPS
${
imagination_nna_subgraph_bridge_deps
}
)
#lite_cc_library(subgraph_bridge_scale_op_imagination_nna SRCS scale_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_softmax_op_imagination_nna SRCS softmax_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
lite_cc_library
(
subgraph_bridge_pool_op_imagination_nna SRCS pool_op.cc DEPS
${
imagination_nna_subgraph_bridge_deps
}
)
lite_cc_library
(
subgraph_bridge_pool_op_imagination_nna SRCS pool_op.cc DEPS
${
imagination_nna_subgraph_bridge_deps
}
)
#lite_cc_library(subgraph_bridge_batch_norm_op_imagination_nna SRCS batch_norm_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_elementwise_ops_imagination_nna SRCS elementwise_ops.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_reshape_op_imagination_nna SRCS reshape_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_conv_transpose_op_imagination_nna SRCS conv_transpose_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_interpolate_op_imagination_nna SRCS interpolate_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_transpose_op_imagination_nna SRCS transpose_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_split_op_imagination_nna SRCS split_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_concat_op_imagination_nna SRCS concat_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_shuffle_channel_op_imagination_nna SRCS shuffle_channel_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_pad2d_op_imagination_nna SRCS pad2d_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_reduce_mean_op_imagination_nna SRCS reduce_mean_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_unsqueeze_op_imagination_nna SRCS unsqueeze_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_gather_op_imagination_nna SRCS gather_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_lookup_table_op_imagination_nna SRCS lookup_table_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_argmax_op_imagination_nna SRCS argmax_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_instance_norm_op_imagination_nna SRCS instance_norm_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_dropout_op_imagination_nna SRCS dropout_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_topk_op_imagination_nna SRCS topk_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_layer_norm_op_imagination_nna SRCS layer_norm_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_fill_constant_op_imagination_nna SRCS fill_constant_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_fill_constant_batch_size_like_op_imagination_nna SRCS fill_constant_batch_size_like_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_increment_op_imagination_nna SRCS increment_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_compare_op_imagination_nna SRCS compare_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
#lite_cc_library(subgraph_bridge_shape_op_imagination_nna SRCS shape_op.cc DEPS ${imagination_nna_subgraph_bridge_deps})
set
(
imagination_nna_subgraph_bridges
set
(
imagination_nna_subgraph_bridges
subgraph_bridge_registry
subgraph_bridge_registry
...
@@ -47,35 +18,8 @@ set(imagination_nna_subgraph_bridges
...
@@ -47,35 +18,8 @@ set(imagination_nna_subgraph_bridges
subgraph_bridge_graph_imagination_nna
subgraph_bridge_graph_imagination_nna
subgraph_bridge_fc_op_imagination_nna
subgraph_bridge_fc_op_imagination_nna
subgraph_bridge_conv_op_imagination_nna
subgraph_bridge_conv_op_imagination_nna
#subgraph_bridge_matmul_op_imagination_nna
#subgraph_bridge_mul_op_imagination_nna
subgraph_bridge_act_op_imagination_nna
subgraph_bridge_act_op_imagination_nna
#subgraph_bridge_scale_op_imagination_nna
#subgraph_bridge_softmax_op_imagination_nna
subgraph_bridge_pool_op_imagination_nna
subgraph_bridge_pool_op_imagination_nna
#subgraph_bridge_batch_norm_op_imagination_nna
#subgraph_bridge_elementwise_ops_imagination_nna
#subgraph_bridge_reshape_op_imagination_nna
#subgraph_bridge_conv_transpose_op_imagination_nna
#subgraph_bridge_interpolate_op_imagination_nna
#subgraph_bridge_transpose_op_imagination_nna
#subgraph_bridge_split_op_imagination_nna
#subgraph_bridge_concat_op_imagination_nna
#subgraph_bridge_shuffle_channel_op_imagination_nna
#subgraph_bridge_pad2d_op_imagination_nna
#subgraph_bridge_reduce_mean_op_imagination_nna
#subgraph_bridge_unsqueeze_op_imagination_nna
#subgraph_bridge_gather_op_imagination_nna
#subgraph_bridge_lookup_table_op_imagination_nna
#subgraph_bridge_argmax_op_imagination_nna
#subgraph_bridge_instance_norm_op_imagination_nna
#subgraph_bridge_dropout_op_imagination_nna
#subgraph_bridge_topk_op_imagination_nna
#subgraph_bridge_layer_norm_op_imagination_nna
#subgraph_bridge_fill_constant_op_imagination_nna
#subgraph_bridge_fill_constant_batch_size_like_op_imagination_nna
#subgraph_bridge_increment_op_imagination_nna
#subgraph_bridge_compare_op_imagination_nna
CACHE INTERNAL
"imagination_nna_subgraph_bridges"
)
CACHE INTERNAL
"imagination_nna_subgraph_bridges"
)
message
(
STATUS
"+++++ imagination_nna_subgraph_bridges:
${
imagination_nna_subgraph_bridges
}
"
)
message
(
STATUS
"+++++ imagination_nna_subgraph_bridges:
${
imagination_nna_subgraph_bridges
}
"
)
lite/kernels/imagination_nna/bridges/batch_norm_op.cc
浏览文件 @
5533eddb
...
@@ -30,7 +30,7 @@ int BatchNormConverter(void* ctx, OpLite* op, KernelBase* kernel) {
...
@@ -30,7 +30,7 @@ int BatchNormConverter(void* ctx, OpLite* op, KernelBase* kernel) {
auto
scope
=
op
->
scope
();
auto
scope
=
op
->
scope
();
VLOG
(
3
)
<<
"[NNA] Converting "
+
op_type
+
"..."
;
VLOG
(
3
)
<<
"[NNA] Converting "
+
op_type
+
"..."
;
// Get i
imagination_nna
t and output vars and op attributes
// Get i
npu
t and output vars and op attributes
auto
x_name
=
op_info
->
Input
(
"X"
).
front
();
auto
x_name
=
op_info
->
Input
(
"X"
).
front
();
auto
x
=
scope
->
FindMutableTensor
(
x_name
);
auto
x
=
scope
->
FindMutableTensor
(
x_name
);
auto
x_dims
=
x
->
dims
();
auto
x_dims
=
x
->
dims
();
...
@@ -43,24 +43,14 @@ int BatchNormConverter(void* ctx, OpLite* op, KernelBase* kernel) {
...
@@ -43,24 +43,14 @@ int BatchNormConverter(void* ctx, OpLite* op, KernelBase* kernel) {
auto
variance_name
=
op_info
->
Input
(
"Variance"
).
front
();
auto
variance_name
=
op_info
->
Input
(
"Variance"
).
front
();
auto
variance
=
scope
->
FindMutableTensor
(
variance_name
);
auto
variance
=
scope
->
FindMutableTensor
(
variance_name
);
auto
y_name
=
op_info
->
Output
(
"Y"
).
front
();
auto
y_name
=
op_info
->
Output
(
"Y"
).
front
();
// float momentum = op_info->GetAttr<float>("momentum");
float
epsilon
=
op_info
->
GetAttr
<
float
>
(
"epsilon"
);
float
epsilon
=
op_info
->
GetAttr
<
float
>
(
"epsilon"
);
// int mode = 1; // bnScale, bnBias tensor dims are 1xCx1x1
/*
bool use_global_stats = !op_info->HasAttr("use_global_stats") ||
op_info->GetAttr<bool>("use_global_stats");
if (!use_global_stats) {
LOG(WARNING) << "[NNA] Only use_global_stats=true is supported by DDK";
}
*/
// X node
// X node
std
::
shared_ptr
<
Node
>
x_node
=
nullptr
;
std
::
shared_ptr
<
Node
>
x_node
=
nullptr
;
if
(
graph
->
Has
(
x_name
))
{
if
(
graph
->
Has
(
x_name
))
{
x_node
=
graph
->
Get
(
x_name
);
x_node
=
graph
->
Get
(
x_name
);
}
else
{
}
else
{
// x_node = graph->Add(x_name, *x);
LOG
(
WARNING
)
<<
"[Imagination NNA] BatchNormConverter: x_node not in graph"
;
LOG
(
WARNING
)
<<
"BatchNormConverter:x_node not in graph"
;
}
}
ConvNetBuilder
&
builder
=
graph
->
GetBuilder
();
ConvNetBuilder
&
builder
=
graph
->
GetBuilder
();
...
@@ -71,7 +61,6 @@ int BatchNormConverter(void* ctx, OpLite* op, KernelBase* kernel) {
...
@@ -71,7 +61,6 @@ int BatchNormConverter(void* ctx, OpLite* op, KernelBase* kernel) {
bn_out
=
builder
.
createScaleLayer
(
bn_out
=
builder
.
createScaleLayer
(
bn_out
,
true
,
scale
->
mutable_data
<
float
>
(),
bias
->
mutable_data
<
float
>
());
bn_out
,
true
,
scale
->
mutable_data
<
float
>
(),
bias
->
mutable_data
<
float
>
());
// PrecisionType precision = x->precision();
imgdnn_tensor_descriptor
desc
;
imgdnn_tensor_descriptor
desc
;
imgdnn_err_code
err
=
imgdnnGetTensorDescriptor
(
bn_out
,
&
desc
);
imgdnn_err_code
err
=
imgdnnGetTensorDescriptor
(
bn_out
,
&
desc
);
CHECK
(
err
==
IMGDNN_SUCCESS
)
<<
"fail get tensor description(BN)"
;
CHECK
(
err
==
IMGDNN_SUCCESS
)
<<
"fail get tensor description(BN)"
;
...
...
lite/kernels/imagination_nna/bridges/graph.cc
浏览文件 @
5533eddb
...
@@ -45,7 +45,7 @@ std::shared_ptr<Node> Graph::Add(const std::string& name,
...
@@ -45,7 +45,7 @@ std::shared_ptr<Node> Graph::Add(const std::string& name,
const
void
*
const
const_data
,
const
void
*
const
const_data
,
std
::
vector
<
int64_t
>
shape
,
std
::
vector
<
int64_t
>
shape
,
const
TensorInfo
&
qnt
,
const
TensorInfo
&
qnt
,
Node
::
Role
role
/* = Node::Role::kData*/
)
{
Node
::
Role
role
)
{
auto
node
=
std
::
make_shared
<
Node
>
(
qnt
.
type
,
qnt
.
layout
,
role
);
auto
node
=
std
::
make_shared
<
Node
>
(
qnt
.
type
,
qnt
.
layout
,
role
);
auto
idx
=
Add
(
name
,
node
);
auto
idx
=
Add
(
name
,
node
);
CHECK_GE
(
idx
,
1
);
CHECK_GE
(
idx
,
1
);
...
...
lite/kernels/imagination_nna/bridges/graph.h
浏览文件 @
5533eddb
...
@@ -79,28 +79,16 @@ class Graph {
...
@@ -79,28 +79,16 @@ class Graph {
public:
public:
explicit
Graph
(
lite
::
imagination_nna
::
ImgdnnManager
*
pMgr
)
{
explicit
Graph
(
lite
::
imagination_nna
::
ImgdnnManager
*
pMgr
)
{
pImgdnnMgr
=
pMgr
;
pImgdnnMgr
=
pMgr
;
std
::
cout
<<
"graph construct"
<<
std
::
endl
;
}
}
~
Graph
()
{
std
::
cout
<<
"Graph deconst"
<<
std
::
endl
;
}
// Add constant tensor, such as weights,bias
// Add 1
int
Add
(
const
std
::
string
&
name
,
std
::
shared_ptr
<
Node
>
node
);
// Add 2, weights,bias
std
::
shared_ptr
<
Node
>
Add
(
const
std
::
string
&
name
,
std
::
shared_ptr
<
Node
>
Add
(
const
std
::
string
&
name
,
const
void
*
const
const_data
,
const
void
*
const
const_data
,
std
::
vector
<
int64_t
>
shape
,
std
::
vector
<
int64_t
>
shape
,
const
TensorInfo
&
qnt
,
const
TensorInfo
&
qnt
,
Node
::
Role
role
/* = Node::Role::kData*/
);
// Add 3
std
::
shared_ptr
<
Node
>
Add
(
const
std
::
string
&
name
,
const
Tensor
&
tensor
,
std
::
vector
<
int64_t
>
shape
,
const
TensorInfo
&
qnt
,
Node
::
Role
role
);
Node
::
Role
role
);
// Add 4
// Add input tensor
std
::
shared_ptr
<
Node
>
Add
(
const
std
::
string
&
name
,
std
::
shared_ptr
<
Node
>
Add
(
const
std
::
string
&
name
,
const
Tensor
&
tensor
,
const
Tensor
&
tensor
,
const
TensorInfo
&
qnt
,
const
TensorInfo
&
qnt
,
...
@@ -108,15 +96,14 @@ class Graph {
...
@@ -108,15 +96,14 @@ class Graph {
return
Add
(
name
,
tensor
,
tensor
.
dims
().
Vectorize
(),
qnt
,
role
);
return
Add
(
name
,
tensor
,
tensor
.
dims
().
Vectorize
(),
qnt
,
role
);
}
}
// Used to add intermediate tensor
// Add intermediate activation tensor
// Add 5
int
Add
(
const
std
::
string
&
name
,
int
Add
(
const
std
::
string
&
name
,
imgdnn_tensor
tensor
,
imgdnn_tensor
img_
tensor
,
imgdnn_type
type
,
imgdnn_type
type
,
DataLayoutType
layout
=
DATALAYOUT
(
kNCHW
))
{
DataLayoutType
layout
=
DATALAYOUT
(
kNCHW
))
{
Node
::
Role
role
=
Node
::
Role
::
kData
;
Node
::
Role
role
=
Node
::
Role
::
kData
;
auto
node
=
std
::
make_shared
<
Node
>
(
type
,
layout
,
role
);
auto
node
=
std
::
make_shared
<
Node
>
(
type
,
layout
,
role
);
node
->
set_data
(
tensor
);
node
->
set_data
(
img_
tensor
);
return
Add
(
name
,
node
);
// call Add 1
return
Add
(
name
,
node
);
// call Add 1
}
}
...
@@ -135,11 +122,19 @@ class Graph {
...
@@ -135,11 +122,19 @@ class Graph {
}
}
private:
private:
int
Add
(
const
std
::
string
&
name
,
std
::
shared_ptr
<
Node
>
node
);
std
::
shared_ptr
<
Node
>
Add
(
const
std
::
string
&
name
,
const
Tensor
&
tensor
,
std
::
vector
<
int64_t
>
shape
,
const
TensorInfo
&
qnt
,
Node
::
Role
role
);
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>>
nodes_
;
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>>
nodes_
;
lite
::
imagination_nna
::
ImgdnnManager
*
pImgdnnMgr
{
nullptr
};
lite
::
imagination_nna
::
ImgdnnManager
*
pImgdnnMgr
{
nullptr
};
};
};
}
// namespace imagination_nna
}
// namespace imagination_nna
}
// namespace subgraph
}
// namespace subgraph
}
// namespace lite
}
// namespace lite
}
// namespace paddle
}
// namespace paddle
lite/kernels/imagination_nna/bridges/paddle_use_bridges.h
浏览文件 @
5533eddb
...
@@ -19,4 +19,3 @@ USE_SUBGRAPH_BRIDGE(conv2d, kImaginationNNA);
...
@@ -19,4 +19,3 @@ USE_SUBGRAPH_BRIDGE(conv2d, kImaginationNNA);
USE_SUBGRAPH_BRIDGE
(
depthwise_conv2d
,
kImaginationNNA
);
USE_SUBGRAPH_BRIDGE
(
depthwise_conv2d
,
kImaginationNNA
);
USE_SUBGRAPH_BRIDGE
(
fc
,
kImaginationNNA
);
USE_SUBGRAPH_BRIDGE
(
fc
,
kImaginationNNA
);
USE_SUBGRAPH_BRIDGE
(
pool2d
,
kImaginationNNA
);
USE_SUBGRAPH_BRIDGE
(
pool2d
,
kImaginationNNA
);
// USE_SUBGRAPH_BRIDGE(softmax, kImaginationNNA);
lite/kernels/imagination_nna/bridges/pool_op.cc
浏览文件 @
5533eddb
...
@@ -97,9 +97,9 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
...
@@ -97,9 +97,9 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
ksize
);
ksize
);
// ceil mode
// ceil mode
/* bool ceil_mode =
if
(
op_info
->
HasAttr
(
"ceil_mode"
))
op_info->HasAttr("ceil_mode") && op_info->GetAttr<bool>("ceil_mode");
LOG
(
WARNING
)
<<
"[NNA] imgdnn has no ceil_mode: "
*/
<<
op_info
->
GetAttr
<
bool
>
(
"ceil_mode"
);
unsigned
int
img_ksize
[
2
]
=
{(
unsigned
int
)
ksize
[
0
],
(
unsigned
int
)
ksize
[
1
]};
unsigned
int
img_ksize
[
2
]
=
{(
unsigned
int
)
ksize
[
0
],
(
unsigned
int
)
ksize
[
1
]};
unsigned
int
img_stride
[
2
]
=
{(
unsigned
int
)
strides
[
0
],
unsigned
int
img_stride
[
2
]
=
{(
unsigned
int
)
strides
[
0
],
...
@@ -126,11 +126,8 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
...
@@ -126,11 +126,8 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
pad_to_end
,
pad_to_end
,
img_pool_type
);
img_pool_type
);
// LOG(INFO) << "pooling op output:" << static_cast<int>(pooling_out);
imgdnn_tensor_descriptor
desc
=
graph
->
GetBuilder
()
->
getTensorDescriptor
(
pooling_out
);
imgdnn_tensor_descriptor
desc
;
imgdnn_err_code
err
=
imgdnnGetTensorDescriptor
(
pooling_out
,
&
desc
);
CHECK
(
err
==
IMGDNN_SUCCESS
)
<<
"fail get tensor description(POOL)"
;
graph
->
Add
(
out_name
,
pooling_out
,
desc
.
type
);
graph
->
Add
(
out_name
,
pooling_out
,
desc
.
type
);
...
...
lite/kernels/imagination_nna/bridges/utility.cc
浏览文件 @
5533eddb
...
@@ -55,9 +55,7 @@ void TensorInfoReset(TensorInfo* qnt) {
...
@@ -55,9 +55,7 @@ void TensorInfoReset(TensorInfo* qnt) {
qnt
->
count
=
0
;
qnt
->
count
=
0
;
qnt
->
axis
=
0
;
qnt
->
axis
=
0
;
qnt
->
scales
.
clear
();
qnt
->
scales
.
clear
();
// qnt.scales.shrink_to_fit();
qnt
->
zero_points
.
clear
();
qnt
->
zero_points
.
clear
();
// qnt.zero_points.shrink_to_fit();
qnt
->
layout
=
DATALAYOUT
(
kNCHW
);
qnt
->
layout
=
DATALAYOUT
(
kNCHW
);
}
}
...
...
lite/kernels/imagination_nna/subgraph_compute.cc
浏览文件 @
5533eddb
...
@@ -97,8 +97,6 @@ bool SubgraphEngine::BuildDeviceProgram() {
...
@@ -97,8 +97,6 @@ bool SubgraphEngine::BuildDeviceProgram() {
imgdnn_mgr_
.
getNetworkObjectInputs
(
imgdnn_mgr_
.
getNetworkObjectInputs
(
std
::
numeric_limits
<
unsigned
int
>::
max
(),
nullptr
,
&
num_inputs
);
std
::
numeric_limits
<
unsigned
int
>::
max
(),
nullptr
,
&
num_inputs
);
CHECK_EQ
(
num_inputs
,
device_inames_
.
size
());
CHECK_EQ
(
num_inputs
,
device_inames_
.
size
());
// origin_idims_.resize(num_inputs);
// origin_itensors_.resize(num_inputs);
device_itensors_
.
resize
(
num_inputs
);
device_itensors_
.
resize
(
num_inputs
);
imgdnn_mgr_
.
getNetworkObjectInputs
(
imgdnn_mgr_
.
getNetworkObjectInputs
(
num_inputs
,
device_itensors_
.
data
(),
nullptr
);
num_inputs
,
device_itensors_
.
data
(),
nullptr
);
...
@@ -108,9 +106,6 @@ bool SubgraphEngine::BuildDeviceProgram() {
...
@@ -108,9 +106,6 @@ bool SubgraphEngine::BuildDeviceProgram() {
auto
node
=
graph
.
Get
(
device_inames_
[
i
]);
auto
node
=
graph
.
Get
(
device_inames_
[
i
]);
auto
type
=
node
->
type
();
auto
type
=
node
->
type
();
auto
layout
=
node
->
layout
();
auto
layout
=
node
->
layout
();
// origin_itensors_[i] = scope_->FindMutableTensor(device_inames_[i]);
// CHECK(origin_itensors_[i]);
// origin_idims_[i] = origin_itensors_[i]->dims();
VLOG
(
3
)
<<
"[NNA] Inputs["
<<
i
<<
"] name: "
<<
device_inames_
[
i
]
VLOG
(
3
)
<<
"[NNA] Inputs["
<<
i
<<
"] name: "
<<
device_inames_
[
i
]
<<
" type: "
<<
type
<<
" layout: "
<<
DataLayoutToStr
(
layout
);
<<
" type: "
<<
type
<<
" layout: "
<<
DataLayoutToStr
(
layout
);
}
}
...
@@ -119,8 +114,6 @@ bool SubgraphEngine::BuildDeviceProgram() {
...
@@ -119,8 +114,6 @@ bool SubgraphEngine::BuildDeviceProgram() {
imgdnn_mgr_
.
getNetworkObjectOutputs
(
imgdnn_mgr_
.
getNetworkObjectOutputs
(
std
::
numeric_limits
<
unsigned
int
>::
max
(),
nullptr
,
&
num_outputs
);
std
::
numeric_limits
<
unsigned
int
>::
max
(),
nullptr
,
&
num_outputs
);
CHECK_EQ
(
num_outputs
,
device_onames_
.
size
());
CHECK_EQ
(
num_outputs
,
device_onames_
.
size
());
// origin_odims_.resize(num_outputs);
// origin_otensors_.resize(num_outputs);
device_otensors_
.
resize
(
num_outputs
);
device_otensors_
.
resize
(
num_outputs
);
imgdnn_mgr_
.
getNetworkObjectOutputs
(
imgdnn_mgr_
.
getNetworkObjectOutputs
(
num_outputs
,
device_otensors_
.
data
(),
nullptr
);
num_outputs
,
device_otensors_
.
data
(),
nullptr
);
...
@@ -129,9 +122,6 @@ bool SubgraphEngine::BuildDeviceProgram() {
...
@@ -129,9 +122,6 @@ bool SubgraphEngine::BuildDeviceProgram() {
auto
node
=
graph
.
Get
(
device_onames_
[
i
]);
auto
node
=
graph
.
Get
(
device_onames_
[
i
]);
auto
type
=
node
->
type
();
auto
type
=
node
->
type
();
auto
layout
=
node
->
layout
();
auto
layout
=
node
->
layout
();
// origin_otensors_[i] = scope_->FindMutableTensor(device_onames_[i]);
// CHECK(origin_otensors_[i]);
// origin_odims_[i] = origin_otensors_[i]->dims();
VLOG
(
3
)
<<
"[NNA] Outputs["
<<
i
<<
"] name: "
<<
device_onames_
[
i
]
VLOG
(
3
)
<<
"[NNA] Outputs["
<<
i
<<
"] name: "
<<
device_onames_
[
i
]
<<
" type: "
<<
type
<<
" layout: "
<<
DataLayoutToStr
(
layout
);
<<
" type: "
<<
type
<<
" layout: "
<<
DataLayoutToStr
(
layout
);
// Prepare the device output tensors
// Prepare the device output tensors
...
@@ -161,8 +151,10 @@ bool SubgraphEngine::BuildDeviceProgram() {
...
@@ -161,8 +151,10 @@ bool SubgraphEngine::BuildDeviceProgram() {
}
}
bool
SubgraphEngine
::
LaunchDeviceProgram
()
{
bool
SubgraphEngine
::
LaunchDeviceProgram
()
{
if
(
!
device_program_ready
)
// build device program fail
if
(
!
device_program_ready
)
{
LOG
(
WARNING
)
<<
"[NNA] Build device program fail, run origin program"
;
LaunchOriginProgram
();
LaunchOriginProgram
();
}
// Set input buffer
// Set input buffer
for
(
size_t
i
=
0
;
i
<
origin_itensors_
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
origin_itensors_
.
size
();
i
++
)
{
...
...
tools/codestyle/clang_format.hook
浏览文件 @
5533eddb
#!/bin/bash
#!/bin/bash
set
-e
set
-e
readonly
VERSION
=
"
6.0.0
"
readonly
VERSION
=
"
3.8
"
version
=
$(
clang-format
-version
)
version
=
$(
clang-format
-version
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录