MCPcopy Create free account
hub / github.com/MegEngine/MegCC / assert_tensor_eq

Function assert_tensor_eq

runtime/test/common/common.cpp:102–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102::testing::AssertionResult assert_tensor_eq(
103 const char* expr0, const char* expr1, const char* /*expr_maxerr*/,
104 const char* /*expr_maxerr_avg*/, const char* /*expr_maxerr_avg*/,
105 const Tensor& v0, const Tensor& v1, float maxerr, float maxerr_avg,
106 float maxerr_avg_biased) {
107 if (!equal_layout(v0.layout, v1.layout)) {
108 return ::testing::AssertionFailure()
109 << "Layout mismatch\n"
110 << "Value of: " << expr1 << "\n"
111 << " Actual: " << layout_to_string(v1.layout) << "\n"
112 << "Expected: " << expr0 << "\n"
113 << "Which is: " << layout_to_string(v0.layout) << "\n";
114 }
115 if (v0.dtype.type_enum != v1.dtype.type_enum) {
116 return ::testing::AssertionFailure() << "Dtype mismatch " << v0.dtype.type_enum
117 << " vs " << v1.dtype.type_enum << "\n ";
118 }
119 switch (v0.dtype.type_enum) {
120#define CASE(enum_, ctype_) \
121 case enum_: { \
122 return assert_tensor_eq_with_dtype<ctype_>( \
123 expr0, expr1, v0, v1, maxerr, maxerr_avg, maxerr_avg_biased); \
124 }
125 CASE(TinyNN_FLOAT, float)
126 CASE(TinyNN_INT, int)
127 CASE(TinyNN_INT8, int8_t)
128 CASE(TinyNN_UINT8, uint8_t)
129 CASE(TinyNN_INT16, int16_t)
130 default:
131 printf("unsupport dtype in check tensor equal.");
132 abort();
133#undef CASE
134 }
135}
136
137} // namespace
138

Callers

nothing calls this directly

Calls 2

equal_layoutFunction · 0.85
layout_to_stringFunction · 0.85

Tested by

no test coverage detected