| 151 | } |
| 152 | |
| 153 | void GrapplerTest::CompareNodes(const NodeDef& want, const NodeDef& got) const { |
| 154 | EXPECT_EQ(want.name(), got.name()); |
| 155 | EXPECT_EQ(want.op(), got.op()); |
| 156 | |
| 157 | std::vector<string> want_inputs(want.input().begin(), want.input().end()); |
| 158 | std::vector<string> got_inputs(got.input().begin(), got.input().end()); |
| 159 | EXPECT_EQ(want_inputs, got_inputs); |
| 160 | |
| 161 | const auto attr_name = [](const std::pair<const string, AttrValue>& attr) { |
| 162 | return attr.first; |
| 163 | }; |
| 164 | |
| 165 | std::vector<string> want_attrs; |
| 166 | std::vector<string> got_attrs; |
| 167 | absl::c_transform(want.attr(), std::back_inserter(want_attrs), attr_name); |
| 168 | absl::c_transform(got.attr(), std::back_inserter(got_attrs), attr_name); |
| 169 | absl::c_sort(want_attrs); |
| 170 | absl::c_sort(got_attrs); |
| 171 | EXPECT_EQ(want_attrs, got_attrs); |
| 172 | |
| 173 | for (const string& attr : want_attrs) { |
| 174 | EXPECT_TRUE(AreAttrValuesEqual(want.attr().at(attr), got.attr().at(attr))); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | bool GrapplerTest::IsNodesDirectlyConnected(const NodeMap& node_map, |
| 179 | const string& src, |