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

Method __assert_tensor_eq

dnn/test/common/checker.cpp:117–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115} // anonymous namespace
116
117::testing::AssertionResult test::__assert_tensor_eq(
118 const char* expr0, const char* expr1, const char* /*expr_maxerr*/,
119 const char* /*expr_maxerr_avg*/, const char* /*expr_maxerr_avg*/,
120 const TensorND& v0, const TensorND& v1, float maxerr, float maxerr_avg,
121 float maxerr_avg_biased, bool allow_invalid) {
122 if (!v0.layout.eq_shape(v1.layout)) {
123 return ::testing::AssertionFailure()
124 << "Shape mismatch\n"
125 << "Value of: " << expr1 << "\n"
126 << " Actual: " << v1.layout.TensorShape::to_string() << "\n"
127 << "Expected: " << expr0 << "\n"
128 << "Which is: " << v0.layout.TensorShape::to_string() << "\n";
129 }
130 auto dtype = v0.layout.dtype;
131 if (dtype != v1.layout.dtype) {
132 return ::testing::AssertionFailure()
133 << "Data type mismatch\n"
134 << "Value of: " << expr1 << "\n"
135 << " Actual: " << v1.layout.dtype.name() << "\n"
136 << "Expected: " << expr0 << "\n"
137 << "Which is: " << v0.layout.dtype.name() << "\n";
138 }
139
140 switch (dtype.enumv()) {
141#define cb(_dt) \
142 case DTypeTrait<_dt>::enumv: \
143 return assert_tensor_eq_with_dtype<DTypeTrait<_dt>::ctype>( \
144 expr0, expr1, v0, v1, maxerr, maxerr_avg, maxerr_avg_biased, \
145 allow_invalid);
146 MEGDNN_FOREACH_COMPUTING_DTYPE(cb)
147 MEGDNN_FOREACH_QUANTIZED_DTYPE(cb)
148 //! In order to avoid an unnecessary increase in binary size, we just
149 //! use QuantizedS16 dtype in winograd_filter_preprocess now.
150 cb(::megdnn::dtype::QuantizedS16) MEGDNN_FOREACH_QUANTIZED_LOWBIT_DTYPE(cb)
151 cb(::megdnn::dtype::Uint16) cb(::megdnn::dtype::QuantizedS1)
152 cb(::megdnn::dtype::Bool)
153#undef cb
154 default : megdnn_trap();
155 }
156}
157
158::testing::AssertionResult test::__assert_tensor_eq_allow_invalid(
159 const char* expr0, const char* expr1, const char* expr_maxerr,

Callers

nothing calls this directly

Calls 4

cbFunction · 0.50
eq_shapeMethod · 0.45
nameMethod · 0.45
enumvMethod · 0.45

Tested by

no test coverage detected