Skip to content

Commit

Permalink
fix a bug during folding quantize op (alibaba#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guo-Peilin authored Jan 19, 2023
1 parent 2e56fa8 commit ca7f28e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tao_compiler/mlir/disc/IR/hlo_disc_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ OpFoldResult QuantizeOp::fold(ArrayRef<Attribute> operands) {
return {};
}

DenseElementsAttr scale = operands[1].dyn_cast<DenseElementsAttr>();
DenseElementsAttr zeroPoint = operands[2].dyn_cast<DenseElementsAttr>();
DenseElementsAttr scale = operands[1].dyn_cast_or_null<DenseElementsAttr>();
DenseElementsAttr zeroPoint =
operands[2].dyn_cast_or_null<DenseElementsAttr>();
if (!scale || !zeroPoint) return {};
ArrayRef<int64_t> scaleShape = scale.getType().getShape();
ArrayRef<int64_t> zeroPointShape = zeroPoint.getType().getShape();
// scale & zero_point must have the same shape
Expand Down

0 comments on commit ca7f28e

Please sign in to comment.