NOLINTNEXTLINE(performance-unnecessary-value-param)
| 388 | |
| 389 | // NOLINTNEXTLINE(performance-unnecessary-value-param) |
| 390 | bool CompareTensor(Tensor lhs, Tensor rhs) { |
| 391 | if (lhs.same_as(rhs)) return true; |
| 392 | if (lhs.ndim() != rhs.ndim()) return false; |
| 393 | for (int i = 0; i < lhs.ndim(); ++i) { |
| 394 | if (lhs.size(i) != rhs.size(i)) return false; |
| 395 | } |
| 396 | |
| 397 | if (lhs.dtype() != rhs.dtype()) return false; |
| 398 | if (!skip_tensor_content_) { |
| 399 | TVM_FFI_ICHECK_EQ(lhs.device().device_type, kDLCPU) << "can only compare CPU tensor"; |
| 400 | TVM_FFI_ICHECK_EQ(rhs.device().device_type, kDLCPU) << "can only compare CPU tensor"; |
| 401 | TVM_FFI_ICHECK(lhs.IsContiguous()) << "Can only compare contiguous tensor"; |
| 402 | TVM_FFI_ICHECK(rhs.IsContiguous()) << "Can only compare contiguous tensor"; |
| 403 | size_t data_size = GetDataSize(lhs); |
| 404 | return std::memcmp(lhs.data_ptr(), rhs.data_ptr(), data_size) == 0; |
| 405 | } else { |
| 406 | return true; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | Any MapLhsToRhs(Any lhs) const { |
| 411 | if (lhs.type_index() < TypeIndex::kTVMFFIStaticObjectBegin) { |
nothing calls this directly
no test coverage detected