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

Method configure

src/gpu/cl/kernels/ClMulKernel.cpp:135–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135void ClMulKernel::configure(const CLCompileContext &compile_context,
136 ITensorInfo *src1,
137 ITensorInfo *src2,
138 ITensorInfo *dst,
139 float scale,
140 ConvertPolicy overflow_policy,
141 RoundingPolicy rounding_policy,
142 const ActivationLayerInfo &act_info)
143{
144 ARM_COMPUTE_ERROR_ON_NULLPTR(src1, src2, dst);
145 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src1, src2, dst, scale, overflow_policy, rounding_policy, act_info));
146
147 auto padding_info = get_padding_info({src1, src2, dst});
148
149 const TensorShape &out_shape = TensorShape::broadcast_shape(src1->tensor_shape(), src2->tensor_shape());
150 auto_init_if_empty(*dst, src1->clone()->set_tensor_shape(out_shape));
151
152 int scale_int = -1;
153 // Extract sign, exponent and mantissa
154 int exponent = 0;
155 float normalized_mantissa = std::frexp(scale, &exponent);
156 // Use int scaling if factor is equal to 1/2^n for 0 <= n <= 15
157 // frexp returns 0.5 as mantissa which means that the exponent will be in the range of -1 <= e <= 14
158 // Moreover, it will be negative as we deal with 1/2^n
159 if ((normalized_mantissa == 0.5f) && (-14 <= exponent) && (exponent <= 1))
160 {
161 // Store the positive exponent. We know that we compute 1/2^n
162 // Additionally we need to subtract 1 to compensate that frexp used a mantissa of 0.5
163 scale_int = std::abs(exponent - 1);
164 }
165
166 std::string acc_type;
167 // Check if it has float src and dst
168 if (is_data_type_float(src1->data_type()) || is_data_type_float(src2->data_type()))
169 {
170 scale_int = -1;
171 acc_type = (src1->data_type() == DataType::F32 || src2->data_type() == DataType::F32) ? "float" : "half";
172 }
173 else
174 {
175 if (src1->element_size() == 4 || src2->element_size() == 4)
176 {
177 // use 64 bit accumulator for 32-bit input
178 acc_type = "long";
179 }
180 else if (src1->element_size() == 2 || src2->element_size() == 2)
181 {
182 // Use 32-bit accumulator for 16-bit input
183 acc_type = "int";
184 }
185 else
186 {
187 // Use 16-bit accumulator for 8-bit input
188 acc_type = "ushort";
189 }
190 }
191
192 const bool is_quantized = is_data_type_quantized(src1->data_type());

Callers

nothing calls this directly

Calls 15

get_padding_infoFunction · 0.85
auto_init_if_emptyFunction · 0.85
frexpFunction · 0.85
absFunction · 0.85
is_data_type_floatFunction · 0.85
is_data_type_quantizedFunction · 0.85
adjust_vec_sizeFunction · 0.85
lower_stringFunction · 0.85
create_kernelFunction · 0.85

Tested by

no test coverage detected