| 1456 | } // namespace |
| 1457 | |
| 1458 | bool SparseTensorEquals(const SparseTensor& left, const SparseTensor& right, |
| 1459 | const EqualOptions& opts) { |
| 1460 | if (left.type()->id() != right.type()->id()) { |
| 1461 | return false; |
| 1462 | } else if (left.size() == 0 && right.size() == 0) { |
| 1463 | return true; |
| 1464 | } else if (left.shape() != right.shape()) { |
| 1465 | return false; |
| 1466 | } else if (left.non_zero_length() != right.non_zero_length()) { |
| 1467 | return false; |
| 1468 | } |
| 1469 | |
| 1470 | switch (left.format_id()) { |
| 1471 | case SparseTensorFormat::COO: { |
| 1472 | const auto& left_coo = checked_cast<const SparseTensorImpl<SparseCOOIndex>&>(left); |
| 1473 | return SparseTensorEqualsImplDispatch(left_coo, right, opts); |
| 1474 | } |
| 1475 | |
| 1476 | case SparseTensorFormat::CSR: { |
| 1477 | const auto& left_csr = checked_cast<const SparseTensorImpl<SparseCSRIndex>&>(left); |
| 1478 | return SparseTensorEqualsImplDispatch(left_csr, right, opts); |
| 1479 | } |
| 1480 | |
| 1481 | case SparseTensorFormat::CSC: { |
| 1482 | const auto& left_csc = checked_cast<const SparseTensorImpl<SparseCSCIndex>&>(left); |
| 1483 | return SparseTensorEqualsImplDispatch(left_csc, right, opts); |
| 1484 | } |
| 1485 | |
| 1486 | case SparseTensorFormat::CSF: { |
| 1487 | const auto& left_csf = checked_cast<const SparseTensorImpl<SparseCSFIndex>&>(left); |
| 1488 | return SparseTensorEqualsImplDispatch(left_csf, right, opts); |
| 1489 | } |
| 1490 | |
| 1491 | default: |
| 1492 | return false; |
| 1493 | } |
| 1494 | } |
| 1495 | |
| 1496 | bool TypeEquals(const DataType& left, const DataType& right, bool check_metadata) { |
| 1497 | // The arrays are the same object |
no test coverage detected