MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / MatchAndExplain

Method MatchAndExplain

tensorflow/compiler/jit/node_matchers.cc:109–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107
108struct NodeMatcher : public ::testing::MatcherInterface<const Node*> {
109 bool MatchAndExplain(
110 const Node* node,
111 ::testing::MatchResultListener* listener) const override {
112 if (op && node->type_string() != *op) {
113 if (listener->IsInterested()) {
114 *listener << "\nexpected op " << *op << " but found "
115 << node->type_string();
116 }
117 return false;
118 }
119
120 if (assigned_device && node->assigned_device_name() != *assigned_device) {
121 if (listener->IsInterested()) {
122 *listener << "\nexpected assigned_device " << *assigned_device
123 << " but found \"" << node->assigned_device_name() << "\"";
124 }
125 return false;
126 }
127
128 if (name && node->name() != *name) {
129 if (listener->IsInterested()) {
130 *listener << "\nexpected name " << *name << " but found "
131 << node->name();
132 }
133 return false;
134 }
135
136 if (constant_value) {
137 const TensorProto* proto = nullptr;
138 if (!TryGetNodeAttr(node->def(), "value", &proto)) {
139 if (listener->IsInterested()) {
140 *listener << "\ncould not find \"value\" attribute in node";
141 }
142 return false;
143 }
144
145 Tensor tensor(proto->dtype());
146 if (!tensor.FromProto(*proto)) {
147 if (listener->IsInterested()) {
148 *listener << "\ncould not convert TensorProto in \"value\" attribute "
149 "to Tensor";
150 }
151 return false;
152 }
153
154 if (!MatchAndExplainTensor(/*tensor=*/tensor,
155 /*expected_tensor=*/*constant_value,
156 listener)) {
157 return false;
158 }
159 }
160
161 if (input_matchers) {
162 if (input_matchers->size() != node->num_inputs()) {
163 if (listener->IsInterested()) {
164 *listener << "\nexpected " << input_matchers->size()
165 << " inputs but node has " << node->num_inputs();
166 }

Callers 3

ExplainFunction · 0.45
MatchAndExplainInputMethod · 0.45
MatchAndExplainMethod · 0.45

Calls 15

MatchAndExplainTensorFunction · 0.85
AreAttrValuesEqualFunction · 0.85
SummarizeAttrValueFunction · 0.85
attrMethod · 0.80
nameMethod · 0.65
StrCatFunction · 0.50
dtypeMethod · 0.45
FromProtoMethod · 0.45
sizeMethod · 0.45
num_inputsMethod · 0.45
IsControlEdgeMethod · 0.45
push_backMethod · 0.45

Tested by 1

ExplainFunction · 0.36