Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
eb4bee3c
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
eb4bee3c
编写于
8月 07, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 07, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4077 fix anf exporter add concat and transpose populater
Merge pull request !4077 from wangchangkai/master
上级
6fc6f290
88cda696
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
198 addition
and
0 deletion
+198
-0
mindspore/lite/src/common/anf_exporter/anf_exporter.cc
mindspore/lite/src/common/anf_exporter/anf_exporter.cc
+12
-0
mindspore/lite/src/common/anf_exporter/anf_populater/anf_activation_populater.cc
...on/anf_exporter/anf_populater/anf_activation_populater.cc
+3
-0
mindspore/lite/src/common/anf_exporter/anf_populater/anf_concat_populater.cc
...common/anf_exporter/anf_populater/anf_concat_populater.cc
+45
-0
mindspore/lite/src/common/anf_exporter/anf_populater/anf_concat_populater.h
.../common/anf_exporter/anf_populater/anf_concat_populater.h
+32
-0
mindspore/lite/src/common/anf_exporter/anf_populater/anf_depthwiseconv2d_populater.cc
...f_exporter/anf_populater/anf_depthwiseconv2d_populater.cc
+20
-0
mindspore/lite/src/common/anf_exporter/anf_populater/anf_node_populater.h
...rc/common/anf_exporter/anf_populater/anf_node_populater.h
+3
-0
mindspore/lite/src/common/anf_exporter/anf_populater/anf_transpose_populater.cc
...mon/anf_exporter/anf_populater/anf_transpose_populater.cc
+54
-0
mindspore/lite/src/common/anf_exporter/anf_populater/anf_transpose_populater.h
...mmon/anf_exporter/anf_populater/anf_transpose_populater.h
+29
-0
未找到文件。
mindspore/lite/src/common/anf_exporter/anf_exporter.cc
浏览文件 @
eb4bee3c
...
...
@@ -338,6 +338,18 @@ void AnfExporter::SetOpInputNode(const CNodePtr &cnode,
meta_graph
->
allTensors
.
size
();
fbNode
->
inputIndex
.
emplace_back
(
meta_graph
->
allTensors
.
size
());
meta_graph
->
allTensors
.
emplace_back
(
std
::
move
(
paramTensor
));
}
else
if
(
value
->
isa
<
mindspore
::
Int32Imm
>
())
{
auto
valueAbstract
=
valueNode
->
abstract
();
auto
abstractScalar
=
utils
::
cast
<
abstract
::
AbstractScalarPtr
>
(
valueAbstract
);
auto
typePtr
=
abstractScalar
->
GetTypeTrack
();
paramTensor
->
dataType
=
typePtr
->
type_id
();
paramTensor
->
dims
=
{
1
};
paramTensor
->
nodeType
=
schema
::
NodeType_ValueNode
;
auto
data
=
value
->
cast
<
mindspore
::
Int32ImmPtr
>
();
paramTensor
->
data
.
emplace_back
(
data
->
value
());
nodeIdMap
[
valueNode
->
fullname_with_scope
()]
=
meta_graph
->
allTensors
.
size
();
fbNode
->
inputIndex
.
emplace_back
(
meta_graph
->
allTensors
.
size
());
meta_graph
->
allTensors
.
emplace_back
(
std
::
move
(
paramTensor
));
}
else
if
(
value
->
isa
<
mindspore
::
ValueSequeue
>
())
{
MS_LOG
(
INFO
)
<<
"Value type is ValueSequence."
;
break
;
...
...
mindspore/lite/src/common/anf_exporter/anf_populater/anf_activation_populater.cc
浏览文件 @
eb4bee3c
...
...
@@ -29,6 +29,8 @@ int mindspore::lite::AnfActivationPopulater::Parse(mindspore::CNodePtr cnodePtr,
attr
->
type
=
schema
::
ActivationType_RELU
;
}
else
if
(
p
->
name
()
==
"Sigmoid"
)
{
attr
->
type
=
schema
::
ActivationType_SIGMOID
;
}
else
if
(
p
->
name
()
==
"ReLU6"
)
{
attr
->
type
=
schema
::
ActivationType_RELU6
;
}
node
->
nodeType
=
schema
::
NodeType_CNode
;
...
...
@@ -38,5 +40,6 @@ int mindspore::lite::AnfActivationPopulater::Parse(mindspore::CNodePtr cnodePtr,
return
0
;
}
AnfNodePopulaterRegistrar
anfReLUParser
(
"ReLU"
,
new
AnfActivationPopulater
());
AnfNodePopulaterRegistrar
anfReLU6Parser
(
"ReLU6"
,
new
AnfActivationPopulater
());
AnfNodePopulaterRegistrar
anfSigmoidParser
(
"Sigmoid"
,
new
AnfActivationPopulater
());
}
// namespace mindspore::lite
mindspore/lite/src/common/anf_exporter/anf_populater/anf_concat_populater.cc
0 → 100644
浏览文件 @
eb4bee3c
/**
* This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/).
*
* Copyright 2020 Huawei Technologies Co., Ltd
*
* 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.
*/
#include "src/common/anf_exporter/anf_populater/anf_concat_populater.h"
#include <string>
#include <vector>
#include <memory>
#include "src/common/anf_exporter/anf_populater/anf_node_populater_registry.h"
#include "ir/func_graph.h"
#include "ir/primitive.h"
namespace
mindspore
::
lite
{
int
mindspore
::
lite
::
AnfConcatPopulater
::
Parse
(
mindspore
::
CNodePtr
cnodePtr
,
schema
::
CNodeT
*
node
,
std
::
vector
<
schema
::
TensorT
*>
*
outputs
)
{
auto
p
=
GetCNodePrimitive
(
cnodePtr
);
auto
attr
=
std
::
make_unique
<
schema
::
ConcatT
>
();
auto
prim_axis
=
GetValue
<
int
>
(
p
->
GetAttr
(
"axis"
));
attr
->
axis
=
prim_axis
;
node
->
nodeType
=
schema
::
NodeType_CNode
;
node
->
primitive
=
std
::
make_unique
<
schema
::
PrimitiveT
>
();
node
->
primitive
->
value
.
type
=
schema
::
PrimitiveType_Concat
;
node
->
primitive
->
value
.
value
=
attr
.
release
();
return
0
;
}
AnfNodePopulaterRegistrar
anfConcatParser
(
"Concat"
,
new
AnfConcatPopulater
());
}
// namespace mindspore::lite
mindspore/lite/src/common/anf_exporter/anf_populater/anf_concat_populater.h
0 → 100644
浏览文件 @
eb4bee3c
/**
* This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/).
*
* Copyright 2020 Huawei Technologies Co., Ltd
*
* 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.
*/
#ifndef MINDSPORE_ANF_CONCAT_PARSER_H
#define MINDSPORE_ANF_CONCAT_PARSER_H
#include "src/common/anf_exporter/anf_populater/anf_node_populater.h"
#include <vector>
namespace
mindspore
::
lite
{
class
AnfConcatPopulater
:
public
AnfNodePopulater
{
public:
AnfConcatPopulater
()
=
default
;
~
AnfConcatPopulater
()
override
=
default
;
int
Parse
(
CNodePtr
cnodePtr
,
schema
::
CNodeT
*
node
,
std
::
vector
<
schema
::
TensorT
*>
*
outputs
)
override
;
};
}
// namespace mindspore::lite
#endif // MINDSPORE_ANF_CONCAT_PARSER_H
mindspore/lite/src/common/anf_exporter/anf_populater/anf_depthwiseconv2d_populater.cc
浏览文件 @
eb4bee3c
...
...
@@ -62,6 +62,26 @@ int mindspore::lite::AnfDepwiseconv2DPopulater::Parse(mindspore::CNodePtr cnodeP
attr
->
padMode
=
schema
::
PadMode_NOTSET
;
}
auto
channel_multiplier
=
GetValue
<
int
>
(
p
->
GetAttr
(
"channel_multiplier"
));
attr
->
channelMultiplier
=
channel_multiplier
;
MS_ASSERT
(
cnodePtr
->
size
()
==
kAnfPopulaterThree
);
auto
inputNode
=
cnodePtr
->
input
(
kAnfPopulaterTwo
);
MS_ASSERT
(
inputNode
!=
nullptr
);
if
(
inputNode
->
isa
<
Parameter
>
())
{
auto
paramNode
=
inputNode
->
cast
<
ParameterPtr
>
();
auto
abstractBase
=
paramNode
->
abstract
();
MS_ASSERT
(
abstractBase
!=
nullptr
);
if
(
utils
::
isa
<
abstract
::
AbstractTensorPtr
>
(
abstractBase
))
{
auto
abstractTensor
=
utils
::
cast
<
abstract
::
AbstractTensorPtr
>
(
abstractBase
);
MS_ASSERT
(
abstractTensor
!=
nullptr
);
if
(
utils
::
isa
<
abstract
::
ShapePtr
>
(
abstractTensor
->
BuildShape
()))
{
auto
dims
=
utils
::
cast
<
abstract
::
ShapePtr
>
(
abstractTensor
->
BuildShape
())
->
shape
();
attr
->
channelIn
=
dims
[
kAnfPopulaterOne
];
}
}
}
node
->
nodeType
=
schema
::
NodeType_CNode
;
node
->
primitive
=
std
::
make_unique
<
schema
::
PrimitiveT
>
();
node
->
primitive
->
value
.
type
=
schema
::
PrimitiveType_DepthwiseConv2D
;
...
...
mindspore/lite/src/common/anf_exporter/anf_populater/anf_node_populater.h
浏览文件 @
eb4bee3c
...
...
@@ -21,6 +21,9 @@
#include "ir/anf.h"
#include "schema/inner/model_generated.h"
namespace
mindspore
::
lite
{
constexpr
int
kAnfPopulaterOne
=
1
;
constexpr
int
kAnfPopulaterTwo
=
2
;
constexpr
int
kAnfPopulaterThree
=
3
;
class
AnfNodePopulater
{
public:
AnfNodePopulater
()
=
default
;
...
...
mindspore/lite/src/common/anf_exporter/anf_populater/anf_transpose_populater.cc
0 → 100644
浏览文件 @
eb4bee3c
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* 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.
*/
#include "src/common/anf_exporter/anf_populater/anf_transpose_populater.h"
#include <vector>
#include <string>
#include <memory>
#include "src/common/anf_exporter/anf_populater/anf_node_populater_registry.h"
#include "ir/func_graph.h"
#include "ir/primitive.h"
namespace
mindspore
::
lite
{
int
mindspore
::
lite
::
AnfTransposePopulater
::
Parse
(
mindspore
::
CNodePtr
cnodePtr
,
schema
::
CNodeT
*
node
,
std
::
vector
<
schema
::
TensorT
*>
*
outputs
)
{
auto
attr
=
std
::
make_unique
<
schema
::
TransposeT
>
();
MS_ASSERT
(
cnodePtr
->
size
()
==
kAnfPopulaterThree
);
auto
inputNode
=
cnodePtr
->
input
(
kAnfPopulaterTwo
);
if
(
inputNode
->
isa
<
ValueNode
>
())
{
auto
valNode
=
inputNode
->
cast
<
ValueNodePtr
>
();
MS_ASSERT
(
valNode
!=
nullptr
);
auto
val
=
valNode
->
value
();
MS_ASSERT
(
val
!=
nullptr
);
if
(
val
->
isa
<
ValueTuple
>
())
{
auto
tuple
=
val
->
cast
<
ValueTuplePtr
>
();
MS_ASSERT
(
tuple
!=
nullptr
);
for
(
size_t
i
=
0
;
i
<
tuple
->
size
();
i
++
)
{
auto
elem
=
tuple
->
value
()[
i
]
->
cast
<
Int32ImmPtr
>
();
MS_ASSERT
(
elem
!=
nullptr
);
attr
->
perm
.
emplace_back
(
static_cast
<
int
>
(
elem
->
value
()));
}
}
}
node
->
nodeType
=
schema
::
NodeType_CNode
;
node
->
primitive
=
std
::
make_unique
<
schema
::
PrimitiveT
>
();
node
->
primitive
->
value
.
type
=
schema
::
PrimitiveType_Transpose
;
node
->
primitive
->
value
.
value
=
attr
.
release
();
return
0
;
}
AnfNodePopulaterRegistrar
anfTransposeParser
(
"Transpose"
,
new
AnfTransposePopulater
());
}
// namespace mindspore::lite
mindspore/lite/src/common/anf_exporter/anf_populater/anf_transpose_populater.h
0 → 100644
浏览文件 @
eb4bee3c
/**
* Copyright 2019 Huawei Technologies Co., Ltd
*
* 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.
*/
#ifndef MINDSPORE_ANF_TRANSPOSE_PARSER_H
#define MINDSPORE_ANF_TRANSPOSE_PARSER_H
#include "src/common/anf_exporter/anf_populater/anf_node_populater.h"
#include <vector>
namespace
mindspore
::
lite
{
class
AnfTransposePopulater
:
public
AnfNodePopulater
{
public:
AnfTransposePopulater
()
=
default
;
~
AnfTransposePopulater
()
override
=
default
;
int
Parse
(
CNodePtr
cnodePtr
,
schema
::
CNodeT
*
node
,
std
::
vector
<
schema
::
TensorT
*>
*
outputs
)
override
;
};
}
// namespace mindspore::lite
#endif // MINDSPORE_ANF_TRANSPOSE_PARSER_H
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录