Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zezhang committed Jul 16, 2024
1 parent 6ba811e commit bf3aa99
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Conversion/TorchToTcp/TcpCustomOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,15 @@ class ConvertAtenFakeQuantizePerTensorAffineTensorQparamsOp
helper.addIntAttr("quant_max", op.getQuantMax());

// scale
auto scaleTy = adaptor.getScale().dyn_cast<RankedTensorType>();
auto scaleTy = adaptor.getScale().getType().dyn_cast<RankedTensorType>();
if (!scaleTy || scaleTy.getShape().size() != 1 ||
scaleTy.getNumElements() != 1)
return rewriter.notifyMatchFailure(op, "Unsupported scale type or size");
helper.addOperand("scale", adaptor.getScale());

// zero_point
auto zeroPointTy = adaptor.getZeroPoint().dyn_cast<RankedTensorType>();
auto zeroPointTy =
adaptor.getZeroPoint().getType().dyn_cast<RankedTensorType>();
if (!zeroPointTy || zeroPointTy.getShape().size() != 1 ||
zeroPointTy.getNumElements() != scaleTy.getNumElements())
return rewriter.notifyMatchFailure(op,
Expand All @@ -188,13 +189,14 @@ class ConvertAtenFakeQuantizePerChannelAffineOp
helper.addIntAttr("quant_max", op.getQuantMax());

// scale
auto scaleTy = adaptor.getScale().dyn_cast<RankedTensorType>();
auto scaleTy = adaptor.getScale().getType().dyn_cast<RankedTensorType>();
if (!scaleTy || scaleTy.getShape().size() != 1)
return rewriter.notifyMatchFailure(op, "Unsupported scale type or size");
helper.addOperand("scale", adaptor.getScale());

// zero_point
auto zeroPointTy = adaptor.getZeroPoint().dyn_cast<RankedTensorType>();
auto zeroPointTy =
adaptor.getZeroPoint().getType().dyn_cast<RankedTensorType>();
if (!zeroPointTy || zeroPointTy.getShape().size() != 1 ||
zeroPointTy.getNumElements() != scaleTy.getNumElements())
return rewriter.notifyMatchFailure(op,
Expand Down

0 comments on commit bf3aa99

Please sign in to comment.