1 #ifndef CHECK_CALL_GRAPHS_H
2 #define CHECK_CALL_GRAPHS_H
14 typedef std::map<std::string, std::vector<std::string>>
CallGraphs;
43 if (std::find(callees.begin(), callees.end(), op->
name) == callees.end()) {
44 callees.push_back(op->
name);
60 if (result.size() != expected.size()) {
61 printf(
"Expect %d callers instead of %d\n", (
int)expected.size(), (
int)result.size());
64 for (
auto &iter : expected) {
65 if (result.count(iter.first) == 0) {
66 printf(
"Expect %s to be in the call graphs\n", iter.first.c_str());
69 std::vector<std::string> &expected_callees = iter.second;
70 std::vector<std::string> &result_callees = result[iter.first];
71 std::sort(expected_callees.begin(), expected_callees.end());
72 std::sort(result_callees.begin(), result_callees.end());
73 if (expected_callees != result_callees) {
74 std::string expected_str = std::accumulate(
75 expected_callees.begin(), expected_callees.end(), std::string{},
76 [](
const std::string &a,
const std::string &b) {
77 return a.empty() ? b : a +
", " + b;
79 std::string result_str = std::accumulate(
80 result_callees.begin(), result_callees.end(), std::string{},
81 [](
const std::string &a,
const std::string &b) {
82 return a.empty() ? b : a +
", " + b;
85 printf(
"Expect callees of %s to be (%s); got (%s) instead\n",
86 iter.first.c_str(), expected_str.c_str(), result_str.c_str());
93 template<
typename T,
typename F>
95 for (
int y = 0; y < im.height(); y++) {
96 for (
int x = 0; x < im.width(); x++) {
97 T correct = func(x, y);
98 if (im(x, y) != correct) {
99 std::cout <<
"im(" << x <<
", " << y <<
") = " << im(x, y)
100 <<
" instead of " << correct <<
"\n";
108 template<
typename T,
typename F>
110 for (
int z = 0; z < im.channels(); z++) {
111 for (
int y = 0; y < im.height(); y++) {
112 for (
int x = 0; x < im.width(); x++) {
113 T correct = func(x, y, z);
114 if (im(x, y, z) != correct) {
115 std::cout <<
"im(" << x <<
", " << y <<
", " << z <<
") = "
116 << im(x, y, z) <<
" instead of " << correct <<
"\n";
125 template<
typename T,
typename F>
131 template<
typename T,
typename F>