MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / verify_args

Function verify_args

src/verify_args.cpp:32–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30inline namespace MIGRAPHX_INLINE_NS {
31
32bool verify_args(const std::string& name,
33 const argument& target_arg,
34 const verify::expected<argument>& ref_arg,
35 verify::tolerance tols)
36{
37 bool passed = true;
38 argument t_arg = target_arg;
39 argument r_arg = ref_arg.data();
40 if(not t_arg.get_shape().computable())
41 {
42 shape o_t_shape = t_arg.get_shape();
43 shape o_r_shape = r_arg.get_shape();
44 assert(o_t_shape.type() == o_r_shape.type());
45 t_arg = t_arg.reshape(shape{shape::uint8_type, o_t_shape.lens(), o_t_shape.strides()});
46 r_arg = r_arg.reshape(shape{shape::uint8_type, o_r_shape.lens(), o_r_shape.strides()});
47 }
48 visit_all(r_arg, t_arg)([&](auto ref, auto target) {
49 double rms_error;
50 passed =
51 verify::verify_range_with_tolerance(target, verify::expected{ref}, tols, &rms_error);
52 if(not passed)
53 {
54 // TODO: Check for nans
55 std::cout << "FAILED: " << name << std::endl;
56 std::cout << "RMS Error: " << rms_error << std::endl;
57 if(ref.size() < 32 or enabled(MIGRAPHX_VERIFY_DUMP_DIFF{}))
58 std::cout << "ref:" << ref << std::endl;
59 if(target.size() < 32 or enabled(MIGRAPHX_VERIFY_DUMP_DIFF{}))
60 std::cout << "target:" << target << std::endl;
61 if(verify::range_zero(ref))
62 std::cout << "Ref data is all zeros" << std::endl;
63 if(verify::range_zero(target))
64 std::cout << "Target data is all zeros" << std::endl;
65
66 auto mxdiff = verify::max_diff(ref, target);
67 std::cout << "Max diff: " << mxdiff << std::endl;
68
69 auto idx = verify::mismatch_idx(ref, target, float_equal);
70 if(idx < verify::range_distance(ref))
71 {
72 std::cout << "Mismatch at " << idx << ": " << ref[idx] << " != " << target[idx]
73 << std::endl;
74 }
75
76 auto ref_nan_idx = find_idx(ref, verify::not_finite);
77 if(ref_nan_idx >= 0)
78 std::cout << "Non finite number found in ref at " << ref_nan_idx << ": "
79 << ref[ref_nan_idx] << std::endl;
80
81 auto target_nan_idx = find_idx(target, verify::not_finite);
82 if(target_nan_idx >= 0)
83 std::cout << "Non finite number found in target at " << target_nan_idx << ": "
84 << target[target_nan_idx] << std::endl;
85 std::cout << std::endl;
86 }
87 else
88 {
89 if(verify::range_zero(ref))

Callers 2

verify_programFunction · 0.85

Calls 15

visit_allFunction · 0.85
range_zeroFunction · 0.85
max_diffFunction · 0.85
mismatch_idxFunction · 0.85
range_distanceFunction · 0.85
find_idxFunction · 0.85
computableMethod · 0.80
reshapeMethod · 0.80
lensMethod · 0.80
enabledFunction · 0.70
dataMethod · 0.45

Tested by

no test coverage detected