提交 b77d113c 编写于 作者: L Liangliang He

Diasble OpenCL symbol loading error checking and fix kernels syntax error

上级 50f5ab5e
...@@ -290,16 +290,15 @@ void *OpenCLLibraryImpl::LoadFromPath(const std::string &path) { ...@@ -290,16 +290,15 @@ void *OpenCLLibraryImpl::LoadFromPath(const std::string &path) {
return nullptr; return nullptr;
} }
#define MACE_CL_ASSIGN_FROM_DLSYM(func) \ #define MACE_CL_ASSIGN_FROM_DLSYM(func) \
do { \ do { \
void *ptr = dlsym(handle, #func); \ void *ptr = dlsym(handle, #func); \
if (ptr == nullptr) { \ if (ptr == nullptr) { \
LOG(ERROR) << "Failed to load " << #func << " from " << path; \ VLOG(1) << "Failed to load " << #func << " from " << path; \
dlclose(handle); \ continue; \
return nullptr; \ } \
} \ func = reinterpret_cast<func##Func>(ptr); \
func = reinterpret_cast<func##Func>(ptr); \ VLOG(2) << "Loaded " << #func << " from " << path; \
VLOG(2) << "Loaded " << #func << " from " << path; \
} while (false) } while (false)
MACE_CL_ASSIGN_FROM_DLSYM(clGetPlatformIDs); MACE_CL_ASSIGN_FROM_DLSYM(clGetPlatformIDs);
......
...@@ -28,19 +28,19 @@ inline DATA_TYPE4 do_activation(DATA_TYPE4 in, ...@@ -28,19 +28,19 @@ inline DATA_TYPE4 do_activation(DATA_TYPE4 in,
__private const float relux_max_limit) { __private const float relux_max_limit) {
DATA_TYPE4 out; DATA_TYPE4 out;
#ifdef USE_RELU #ifdef USE_RELU
out = fmax(in, 0); out = fmax(in, (DATA_TYPE)0);
#endif #endif
#ifdef USE_RELUX #ifdef USE_RELUX
out = clamp(in, 0, relux_max_limit); out = clamp(in, (DATA_TYPE4)0, relux_max_limit);
#endif #endif
#ifdef USE_PRELU #ifdef USE_PRELU
out = select(prelu_alpha * in, in, in >= 0); out = select(prelu_alpha * in, in, in >= (DATA_TYPE)0);
#endif #endif
#ifdef USE_TANH #ifdef USE_TANH
out = tanh(in); out = tanh(in);
#endif #endif
#ifdef USE_SIGMOID #ifdef USE_SIGMOID
out = native_recip(1.0 + native_exp(-in)); out = native_recip((DATA_TYPE)1 + native_exp(-in));
#endif #endif
return out; return out;
} }
......
...@@ -81,7 +81,7 @@ __kernel void fully_connected_width(__read_only image2d_t input, ...@@ -81,7 +81,7 @@ __kernel void fully_connected_width(__read_only image2d_t input,
int2 input_coord, weight_coord; int2 input_coord, weight_coord;
DATA_TYPE4 in, w; DATA_TYPE4 in, w;
DATA_TYPE sum = 0.0; DATA_TYPE sum = 0;
input_coord = (int2)(0, mul24(batch_idx, input_height)); input_coord = (int2)(0, mul24(batch_idx, input_height));
...@@ -107,7 +107,8 @@ __kernel void fully_connected_width(__read_only image2d_t input, ...@@ -107,7 +107,8 @@ __kernel void fully_connected_width(__read_only image2d_t input,
input_coord.y++; input_coord.y++;
} }
const short inter_out_offset = mad24(get_local_id(1), 4, get_local_id(0)); const short inter_out_offset = mad24((short)get_local_id(1), (short)4,
(short)get_local_id(0));
const short local_width_blk_size = (short)get_local_size(1); const short local_width_blk_size = (short)get_local_size(1);
const short local_size = mul24((short)get_local_size(0), const short local_size = mul24((short)get_local_size(0),
local_width_blk_size); local_width_blk_size);
......
...@@ -12,7 +12,7 @@ __kernel void softmax(__read_only image2d_t input, ...@@ -12,7 +12,7 @@ __kernel void softmax(__read_only image2d_t input,
int pos = width_idx; int pos = width_idx;
DATA_TYPE max_value = -FLT_MAX; DATA_TYPE max_value = -FLT_MAX;
DATA_TYPE sum = 0.0; DATA_TYPE sum = 0;
DATA_TYPE4 data; DATA_TYPE4 data;
for (short i = 0; i < chan_blks; ++i) { for (short i = 0; i < chan_blks; ++i) {
data = READ_IMAGET(input, SAMPLER, (int2)(pos, hb_idx)); data = READ_IMAGET(input, SAMPLER, (int2)(pos, hb_idx));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册