| 109 | |
| 110 | template <typename T> |
| 111 | Status IsEqual(const Tensor& t1, const Tensor& t2) { |
| 112 | if (t1.dtype() != t2.dtype()) { |
| 113 | return tensorflow::errors::Internal( |
| 114 | "Two tensors have different dtypes: ", DataTypeString(t1.dtype()), |
| 115 | " vs. ", DataTypeString(t2.dtype())); |
| 116 | } |
| 117 | if (!t1.IsSameSize(t2)) { |
| 118 | return tensorflow::errors::Internal( |
| 119 | "Two tensors have different shapes: ", t1.shape().DebugString(), |
| 120 | " vs. ", t2.shape().DebugString()); |
| 121 | } |
| 122 | |
| 123 | auto flat_t1 = t1.flat<T>(); |
| 124 | auto flat_t2 = t2.flat<T>(); |
| 125 | auto length = flat_t1.size(); |
| 126 | |
| 127 | for (int i = 0; i < length; ++i) { |
| 128 | if (flat_t1(i) != flat_t2(i)) { |
| 129 | return tensorflow::errors::Internal( |
| 130 | "Two tensors have different values " |
| 131 | "at [", |
| 132 | i, "]: ", flat_t1(i), " vs. ", flat_t2(i)); |
| 133 | } |
| 134 | } |
| 135 | return Status::OK(); |
| 136 | } |
| 137 | |
| 138 | Status DatasetOpsTestBase::ExpectEqual(const Tensor& a, const Tensor& b) { |
| 139 | switch (a.dtype()) { |
nothing calls this directly
no test coverage detected