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

Function Verify

tensorflow/compiler/mlir/tensorflow/ir/tf_executor.cc:192–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190namespace {
191
192LogicalResult Verify(GraphOp graph) {
193 auto *executorDialect = graph.getDialect();
194
195 if (graph.GetBody().empty())
196 return graph.emitOpError() << "expects a non-empty body";
197
198 // Only tf_executor dialect operations are allowed to be immediately nested
199 // in a tf_executor.graph region.
200 for (Operation &op : graph.GetBody()) {
201 if (op.getDialect() != executorDialect)
202 return op.emitOpError() << "unallowed inside a tf_executor.graph region";
203 if (isa<GraphOp>(op))
204 return op.emitOpError()
205 << "unallowed directly inside another tf_executor.graph";
206 }
207
208 Operation &fetch = graph.GetBody().back();
209 if (!isa<FetchOp>(fetch))
210 return fetch.emitOpError()
211 << "invalid tf_executor.graph terminator, fetch expected";
212
213 // Ensure that the fetch terminator operands matches the graph result type.
214 // All the non-control operands of the fetch operation must match the graph
215 // returned value.
216 if (fetch.getNumOperands() < graph.getNumResults())
217 return fetch.emitOpError() << "does not have enough operands to cover the "
218 "graph returned values";
219 for (int i : llvm::seq<int>(0, fetch.getNumOperands())) {
220 Value operand = fetch.getOperand(i);
221 // Break out of the loop at the first control operand encountered.
222 if (operand.getType().isa<ControlType>()) {
223 if (i != graph.getNumResults())
224 return fetch.emitOpError()
225 << "operand #" << i
226 << " is a control type, can't be bound to a graph result";
227 break;
228 }
229 if (i >= graph.getNumResults())
230 return fetch.emitOpError()
231 << "operand #" << i << " does not have a graph results to bind";
232 if (graph.getResult(i).getType() != operand.getType())
233 return fetch.emitOpError()
234 << "operand #" << i << " type mismatch graph results";
235 }
236 return success();
237}
238
239void Print(GraphOp graph, OpAsmPrinter &p) {
240 p << graph.getOperationName();

Callers

nothing calls this directly

Calls 11

DropRefTypeFunction · 0.85
DropTypeSubTypesFunction · 0.85
getContextMethod · 0.80
tokenMethod · 0.80
outputMethod · 0.65
getFunction · 0.50
emptyMethod · 0.45
backMethod · 0.45
getTypeMethod · 0.45
outputsMethod · 0.45
inputMethod · 0.45

Tested by

no test coverage detected