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