Skip to content

Commit

Permalink
relax aten.view conversion constraint (#94)
Browse files Browse the repository at this point in the history
Only convert aten.view to tcp.custom_op when the `size` array is
non-constant. The rest will be handled through torch-to-tosa.

TODO: send out an upstream PR to fix` tosa.reshape` size calculation
logic.
  • Loading branch information
zezhang authored Sep 5, 2024
1 parent 29062f8 commit 78c1c25
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/Conversion/TorchToTcp/TcpCustomOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,11 @@ class ConvertAtenViewOp : public OpConversionPattern<AtenViewOp> {
torch_to_tcp::TorchToTcpCustomOpConversionHelper helper{op, rewriter,
getTypeConverter()};
Value self = adaptor.getSelf();
auto srcType = self.getType().cast<RankedTensorType>();
auto resultType =
getTypeConverter()->convertType(op.getType()).cast<RankedTensorType>();

SmallVector<int64_t> size;
// static shape will be handled through TOSA dialect
if (matchPattern(op.getSize(), m_TorchListOfConstantInts(size)) &&
srcType.hasStaticShape() && resultType.hasStaticShape())
return rewriter.notifyMatchFailure(op, "only dynamic shape is supported");
// static size array will be handled through TOSA dialect
if (matchPattern(op.getSize(), m_TorchListOfConstantInts(size)))
return rewriter.notifyMatchFailure(op,
"only non-constant size is supported");

helper.addOperand("self", self);
Operation *primListOp = op.getSize().getDefiningOp();
Expand Down

0 comments on commit 78c1c25

Please sign in to comment.