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

Function ParseLoopCondOp

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

Source from the content-addressed store, hash-verified

1001}
1002
1003ParseResult ParseLoopCondOp(OpAsmParser &parser, OperationState &result) {
1004 SmallVector<OpAsmParser::OperandType, 2> op_infos;
1005
1006 if (parser.parseOperandList(op_infos)) return failure();
1007 if (op_infos.empty())
1008 return parser.emitError(parser.getNameLoc())
1009 << "expects at least one operand";
1010
1011 SmallVector<Type, 1> types;
1012 if (parser.parseColonTypeList(types)) return failure();
1013
1014 // Support parsing either a functional type (in which case all the types are
1015 // fully qualified) or a short form with a single type (in which case the data
1016 // input and the outputs are all using this type).
1017 Type control_type = ControlType::get(parser.getBuilder().getContext());
1018 if (FunctionType type = types.front().dyn_cast<FunctionType>()) {
1019 if (llvm::count_if(type.getInputs(),
1020 [=](Type type) { return type != control_type; }) != 1)
1021 return parser.emitError(parser.getNameLoc())
1022 << " expects a single data type";
1023 result.types.assign(type.getResults().begin(), type.getResults().end());
1024 types.assign(type.getInputs().begin(), type.getInputs().end());
1025 } else {
1026 if (types.size() != 1)
1027 return parser.emitError(parser.getNameLoc())
1028 << " expects a single data type";
1029 types.append(op_infos.size() - 1, control_type);
1030 result.addTypes({types.front(), control_type});
1031 }
1032
1033 llvm::SMLoc loc = parser.getCurrentLocation();
1034 if (parser.resolveOperands(op_infos, types, loc, result.operands))
1035 return failure();
1036
1037 return parser.parseOptionalAttrDict(result.attributes);
1038}
1039
1040} // namespace
1041

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected