Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
野马c
Mace
提交
164569b4
Mace
项目概览
野马c
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
164569b4
编写于
7月 30, 2018
作者:
刘
刘琦
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fc' into 'master'
Fix fc bias nullptr See merge request !690
上级
3c5da142
e0b0b945
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
11 deletion
+20
-11
mace/kernels/fully_connected.h
mace/kernels/fully_connected.h
+8
-5
mace/ops/fully_connected.h
mace/ops/fully_connected.h
+12
-6
未找到文件。
mace/kernels/fully_connected.h
浏览文件 @
164569b4
...
...
@@ -64,17 +64,20 @@ struct FullyConnectedFunctor<DeviceType::CPU, float>: FullyConnectedBase {
Tensor
::
MappingGuard
guard_input
(
input
);
Tensor
::
MappingGuard
guard_weight
(
weight
);
Tensor
::
MappingGuard
guard_bias
(
bias
);
Tensor
::
MappingGuard
guard_output
(
output
);
const
float
*
input_ptr
=
input
->
data
<
float
>
();
const
float
*
weight_ptr
=
weight
->
data
<
float
>
();
const
float
*
bias_ptr
=
bias
==
nullptr
?
nullptr
:
bias
->
data
<
float
>
();
float
*
output_ptr
=
output
->
mutable_data
<
float
>
();
Gemv
(
weight_ptr
,
input_ptr
,
N
,
input_size
,
output_size
,
output_ptr
);
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
for
(
int
j
=
0
;
j
<
output_size
;
++
j
)
{
output_ptr
[
j
+
i
*
output_size
]
+=
bias_ptr
[
j
];
if
(
bias
)
{
Tensor
::
MappingGuard
guard_bias
(
bias
);
const
float
*
bias_ptr
=
bias
==
nullptr
?
nullptr
:
bias
->
data
<
float
>
();
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
for
(
int
j
=
0
;
j
<
output_size
;
++
j
)
{
output_ptr
[
j
+
i
*
output_size
]
+=
bias_ptr
[
j
];
}
}
}
...
...
mace/ops/fully_connected.h
浏览文件 @
164569b4
...
...
@@ -42,17 +42,23 @@ class FullyConnectedOp : public Operator<D, T> {
if
(
D
==
DeviceType
::
CPU
)
{
MACE_CHECK
(
input
->
dim
(
1
)
==
weight
->
dim
(
1
)
&&
input
->
dim
(
2
)
==
weight
->
dim
(
2
)
&&
input
->
dim
(
3
)
==
weight
->
dim
(
3
)
&&
weight
->
dim
(
0
)
==
bias
->
dim
(
0
)
,
input
->
dim
(
3
)
==
weight
->
dim
(
3
),
"The shape of Input: "
,
MakeString
(
input
->
shape
()),
"The shape of Weight: "
,
MakeString
(
weight
->
shape
()),
" and Bias "
,
bias
->
dim
(
0
),
" don't match."
);
"The shape of Weight: "
,
MakeString
(
weight
->
shape
()),
" don't match."
);
}
else
{
MACE_CHECK
(
input
->
dim
(
1
)
==
weight
->
dim
(
2
)
&&
input
->
dim
(
2
)
==
weight
->
dim
(
3
)
&&
input
->
dim
(
3
)
==
weight
->
dim
(
1
)
&&
weight
->
dim
(
0
)
==
bias
->
dim
(
0
)
,
input
->
dim
(
3
)
==
weight
->
dim
(
1
),
"The shape of Input: "
,
MakeString
(
input
->
shape
()),
"The shape of Weight: "
,
MakeString
(
weight
->
shape
()),
" and Bias "
,
bias
->
dim
(
0
),
" don't match."
);
"The shape of Weight: "
,
MakeString
(
weight
->
shape
()),
" don't match."
);
}
if
(
bias
)
{
MACE_CHECK
(
weight
->
dim
(
0
)
==
bias
->
dim
(
0
),
"The shape of Weight: "
,
MakeString
(
weight
->
shape
()),
" and shape of Bias: "
,
bias
->
dim
(
0
),
" don't match."
);
}
return
functor_
(
input
,
weight
,
bias
,
output
,
future
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录