Skip to content

Canonicalize type annotation during construction of Var and SizeVar#11443

Merged
tqchen merged 4 commits intoapache:mainfrom
vinx13:fix/var-type-anno
May 30, 2022
Merged

Canonicalize type annotation during construction of Var and SizeVar#11443
tqchen merged 4 commits intoapache:mainfrom
vinx13:fix/var-type-anno

Conversation

@vinx13
Copy link
Member

@vinx13 vinx13 commented May 24, 2022

var->type_annotation may be empty when only runtime::DataType is passed to the constructor. This PR added canonicalization during the construction of Var and SizeVar, so that Var(dtype="float32", type_annotation=PrimType(Float(32))) is equivalent to Var(dtype="float32", type_annotation=None).

The printer side for Var and SizeVar is not affected and doesn't need update.
ReprPrinter always omit type information: https://github.com/apache/tvm/blob/main/src/tir/ir/expr.cc#L120
TextPrinter has already been implicitly converting from runtime::DataType to Type: https://github.com/apache/tvm/blob/main/src/printer/tir_text_printer.cc#L782

cc @tqchen

@github-actions github-actions bot requested a review from tqchen May 24, 2022 22:01
@vinx13 vinx13 force-pushed the fix/var-type-anno branch from 5088534 to 0183f3e Compare May 25, 2022 20:33
@junrushao
Copy link
Member

Looks like unittests are failing because of this

@vinx13 vinx13 force-pushed the fix/var-type-anno branch from 0147ce8 to 2ea27a0 Compare May 27, 2022 22:21
@tqchen tqchen merged commit c6415d1 into apache:main May 30, 2022
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