212{
213 assert(input != nullptr);
214 assert(output != nullptr);
215
218
219 switch (op_type)
220 {
222 if ((
input->data_type() == OperandType::FLOAT32))
223 {
224 _kernel = absFloat32;
225 }
226 else
227 {
228 throw std::runtime_error{"Abs: Unsupported data type"};
229 }
230 break;
233 break;
235 if ((
input->data_type() == OperandType::FLOAT32))
236 {
237 _kernel = cosFloat32;
238 }
239 else
240 {
241 throw std::runtime_error{"Cos: Unsupported data type"};
242 }
243 break;
245 if ((
input->data_type() == OperandType::QUANT_UINT8_ASYMM))
246 {
247 _kernel = dequantizeUint8;
248 }
249 else if ((
input->data_type() == OperandType::QUANT_INT8_ASYMM) ||
250 (
input->data_type() == OperandType::QUANT_INT8_SYMM))
251 {
252 _kernel = dequantizeInt8;
253 }
254 else
255 {
256 throw std::runtime_error{"Dequantize: Unsupported data type"};
257 }
258 break;
260 if ((
input->data_type() == OperandType::FLOAT32))
261 {
262 _kernel = expFloat32;
263 }
264 else
265 {
266 throw std::runtime_error{"Exp: Unsupported data type"};
267 }
268 break;
270 if ((
input->data_type() == OperandType::FLOAT32))
271 {
272 _kernel = erfFloat32;
273 }
274 else
275 {
276 throw std::runtime_error{"Exp: Unsupported data type"};
277 }
278 break;
280 if ((
input->data_type() == OperandType::FLOAT32))
281 {
282 _kernel = floorFloat32;
283 }
284 else
285 {
286 throw std::runtime_error{"Floor: Unsupported data type"};
287 }
288 break;
290 if ((
input->data_type() == OperandType::FLOAT32))
291 {
292 _kernel = logFloat32;
293 }
294 else
295 {
296 throw std::runtime_error{"Log: Unsupported data type"};
297 }
298 break;
300 if ((
input->data_type() == OperandType::BOOL8))
301 {
302 static_assert(sizeof(bool) == 1, "cpu backend supports bool type which is 1 byte");
303 _kernel = logicalNot;
304 }
305 else
306 {
307 throw std::runtime_error{"LogicalNot: Unsupported data type"};
308 }
309 break;
311 if ((
input->data_type() == OperandType::FLOAT32))
312 {
313 _kernel = neg<float>;
314 }
315 else if ((
input->data_type() == OperandType::INT64))
316 {
317 _kernel = neg<int64_t>;
318 }
319 else if ((
input->data_type() == OperandType::INT32))
320 {
321 _kernel = neg<int32_t>;
322 }
323 else
324 {
325 throw std::runtime_error{"Neg: Unsupported data type"};
326 }
327 break;
329 if ((
input->data_type() == OperandType::FLOAT32))
330 {
331 _kernel = roundFloat32;
332 }
333 else
334 {
335 throw std::runtime_error{"Round: Unsupported data type"};
336 }
337 break;
339 if ((
input->data_type() == OperandType::FLOAT32))
340 {
341 _kernel = rsqrtFloat32;
342 }
343 else
344 {
345 throw std::runtime_error{"RSqrt: Unsupported data type"};
346 }
347 break;
349 if ((
input->data_type() == OperandType::FLOAT32))
350 {
351 _kernel = sinFloat32;
352 }
353 else
354 {
355 throw std::runtime_error{"Sin: Unsupported data type"};
356 }
357 break;
359 if ((
input->data_type() == OperandType::FLOAT32))
360 {
361 _kernel = sqrtFloat32;
362 }
363 else
364 {
365 throw std::runtime_error{"Sqrt: Unsupported data type"};
366 }
367 break;
369 if ((
input->data_type() == OperandType::FLOAT32))
370 {
371 _kernel = squareFloat32;
372 }
373 else
374 {
375 throw std::runtime_error{"Square: Unsupported data type"};
376 }
377 break;
379 if (
input->data_type() == OperandType::FLOAT32)
380 {
381 _kernel = zerosLikeFloat32<float>;
382 }
383 else if (
input->data_type() == OperandType::INT32)
384 {
385 _kernel = zerosLikeFloat32<int32_t>;
386 }
387 else
388 {
389 throw std::runtime_error{"ZerosLike: Unsupported data type"};
390 }
391 break;
392 default:
393 throw std::runtime_error{"ElementwiseUnary: Unsupported ElementwiseUnary type"};
394 }
395}
T * cast(Object *)
Cast a generic object as a specific one.