Skip to content

Conversation

@Lallapallooza
Copy link
Contributor

  • Extend ValueTensorLiteral lowering so DenseResourceElementsAttr integers are rebuilt with signless element types before emitting tosa.const, matching the converted tensor type.
  • Add lit coverage for resource-backed i32/i64 vtensor literals.
  • Add FX importer e2e tests that return constant int32/int64 tensors.

- Extend ValueTensorLiteral lowering so DenseResourceElementsAttr integers
  are rebuilt with signless element types before emitting tosa.const,
  matching the converted tensor type.
- Add lit coverage for resource-backed i32/i64 vtensor literals.
- Add FX importer e2e tests that return constant int32/int64 tensors.

Change-Id: I2fecd474c9516b868cd5184f00d4998cf44661d5
@Lallapallooza Lallapallooza force-pushed the fix-tosa-resource-literal branch from a58c1ce to 640d4c6 Compare November 7, 2025 16:52
@Lallapallooza
Copy link
Contributor Author

@sahas3 @sjarus can you please take a look?

attr = DenseResourceElementsAttr::get(newTy, res.getRawHandle());
}
}
rewriter.replaceOpWithNewOp<tosa::ConstOp>(op, outputTy, attr);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small: these two lines could be removed and the same call would be make from rewriter.replaceOpWithNewOptosa::ConstOp on line 3020.

@catcor01
Copy link

Other than the above small nit this looks good to me. Reviewed.

Copy link
Member

@sahas3 sahas3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

if (auto intTy = dyn_cast<IntegerType>(shapedAttrTy.getElementType())) {
auto signlessTy =
IntegerType::get(rewriter.getContext(), intTy.getWidth());
if (intTy != signlessTy) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: You can check !intTy.isSignless() and then create the signedless type here instead of creating signedless type always and comparing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants