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

Method format_msg

src/plugin/impl/num_range_checker.cpp:91–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89
90template <typename ctype>
91std::string NumRangeChecker::format_msg(const HostTensorND& hv, float range) {
92 auto iter = megdnn::tensor_iter<ctype>(hv.as_megdnn()).begin();
93 for (size_t i = 0, it = hv.shape().total_nr_elems(); i < it; ++i) {
94 float val = static_cast<float>(*iter);
95 if (!(std::fabs(val) < range)) {
96 TensorShape idx_shp;
97 idx_shp.ndim = hv.shape().ndim;
98 std::copy(iter.idx(), iter.idx() + idx_shp.ndim, idx_shp.shape);
99 return mgb_ssprintf_log(
100 " value=%g range=%g index=%s/%s", val, range,
101 idx_shp.to_string().c_str(), hv.shape().to_string().c_str());
102 }
103 ++iter;
104 }
105 return mgb_cstr_log(" <error: range check passed on host>");
106}
107
108// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}

Callers

nothing calls this directly

Calls 8

as_megdnnMethod · 0.80
idxMethod · 0.80
fabsFunction · 0.50
copyFunction · 0.50
beginMethod · 0.45
total_nr_elemsMethod · 0.45
shapeMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected