@@ -445,6 +445,12 @@ static DispatchKeySet keysForEnteringDynamicLayer(DispatchKey key) {
445
445
}
446
446
}
447
447
448
+ static void dump_local_tls () {
449
+ auto tls = c10::impl::tls_local_dispatch_key_set ();
450
+ std::cout << " [Local Include] " << tls.included_ << std::endl;
451
+ std::cout << " [Local Exclude] " << tls.excluded_ << std::endl;
452
+ }
453
+
448
454
static DispatchKeySet keysToExcludeWhenEnteringDynamicLayer (DispatchKey key) {
449
455
DispatchKeySet exclude = all_dynlayer_keyset;
450
456
exclude = exclude.remove (kDynamicLayerBackModeKey );
@@ -457,6 +463,7 @@ void dynamicLayerFrontFallback(const c10::OperatorHandle& op, torch::jit::Stack*
457
463
#ifdef HAS_TORCH_SHOW_DISPATCH_TRACE
458
464
if (c10::show_dispatch_trace_enabled ()) {
459
465
std::cout << dynamicLayerStack << std::endl;
466
+ dump_local_tls ();
460
467
}
461
468
#endif
462
469
if (dynamicLayerStack.size () == 0 ) {
@@ -498,6 +505,12 @@ void dynamicLayerFrontFallback(const c10::OperatorHandle& op, torch::jit::Stack*
498
505
local_keyset.included_ = local_keyset.included_ | hacky_include;
499
506
ForceLocalDispatchKeySet guard (local_keyset);
500
507
508
+ #ifdef HAS_TORCH_SHOW_DISPATCH_TRACE
509
+ if (c10::show_dispatch_trace_enabled ()) {
510
+ dump_local_tls ();
511
+ }
512
+ #endif
513
+
501
514
// Re-dispatch
502
515
op.callBoxed (stack);
503
516
}
@@ -594,6 +607,12 @@ void dynamicLayerBackFallback(const c10::OperatorHandle& op, torch::jit::Stack*
594
607
c10::impl::_force_tls_local_dispatch_key_set (keyset);
595
608
setDynamicLayerFrontBackKeysIncluded (true );
596
609
610
+ #ifdef HAS_TORCH_SHOW_DISPATCH_TRACE
611
+ if (c10::show_dispatch_trace_enabled ()) {
612
+ dump_local_tls ();
613
+ }
614
+ #endif
615
+
597
616
// Re-dispatch
598
617
if (cur_key == DispatchKey::Autograd && *prev_grad_mode == false ) {
599
618
// See NOTE [grad and vjp interaction with no_grad]
0 commit comments