/usr/local/lib64/python3.6/site-packages/torch/include/ATen
NameSizeModeActions
core/-0755rm
cpu/-0755rm
cuda/-0755rm
cudnn/-0755rm
detail/-0755rm
hip/-0755rm
native/-0755rm
quantized/-0755rm
AccumulateType.h44380644editdlrm
ArrayRef.h440644editdlrm
ATen.h9980644editdlrm
autocast_mode.h67160644editdlrm
Backend.h430644editdlrm
Backtrace.h460644editdlrm
BatchedFallback.h9650644editdlrm
BatchedTensorImpl.h53830644editdlrm
CompositeExplicitAutogradFunctions.h16220644editdlrm
CompositeExplicitAutogradFunctions_inl.h540750644editdlrm
CompositeImplicitAutogradFunctions.h16220644editdlrm
CompositeImplicitAutogradFunctions_inl.h1420820644editdlrm
Config.h7340644editdlrm
Context.h127670644editdlrm
cpp_custom_type_hack.h53260644editdlrm
CPUApplyUtils.h125820644editdlrm
CPUFixedAllocator.h8300644editdlrm
CPUFunctions.h16000644editdlrm
CPUFunctions_inl.h1719240644editdlrm
CPUGeneratorImpl.h14310644editdlrm
CUDAFunctions.h16010644editdlrm
CUDAFunctions_inl.h1856960644editdlrm
CUDAGeneratorImpl.h46950644editdlrm
Device.h420644editdlrm
DeviceGuard.h11340644editdlrm
Dimname.h310644editdlrm
DimVector.h460644editdlrm
Dispatch.h521370644editdlrm
div_rtn.h2040644editdlrm
DLConvertor.h5760644editdlrm
dlpack.h52440644editdlrm
DynamicLibrary.h3690644editdlrm
ExpandUtils.h145060644editdlrm
Formatting.h340644editdlrm
Functions.h8463260644editdlrm
Generator.h460644editdlrm
InferSize.h21430644editdlrm
InitialTensorOptions.h4450644editdlrm
Layout.h420644editdlrm
MapAllocator.h29990644editdlrm
MatrixRef.h30160644editdlrm
MemoryOverlap.h11170644editdlrm
MetaFunctions.h16010644editdlrm
MetaFunctions_inl.h840060644editdlrm
NamedTensor.h350644editdlrm
NamedTensorUtils.h57470644editdlrm
NativeFunctions.h3546510644editdlrm
NativeMetaFunctions.h354450644editdlrm
NumericUtils.h27870644editdlrm
OpaqueTensorImpl.h60800644editdlrm
Operators.h17071990644editdlrm
OpMathType.h4600644editdlrm
Parallel.h48750644editdlrm
ParallelNative.h24430644editdlrm
ParallelNativeTBB.h29340644editdlrm
ParallelOpenMP.h30490644editdlrm
PTThreadPool.h3940644editdlrm
record_function.h240440644editdlrm
RedispatchFunctions.h11128860644editdlrm
RegistrationDeclarations.h5457770644editdlrm
SavedTensorHooks.h3280644editdlrm
Scalar.h440644editdlrm
ScalarOps.h22720644editdlrm
ScalarType.h1290644editdlrm
SequenceNumber.h3730644editdlrm
SmallVector.h470644editdlrm
SparseCsrTensorImpl.h20450644editdlrm
SparseCsrTensorUtils.h5230644editdlrm
SparseTensorImpl.h124170644editdlrm
SparseTensorUtils.h42190644editdlrm
Storage.h430644editdlrm
Tensor.h480644editdlrm
TensorAccessor.h510644editdlrm
TensorGeometry.h18550644editdlrm
TensorIndexing.h219230644editdlrm
TensorIterator.h299620644editdlrm
TensorIteratorInternal.h18620644editdlrm
TensorMeta.h29170644editdlrm
TensorNames.h25190644editdlrm
TensorOperators.h32750644editdlrm
TensorOptions.h490644editdlrm
TensorUtils.h56870644editdlrm
ThreadLocalState.h32890644editdlrm
TracerMode.h55760644editdlrm
TypeDefault.h6800644editdlrm
Utils.h59930644editdlrm
Version.h3400644editdlrm
VmapMode.h9520644editdlrm
VmapTransforms.h76540644editdlrm
WrapDimUtils.h34380644editdlrm
WrapDimUtilsMulti.h7680644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/ATen/TracerMode.h (5576B)
#pragma once #include #include #include // NOTE [Tracing Mode Switches] // // Historically, tracing function was controlled by two switches: // // - `AutoDispatchBelowADInplaceOrView` guard // // Tracing function used to be script-generated inside `VariableType_*.cpp` // kernels, sharing the same `Autograd` dispatch key with autograd function. // Therefore, before tracing function was moved out of VariableType, // `AutoDispatchBelowADInplaceOrView` guard can also disable tracing as a side effect // of disabling `Autograd` dispatching. // // - `setTracingState()` API in `torch/csrc/jit/frontend/tracer.h` // // It stores tracing data in a `TracingState` object in TLS. If the // `TracingState` object in TLS is `null`, then tracing is paused. // // The `TracingState` object is created in `tracer::trace()` - the main // entrance of tracing function. It's temporarily set to `null` inside // generated VariableType (now TraceType) to bypass tracing for intermediate // ops (ops being called by other ops). After the intermediate op call // finishes it's set back to the original `TracingState` object. // // The `TracingState` obect in TLS can also be read/written via its Python // binding in `python_tracer.cpp`, and `get/setTracingState()` C++ APIs, // which are also exposed as `TORCH_API`. // // Two new switches were introduced since tracing function was moved out of // VariableType: // // - `tracer::impl::set_dispatch_enabled()` API // // Unlike the special `Autograd` dispatch key which is included in dispatch // key set by default, `Tracer` dispatch key is off by default. The // dispatching switch can be toggled via this new API. // // - `tracer::impl::NoTracerDispatchMode` guard // // It's used to cover the old semantics of `AutoDispatchBelowADInplaceOrView` after // tracing was moved out of VariableType. // // Before tracing function was moved out of VariableType, tracing was enabled // when the following conditions are satisfied: // // 1) `TracingState` object in TLS != null; // - Either inside the execution scope of `tracer::trace()`, or // - Eagerly called `setTracingState()` with non-null object. // 2) Not inside `AutoDispatchBelowADInplaceOrView` scope; // // After: // // 1) `TracingState` object in TLS != null; // 2) Has called `tracer::impl::set_dispatch_enabled(true)`; // 3) Not inside `tracer::impl::NonDispatchGuard` scope; // // [TODOs] // // - `setTracingState()` v.s. `tracer::impl::set_dispatch_enabled()` // // Currently `set_dispatch_enabled()` is set/unset inside `setTracingState()` // to keep the semantics exactly the same as before - it's confusing to keep // both switches, though. We should consider simplifying/limiting the exposed // `setTracingState()` Python/C++ APIs (and other APIs calling it) so that // these two can be unified. // // - `AutoDispatchBelowADInplaceOrView` v.s. `tracer::impl::NoTracerDispatchMode` // // We don't need to always set both guards together to keep semantics // unchanged. For the follow use cases of `AutoDispatchBelowADInplaceOrView` we don't // need set the new tracer guard: // // * Script-generated VariableType kernels. The guard is not necessary as // tracing is already disabled explicitly by `setTracingState(null)` in // generated TraceType kernels - we could keep it as is or use the new guard // instead. // // * Custom ops. Will be handled by fallback kernel for `Tracer`. // // * Functions that are not likely to be called in tracing context (no python // binding / not an operator), e.g.: all mobile forward() wrappers, test // binaries, and etc. // // * Where new threads are spawned, e.g.: ATen/native/ConvolutionMM2d.cpp. // It's not necessary as tracing is off by default. // // For the rest of cases we might need have both: // // * Functions that might be reachable from eager mode python (especially // factory methods), e.g.: // `internal_new_from_data()` in `torch/csrc/utils/tensor_new.cpp`. // Without the new guard it will add `aten::empty` to the traced graph. // // * Some manually maintained functions, e.g.: // `torch/csrc/autograd/VariableTypeManual.cpp`. // Set the new guard if it's not obvious whether `setTracingState(null)` // has been called before it reaches the `AutoDispatchBelowADInplaceOrView` guard. // // We might need tweak the usage of the new guard to optimize/fix things. // It should only affect the correctness of tracing function, because the // guard is essentially no-op when the master `setTracingState()` switch is // off. namespace at { // TODO: move this from `at::` to `jit::torch::` after // `aten/src/ATen/cpp_custom_type_hack.h` is removed. namespace tracer { namespace impl { static inline bool is_dispatch_enabled() { return c10::impl::tls_is_dispatch_key_included(at::DispatchKey::Tracer) && !c10::impl::tls_is_dispatch_key_excluded(at::DispatchKey::Tracer); } static inline void set_dispatch_enabled(bool enabled) { TORCH_INTERNAL_ASSERT( !c10::impl::tls_is_dispatch_key_excluded(at::DispatchKey::Tracer), "Cannot enable tracing within the scope of NoTracerDispatchMode!"); c10::impl::tls_set_dispatch_key_included(at::DispatchKey::Tracer, enabled); } struct NoTracerDispatchMode { c10::impl::ExcludeDispatchKeyGuard guard_{at::DispatchKey::Tracer}; }; } // namespace impl } // namespace tracer } // namespace at