Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
f3699f51
Mace
项目概览
慢慢CG
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
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看板
提交
f3699f51
编写于
9月 20, 2017
作者:
刘
刘琦
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into 'master'
Make bias optional See merge request !53
上级
f4a96655
61155043
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
23 addition
and
13 deletion
+23
-13
mace/kernels/conv_2d.h
mace/kernels/conv_2d.h
+3
-1
mace/kernels/depthwise_conv2d.h
mace/kernels/depthwise_conv2d.h
+3
-1
mace/kernels/neon/conv_2d_neon_1x1.cc
mace/kernels/neon/conv_2d_neon_1x1.cc
+1
-3
mace/kernels/neon/conv_2d_neon_3x3.cc
mace/kernels/neon/conv_2d_neon_3x3.cc
+1
-1
mace/kernels/neon/conv_2d_neon_5x5.cc
mace/kernels/neon/conv_2d_neon_5x5.cc
+2
-3
mace/ops/conv_2d.h
mace/ops/conv_2d.h
+7
-2
mace/ops/depthwise_conv2d.h
mace/ops/depthwise_conv2d.h
+6
-2
未找到文件。
mace/kernels/conv_2d.h
浏览文件 @
f3699f51
...
...
@@ -73,10 +73,12 @@ class Conv2dFunctor {
#pragma omp parallel for collapse(2)
for
(
int
n
=
0
;
n
<
batch
;
++
n
)
{
for
(
int
c
=
0
;
c
<
channels
;
++
c
)
{
T
bias_channel
=
bias
?
bias
[
c
]
:
0
;
for
(
int
h
=
0
;
h
<
height
;
++
h
)
{
for
(
int
w
=
0
;
w
<
width
;
++
w
)
{
index_t
offset
=
n
*
channels
*
height
*
width
+
c
*
height
*
width
+
h
*
width
+
w
;
output
[
offset
]
=
bias_channel
;
T
sum
=
0
;
const
T
*
filter_ptr
=
filter
+
c
*
kernel_size
;
for
(
int
inc
=
0
;
inc
<
input_channels
;
++
inc
)
{
...
...
@@ -102,8 +104,8 @@ class Conv2dFunctor {
++
filter_ptr
;
}
}
output
[
offset
]
=
sum
+
bias
[
c
];
}
output
[
offset
]
+=
sum
;
}
}
}
...
...
mace/kernels/depthwise_conv2d.h
浏览文件 @
f3699f51
...
...
@@ -75,10 +75,12 @@ class DepthwiseConv2dFunctor {
#pragma omp parallel for collapse(2)
for
(
int
n
=
0
;
n
<
batch
;
++
n
)
{
for
(
int
c
=
0
;
c
<
channels
;
++
c
)
{
T
bias_channel
=
bias
?
bias
[
c
]
:
0
;
for
(
int
h
=
0
;
h
<
height
;
++
h
)
{
for
(
int
w
=
0
;
w
<
width
;
++
w
)
{
index_t
offset
=
n
*
channels
*
height
*
width
+
c
*
height
*
width
+
h
*
width
+
w
;
output
[
offset
]
=
bias_channel
;
T
sum
=
0
;
const
T
*
filter_ptr
=
filter
+
c
*
kernel_size
;
for
(
int
kh
=
0
;
kh
<
kernel_h
;
++
kh
)
{
...
...
@@ -103,7 +105,7 @@ class DepthwiseConv2dFunctor {
++
filter_ptr
;
}
}
output
[
offset
]
=
sum
+
bias
[
c
]
;
output
[
offset
]
+=
sum
;
}
}
}
...
...
mace/kernels/neon/conv_2d_neon_1x1.cc
浏览文件 @
f3699f51
...
...
@@ -47,9 +47,7 @@ void Conv2dNeonK1x1S1(const float *input, // NCHW
// Fill with bias
float
*
output_ptr
=
channel_output_start
;
for
(
index_t
ptr
=
0
;
ptr
<
total_pixels
;
++
ptr
)
{
output_ptr
[
ptr
]
=
bias
[
c
];
// TODO can we avoid this?
}
std
::
fill
(
output_ptr
,
output_ptr
+
total_pixels
,
bias
?
bias
[
c
]
:
0
);
index_t
inc
=
0
;
// Process 4 input channels in batch
...
...
mace/kernels/neon/conv_2d_neon_3x3.cc
浏览文件 @
f3699f51
...
...
@@ -28,7 +28,7 @@ namespace kernels {
input_ptr += (oc / multiplier) * input_height * input_width; \
} \
float *output_ptr = output_ptr_base + oc * output_height * output_width; \
std::fill(output_ptr, output_ptr + output_height * output_width, bias
[oc]);
\
std::fill(output_ptr, output_ptr + output_height * output_width, bias
? bias[oc] : 0);
\
for (int ic = 0; ic < filter_in_channels; ++ic) { \
float32x4_t n_filter_v[3] = {vld1q_f32(filter_ptr), vld1q_f32(filter_ptr+3), vld1q_f32(filter_ptr+6)};
...
...
mace/kernels/neon/conv_2d_neon_5x5.cc
浏览文件 @
f3699f51
...
...
@@ -45,9 +45,8 @@ void Conv2dNeonK5x5S1(const float *input, // NCHW
const
float
*
input_ptr
=
input
+
n
*
input_total_pixels_per_batch
;
// Fill with bias
for
(
index_t
i
=
0
;
i
<
output_total_pixels_per_channel
;
++
i
)
{
output_ptr
[
i
]
=
bias
[
c
];
}
std
::
fill
(
output_ptr
,
output_ptr
+
output_total_pixels_per_channel
,
bias
?
bias
[
c
]
:
0
);
for
(
index_t
inc
=
0
;
inc
<
input_channels
;
++
inc
)
{
float
*
outptr
=
output_ptr
;
...
...
mace/ops/conv_2d.h
浏览文件 @
f3699f51
...
...
@@ -27,7 +27,12 @@ class Conv2dOp : public ConvPool2dOpBase<D, T> {
bool
Run
()
override
{
const
Tensor
*
input
=
this
->
Input
(
INPUT
);
const
Tensor
*
filter
=
this
->
Input
(
FILTER
);
const
Tensor
*
bias
=
this
->
Input
(
BIAS
);
const
T
*
bias_data
=
nullptr
;
if
(
this
->
InputSize
()
>=
3
)
{
const
Tensor
*
bias
=
this
->
Input
(
BIAS
);
bias_data
=
bias
->
data
<
T
>
();
}
Tensor
*
output
=
this
->
Output
(
OUTPUT
);
std
::
vector
<
index_t
>
output_shape
(
4
);
...
...
@@ -36,7 +41,7 @@ class Conv2dOp : public ConvPool2dOpBase<D, T> {
output
->
Resize
(
output_shape
);
functor_
(
input
->
data
<
T
>
(),
input
->
shape
().
data
(),
filter
->
data
<
T
>
(),
filter
->
shape
().
data
(),
bias
->
data
<
T
>
()
,
output
->
mutable_data
<
T
>
(),
filter
->
shape
().
data
(),
bias
_data
,
output
->
mutable_data
<
T
>
(),
output
->
shape
().
data
());
return
true
;
...
...
mace/ops/depthwise_conv2d.h
浏览文件 @
f3699f51
...
...
@@ -26,7 +26,11 @@ class DepthwiseConv2dOp : public ConvPool2dOpBase<D, T> {
bool
Run
()
override
{
const
Tensor
*
input
=
this
->
Input
(
INPUT
);
const
Tensor
*
filter
=
this
->
Input
(
FILTER
);
const
Tensor
*
bias
=
this
->
Input
(
BIAS
);
const
T
*
bias_data
=
nullptr
;
if
(
this
->
InputSize
()
>=
3
)
{
const
Tensor
*
bias
=
this
->
Input
(
BIAS
);
bias_data
=
bias
->
data
<
T
>
();
}
Tensor
*
output
=
this
->
Output
(
OUTPUT
);
// resize filter shape.
...
...
@@ -38,7 +42,7 @@ class DepthwiseConv2dOp : public ConvPool2dOpBase<D, T> {
output
->
Resize
(
output_shape
);
functor_
(
input
->
data
<
T
>
(),
input
->
shape
().
data
(),
filter
->
data
<
T
>
(),
filter_shape
.
data
(),
bias
->
data
<
T
>
()
,
output
->
mutable_data
<
T
>
(),
filter_shape
.
data
(),
bias
_data
,
output
->
mutable_data
<
T
>
(),
output
->
shape
().
data
());
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录