MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / equals

Method equals

dnn/src/common/cv/mat.cpp:97–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96template <typename T>
97bool 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
123template <typename T>
124bool Mat<T>::is_continuous() const {

Callers

nothing calls this directly

Calls 2

ptrMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected