Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
d1c3fef4
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看板
提交
d1c3fef4
编写于
12月 25, 2017
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename space_to_batch helper function name for readability.
上级
5030c087
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
21 deletion
+20
-21
mace/ops/batch_to_space.h
mace/ops/batch_to_space.h
+5
-5
mace/ops/space_to_batch.h
mace/ops/space_to_batch.h
+15
-16
未找到文件。
mace/ops/batch_to_space.h
浏览文件 @
d1c3fef4
...
@@ -24,18 +24,18 @@ class BatchToSpaceNDOp : public Operator<D, T> {
...
@@ -24,18 +24,18 @@ class BatchToSpaceNDOp : public Operator<D, T> {
bool
Run
(
StatsFuture
*
future
)
override
{
bool
Run
(
StatsFuture
*
future
)
override
{
const
Tensor
*
batch_tensor
=
this
->
Input
(
INPUT
);
const
Tensor
*
batch_tensor
=
this
->
Input
(
INPUT
);
Tensor
*
space_tensor
=
this
->
Output
(
OUTPUT
);
Tensor
*
space_tensor
=
this
->
Output
(
OUTPUT
);
std
::
vector
<
index_t
>
output_shape
(
4
,
0
);
std
::
vector
<
index_t
>
output_shape
(
4
,
0
);
BatchToSpaceHelper
(
batch_tensor
,
space_tensor
,
output_shape
);
CalculateOutputShape
(
batch_tensor
,
space_tensor
,
output_shape
.
data
()
);
functor_
(
space_tensor
,
output_shape
,
const_cast
<
Tensor
*>
(
batch_tensor
),
future
);
functor_
(
space_tensor
,
output_shape
,
const_cast
<
Tensor
*>
(
batch_tensor
),
future
);
return
true
;
return
true
;
}
}
private:
private:
inline
void
BatchToSpaceHelper
(
const
Tensor
*
input_tensor
,
inline
void
CalculateOutputShape
(
const
Tensor
*
input_tensor
,
Tensor
*
output
,
Tensor
*
output
,
std
::
vector
<
index_t
>
&
output_shape
)
{
index_t
*
output_shape
)
{
auto
crops
=
OperatorBase
::
GetRepeatedArgument
<
int
>
(
"crops"
,
{
0
,
0
,
0
,
0
});
auto
crops
=
OperatorBase
::
GetRepeatedArgument
<
int
>
(
"crops"
,
{
0
,
0
,
0
,
0
});
auto
block_shape
=
OperatorBase
::
GetRepeatedArgument
<
int
>
(
"block_shape"
,
{
1
,
1
});
auto
block_shape
=
OperatorBase
::
GetRepeatedArgument
<
int
>
(
"block_shape"
,
{
1
,
1
});
MACE_CHECK
(
input_tensor
->
dim_size
()
==
4
,
"Input's shape should be 4D"
);
MACE_CHECK
(
input_tensor
->
dim_size
()
==
4
,
"Input's shape should be 4D"
);
...
...
mace/ops/space_to_batch.h
浏览文件 @
d1c3fef4
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
namespace
mace
{
namespace
mace
{
template
<
DeviceType
D
,
typename
T
>
template
<
DeviceType
D
,
typename
T
>
class
SpaceToBatchNDOp
:
public
Operator
<
D
,
T
>
{
class
SpaceToBatchNDOp
:
public
Operator
<
D
,
T
>
{
public:
public:
...
@@ -24,20 +23,20 @@ class SpaceToBatchNDOp : public Operator<D, T> {
...
@@ -24,20 +23,20 @@ class SpaceToBatchNDOp : public Operator<D, T> {
false
)
{}
false
)
{}
bool
Run
(
StatsFuture
*
future
)
override
{
bool
Run
(
StatsFuture
*
future
)
override
{
const
Tensor
*
space_tensor
=
this
->
Input
(
INPUT
);
const
Tensor
*
space_tensor
=
this
->
Input
(
INPUT
);
Tensor
*
batch_tensor
=
this
->
Output
(
OUTPUT
);
Tensor
*
batch_tensor
=
this
->
Output
(
OUTPUT
);
std
::
vector
<
index_t
>
output_shape
(
4
,
0
);
std
::
vector
<
index_t
>
output_shape
(
4
,
0
);
SpaceToBatchHelper
(
space_tensor
,
batch_tensor
,
output_shape
);
CalculateOutputShape
(
space_tensor
,
batch_tensor
,
output_shape
.
data
()
);
functor_
(
const_cast
<
Tensor
*>
(
space_tensor
),
output_shape
,
batch_tensor
,
future
);
functor_
(
const_cast
<
Tensor
*>
(
space_tensor
),
output_shape
,
batch_tensor
,
future
);
return
true
;
return
true
;
}
}
private:
private:
inline
void
SpaceToBatchHelper
(
const
Tensor
*
input_tensor
,
inline
void
CalculateOutputShape
(
const
Tensor
*
input_tensor
,
Tensor
*
output
,
Tensor
*
output
,
std
::
vector
<
index_t
>
&
output_shape
)
{
index_t
*
output_shape
)
{
auto
paddings
=
OperatorBase
::
GetRepeatedArgument
<
int
>
(
"paddings"
,
{
0
,
0
,
0
,
0
});
auto
paddings
=
OperatorBase
::
GetRepeatedArgument
<
int
>
(
"paddings"
,
{
0
,
0
,
0
,
0
});
auto
block_shape
=
OperatorBase
::
GetRepeatedArgument
<
int
>
(
"block_shape"
,
{
1
,
1
});
auto
block_shape
=
OperatorBase
::
GetRepeatedArgument
<
int
>
(
"block_shape"
,
{
1
,
1
});
MACE_CHECK
(
input_tensor
->
dim_size
()
==
4
,
"Input's shape should be 4D"
);
MACE_CHECK
(
input_tensor
->
dim_size
()
==
4
,
"Input's shape should be 4D"
);
...
@@ -47,15 +46,15 @@ class SpaceToBatchNDOp : public Operator<D, T> {
...
@@ -47,15 +46,15 @@ class SpaceToBatchNDOp : public Operator<D, T> {
const
index_t
block_dims
=
block_shape
.
size
();
const
index_t
block_dims
=
block_shape
.
size
();
index_t
block_shape_product
=
1
;
index_t
block_shape_product
=
1
;
for
(
uint32_t
block_dim
=
0
;
block_dim
<
block_dims
;
++
block_dim
)
{
for
(
uint32_t
block_dim
=
0
;
block_dim
<
block_dims
;
++
block_dim
)
{
MACE_CHECK
(
block_shape
[
block_dim
]
>
1
,
"block_shape's value should be great to 1"
);
MACE_CHECK
(
block_shape
[
block_dim
]
>
1
,
"block_shape's value should be great to 1"
);
const
index_t
block_shape_value
=
block_shape
[
block_dim
];
const
index_t
block_shape_value
=
block_shape
[
block_dim
];
const
index_t
padded_input_size
=
input_tensor
->
dim
(
block_dim
+
1
)
const
index_t
padded_input_size
=
input_tensor
->
dim
(
block_dim
+
1
)
+
paddings
[
block_dim
*
2
]
+
paddings
[
block_dim
*
2
]
+
paddings
[
block_dim
*
2
+
1
];
+
paddings
[
block_dim
*
2
+
1
];
MACE_CHECK
(
padded_input_size
%
block_shape_value
==
0
,
MACE_CHECK
(
padded_input_size
%
block_shape_value
==
0
,
"padded input "
,
padded_input_size
,
" is not divisible by block_shape"
);
"padded input "
,
padded_input_size
,
" is not divisible by block_shape"
);
block_shape_product
*=
block_shape_value
;
block_shape_product
*=
block_shape_value
;
output_shape
[
block_dim
+
1
]
=
padded_input_size
/
block_shape_value
;
output_shape
[
block_dim
+
1
]
=
padded_input_size
/
block_shape_value
;
}
}
output_shape
[
0
]
=
input_tensor
->
dim
(
0
)
*
block_shape_product
;
output_shape
[
0
]
=
input_tensor
->
dim
(
0
)
*
block_shape_product
;
output_shape
[
3
]
=
input_tensor
->
dim
(
3
);
output_shape
[
3
]
=
input_tensor
->
dim
(
3
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录