-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Several type mismatch fixes and checks (#12041)
* Compute common type for shape elements in BroadcastHelper The corresponding dimensions in the input/output tensors in a broadcast operations may have the same value, but different types (e.g. int32 vs int64). When the broadcast helper tries to unify the dimensions it also needs to compute the common type to hold the dimension. * Cast and simplify both members of `Range` Only the `min` member was type-casted, which could lead to ranges with different types for `min` and `extent`. Move the casts to the argument of Simplify, so that they can be eliminated if they aren't needed. * Type-check iv domain ranges, use cast only if needed in MakeLoopNest In some cases the domain ranges had the `min` and the `extent` values be of different types (e.g. [(int64)0, 32)). This is an error, and it can lead to compilation failures later on. Add a check for equal types here to catch this early. Also, only add the cast operation when the desired type differs from the current one to keep the expressions simpler. * Check that variable and substituted expression have same types Add a check to IRSubstitute to detect when the type of a variable and the type of the expression to replace it with have different types. * Add testcase * [TVMScript] Use void for lambda parameters, allow mismatch in Substitute When the script parser deals with lambdas, it creates Var objects for each parameter. Their actual types are not known at the time, and the properly typed variables are subtituted in the body later. Since the default dtype of a Var is "int32", this could lead to a type mismatch in Substitute. To deal with this scenario, use "void" for newly created Vars in the parser, and add an exception to Substitute to allow replacing void Vars with expressions of any type. * Fix type error in test_reduce_combiner_simplify * Restart CI Co-authored-by: Jiawei Liu <jaway.liu@gmail.com>
- Loading branch information
Showing
8 changed files
with
93 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters