Skip to content

Commit

Permalink
RefineTypes aten.sum: check dtype exists before accessing methods (#1944
Browse files Browse the repository at this point in the history
)

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`.
  • Loading branch information
ramiro050 authored Mar 16, 2023
1 parent 91cd372 commit 1803502
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Dialect/Torch/Transforms/RefineTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,13 @@ void TypeAnalysis::visitOperation(Operation *op,

if (auto sum = dyn_cast<AtenSumOp>(op)) {
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 (defaultDtype.isInteger(1))
defaultDtype =
Expand Down

0 comments on commit 1803502

Please sign in to comment.