Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
闹闹不闹!
Mace
提交
358ebd4d
Mace
项目概览
闹闹不闹!
/
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,发现更多精彩内容 >>
提交
358ebd4d
编写于
3月 06, 2018
作者:
李
李寅
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. Fix ResizeLike.
2. Distinguish opencl buffer and image
上级
422360c1
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
119 addition
and
80 deletion
+119
-80
mace/core/buffer.h
mace/core/buffer.h
+11
-3
mace/core/tensor.h
mace/core/tensor.h
+46
-12
mace/kernels/opencl/activation_opencl.cc
mace/kernels/opencl/activation_opencl.cc
+3
-3
mace/kernels/opencl/addn.cc
mace/kernels/opencl/addn.cc
+2
-2
mace/kernels/opencl/batch_norm_opencl.cc
mace/kernels/opencl/batch_norm_opencl.cc
+6
-6
mace/kernels/opencl/bias_add_opencl.cc
mace/kernels/opencl/bias_add_opencl.cc
+3
-3
mace/kernels/opencl/buffer_to_image.cc
mace/kernels/opencl/buffer_to_image.cc
+2
-3
mace/kernels/opencl/concat.cc
mace/kernels/opencl/concat.cc
+5
-5
mace/kernels/opencl/conv_2d_opencl_1x1.cc
mace/kernels/opencl/conv_2d_opencl_1x1.cc
+4
-4
mace/kernels/opencl/conv_2d_opencl_3x3.cc
mace/kernels/opencl/conv_2d_opencl_3x3.cc
+4
-4
mace/kernels/opencl/conv_2d_opencl_general.cc
mace/kernels/opencl/conv_2d_opencl_general.cc
+4
-4
mace/kernels/opencl/depthwise_conv_opencl.cc
mace/kernels/opencl/depthwise_conv_opencl.cc
+4
-5
mace/kernels/opencl/eltwise_opencl.cc
mace/kernels/opencl/eltwise_opencl.cc
+3
-3
mace/kernels/opencl/fully_connected_opencl.cc
mace/kernels/opencl/fully_connected_opencl.cc
+4
-4
mace/kernels/opencl/matmul.cc
mace/kernels/opencl/matmul.cc
+3
-4
mace/kernels/opencl/pooling_opencl.cc
mace/kernels/opencl/pooling_opencl.cc
+2
-2
mace/kernels/opencl/resize_bilinear_opencl.cc
mace/kernels/opencl/resize_bilinear_opencl.cc
+2
-2
mace/kernels/opencl/softmax_opencl.cc
mace/kernels/opencl/softmax_opencl.cc
+2
-2
mace/kernels/opencl/space_to_batch_opencl.cc
mace/kernels/opencl/space_to_batch_opencl.cc
+4
-4
mace/kernels/opencl/winograd_transform.cc
mace/kernels/opencl/winograd_transform.cc
+5
-5
未找到文件。
mace/core/buffer.h
浏览文件 @
358ebd4d
...
...
@@ -241,7 +241,9 @@ class Image : public BufferBase {
mapped_buf_
=
nullptr
;
};
void
Resize
(
index_t
size
)
{}
void
Resize
(
index_t
size
)
{
MACE_NOT_IMPLEMENTED
;
}
void
Copy
(
void
*
src
,
index_t
offset
,
index_t
length
)
{
MACE_NOT_IMPLEMENTED
;
...
...
@@ -263,7 +265,11 @@ class Image : public BufferBase {
class
BufferSlice
:
public
BufferBase
{
public:
BufferSlice
()
{}
BufferSlice
()
:
buffer_
(
nullptr
),
mapped_buf_
(
nullptr
),
offset_
(
0
),
length_
(
0
)
{}
BufferSlice
(
BufferBase
*
buffer
,
index_t
offset
,
index_t
length
)
:
BufferBase
(
buffer
->
size
()),
buffer_
(
buffer
),
...
...
@@ -284,12 +290,13 @@ class BufferSlice : public BufferBase {
other
.
length_
)
{}
~
BufferSlice
()
{
if
(
mapped_buf_
!=
nullptr
)
{
if
(
buffer_
!=
nullptr
&&
mapped_buf_
!=
nullptr
)
{
UnMap
();
}
}
void
*
buffer
()
{
MACE_CHECK_NOTNULL
(
buffer_
);
return
buffer_
->
buffer
();
};
...
...
@@ -330,6 +337,7 @@ class BufferSlice : public BufferBase {
};
void
Resize
(
index_t
size
)
{
MACE_NOT_IMPLEMENTED
;
}
void
Copy
(
void
*
src
,
index_t
offset
,
index_t
length
)
{
...
...
mace/core/tensor.h
浏览文件 @
358ebd4d
...
...
@@ -5,6 +5,7 @@
#ifndef MACE_CORE_TENSOR_H_
#define MACE_CORE_TENSOR_H_
#include "mace/core/runtime/opencl/cl2.hpp"
#include "mace/core/buffer.h"
#include "mace/utils/logging.h"
#include "mace/core/types.h"
...
...
@@ -112,10 +113,24 @@ class Tensor {
return
size
()
*
SizeOfType
();
}
inline
void
*
buffer
()
const
{
MACE_CHECK
(
buffer_
!=
nullptr
&&
buffer_
->
buffer
()
!=
nullptr
,
"buffer is null"
);
return
buffer_
->
buffer
();
inline
bool
has_opencl_image
()
const
{
return
buffer_
!=
nullptr
&&
!
buffer_
->
OnHost
()
&&
typeid
(
*
buffer_
)
==
typeid
(
Image
);
}
inline
bool
has_opencl_buffer
()
const
{
return
buffer_
!=
nullptr
&&
!
buffer_
->
OnHost
()
&&
!
has_opencl_image
();
}
inline
cl
::
Image
*
opencl_image
()
const
{
MACE_CHECK
(
has_opencl_image
(),
"do not have image"
);
return
static_cast
<
cl
::
Image
*>
(
buffer_
->
buffer
());
}
inline
cl
::
Buffer
*
opencl_buffer
()
const
{
MACE_CHECK
(
has_opencl_buffer
(),
"do not have opencl buffer"
);
return
static_cast
<
cl
::
Buffer
*>
(
buffer_
->
buffer
());
}
inline
index_t
buffer_offset
()
const
{
...
...
@@ -152,6 +167,7 @@ class Tensor {
inline
void
Resize
(
const
std
::
vector
<
index_t
>
&
shape
)
{
shape_
=
shape
;
if
(
buffer_
!=
nullptr
)
{
MACE_CHECK
(
!
has_opencl_image
(),
"Cannot resize image, use ResizeImage."
);
buffer_
->
Resize
(
raw_size
());
}
else
{
buffer_
=
new
Buffer
(
allocator_
,
raw_size
());
...
...
@@ -159,20 +175,38 @@ class Tensor {
}
}
inline
void
ResizeLike
(
const
Tensor
&
other
)
{
Resize
(
other
.
shape
());
}
inline
void
ResizeLike
(
const
Tensor
*
other
)
{
Resize
(
other
->
shape
());
}
inline
void
ResizeImage
(
const
std
::
vector
<
index_t
>
&
shape
,
const
std
::
vector
<
size_t
>
&
image_shape
)
{
shape_
=
shape
;
if
(
buffer_
==
nullptr
)
{
buffer_
=
new
Image
(
image_shape
,
dtype_
);
is_buffer_owner_
=
true
;
}
else
{
MACE_CHECK
(
has_opencl_image
(),
"Cannot ResizeImage buffer, use Resize."
);
Image
*
image
=
dynamic_cast
<
Image
*>
(
buffer_
);
MACE_CHECK
(
image_shape
[
0
]
<=
image
->
image_shape
()[
0
]
&&
image_shape
[
1
]
<=
image
->
image_shape
()[
1
]);
}
}
inline
void
ResizeLike
(
const
Tensor
&
other
)
{
ResizeLike
(
&
other
);
}
inline
void
ResizeLike
(
const
Tensor
*
other
)
{
if
(
other
->
has_opencl_image
())
{
if
(
is_buffer_owner_
&&
buffer_
!=
nullptr
&&
!
has_opencl_image
())
{
delete
buffer_
;
buffer_
=
nullptr
;
}
ResizeImage
(
other
->
shape
(),
dynamic_cast
<
Image
*>
(
other
->
UnderlyingBuffer
())
->
image_shape
());
}
else
{
if
(
is_buffer_owner_
&&
buffer_
!=
nullptr
&&
has_opencl_image
())
{
delete
buffer_
;
buffer_
=
nullptr
;
}
Resize
(
other
->
shape
());
}
}
...
...
mace/kernels/opencl/activation_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -60,12 +60,12 @@ void ActivationFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
kernel_
=
runtime
->
BuildKernel
(
"activation"
,
kernel_name
,
built_options
);
int
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
input
->
opencl_image
(
)));
if
(
activation_
==
PRELU
)
{
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
alpha
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
alpha
->
opencl_image
(
)));
}
kernel_
.
setArg
(
idx
++
,
static_cast
<
float
>
(
relux_max_limit_
));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
output
->
opencl_image
(
)));
}
const
uint32_t
gws
[
3
]
=
{
static_cast
<
uint32_t
>
(
channel_blocks
),
...
...
mace/kernels/opencl/addn.cc
浏览文件 @
358ebd4d
...
...
@@ -58,9 +58,9 @@ void AddNFunctor<DeviceType::OPENCL, T>::operator()(
uint32_t
idx
=
0
;
for
(
auto
input
:
input_tensors
)
{
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
*
(
input
->
opencl_image
(
)));
}
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output_tensor
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
output_tensor
->
opencl_image
(
)));
}
const
uint32_t
gws
[
2
]
=
{
...
...
mace/kernels/opencl/batch_norm_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -64,17 +64,17 @@ void BatchNormFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
runtime
->
BuildKernel
(
"batch_norm"
,
kernel_name
,
built_options
);
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
s
tatic_cast
<
const
cl
::
Image2D
*>
(
scale
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
input
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
s
cale
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
offset
->
buffer
()
)));
*
(
offset
->
opencl_image
(
)));
if
(
!
folded_constant_
)
{
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
mean
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
var
->
buffer
()
)));
*
(
mean
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
var
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
epsilon
);
}
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
output
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
relux_max_limit_
);
}
...
...
mace/kernels/opencl/bias_add_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -35,9 +35,9 @@ void BiasAddFunctor<DeviceType::OPENCL, T>::operator()(
kernel_
=
runtime
->
BuildKernel
(
"bias_add"
,
kernel_name
,
built_options
);
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
bias
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
input
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
bias
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
output
->
opencl_image
(
)));
}
const
uint32_t
gws
[
3
]
=
{
static_cast
<
uint32_t
>
(
channel_blocks
),
...
...
mace/kernels/opencl/buffer_to_image.cc
浏览文件 @
358ebd4d
...
...
@@ -77,7 +77,7 @@ void BufferToImageFunctor<DeviceType::OPENCL, T>::operator()(Tensor *buffer,
built_options
);
uint32_t
idx
=
0
;
b2f_kernel
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Buffer
*>
(
buffer
->
buffer
()
)));
b2f_kernel
.
setArg
(
idx
++
,
*
(
buffer
->
opencl_buffer
(
)));
if
(
!
i2b_
)
{
MACE_CHECK
(
buffer
->
buffer_offset
()
%
GetEnumTypeSize
(
buffer
->
dtype
())
==
0
,
"buffer offset not aligned"
);
b2f_kernel
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
buffer
->
buffer_offset
()
/
GetEnumTypeSize
(
buffer
->
dtype
())));
...
...
@@ -93,8 +93,7 @@ void BufferToImageFunctor<DeviceType::OPENCL, T>::operator()(Tensor *buffer,
b2f_kernel
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
buffer
->
dim
(
2
)));
b2f_kernel
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
buffer
->
dim
(
3
)));
}
b2f_kernel
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
image
->
buffer
())));
b2f_kernel
.
setArg
(
idx
++
,
*
(
image
->
opencl_image
()));
const
std
::
vector
<
uint32_t
>
lws
=
{
16
,
64
};
cl
::
Event
event
;
cl_int
error
=
runtime
->
command_queue
().
enqueueNDRangeKernel
(
...
...
mace/kernels/opencl/concat.cc
浏览文件 @
358ebd4d
...
...
@@ -42,10 +42,10 @@ static void Concat2(cl::Kernel *kernel,
*
kernel
=
runtime
->
BuildKernel
(
"concat"
,
kernel_name
,
built_options
);
uint32_t
idx
=
0
;
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input0
->
buffer
())));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input1
->
buffer
())));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input0
->
opencl_image
())));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input1
->
opencl_image
())));
kernel
->
setArg
(
idx
++
,
static_cast
<
int32_t
>
(
input0
->
dim
(
3
)));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
())));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
opencl_image
())));
}
const
uint32_t
gws
[
3
]
=
{
...
...
@@ -90,9 +90,9 @@ static void ConcatN(cl::Kernel *kernel,
for
(
int
i
=
0
;
i
<
inputs_count
;
++
i
)
{
const
Tensor
*
input
=
input_list
[
i
];
uint32_t
idx
=
0
;
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
kernel
->
setArg
(
idx
++
,
*
(
input
->
opencl_image
(
)));
kernel
->
setArg
(
idx
++
,
static_cast
<
int32_t
>
(
chan_blk_offset
));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
()
)));
kernel
->
setArg
(
idx
++
,
*
(
output
->
opencl_image
(
)));
index_t
input_channel_blk
=
input
->
dim
(
3
)
/
4
;
chan_blk_offset
+=
input_channel_blk
;
...
...
mace/kernels/opencl/conv_2d_opencl_1x1.cc
浏览文件 @
358ebd4d
...
...
@@ -71,15 +71,15 @@ extern void Conv2dOpenclK1x1(cl::Kernel *kernel,
uint32_t
idx
=
0
;
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
*
(
input
->
opencl_image
(
)));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
filter
->
buffer
()
)));
*
(
filter
->
opencl_image
(
)));
if
(
bias
!=
nullptr
)
{
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
bias
->
buffer
()
)));
*
(
bias
->
opencl_image
(
)));
}
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
output
->
buffer
()
)));
*
(
output
->
opencl_image
(
)));
// FIXME handle flexable data type: half not supported
kernel
->
setArg
(
idx
++
,
relux_max_limit
);
kernel
->
setArg
(
idx
++
,
static_cast
<
int
>
(
input_height
));
...
...
mace/kernels/opencl/conv_2d_opencl_3x3.cc
浏览文件 @
358ebd4d
...
...
@@ -66,15 +66,15 @@ extern void Conv2dOpenclK3x3(cl::Kernel *kernel,
uint32_t
idx
=
0
;
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
*
(
input
->
opencl_image
(
)));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
filter
->
buffer
()
)));
*
(
filter
->
opencl_image
(
)));
if
(
bias
!=
nullptr
)
{
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
bias
->
buffer
()
)));
*
(
bias
->
opencl_image
(
)));
}
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
output
->
buffer
()
)));
*
(
output
->
opencl_image
(
)));
kernel
->
setArg
(
idx
++
,
relux_max_limit
);
kernel
->
setArg
(
idx
++
,
static_cast
<
int
>
(
input
->
dim
(
1
)));
kernel
->
setArg
(
idx
++
,
static_cast
<
int
>
(
input
->
dim
(
2
)));
...
...
mace/kernels/opencl/conv_2d_opencl_general.cc
浏览文件 @
358ebd4d
...
...
@@ -66,15 +66,15 @@ extern void Conv2dOpencl(cl::Kernel *kernel,
uint32_t
idx
=
0
;
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
*
(
input
->
opencl_image
(
)));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
filter
->
buffer
()
)));
*
(
filter
->
opencl_image
(
)));
if
(
bias
!=
nullptr
)
{
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
bias
->
buffer
()
)));
*
(
bias
->
opencl_image
(
)));
}
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
output
->
buffer
()
)));
*
(
output
->
opencl_image
(
)));
kernel
->
setArg
(
idx
++
,
relux_max_limit
);
kernel
->
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
input
->
dim
(
1
)));
kernel
->
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
input
->
dim
(
2
)));
...
...
mace/kernels/opencl/depthwise_conv_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -81,16 +81,15 @@ void DepthwiseConv2d(cl::Kernel *kernel,
*
kernel
=
runtime
->
BuildKernel
(
"depthwise_conv2d"
,
kernel_name
,
built_options
);
uint32_t
idx
=
0
;
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
())));
kernel
->
setArg
(
idx
++
,
*
(
input
->
opencl_image
()));
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
filter
->
buffer
()
)));
idx
++
,
*
(
filter
->
opencl_image
(
)));
if
(
bias
!=
nullptr
)
{
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
bias
->
buffer
()
)));
idx
++
,
*
(
bias
->
opencl_image
(
)));
}
kernel
->
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
output
->
buffer
()
)));
idx
++
,
*
(
output
->
opencl_image
(
)));
kernel
->
setArg
(
idx
++
,
relux_max_limit
);
kernel
->
setArg
(
idx
++
,
static_cast
<
short
>
(
input_height
));
kernel
->
setArg
(
idx
++
,
static_cast
<
short
>
(
input_width
));
...
...
mace/kernels/opencl/eltwise_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -39,14 +39,14 @@ void EltwiseFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input0,
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input0
->
buffer
()
)));
*
(
input0
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input1
->
buffer
()
)));
*
(
input1
->
opencl_image
(
)));
if
(
!
coeff_
.
empty
())
{
kernel_
.
setArg
(
idx
++
,
coeff_
[
0
]);
kernel_
.
setArg
(
idx
++
,
coeff_
[
1
]);
}
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
output
->
opencl_image
(
)));
}
const
uint32_t
gws
[
2
]
=
{
...
...
mace/kernels/opencl/fully_connected_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -61,15 +61,15 @@ void FullyConnectedFunctor<DeviceType::OPENCL, T>::operator()(
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
*
(
input
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
weight
->
buffer
()
)));
*
(
weight
->
opencl_image
(
)));
if
(
bias
!=
nullptr
)
{
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
bias
->
buffer
()
)));
*
(
bias
->
opencl_image
(
)));
}
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
output
->
buffer
()
)));
*
(
output
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int
>
(
input
->
dim
(
1
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int
>
(
input
->
dim
(
2
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int
>
(
input
->
dim
(
3
)));
...
...
mace/kernels/opencl/matmul.cc
浏览文件 @
358ebd4d
...
...
@@ -40,11 +40,10 @@ void MatMulFunctor<DeviceType::OPENCL, T>::operator()(
kernel_
=
runtime
->
BuildKernel
(
"matmul"
,
kernel_name
,
built_options
);
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
A
->
opencl_image
()));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
A
->
buffer
())));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
B
->
buffer
())));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
C
->
buffer
())));
*
(
B
->
opencl_image
()));
kernel_
.
setArg
(
idx
++
,
*
(
C
->
opencl_image
()));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int
>
(
height
));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int
>
(
width
));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int
>
(
A
->
dim
(
2
)));
...
...
mace/kernels/opencl/pooling_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -65,7 +65,7 @@ void PoolingFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
kernel_
=
runtime
->
BuildKernel
(
"pooling"
,
kernel_name
,
built_options
);
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
input
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int32_t
>
(
input
->
dim
(
1
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int32_t
>
(
input
->
dim
(
2
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int32_t
>
(
out_height
));
...
...
@@ -73,7 +73,7 @@ void PoolingFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
kernel_
.
setArg
(
idx
++
,
paddings
[
1
]
/
2
);
kernel_
.
setArg
(
idx
++
,
strides_
[
0
]);
kernel_
.
setArg
(
idx
++
,
kernels_
[
0
]);
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
output
->
opencl_image
(
)));
}
const
uint32_t
gws
[
3
]
=
{
...
...
mace/kernels/opencl/resize_bilinear_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -48,8 +48,8 @@ void ResizeBilinearFunctor<DeviceType::OPENCL, T>::operator()(
kernel_
=
runtime
->
BuildKernel
(
"resize_bilinear"
,
kernel_name
,
built_options
);
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
input
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
output
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
height_scale
);
kernel_
.
setArg
(
idx
++
,
width_scale
);
kernel_
.
setArg
(
idx
++
,
static_cast
<
int32_t
>
(
in_height
));
...
...
mace/kernels/opencl/softmax_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -35,10 +35,10 @@ void SoftmaxFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *logits,
kernel_
=
runtime
->
BuildKernel
(
"softmax"
,
kernel_name
,
built_options
);
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
logits
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
logits
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
int
>
(
channels
));
kernel_
.
setArg
(
idx
++
,
remain_channels
);
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
output
->
opencl_image
(
)));
}
const
uint32_t
gws
[
3
]
=
{
static_cast
<
uint32_t
>
(
channel_blocks
),
static_cast
<
uint32_t
>
(
width
),
...
...
mace/kernels/opencl/space_to_batch_opencl.cc
浏览文件 @
358ebd4d
...
...
@@ -42,11 +42,11 @@ void SpaceToBatchFunctor<DeviceType::OPENCL, T>::operator()(Tensor *space_tensor
uint32_t
idx
=
0
;
if
(
b2s_
)
{
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
batch_tensor
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
s
tatic_cast
<
cl
::
Image2D
*>
(
space_tensor
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
batch_tensor
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
s
pace_tensor
->
opencl_image
(
)));
}
else
{
kernel_
.
setArg
(
idx
++
,
*
(
s
tatic_cast
<
const
cl
::
Image2D
*>
(
space_tensor
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
batch_tensor
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
s
pace_tensor
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
batch_tensor
->
opencl_image
(
)));
}
kernel_
.
setArg
(
idx
++
,
block_shape_
[
0
]);
kernel_
.
setArg
(
idx
++
,
block_shape_
[
1
]);
...
...
mace/kernels/opencl/winograd_transform.cc
浏览文件 @
358ebd4d
...
...
@@ -49,8 +49,8 @@ void WinogradTransformFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *i
built_options
);
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input_tensor
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output_tensor
->
buffer
()
)));
kernel_
.
setArg
(
idx
++
,
*
(
input_tensor
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
*
(
output_tensor
->
opencl_image
(
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
input_tensor
->
dim
(
1
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
input_tensor
->
dim
(
2
)));
kernel_
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
input_tensor
->
dim
(
3
)));
...
...
@@ -119,11 +119,11 @@ void WinogradInverseTransformFunctor<DeviceType::OPENCL, T>::operator()(const Te
const
uint32_t
round_h
=
(
height_
+
1
)
/
2
;
const
uint32_t
round_w
=
(
width_
+
1
)
/
2
;
uint32_t
idx
=
0
;
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input_tensor
->
buffer
())));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
input_tensor
->
opencl_image
())));
if
(
bias
!=
nullptr
)
{
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
bias
->
buffer
())));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
const
cl
::
Image2D
*>
(
bias
->
opencl_image
())));
}
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output_tensor
->
buffer
())));
kernel_
.
setArg
(
idx
++
,
*
(
static_cast
<
cl
::
Image2D
*>
(
output_tensor
->
opencl_image
())));
kernel_
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
output_shape
[
1
]));
kernel_
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
output_shape
[
2
]));
kernel_
.
setArg
(
idx
++
,
static_cast
<
uint32_t
>
(
round_h
*
round_w
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录