Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
f7ee19a5
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看板
提交
f7ee19a5
编写于
8月 20, 2020
作者:
Z
zhanyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.Fix bugs of some InferShape. 2.Fix the bug of fc int8
上级
b4925d3e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
22 deletion
+37
-22
mindspore/lite/src/ops/dedepthwise_conv2d.cc
mindspore/lite/src/ops/dedepthwise_conv2d.cc
+2
-2
mindspore/lite/src/ops/full_connection.cc
mindspore/lite/src/ops/full_connection.cc
+33
-18
mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc
...e/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc
+2
-2
未找到文件。
mindspore/lite/src/ops/dedepthwise_conv2d.cc
浏览文件 @
f7ee19a5
...
...
@@ -141,8 +141,8 @@ int DeDepthwiseConv2D::InferShape(std::vector<lite::tensor::Tensor *> inputs_,
pad_u_
=
GetPadUp
();
pad_d_
=
GetPadDown
();
pad_r_
=
GetPadRight
();
output_h
=
GetStrideH
()
*
(
input_h
-
1
)
*
GetKernelH
()
-
pad_u_
-
pad_d_
;
output_w
=
GetStrideW
()
*
(
input_w
-
1
)
*
GetKernelW
()
-
pad_l_
-
pad_r_
;
output_h
=
GetStrideH
()
*
(
input_h
-
1
)
+
GetKernelH
()
-
pad_u_
-
pad_d_
;
output_w
=
GetStrideW
()
*
(
input_w
-
1
)
+
GetKernelW
()
-
pad_l_
-
pad_r_
;
if
((
output_h
+
GetPadUp
()
+
GetPadDown
()
-
GetKernelH
())
%
GetStrideH
()
!=
0
)
{
output_h
+=
(
output_h
+
GetPadLeft
()
+
GetPadRight
()
-
GetKernelH
())
%
GetStrideH
();
}
...
...
mindspore/lite/src/ops/full_connection.cc
浏览文件 @
f7ee19a5
...
...
@@ -28,7 +28,7 @@ void FullConnection::SetHasBias(bool has_bias) { this->primitive->value.AsFullCo
void
FullConnection
::
SetAxis
(
int
axis
)
{
this
->
primitive
->
value
.
AsFullConnection
()
->
axis
=
axis
;
}
void
FullConnection
::
SetUseAxis
(
bool
use_axis
)
{
this
->
primitive
->
value
.
AsFullConnection
()
->
useAxis
=
use_axis
;
}
void
FullConnection
::
SetActivationType
(
int
activationType
)
{
this
->
primitive
->
value
.
AsFullConnection
()
->
activationType
=
(
schema
::
ActivationType
)
activationType
;
this
->
primitive
->
value
.
AsFullConnection
()
->
activationType
=
(
schema
::
ActivationType
)
activationType
;
}
#else
...
...
@@ -47,43 +47,58 @@ int FullConnection::InferShape(std::vector<lite::tensor::Tensor *> inputs_,
MS_ASSERT
(
this
->
primitive
!=
nullptr
);
auto
input0
=
inputs_
.
front
();
MS_ASSERT
(
input0
!=
nullptr
);
auto
input1
=
inputs_
.
at
(
1
)
;
auto
input1
=
inputs_
[
1
]
;
MS_ASSERT
(
input1
!=
nullptr
);
auto
output
=
outputs_
.
front
();
MS_ASSERT
(
output
!=
nullptr
);
output
->
set_data_type
(
input0
->
data_type
());
output
->
SetFormat
(
input0
->
GetFormat
());
if
(
!
GetInferFlag
())
{
return
RET_OK
;
}
if
((
GetHasBias
()
&&
inputs_
.
size
()
!=
kMultiNum
)
||
(
!
GetHasBias
()
&&
inputs_
.
size
()
!=
kDoubleNum
))
{
MS_LOG
(
ERROR
)
<<
"Input tensors num error"
;
return
1
;
return
RET_INPUT_TENSOR_ERROR
;
}
if
(
Get
Axis
()
<
1
||
GetAxis
()
>
static_cast
<
int
>
(
input0
->
shape
().
size
(
)))
{
if
(
Get
UseAxis
()
&&
(
GetAxis
()
<
1
||
GetAxis
()
>
static_cast
<
int
>
(
input0
->
shape
().
size
()
)))
{
MS_LOG
(
ERROR
)
<<
"FullConnection axis invalid"
;
return
1
;
return
RET_ERROR
;
}
int
new_k
=
1
;
for
(
size_t
i
=
GetAxis
();
i
<
input0
->
shape
().
size
();
++
i
)
{
new_k
*=
input0
->
shape
().
at
(
i
);
}
if
(
new_k
!=
input1
->
shape
().
at
(
1
))
{
MS_LOG
(
ERROR
)
<<
"Input1 size invalid"
;
return
1
;
if
(
GetUseAxis
())
{
for
(
int
i
=
GetAxis
();
i
<
input0
->
shape
().
size
();
++
i
)
{
new_k
*=
input0
->
shape
()[
i
];
}
if
(
new_k
!=
input1
->
shape
()[
1
])
{
MS_LOG
(
ERROR
)
<<
"Input1 size invalid"
;
return
RET_INPUT_TENSOR_ERROR
;
}
}
else
{
new_k
=
input1
->
shape
()[
1
];
}
if
(
GetHasBias
())
{
if
(
inputs_
.
at
(
2
)
->
shape
()[
0
]
!=
input1
->
shape
()[
0
])
{
if
(
inputs_
[
2
]
->
shape
()[
0
]
!=
input1
->
shape
()[
0
])
{
MS_LOG
(
ERROR
)
<<
"bias size invalid"
;
return
1
;
return
RET_INPUT_TENSOR_ERROR
;
}
}
std
::
vector
<
int
>
out_shape
{
inputs_
[
0
]
->
shape
()};
out_shape
.
resize
(
GetAxis
()
+
1
);
out_shape
[
GetAxis
()]
=
input1
->
shape
()[
0
];
if
(
GetUseAxis
())
{
out_shape
.
resize
(
GetAxis
()
+
1
);
out_shape
[
GetAxis
()]
=
input1
->
shape
()[
0
];
}
else
{
int
total
=
1
;
for
(
int
i
=
0
;
i
<
input0
->
shape
().
size
();
++
i
)
{
total
*=
input0
->
shape
()[
i
];
}
out_shape
.
resize
(
2
);
auto
batch_size
=
total
/
new_k
;
out_shape
[
0
]
=
batch_size
;
out_shape
[
1
]
=
input1
->
shape
()[
0
];
}
output
->
set_shape
(
out_shape
);
output
->
set_data_type
(
input0
->
data_type
());
output
->
SetFormat
(
input0
->
GetFormat
());
return
0
;
return
RET_OK
;
}
}
// namespace lite
}
// namespace mindspore
mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc
浏览文件 @
f7ee19a5
...
...
@@ -91,8 +91,8 @@ int FullconnectionInt8CPUKernel::ReSize() {
QuantizeRoundParameter
(
real_multiplier
,
&
quant_params_
.
quant_multiplier
,
&
quant_params_
.
left_shift
,
&
quant_params_
.
right_shift
);
CalculateActivationRangeQuantized
(
fc_param_
->
act_type_
==
ActType_Relu
,
fc_param_
->
act_type_
==
ActType_Relu6
,
quant_params_
.
output
.
zp_
,
quant_params_
.
output
.
scale_
,
&
quant_params_
.
out_act_m
ax
,
&
quant_params_
.
out_act_m
in
);
quant_params_
.
output
.
zp_
,
quant_params_
.
output
.
scale_
,
&
quant_params_
.
out_act_m
in
,
&
quant_params_
.
out_act_m
ax
);
return
RET_OK
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录