MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / IsEqual

Function IsEqual

tensorflow/core/kernels/data/dataset_test_base.cc:111–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109
110template <typename T>
111Status 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
138Status DatasetOpsTestBase::ExpectEqual(const Tensor& a, const Tensor& b) {
139 switch (a.dtype()) {

Callers

nothing calls this directly

Calls 7

InternalFunction · 0.85
DataTypeStringFunction · 0.50
dtypeMethod · 0.45
IsSameSizeMethod · 0.45
DebugStringMethod · 0.45
shapeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected