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

Function ParseSwitchOp

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

Source from the content-addressed store, hash-verified

473namespace {
474
475ParseResult ParseSwitchOp(OpAsmParser &parser, OperationState &result) {
476 SmallVector<OpAsmParser::OperandType, 2> op_infos;
477 SmallVector<Type, 1> types;
478 if (parser.parseOperandList(op_infos, 2) || parser.parseColonTypeList(types))
479 return failure();
480 if (types.size() != 1)
481 return parser.emitError(parser.getNameLoc())
482 << " expects only a single data type";
483
484 // Support parsing either a functional type (in which case all the types are
485 // fully qualified) or a short form with a single type (in which case the data
486 // input and the outputs are all using this type and predicate is tensor<i1>
487 // type).
488 if (types.front().isa<FunctionType>()) {
489 FunctionType type = types.front().cast<FunctionType>();
490 if (type.getNumInputs() != 2)
491 return parser.emitError(parser.getNameLoc())
492 << " expects a single data type and a predicate";
493 result.types.assign(type.getResults().begin(), type.getResults().end());
494 types.assign(type.getInputs().begin(), type.getInputs().end());
495 } else {
496 Type control_type = ControlType::get(parser.getBuilder().getContext());
497 result.types.append(2, types[0]);
498 result.types.push_back(control_type);
499 Type i1_type = parser.getBuilder().getI1Type();
500 RankedTensorType predicate_type = RankedTensorType::get({}, i1_type);
501 types.push_back(predicate_type);
502 types.append(op_infos.size() - 2, control_type);
503 }
504
505 llvm::SMLoc loc = parser.getCurrentLocation();
506 if (parser.resolveOperands(op_infos, types, loc, result.operands))
507 return failure();
508
509 return parser.parseOptionalAttrDict(result.attributes);
510}
511
512void Print(SwitchOp switch_op, OpAsmPrinter &p) {
513 p << switch_op.getOperationName() << ' ';

Callers

nothing calls this directly

Calls 9

getContextMethod · 0.80
getFunction · 0.50
sizeMethod · 0.45
frontMethod · 0.45
assignMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
appendMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected