Created
March 7, 2025 21:02
-
-
Save bjacob/07943061d57e82b882fd43d05b502095 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::mlir::ParseResult ExpectAlmostEqConstOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { | |
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> deviceOperands; | |
::llvm::SMLoc deviceOperandsLoc; | |
(void)deviceOperandsLoc; | |
::mlir::OpAsmParser::UnresolvedOperand lhsRawOperand{}; | |
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(&lhsRawOperand, 1); ::llvm::SMLoc lhsOperandsLoc; | |
(void)lhsOperandsLoc; | |
::mlir::ElementsAttr valueAttr; | |
::mlir::FloatAttr toleranceAttr; | |
::mlir::Type lhsRawType{}; | |
::llvm::ArrayRef<::mlir::Type> lhsTypes(&lhsRawType, 1); | |
if (::mlir::succeeded(parser.parseOptionalLess())) { | |
{ | |
deviceOperandsLoc = parser.getCurrentLocation(); | |
::mlir::OpAsmParser::UnresolvedOperand operand; | |
::mlir::OptionalParseResult parseResult = | |
parser.parseOptionalOperand(operand); | |
if (parseResult.has_value()) { | |
if (failed(*parseResult)) | |
return ::mlir::failure(); | |
deviceOperands.push_back(operand); | |
} | |
} | |
if (parser.parseGreater()) | |
return ::mlir::failure(); | |
} | |
if (parser.parseLParen()) | |
return ::mlir::failure(); | |
lhsOperandsLoc = parser.getCurrentLocation(); | |
if (parser.parseOperand(lhsRawOperand)) | |
return ::mlir::failure(); | |
if (parser.parseComma()) | |
return ::mlir::failure(); | |
if (parser.parseCustomAttributeWithFallback(valueAttr, ::mlir::Type{})) { | |
return ::mlir::failure(); | |
} | |
if (valueAttr) result.getOrAddProperties<ExpectAlmostEqConstOp::Properties>().value = valueAttr; | |
{ | |
auto odsResult = parseOptionalFloatTolerance(parser, toleranceAttr); | |
if (odsResult) return ::mlir::failure(); | |
result.getOrAddProperties<ExpectAlmostEqConstOp::Properties>().tolerance = toleranceAttr; | |
} | |
if (parser.parseRParen()) | |
return ::mlir::failure(); | |
{ | |
auto loc = parser.getCurrentLocation();(void)loc; | |
if (parser.parseOptionalAttrDict(result.attributes)) | |
return ::mlir::failure(); | |
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { | |
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; | |
}))) | |
return ::mlir::failure(); | |
} | |
if (parser.parseColon()) | |
return ::mlir::failure(); | |
{ | |
::mlir::TensorType type; | |
if (parser.parseCustomTypeWithFallback(type)) | |
return ::mlir::failure(); | |
lhsRawType = type; | |
} | |
::mlir::Type odsBuildableType0 = parser.getBuilder().getType<IREE::HAL::DeviceType>(); | |
if (parser.resolveOperands(deviceOperands, odsBuildableType0, deviceOperandsLoc, result.operands)) | |
return ::mlir::failure(); | |
if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) | |
return ::mlir::failure(); | |
return ::mlir::success(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment