You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/09/23 20:35:53 UTC

[GitHub] [tvm] Lunderberg commented on a diff in pull request #12691: [Runtime][Bugfix] Added type-checking for Array::insert

Lunderberg commented on code in PR #12691:
URL: https://github.com/apache/tvm/pull/12691#discussion_r979046683


##########
src/te/schedule/schedule_lang.cc:
##########
@@ -200,7 +200,7 @@ Stage& Stage::env_threads(Array<IterVar> threads) {
   ICHECK_EQ(self->env_threads.size(), 0U) << "Already set env_threads";
   Array<IterVar>& leaf_vars = self->leaf_iter_vars;
   Array<IterVar>& all_vars = self->all_iter_vars;
-  std::vector<ObjectRef> temp;
+  std::vector<IterVar> temp;

Review Comment:
   This was actually the exact type of error that I wanted to catch with the `static_assert` statements.  This was a `std::vector<ObjectRef>` which was copied into an `Array<IterVar>`, with no type-checking during the conversion.  It didn't cause any runtime issues, because the `std::vector` was originally populated with `ObjectRef` instances that contain `IterVarNode`, but there were no compile-time checks to ensure that was the case.  Had it been otherwise, the later use of `ObjectRef::DowncastNoCheck<IterVar>` would have invoked undefined behavior.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org