MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle-Lite / tensor_diff_kernel

Function tensor_diff_kernel

lite/tests/utils/tensor_utils.h:333–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331
332template <typename dtype>
333void tensor_diff_kernel(const dtype* src1,
334 const dtype* src2,
335 dtype* dst,
336 int64_t size,
337 PrecisionType precision) {
338 switch (precision) {
339 case PRECISION(kFloat):
340#ifdef ENABLE_ARM_FP16
341 case PRECISION(kFP16):
342#endif
343 case PRECISION(kInt32):
344 for (int i = 0; i < size; ++i) {
345 // VLOG(4) << i << " " << src1[i] << " " << src2[i];
346 dst[i] = src1[i] - src2[i];
347 }
348 return;
349 case PRECISION(kInt8):
350 for (int i = 0; i < size; ++i) {
351 dst[i] = src1[i] - src2[i];
352 if (static_cast<int>(abs(dst[i])) > 0.1) {
353 VLOG(4) << i << " " << static_cast<int>(src1[i]) << " "
354 << static_cast<int>(src2[i]);
355 }
356 }
357 return;
358 default:
359 LOG(FATAL) << "data type error";
360 }
361}
362void tensor_diff(const Tensor& t1, const Tensor& t2, Tensor& tdiff) { // NOLINT
363 int64_t size1 = t1.numel();
364 int64_t size2 = t2.numel();

Callers 1

tensor_diffFunction · 0.85

Calls 1

absFunction · 0.50

Tested by

no test coverage detected