Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
兔爷不爱我
mindspore
提交
f1637f11
M
mindspore
项目概览
兔爷不爱我
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f1637f11
编写于
9月 04, 2020
作者:
H
hangq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. clean review bot
2. fix nan bug
上级
bc4c5afc
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
43 addition
and
47 deletion
+43
-47
mindspore/lite/java/build_aar.sh
mindspore/lite/java/build_aar.sh
+3
-3
mindspore/lite/nnacl/fp16/pack_fp16.c
mindspore/lite/nnacl/fp16/pack_fp16.c
+6
-2
mindspore/lite/nnacl/pack.c
mindspore/lite/nnacl/pack.c
+6
-2
mindspore/lite/tools/converter/converter_flags.cc
mindspore/lite/tools/converter/converter_flags.cc
+2
-2
mindspore/lite/tools/converter/legacy_optimizer/graph/infershape_pass.cc
...tools/converter/legacy_optimizer/graph/infershape_pass.cc
+10
-15
mindspore/lite/tools/converter/parser/tflite/tflite_custom_parser.cc
...ite/tools/converter/parser/tflite/tflite_custom_parser.cc
+6
-9
mindspore/lite/tools/converter/quantizer/quantize_util.h
mindspore/lite/tools/converter/quantizer/quantize_util.h
+2
-5
mindspore/lite/tools/converter/quantizer/weight_quantizer.cc
mindspore/lite/tools/converter/quantizer/weight_quantizer.cc
+0
-1
mindspore/lite/tools/optimizer/common/gllo_utils.cc
mindspore/lite/tools/optimizer/common/gllo_utils.cc
+8
-8
未找到文件。
mindspore/lite/java/build_aar.sh
浏览文件 @
f1637f11
...
...
@@ -5,9 +5,9 @@ BASE_PATH=$(cd "$(dirname $0)"; pwd)
TOP_PATH
=
"
${
BASE_PATH
}
/../../.."
get_version
()
{
VERSION_MAJOR
=
`
grep
"#define MS_VERSION_MAJOR"
../
../
include/version.h |
tr
-dc
"[0-9]"
`
VERSION_MINOR
=
`
grep
"#define MS_VERSION_MINOR"
../
../
include/version.h |
tr
-dc
"[0-9]"
`
VERSION_REVISION
=
`
grep
"#define MS_VERSION_REVISION"
../
../
include/version.h |
tr
-dc
"[0-9]"
`
VERSION_MAJOR
=
`
grep
"#define MS_VERSION_MAJOR"
../include/version.h |
tr
-dc
"[0-9]"
`
VERSION_MINOR
=
`
grep
"#define MS_VERSION_MINOR"
../include/version.h |
tr
-dc
"[0-9]"
`
VERSION_REVISION
=
`
grep
"#define MS_VERSION_REVISION"
../include/version.h |
tr
-dc
"[0-9]"
`
VERSION_STR
=
${
VERSION_MAJOR
}
.
${
VERSION_MINOR
}
.
${
VERSION_REVISION
}
}
...
...
mindspore/lite/nnacl/fp16/pack_fp16.c
浏览文件 @
f1637f11
...
...
@@ -232,6 +232,7 @@ void PackNCHWToNHWCFp16(const void *src, void *dst, int batch, int plane, int ch
void
PackNHWCToNHWC4Fp16
(
const
void
*
src
,
void
*
dst
,
int
batch
,
int
plane
,
int
channel
)
{
int
ic4
=
UP_DIV
(
channel
,
C4NUM
);
int
c4_channel
=
ic4
*
C4NUM
;
int
nhwc4_batch_unit_offset
=
ic4
*
C4NUM
*
plane
;
int
ic_remainder_
=
channel
%
C4NUM
;
if
(
ic_remainder_
!=
0
)
{
...
...
@@ -239,8 +240,11 @@ void PackNHWCToNHWC4Fp16(const void *src, void *dst, int batch, int plane, int c
for
(
int
b
=
0
;
b
<
batch
;
b
++
)
{
int
batch_offset
=
b
*
channel
*
plane
;
for
(
int
i
=
0
;
i
<
plane
;
i
++
)
{
memcpy
((
float16_t
*
)
dst
+
nhwc4_batch_offset
+
i
*
ic4
*
C4NUM
,
(
float16_t
*
)
src
+
batch_offset
+
i
*
channel
,
channel
*
sizeof
(
float16_t
));
float16_t
*
dst_per_plane
=
(
float16_t
*
)
dst
+
nhwc4_batch_offset
+
i
*
c4_channel
;
memcpy
(
dst_per_plane
,
(
float16_t
*
)
src
+
batch_offset
+
i
*
channel
,
channel
*
sizeof
(
float16_t
));
for
(
int
j
=
channel
;
j
<
c4_channel
;
++
j
)
{
dst_per_plane
[
j
]
=
0
;
}
}
nhwc4_batch_offset
+=
nhwc4_batch_unit_offset
;
}
...
...
mindspore/lite/nnacl/pack.c
浏览文件 @
f1637f11
...
...
@@ -611,6 +611,7 @@ void PackNCHWToNC4HW4Fp32(const void *src, void *dst, int batch, int plane, int
void
PackNHWCToNHWC4Fp32
(
const
void
*
src
,
void
*
dst
,
int
batch
,
int
plane
,
int
channel
)
{
int
c4
=
UP_DIV
(
channel
,
C4NUM
);
int
c4_channel
=
c4
*
C4NUM
;
int
nhwc4_batch_unit_offset
=
c4
*
C4NUM
*
plane
;
int
ic_remainder_
=
channel
%
C4NUM
;
if
(
ic_remainder_
!=
0
)
{
...
...
@@ -618,8 +619,11 @@ void PackNHWCToNHWC4Fp32(const void *src, void *dst, int batch, int plane, int c
for
(
int
b
=
0
;
b
<
batch
;
b
++
)
{
int
batch_offset
=
b
*
channel
*
plane
;
for
(
int
i
=
0
;
i
<
plane
;
i
++
)
{
memcpy
((
float
*
)
dst
+
nhwc4_batch_offset
+
i
*
c4
*
C4NUM
,
(
float
*
)
src
+
batch_offset
+
i
*
channel
,
channel
*
sizeof
(
float
));
float
*
dst_per_plane
=
(
float
*
)
dst
+
nhwc4_batch_offset
+
i
*
c4_channel
;
memcpy
(
dst_per_plane
,
(
float
*
)
src
+
batch_offset
+
i
*
channel
,
channel
*
sizeof
(
float
));
for
(
int
j
=
channel
;
j
<
c4_channel
;
++
j
)
{
dst_per_plane
[
j
]
=
0
;
}
}
nhwc4_batch_offset
+=
nhwc4_batch_unit_offset
;
}
...
...
mindspore/lite/tools/converter/converter_flags.cc
浏览文件 @
f1637f11
...
...
@@ -37,8 +37,8 @@ Flags::Flags() {
AddFlag
(
&
Flags
::
mean
,
"mean"
,
"Mean value for aware-quantization"
,
"-0.5"
);
AddFlag
(
&
Flags
::
bitNum
,
"bitNum"
,
"Weight quantization bitNum"
,
"8"
);
AddFlag
(
&
Flags
::
quantSize
,
"quantSize"
,
"Weight quantization size threshold"
,
"0"
);
AddFlag
(
&
Flags
::
convWeightQuantChannelThreshold
,
"convWeightQuantChannelThreshold"
,
"convWeightQuantChannelThreshold"
,
"16"
);
AddFlag
(
&
Flags
::
convWeightQuantChannelThreshold
,
"convWeightQuantChannelThreshold"
,
"convWeightQuantChannelThreshold"
,
"16"
);
AddFlag
(
&
Flags
::
configFile
,
"config_file"
,
"Configuration for post-training."
,
""
);
AddFlag
(
&
Flags
::
formatTrans
,
"formatTrans"
,
"whether transform format. true | false"
,
"true"
);
}
...
...
mindspore/lite/tools/converter/legacy_optimizer/graph/infershape_pass.cc
浏览文件 @
f1637f11
...
...
@@ -21,8 +21,8 @@
#include "src/ir/tensor.h"
#include "src/ops/primitive_c.h"
using
mindspore
::
lite
::
tensor
::
Tensor
;
using
mindspore
::
lite
::
PrimitiveC
;
using
mindspore
::
lite
::
tensor
::
Tensor
;
namespace
mindspore
{
namespace
lite
{
namespace
{
...
...
@@ -33,7 +33,7 @@ std::vector<tensor::Tensor *> ConvertTensorToLiteTensor(MetaGraphT *graph, const
auto
&
tensorT
=
graph
->
allTensors
.
at
(
tensor_indexs
[
i
]);
auto
tensor_shape
=
tensorT
->
dims
;
auto
lite_tensor
=
new
(
std
::
nothrow
)
tensor
::
Tensor
(
TypeId
(
tensorT
->
dataType
),
tensor_shape
,
tensorT
->
format
,
tensorT
->
nodeType
);
std
::
make_unique
<
tensor
::
Tensor
>
(
TypeId
(
tensorT
->
dataType
),
tensor_shape
,
tensorT
->
format
,
tensorT
->
nodeType
);
if
(
lite_tensor
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"lite tensor is nullptr"
;
return
std
::
vector
<
tensor
::
Tensor
*>
();
...
...
@@ -43,27 +43,23 @@ std::vector<tensor::Tensor *> ConvertTensorToLiteTensor(MetaGraphT *graph, const
auto
lite_tensor_size
=
tensorT
->
data
.
size
()
*
sizeof
(
uint8_t
);
// when tensorT as param input
if
(
lite_tensor_size
==
0
)
{
delete
lite_tensor
;
return
std
::
vector
<
tensor
::
Tensor
*>
();
}
auto
tensor_data
=
new
(
std
::
nothrow
)
char
[
lite_tensor_size
/
sizeof
(
char
)]
;
auto
tensor_data
=
std
::
unique_ptr
<
char
[]
>
(
new
(
std
::
nothrow
)
char
[
lite_tensor_size
/
sizeof
(
char
)])
;
if
(
tensor_data
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"tensor_data is nullptr"
;
delete
lite_tensor
;
return
std
::
vector
<
tensor
::
Tensor
*>
();
}
auto
ret
=
memcpy_s
(
tensor_data
,
lite_tensor_size
,
tensorT
->
data
.
data
(),
lite_tensor_size
);
auto
ret
=
memcpy_s
(
tensor_data
.
get
()
,
lite_tensor_size
,
tensorT
->
data
.
data
(),
lite_tensor_size
);
if
(
ret
!=
EOK
)
{
delete
lite_tensor
;
delete
[]
tensor_data
;
MS_LOG
(
ERROR
)
<<
"memcpy error: "
<<
ret
;
return
std
::
vector
<
tensor
::
Tensor
*>
();
}
lite_tensor
->
SetData
(
tensor_data
);
lite_tensors
.
emplace_back
(
lite_tensor
);
lite_tensor
->
SetData
(
tensor_data
.
release
()
);
lite_tensors
.
emplace_back
(
lite_tensor
.
release
()
);
continue
;
}
lite_tensors
.
emplace_back
(
lite_tensor
);
lite_tensors
.
emplace_back
(
lite_tensor
.
release
()
);
}
return
lite_tensors
;
}
...
...
@@ -95,17 +91,16 @@ STATUS InferShapePass::Run(MetaGraphT *graph) {
auto
ret
=
primitiveC
->
InferShape
(
input_tensors
,
output_tensors
);
if
(
ret
==
RET_INFER_INVALID
)
{
MS_LOG
(
INFO
)
<<
"InferShape shouldn't be done before runtime, name: "
<<
node
->
name
<<
", type: "
<<
schema
::
EnumNamePrimitiveType
(
node
->
primitive
->
value
.
type
)
<<
"flag set to false."
;
<<
", type: "
<<
schema
::
EnumNamePrimitiveType
(
node
->
primitive
->
value
.
type
)
<<
"flag set to false."
;
}
else
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
WARNING
)
<<
"InferShape failed, name: "
<<
node
->
name
<<
", type: "
<<
schema
::
EnumNamePrimitiveType
(
node
->
primitive
->
value
.
type
);
<<
", type: "
<<
schema
::
EnumNamePrimitiveType
(
node
->
primitive
->
value
.
type
);
return
RET_INFER_ERR
;
}
// copy output shape to tensorT
for
(
size_t
i
=
0
;
i
<
output_tensors
.
size
();
i
++
)
{
auto
output_dims
=
output_tensors
[
i
]
->
shape
();
auto
&
output_tensor
=
graph
->
allTensors
.
at
(
node
->
outputIndex
[
i
]);
auto
&
output_tensor
=
graph
->
allTensors
.
at
(
node
->
outputIndex
[
i
]);
output_tensor
->
dims
.
swap
(
output_dims
);
output_tensor
->
format
=
output_tensors
[
i
]
->
GetFormat
();
output_tensor
->
dataType
=
output_tensors
[
i
]
->
data_type
();
...
...
mindspore/lite/tools/converter/parser/tflite/tflite_custom_parser.cc
浏览文件 @
f1637f11
...
...
@@ -26,10 +26,8 @@ namespace lite {
STATUS
TfliteCustomParser
::
Parse
(
const
std
::
unique_ptr
<
tflite
::
OperatorT
>
&
tflite_op
,
const
std
::
vector
<
std
::
unique_ptr
<
tflite
::
TensorT
>>
&
tflite_tensors
,
const
std
::
vector
<
std
::
unique_ptr
<
tflite
::
BufferT
>>
&
tflite_model_buffer
,
schema
::
CNodeT
*
op
,
std
::
vector
<
int32_t
>
*
tensors_id
,
std
::
vector
<
schema
::
Format
>
*
tensors_format
,
std
::
map
<
int
,
int
>
*
tensors_id_map
)
{
schema
::
CNodeT
*
op
,
std
::
vector
<
int32_t
>
*
tensors_id
,
std
::
vector
<
schema
::
Format
>
*
tensors_format
,
std
::
map
<
int
,
int
>
*
tensors_id_map
)
{
MS_LOG
(
DEBUG
)
<<
"parse TfliteCustomParser"
;
if
(
op
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"op is null"
;
...
...
@@ -80,12 +78,12 @@ STATUS TfliteCustomParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit
op
->
primitive
->
value
.
value
=
attr
.
release
();
for
(
size_t
i
=
0
;
i
<
tflite_op
->
inputs
.
size
();
++
i
)
{
AddOpInput
(
op
,
tensors_id
,
tensors_format
,
tensors_id_map
,
tflite_
op
->
inputs
[
i
],
tensors_id
->
size
(),
tflite_
tensors
.
size
(),
schema
::
Format_NHWC
);
AddOpInput
(
op
,
tensors_id
,
tensors_format
,
tensors_id_map
,
tflite_op
->
inputs
[
i
],
tensors_id
->
size
(),
tflite_tensors
.
size
(),
schema
::
Format_NHWC
);
}
for
(
size_t
i
=
0
;
i
<
tflite_op
->
outputs
.
size
();
++
i
)
{
AddOpOutput
(
op
,
tensors_id
,
tensors_format
,
tensors_id_map
,
tflite_op
->
outputs
[
i
],
tensors_id
->
size
(),
tflite_tensors
.
size
(),
schema
::
Format_NHWC
);
AddOpOutput
(
op
,
tensors_id
,
tensors_format
,
tensors_id_map
,
tflite_op
->
outputs
[
i
],
tensors_id
->
size
(),
tflite_tensors
.
size
(),
schema
::
Format_NHWC
);
}
return
RET_OK
;
}
...
...
@@ -93,4 +91,3 @@ STATUS TfliteCustomParser::Parse(const std::unique_ptr<tflite::OperatorT> &tflit
TfliteNodeRegister
g_tfliteCustomParser
(
"Custom"
,
new
TfliteCustomParser
());
}
// namespace lite
}
// namespace mindspore
mindspore/lite/tools/converter/quantizer/quantize_util.h
浏览文件 @
f1637f11
...
...
@@ -190,8 +190,7 @@ STATUS QuantFilter(ParamValueLitePtr weight, std::shared_ptr<PrimitiveC> primiti
quant_datas
[
index
]
=
quant_data
;
}
}
auto
ret
=
memcpy_s
(
raw_datas
,
weight
->
tensor_size
(),
quant_datas
.
data
(),
elem_count
*
sizeof
(
T
));
auto
ret
=
memcpy_s
(
raw_datas
,
weight
->
tensor_size
(),
quant_datas
.
data
(),
elem_count
*
sizeof
(
T
));
if
(
ret
!=
EOK
)
{
MS_LOG
(
ERROR
)
<<
"memcpy error: "
<<
ret
;
return
RET_ERROR
;
...
...
@@ -238,15 +237,13 @@ STATUS QuantFilter(ParamValueLitePtr weight, std::shared_ptr<PrimitiveC> primiti
quant_datas
[
index
]
=
quant_data
;
}
}
auto
ret
=
memcpy_s
(
raw_datas
,
weight
->
tensor_size
(),
quant_datas
.
data
(),
elem_count
*
sizeof
(
int8_t
));
auto
ret
=
memcpy_s
(
raw_datas
,
weight
->
tensor_size
(),
quant_datas
.
data
(),
elem_count
*
sizeof
(
int8_t
));
if
(
ret
!=
EOK
)
{
MS_LOG
(
ERROR
)
<<
"memcpy error: "
<<
ret
;
return
RET_ERROR
;
}
weight
->
set_tensor_size
(
elem_count
*
sizeof
(
T
));
}
}
else
{
// per layer
float
min
=
FLT_MAX
;
...
...
mindspore/lite/tools/converter/quantizer/weight_quantizer.cc
浏览文件 @
f1637f11
...
...
@@ -27,7 +27,6 @@ using std::vector;
namespace
mindspore
{
namespace
lite
{
namespace
quant
{
WeightQuantizer
::
WeightQuantizer
(
FuncGraphPtr
graph
,
const
string
&
weightSize
,
const
std
::
string
&
convWeightChannelThreshold
,
const
std
::
string
&
bitNum
)
:
Quantizer
(
graph
)
{
...
...
mindspore/lite/tools/optimizer/common/gllo_utils.cc
浏览文件 @
f1637f11
...
...
@@ -48,11 +48,11 @@ bool IsRealKernel(const AnfNodePtr &node) {
}
auto
input
=
cnode
->
inputs
()[
0
];
bool
is_virtual_node
=
IsPrimitive
(
input
,
prim
::
kPrimImageSummary
)
||
IsPrimitive
(
input
,
prim
::
kPrimScalarSummary
)
||
IsPrimitive
(
input
,
prim
::
kPrimTensorSummary
)
||
IsPrimitive
(
input
,
prim
::
kPrimHistogramSummary
)
||
IsPrimitive
(
input
,
prim
::
kPrimMakeTuple
)
||
IsPrimitive
(
input
,
prim
::
kPrimStateSetItem
)
||
IsPrimitive
(
input
,
prim
::
kPrimDepend
)
||
IsPrimitive
(
input
,
prim
::
kPrimTupleGetItem
)
||
IsPrimitive
(
input
,
prim
::
kPrimControlDepend
)
||
IsPrimitive
(
input
,
prim
::
kPrimReturn
)
||
IsPrimitive
(
input
,
prim
::
kPrimPartial
);
IsPrimitive
(
input
,
prim
::
kPrimTensorSummary
)
||
IsPrimitive
(
input
,
prim
::
kPrimHistogramSummary
)
||
IsPrimitive
(
input
,
prim
::
kPrimMakeTuple
)
||
IsPrimitive
(
input
,
prim
::
kPrimStateSetItem
)
||
IsPrimitive
(
input
,
prim
::
kPrimDepend
)
||
IsPrimitive
(
input
,
prim
::
kPrimTupleGetItem
)
||
IsPrimitive
(
input
,
prim
::
kPrimControlDepend
)
||
IsPrimitive
(
input
,
prim
::
kPrimReturn
)
||
IsPrimitive
(
input
,
prim
::
kPrimPartial
);
return
!
is_virtual_node
;
}
...
...
@@ -159,8 +159,8 @@ bool AnfEqual(const BaseRef &a, const BaseRef &b) {
}
if
(
utils
::
isa
<
lite
::
PrimitiveC
>
(
a_value_ptr
)
&&
utils
::
isa
<
lite
::
PrimitiveC
>
(
b_value_ptr
))
{
auto
a_obj
=
(
lite
::
PrimitiveC
*
)
(
a_value_ptr
.
get
());
auto
b_obj
=
(
lite
::
PrimitiveC
*
)
(
b_value_ptr
.
get
());
auto
a_obj
=
(
lite
::
PrimitiveC
*
)(
a_value_ptr
.
get
());
auto
b_obj
=
(
lite
::
PrimitiveC
*
)(
b_value_ptr
.
get
());
return
(
*
a_obj
)
==
(
*
b_obj
);
}
else
{
return
(
*
a_value_ptr
)
==
(
*
b_value_ptr
);
...
...
@@ -319,7 +319,7 @@ schema::PrimitiveType GetCNodeType(const BaseRef &n) {
if
(
utils
::
isa
<
PrimitiveCPtr
>
(
value
))
{
auto
primitive
=
value
->
cast
<
PrimitiveCPtr
>
();
MS_ASSERT
(
primitive
!=
nullptr
);
return
(
schema
::
PrimitiveType
)
primitive
->
Type
();
return
(
schema
::
PrimitiveType
)
primitive
->
Type
();
}
else
if
(
utils
::
isa
<
Primitive
>
(
value
))
{
auto
primitive
=
value
->
cast
<
PrimitivePtr
>
();
MS_ASSERT
(
primitive
!=
nullptr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录