| 95 | |
| 96 | template <typename T> |
| 97 | bool Mat<T>::equals(const Mat<T>& rhs) const { |
| 98 | if (this->m_rows != rhs.m_rows) |
| 99 | return false; |
| 100 | if (this->m_cols != rhs.m_cols) |
| 101 | return false; |
| 102 | if (this->m_channels != rhs.m_channels) |
| 103 | return false; |
| 104 | std::unique_ptr<T[]> row1(new T[m_cols * m_channels]); |
| 105 | std::unique_ptr<T[]> row2(new T[m_cols * m_channels]); |
| 106 | megdnn_assert(row1); |
| 107 | megdnn_assert(row2); |
| 108 | for (size_t r = 0; r < m_rows; ++r) { |
| 109 | cuda_check(cudaMemcpy( |
| 110 | row1.get(), this->ptr(r), sizeof(T) * m_cols * m_channels, |
| 111 | cudaMemcpyDeviceToHost)); |
| 112 | cuda_check(cudaMemcpy( |
| 113 | row2.get(), rhs.ptr(r), sizeof(T) * m_cols * m_channels, |
| 114 | cudaMemcpyDeviceToHost)); |
| 115 | for (size_t i = 0; i < m_cols * m_channels; ++i) { |
| 116 | if (row1[i] != row2[i]) |
| 117 | return false; |
| 118 | } |
| 119 | } |
| 120 | return true; |
| 121 | } |
| 122 | |
| 123 | template <typename T> |
| 124 | bool Mat<T>::is_continuous() const { |