Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr.Vain
Mace
提交
1ac3d9ff
Mace
项目概览
Mr.Vain
/
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,体验更适合开发者的 AI 搜索 >>
提交
1ac3d9ff
编写于
5月 14, 2018
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compile error and isolate opencl for deconv
上级
a6c8ff43
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
15 deletion
+17
-15
mace/kernels/deconv_2d.h
mace/kernels/deconv_2d.h
+10
-11
mace/ops/deconv_2d.cc
mace/ops/deconv_2d.cc
+2
-0
mace/ops/deconv_2d.h
mace/ops/deconv_2d.h
+1
-4
mace/python/tools/tensor_data.jinja2
mace/python/tools/tensor_data.jinja2
+4
-0
未找到文件。
mace/kernels/deconv_2d.h
浏览文件 @
1ac3d9ff
...
...
@@ -23,12 +23,15 @@
#include <vector>
#include "mace/core/future.h"
#include "mace/core/runtime/opencl/cl2_header.h"
#include "mace/core/tensor.h"
#include "mace/kernels/activation.h"
#include "mace/kernels/conv_pool_2d_util.h"
#include "mace/utils/utils.h"
#ifdef MACE_ENABLE_OPENCL
#include "mace/core/runtime/opencl/cl2_header.h"
#endif // MACE_ENABLE_OPENCL
namespace
mace
{
namespace
kernels
{
...
...
@@ -126,7 +129,6 @@ struct Deconv2dFunctorBase {
const
index_t
in_height
=
isNCHW
?
input_shape
[
2
]
:
input_shape
[
1
];
const
index_t
in_width
=
isNCHW
?
input_shape
[
3
]
:
input_shape
[
2
];
const
index_t
in_channels
=
isNCHW
?
input_shape
[
1
]
:
input_shape
[
3
];
const
index_t
extended_input_height
=
(
in_height
-
1
)
*
strides
[
0
]
+
1
+
padding_size
[
0
];
...
...
@@ -168,11 +170,9 @@ struct Deconv2dFunctorBase {
const
index_t
in_height
=
isNCHW
?
input_shape
[
2
]
:
input_shape
[
1
];
const
index_t
in_width
=
isNCHW
?
input_shape
[
3
]
:
input_shape
[
2
];
const
index_t
in_channels
=
isNCHW
?
input_shape
[
1
]
:
input_shape
[
3
];
const
index_t
out_height
=
isNCHW
?
output_shape
[
2
]
:
output_shape
[
1
];
const
index_t
out_width
=
isNCHW
?
output_shape
[
3
]
:
output_shape
[
2
];
const
index_t
out_channels
=
isNCHW
?
output_shape
[
1
]
:
output_shape
[
3
];
const
index_t
extended_input_height
=
(
in_height
-
1
)
*
strides
[
0
]
+
1
;
const
index_t
extended_input_width
=
(
in_width
-
1
)
*
strides
[
1
]
+
1
;
...
...
@@ -216,9 +216,9 @@ struct Deconv2dFunctorBase {
const
int
*
strides_
;
// [stride_h, stride_w]
const
Padding
padding_type_
;
std
::
vector
<
int
>
paddings_
;
std
::
vector
<
index_t
>
output_shape_
;
const
ActivationType
activation_
;
const
float
relux_max_limit_
;
std
::
vector
<
index_t
>
output_shape_
;
};
template
<
DeviceType
D
,
typename
T
>
...
...
@@ -228,9 +228,7 @@ struct Deconv2dFunctor : Deconv2dFunctorBase {
const
std
::
vector
<
int
>
&
paddings
,
const
std
::
vector
<
index_t
>
&
output_shape
,
const
ActivationType
activation
,
const
float
relux_max_limit
,
const
bool
is_filter_transformed
,
ScratchBuffer
*
scratch
)
const
float
relux_max_limit
)
:
Deconv2dFunctorBase
(
strides
,
padding_type
,
paddings
,
...
...
@@ -243,6 +241,7 @@ struct Deconv2dFunctor : Deconv2dFunctorBase {
const
Tensor
*
bias
,
Tensor
*
output
,
StatsFuture
*
future
)
{
MACE_UNUSED
(
future
);
MACE_CHECK_NOTNULL
(
input
);
MACE_CHECK_NOTNULL
(
filter
);
MACE_CHECK_NOTNULL
(
output
);
...
...
@@ -315,6 +314,7 @@ struct Deconv2dFunctor : Deconv2dFunctorBase {
}
};
#ifdef MACE_ENABLE_OPENCL
template
<
typename
T
>
struct
Deconv2dFunctor
<
DeviceType
::
GPU
,
T
>
:
Deconv2dFunctorBase
{
Deconv2dFunctor
(
const
int
*
strides
,
...
...
@@ -322,9 +322,7 @@ struct Deconv2dFunctor<DeviceType::GPU, T> : Deconv2dFunctorBase {
const
std
::
vector
<
int
>
&
paddings
,
const
std
::
vector
<
index_t
>
&
output_shape
,
const
ActivationType
activation
,
const
float
relux_max_limit
,
const
bool
is_filter_transformed
,
ScratchBuffer
*
scratch
)
const
float
relux_max_limit
)
:
Deconv2dFunctorBase
(
strides
,
padding_type
,
paddings
,
...
...
@@ -343,6 +341,7 @@ struct Deconv2dFunctor<DeviceType::GPU, T> : Deconv2dFunctorBase {
std
::
unique_ptr
<
BufferBase
>
kernel_error_
;
std
::
vector
<
index_t
>
input_shape_
;
};
#endif // MACE_ENABLE_OPENCL
}
// namespace kernels
}
// namespace mace
...
...
mace/ops/deconv_2d.cc
浏览文件 @
1ac3d9ff
...
...
@@ -24,6 +24,7 @@ void Register_Deconv2D(OperatorRegistry *op_registry) {
.
Build
(),
Deconv2dOp
<
DeviceType
::
CPU
,
float
>
);
#ifdef MACE_ENABLE_OPENCL
REGISTER_OPERATOR
(
op_registry
,
OpKeyBuilder
(
"Deconv2D"
)
.
Device
(
DeviceType
::
GPU
)
.
TypeConstraint
<
float
>
(
"T"
)
...
...
@@ -35,6 +36,7 @@ void Register_Deconv2D(OperatorRegistry *op_registry) {
.
TypeConstraint
<
half
>
(
"T"
)
.
Build
(),
Deconv2dOp
<
DeviceType
::
GPU
,
half
>
);
#endif // MACE_ENABLE_OPENCL
}
}
// namespace ops
...
...
mace/ops/deconv_2d.h
浏览文件 @
1ac3d9ff
...
...
@@ -34,10 +34,7 @@ class Deconv2dOp : public ConvPool2dOpBase<D, T> {
this
->
paddings_
,
OperatorBase
::
GetRepeatedArgument
<
index_t
>
(
"output_shape"
),
kernels
::
ActivationType
::
NOOP
,
0.0
f
,
static_cast
<
bool
>
(
OperatorBase
::
GetSingleArgument
<
int
>
(
"is_filter_transformed"
,
false
)),
ws
->
GetScratchBuffer
(
D
))
{}
0.0
f
)
{}
bool
Run
(
StatsFuture
*
future
)
override
{
const
Tensor
*
input
=
this
->
Input
(
INPUT
);
...
...
mace/python/tools/tensor_data.jinja2
浏览文件 @
1ac3d9ff
...
...
@@ -17,6 +17,7 @@
#include <vector>
#include <string>
#include "mace/core/macros.h"
#include "mace/public/mace.h"
#include "mace/utils/env_time.h"
#include "mace/utils/logging.h"
...
...
@@ -42,6 +43,7 @@ alignas(4) const unsigned char model_data[{{ model_data_size }}] = {
const unsigned char *LoadModelData(const char *model_data_file) {
{% if embed_model_data %}
MACE_UNUSED(model_data_file);
return model_data;
{% else %}
int fd = open(model_data_file, O_RDONLY);
...
...
@@ -67,6 +69,8 @@ void UnloadModelData(const unsigned char *model_data) {
int ret = munmap(const_cast<unsigned char *>(model_data),
{{ model_data_size }});
MACE_CHECK(ret == 0, "Failed to unmap model data file, error code: ", errno);
{% else %}
MACE_UNUSED(model_data);
{% endif %}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录