26 #define SUB(x, y) (x - y) 27 #define ADD(x, y) (x + y) 28 #define MAX(x, y) max((x), (y)) 29 #define MIN(x, y) min((x), (y)) 30 #define SQUARED_DIFF(x, y) (x - y) * (x - y) 31 #define PRELU(x, y) (select(y * x, x, CONVERT((x > (DATA_TYPE_OUT)0), SELECT_VEC_DATA_TYPE(float, VEC_SIZE_OUT)))) 32 #define DIV(x, y) (x / y) 34 #define CONVERT_RTE(x, type) (convert_##type##_rte((x))) 35 #define CONVERT_DOWN(x, type) CONVERT_RTE(x, type) 37 #define OP_FUN_NAME_STR(op) elementwise_operation_##op##_quantized 38 #define OP_FUN_NAME(op) OP_FUN_NAME_STR(op) 40 #if defined(OP) && defined(VEC_SIZE_IN1) && defined(VEC_SIZE_IN2) && defined(VEC_SIZE_OUT) && defined(OFFSET_IN1) && defined(OFFSET_IN2) && defined(OFFSET_OUT) && defined(SCALE_IN1) && defined(SCALE_IN2) && defined(SCALE_OUT) && defined(DATA_TYPE_OUT) 42 #define VEC_FLOAT VEC_DATA_TYPE(float, VEC_SIZE_OUT) 43 #define VEC_INT VEC_DATA_TYPE(int, VEC_SIZE_OUT) 44 #define VEC_TYPE VEC_DATA_TYPE(DATA_TYPE_OUT, VEC_SIZE_OUT) 94 #else // VEC_SIZE_IN1 == 1 95 uint in1_x_offs = max((
int)(get_global_id(0) * VEC_SIZE_IN1 - (VEC_SIZE_IN1 - VEC_SIZE_LEFTOVER) % VEC_SIZE_IN1), 0);
96 #endif // VEC_SIZE_IN1 == 1 99 #else // VEC_SIZE_IN2 == 1 100 uint in2_x_offs = max((
int)(get_global_id(0) * VEC_SIZE_IN2 - (VEC_SIZE_IN2 - VEC_SIZE_LEFTOVER) % VEC_SIZE_IN2), 0);
101 #endif // VEC_SIZE_IN2 == 1 102 uint out_x_offs = max((
int)(get_global_id(0) * VEC_SIZE_OUT - (VEC_SIZE_OUT - VEC_SIZE_LEFTOVER) % VEC_SIZE_OUT), 0);
105 __global uchar *in1_addr = in1_ptr + in1_offset_first_element_in_bytes + in1_x_offs *
sizeof(DATA_TYPE_OUT) + get_global_id(1) * in1_step_y + get_global_id(2) * in1_step_z;
106 __global uchar *in2_addr = in2_ptr + in2_offset_first_element_in_bytes + in2_x_offs *
sizeof(DATA_TYPE_OUT) + get_global_id(1) * in2_step_y + get_global_id(2) * in2_step_z;
107 __global uchar *out_addr = out_ptr + out_offset_first_element_in_bytes + out_x_offs *
sizeof(DATA_TYPE_OUT) + get_global_id(1) * out_step_y + get_global_id(2) * out_step_z;
121 STORE_VECTOR_SELECT(res, DATA_TYPE_OUT, out_addr, VEC_SIZE_OUT, VEC_SIZE_LEFTOVER, VEC_SIZE_LEFTOVER != 0 && get_global_id(0) == 0)
#define CONVERT_SAT(a, b)
#define STORE_VECTOR_SELECT(basename, data_type, ptr, vec_size, leftover, cond)
Store a vector that can only be partial in x.
#define CONVERT_DOWN(x, type)
#define TENSOR3D_DECLARATION(name)
#define VEC_DATA_TYPE(type, size)