MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / configure

Method configure

src/gpu/cl/kernels/ClElementwiseUnaryKernel.cpp:93–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void ClElementWiseUnaryKernel::configure(const CLCompileContext &compile_context,
94 const ITensorInfo *src,
95 ITensorInfo *dst,
96 const ElementWiseUnary &op)
97{
98 ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
99
100 auto padding_info = get_padding_info({src, dst});
101
102 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*src, *dst, op));
103 const unsigned int num_elems_processed_per_iteration =
104 adjust_vec_size(vector_size_byte_opencl / dst->element_size(), dst->dimension(0));
105
106 std::string kernel_name = "elementwise_unary";
107 const int vec_size_x = num_elems_processed_per_iteration;
108 const int dst_width_x = dst->dimension(0);
109 if (is_data_type_quantized(src->data_type()))
110 {
111 kernel_name += "_quantized";
112 }
113 // Set kernel build options
114 CLBuildOptions build_opts;
115 build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(src->data_type()));
116 build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(vec_size_x));
117 build_opts.add_option("-DLAST_ACCESSED_X=" + support::cpp11::to_string(std::max<int>(dst_width_x - vec_size_x, 0)));
118 if (is_data_type_quantized(src->data_type()))
119 {
120 const UniformQuantizationInfo iqinfo = src->quantization_info().uniform();
121 const UniformQuantizationInfo oqinfo = dst->quantization_info().uniform();
122 build_opts.add_option("-DOFFSET_IN=" + support::cpp11::to_string(iqinfo.offset));
123 build_opts.add_option("-DOFFSET_OUT=" + support::cpp11::to_string(oqinfo.offset));
124 build_opts.add_option("-DSCALE_IN=" + float_to_string_with_full_precision(iqinfo.scale));
125 build_opts.add_option("-DSCALE_OUT=" + float_to_string_with_full_precision(oqinfo.scale));
126 }
127 switch (op)
128 {
129 case ElementWiseUnary::RSQRT:
130 build_opts.add_option("-DOPERATION=rsqrt_op");
131 break;
132 case ElementWiseUnary::EXP:
133 build_opts.add_option("-DOPERATION=exp_op");
134 break;
135 case ElementWiseUnary::NEG:
136 build_opts.add_option("-DOPERATION=neg_op");
137 break;
138 case ElementWiseUnary::SIN:
139 build_opts.add_option("-DOPERATION=sin_op");
140 break;
141 case ElementWiseUnary::ABS:
142 build_opts.add_option("-DOPERATION=fabs_op");
143 break;
144 case ElementWiseUnary::LOG:
145 build_opts.add_option("-DOPERATION=natural_log_op");
146 break;
147 case ElementWiseUnary::ROUND:
148 build_opts.add_option("-DOPERATION=round_op");
149 break;
150 case ElementWiseUnary::LOGICAL_NOT:

Callers

nothing calls this directly

Calls 15

get_padding_infoFunction · 0.85
adjust_vec_sizeFunction · 0.85
is_data_type_quantizedFunction · 0.85
create_kernelFunction · 0.85
ceil_to_multipleFunction · 0.85
has_padding_changedFunction · 0.85
validate_argumentsFunction · 0.70
to_stringFunction · 0.50
calculate_max_windowFunction · 0.50
DimensionClass · 0.50

Tested by

no test coverage detected