Skip to content

Commit

Permalink
Don't crash when the input to aten.copy is unranked (#2307)
Browse files Browse the repository at this point in the history
This can happen when the input comes from an unsupported operator
  • Loading branch information
mgehre-amd authored Jul 18, 2023
1 parent 718f53f commit 0c17997
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Dialect/Torch/Transforms/DecomposeComplexOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3162,6 +3162,11 @@ class DecomposeAtenCopyOp : public OpRewritePattern<AtenCopyOp> {
return rewriter.notifyMatchFailure(
op, "expected result type to have a dtype");
}
auto srcTy = op.getSrc().getType().cast<BaseTensorType>();
if (!srcTy.hasSizes() || !srcTy.hasDtype()) {
return rewriter.notifyMatchFailure(
op, "expected src type to have a known rank and dtype");
}
Type resultDtype = resultType.getDtype();
Value srcToDtype =
convertTensorToDtype(rewriter, op.getLoc(), op.getSrc(), resultDtype);
Expand Down

0 comments on commit 0c17997

Please sign in to comment.