RefineTypes aten.sum: check dtype exists before accessing methods (#1944)

This commit adds a check that `defaultDtype` exists in the RefineTypes
handling of `AtenSumOp` before accessing the method `isInteger`, which
crashes the program is `defaultDtype` is null.

The handling of `defaultDtype` is the same as the one used for the
`AtenSumDimIntListOp`.
pull/1947/head snapshot-20230317.780
Ramiro Leal-Cavazos 2023-03-16 08:35:49 -07:00 committed by GitHub
parent 91cd37256c
commit 18035021f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -893,6 +893,13 @@ void TypeAnalysis::visitOperation(Operation *op,
if (auto sum = dyn_cast<AtenSumOp>(op)) { if (auto sum = dyn_cast<AtenSumOp>(op)) {
Type defaultDtype = operands[0]->getValue().dtype; Type defaultDtype = operands[0]->getValue().dtype;
if (!defaultDtype) {
incorporateKnowledge(
sum.getResult(),
ValueKnowledge::getTensorPessimisticValueState(op->getContext()));
return;
}
// If the input dtype is bool, the result type should be i64. // If the input dtype is bool, the result type should be i64.
if (defaultDtype.isInteger(1)) if (defaultDtype.isInteger(1))
defaultDtype = defaultDtype =