File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -2535,6 +2535,10 @@ class GuardManager {
25352535 return GuardDebugInfo (true , num_guards_executed);
25362536 }
25372537
2538+ bool has_no_accessors () {
2539+ return _accessors.empty ();
2540+ }
2541+
25382542 int64_t fail_count () const {
25392543 return _fail_count;
25402544 }
@@ -3780,8 +3784,12 @@ class DictGetItemGuardAccessor : public GuardAccessor {
37803784 // NB: Intentional duplication between check_nopybind and
37813785 // check_verbose_nopybind.
37823786 bool check_nopybind (PyObject* obj, bool matches_dict_tag = false ) override {
3783- if (matches_dict_tag && _is_immutable_object) {
3787+ if (matches_dict_tag && _is_immutable_object &&
3788+ _guard_manager->has_no_accessors ()) {
37843789 // immutable object and dict tag matches, we can skip the guard subtree.
3790+ // NB: We only skip the subtree if there are no accessors in the subtree.
3791+ // This is specificallly for tensors which are used in symbolic shape C++
3792+ // guards, and therefore have accessors on the tensor GuardManager itself.
37853793 return true ;
37863794 }
37873795
You can’t perform that action at this time.
0 commit comments