René's URL Explorer Experiment


Title: Device Guards — PyTorch main documentation

Description: Device and stream guards in PyTorch C++ — RAII guards for managing current device and stream context.

Keywords:

direct link

Domain: docs.pytorch.org


Hey, it has json ld scripts:
    {
       "@context": "https://schema.org",
       "@type": "Article",
       "name": "Device Guards",
       "headline": "Device Guards",
       "description": "Device and stream guards in PyTorch C++ \u2014 RAII guards for managing current device and stream context.",
       "url": "/api/c10/guards.html",
       "articleBody": "Device Guards# C10 provides device-agnostic RAII guards for managing the current device context. These guards work across all backends (CUDA, XPU, etc.) and automatically restore the previous device when they go out of scope. For backend-specific guards, see CUDA Guards and XPU Support. DeviceGuard# class DeviceGuard# RAII guard that sets a certain default device in its constructor, and changes it back to the device that was originally active upon destruction. The device is always reset to the one that was active at the time of construction of the guard. Even if you set_device after construction, the destructor will still reset the device to the one that was active at construction time. This device guard does NOT have an uninitialized state; it is guaranteed to reset a device on exit. If you are in a situation where you might want to setup a guard (i.e., are looking for the moral equivalent of std::optional\u003cDeviceGuard\u003e), see OptionalDeviceGuard. Public Functions explicit DeviceGuard() = delete# No default constructor; see Note [Omitted default constructor from RAII]. inline explicit DeviceGuard(Device device)# Set the current device to the passed Device. inline explicit DeviceGuard(Device device, const impl::DeviceGuardImplInterface *impl)# This constructor is for testing only. ~DeviceGuard() = default# DeviceGuard(const DeviceGuard\u0026) = delete# Copy is disallowed. DeviceGuard \u0026operator=(const DeviceGuard\u0026) = delete# DeviceGuard(DeviceGuard \u0026\u0026other) = delete# Move is disallowed, as DeviceGuard does not have an uninitialized state, which is required for moves on types with nontrivial destructors. DeviceGuard \u0026operator=(DeviceGuard \u0026\u0026other) = delete# inline void reset_device(at::Device device)# Sets the device to the given one. The specified device must be consistent with the device type originally specified during guard construction. TODO: The consistency check here is inconsistent with StreamGuard\u2019s behavior with set_stream, where a stream on a different device than the original one isn\u2019t an error; we just reset the stream and then switch devices. inline void reset_device(at::Device device, const impl::DeviceGuardImplInterface *impl)# This method is for testing only. inline void set_index(DeviceIndex index)# Sets the device index to the given one. The device type is inferred from the original device type the guard was constructed with. inline Device original_device() const# Returns the device that was set at the time the guard was constructed. inline Device current_device() const# Returns the most recent device that was set using this device guard, either from construction, or via set_device. Example: #include \u003cc10/core/DeviceGuard.h\u003e { c10::DeviceGuard guard(c10::Device(c10::kCUDA, 1)); // All operations here run on CUDA device 1 } // Previous device is restored OptionalDeviceGuard# class OptionalDeviceGuard# A OptionalDeviceGuard is an RAII class that sets a device to some value on initialization, and resets the device to its original value on destruction. Morally, a OptionalDeviceGuard is equivalent to std::optional\u003cDeviceGuard\u003e, but with extra constructors and methods as appropriate. Besides its obvious use (optionally applying a DeviceGuard), OptionalDeviceGuard is often also used for the following idiom: OptionalDeviceGuard g; for (const auto\u0026 t : tensors) { g.set_device(t.device()); do_something_with(t); } This usage is marginally more efficient than constructing a DeviceGuard every iteration of the for loop, as it avoids an unnecessary device reset. Unlike DeviceGuard, a OptionalDeviceGuard may be uninitialized. This occurs when you use the nullary constructor, or pass a nullopt to the constructor. Uninitialized OptionalDeviceGuards do nothing; they do not know what the original device was and they do not reset on destruction. This is why original_device() and current_device() return std::optional\u003cDevice\u003e rather than Device (as they do in DeviceGuard), and also is why we didn\u2019t just provide OptionalDeviceGuard by default and hide DeviceGuard from users. The semantics of an OptionalDeviceGuard are exactly explained by thinking of it as an std::optional\u003cDeviceGuard\u003e. In particular, an initialized OptionalDeviceGuard doesn\u2019t restore device to its value at construction; it restores device to its value at initialization. So if you have the program: setDevice(1); OptionalDeviceGuard g; setDevice(2); g.reset_device(Device(DeviceType::CUDA, 3)); // initializes! On destruction, g will reset device to 2, rather than 1. An uninitialized OptionalDeviceGuard is distinct from a (initialized) DeviceGuard whose original_device_ and current_device_ match, since the DeviceGuard will still reset the device to original_device_. Public Functions explicit OptionalDeviceGuard() = default# Create an uninitialized guard. Set the guard later using reset_device. inline explicit OptionalDeviceGuard(Device device)# Initialize the guard, setting the current device to the passed Device. inline explicit OptionalDeviceGuard(std::optional\u003cDevice\u003e device)# Initialize the guard if a Device is passed; otherwise leave the guard uninitialized. inline explicit OptionalDeviceGuard(Device device, const impl::DeviceGuardImplInterface *impl)# Constructor for testing only. ~OptionalDeviceGuard() = default# OptionalDeviceGuard(const OptionalDeviceGuard\u0026) = delete# Copy is disallowed. OptionalDeviceGuard \u0026operator=(const OptionalDeviceGuard\u0026) = delete# OptionalDeviceGuard(OptionalDeviceGuard \u0026\u0026other) = delete# Move is disallowed See Note [Explicit initialization of optional fields] and // Note [Move construction for RAII guards is tricky] for rationale. OptionalDeviceGuard \u0026operator=(OptionalDeviceGuard \u0026\u0026other) = delete# inline void reset_device(at::Device device)# Sets the device to the given one. The specified device must be consistent with the device type originally specified during guard construction. inline void reset_device(at::Device device, const impl::DeviceGuardImplInterface *impl)# For testing only. inline std::optional\u003cDevice\u003e original_device() const# Returns the device that was set at the time the guard was constructed. inline std::optional\u003cDevice\u003e current_device() const# Returns the most recent device that was set using this device guard, either from construction, or via reset_device. Example: #include \u003cc10/core/DeviceGuard.h\u003e c10::OptionalDeviceGuard guard; if (use_gpu) { guard.reset_device(c10::Device(c10::kCUDA, 0)); } // Guard only restores device if it was set",
       "author": {
         "@type": "Organization",
         "name": "PyTorch Contributors",
         "url": "https://pytorch.org"
       },
       "image": "https://pytorch.org/docs/stable/_static/img/pytorch_seo.png",
       "mainEntityOfPage": {
         "@type": "WebPage",
         "@id": "/api/c10/guards.html"
       },
       "datePublished": "2023-01-01T00:00:00Z",
       "dateModified": "2023-01-01T00:00:00Z"
     }
 

docsearch:languageen
llm:site-typedocumentation
llm:frameworkPyTorch
llm:descriptionDevice and stream guards in PyTorch C++ — RAII guards for managing current device and stream context.
llm:navigation-filehttps://pytorch.org/docs/stable/llms.txt
llm:sitemaphttps://pytorch.org/docs/stable/sitemap.xml
llm:versionmain
llm:projectPyTorch
llm:page-typedocumentation
og:imagehttps://docs.pytorch.org/docs/stable/_static/img/pytorch_seo.png
None3

Links:

Skip to main contenthttps://docs.pytorch.org/cppdocs/api/c10/guards.html#main-content
Home https://docs.pytorch.org/cppdocs/index.html
mainhttps://docs.pytorch.org/cppdocs/index.html
Installing C++ Distributions of PyTorch https://docs.pytorch.org/cppdocs/installing.html
The C++ Frontend https://docs.pytorch.org/cppdocs/frontend.html
C++ API Reference https://docs.pytorch.org/cppdocs/api/index.html
ATen: Tensor Library https://docs.pytorch.org/cppdocs/api/aten/index.html
C10: Core Utilities https://docs.pytorch.org/cppdocs/api/c10/index.html
Autograd: Automatic Differentiation https://docs.pytorch.org/cppdocs/api/autograd/index.html
CUDA Support https://docs.pytorch.org/cppdocs/api/cuda/index.html
XPU Support https://docs.pytorch.org/cppdocs/api/xpu/index.html
Neural Network Modules (torch::nn) https://docs.pytorch.org/cppdocs/api/nn/index.html
Optimizers (torch::optim) https://docs.pytorch.org/cppdocs/api/optim/index.html
Data Loading (torch::data) https://docs.pytorch.org/cppdocs/api/data/index.html
Serialization (torch::serialize) https://docs.pytorch.org/cppdocs/api/serialize/index.html
Torch Library API https://docs.pytorch.org/cppdocs/api/library/index.html
Torch Stable API https://docs.pytorch.org/cppdocs/api/stable/index.html
FAQ https://docs.pytorch.org/cppdocs/faq.html
Go to pytorch.org https://pytorch.org
Xhttps://x.com/PyTorch
GitHubhttps://github.com/pytorch/pytorch
PyTorch Forumhttps://discuss.pytorch.org/
PyPihttps://pypi.org/project/torch/
mainhttps://docs.pytorch.org/cppdocs/index.html
Installing C++ Distributions of PyTorch https://docs.pytorch.org/cppdocs/installing.html
The C++ Frontend https://docs.pytorch.org/cppdocs/frontend.html
C++ API Reference https://docs.pytorch.org/cppdocs/api/index.html
ATen: Tensor Library https://docs.pytorch.org/cppdocs/api/aten/index.html
C10: Core Utilities https://docs.pytorch.org/cppdocs/api/c10/index.html
Autograd: Automatic Differentiation https://docs.pytorch.org/cppdocs/api/autograd/index.html
CUDA Support https://docs.pytorch.org/cppdocs/api/cuda/index.html
XPU Support https://docs.pytorch.org/cppdocs/api/xpu/index.html
Neural Network Modules (torch::nn) https://docs.pytorch.org/cppdocs/api/nn/index.html
Optimizers (torch::optim) https://docs.pytorch.org/cppdocs/api/optim/index.html
Data Loading (torch::data) https://docs.pytorch.org/cppdocs/api/data/index.html
Serialization (torch::serialize) https://docs.pytorch.org/cppdocs/api/serialize/index.html
Torch Library API https://docs.pytorch.org/cppdocs/api/library/index.html
Torch Stable API https://docs.pytorch.org/cppdocs/api/stable/index.html
FAQ https://docs.pytorch.org/cppdocs/faq.html
Go to pytorch.org https://pytorch.org
Xhttps://x.com/PyTorch
GitHubhttps://github.com/pytorch/pytorch
PyTorch Forumhttps://discuss.pytorch.org/
PyPihttps://pypi.org/project/torch/
ATen: Tensor Libraryhttps://docs.pytorch.org/cppdocs/api/aten/index.html
Tensor Classhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html
Tensor Creationhttps://docs.pytorch.org/cppdocs/api/aten/creation.html
Tensor Indexinghttps://docs.pytorch.org/cppdocs/api/aten/indexing.html
Tensor Accessorshttps://docs.pytorch.org/cppdocs/api/aten/accessors.html
C10: Core Utilitieshttps://docs.pytorch.org/cppdocs/api/c10/index.html
Device and DeviceTypehttps://docs.pytorch.org/cppdocs/api/c10/device.html
Device Guardshttps://docs.pytorch.org/cppdocs/api/c10/guards.html
Streamshttps://docs.pytorch.org/cppdocs/api/c10/streams.html
Core Typeshttps://docs.pytorch.org/cppdocs/api/c10/types.html
Utilitieshttps://docs.pytorch.org/cppdocs/api/c10/utilities.html
Autograd: Automatic Differentiationhttps://docs.pytorch.org/cppdocs/api/autograd/index.html
Gradient Computationhttps://docs.pytorch.org/cppdocs/api/autograd/gradient.html
Custom Autograd Functionshttps://docs.pytorch.org/cppdocs/api/autograd/custom_functions.html
Gradient Modeshttps://docs.pytorch.org/cppdocs/api/autograd/modes.html
CUDA Supporthttps://docs.pytorch.org/cppdocs/api/cuda/index.html
CUDA Streamshttps://docs.pytorch.org/cppdocs/api/cuda/streams.html
CUDA Guardshttps://docs.pytorch.org/cppdocs/api/cuda/guards.html
CUDA Utility Functionshttps://docs.pytorch.org/cppdocs/api/cuda/utilities.html
XPU Supporthttps://docs.pytorch.org/cppdocs/api/xpu/index.html
XPU Streamshttps://docs.pytorch.org/cppdocs/api/xpu/streams.html
XPU Utility Functionshttps://docs.pytorch.org/cppdocs/api/xpu/utilities.html
Neural Network Modules (torch::nn)https://docs.pytorch.org/cppdocs/api/nn/index.html
Containershttps://docs.pytorch.org/cppdocs/api/nn/containers.html
Convolution Layershttps://docs.pytorch.org/cppdocs/api/nn/convolution.html
Pooling Layershttps://docs.pytorch.org/cppdocs/api/nn/pooling.html
Linear Layershttps://docs.pytorch.org/cppdocs/api/nn/linear.html
Activation Functionshttps://docs.pytorch.org/cppdocs/api/nn/activation.html
Normalization Layershttps://docs.pytorch.org/cppdocs/api/nn/normalization.html
Dropout Layershttps://docs.pytorch.org/cppdocs/api/nn/dropout.html
Embedding Layershttps://docs.pytorch.org/cppdocs/api/nn/embedding.html
Recurrent Layershttps://docs.pytorch.org/cppdocs/api/nn/recurrent.html
Transformer Layershttps://docs.pytorch.org/cppdocs/api/nn/transformer.html
Loss Functionshttps://docs.pytorch.org/cppdocs/api/nn/loss.html
Functional APIhttps://docs.pytorch.org/cppdocs/api/nn/functional.html
Utilitieshttps://docs.pytorch.org/cppdocs/api/nn/utilities.html
Optimizers (torch::optim)https://docs.pytorch.org/cppdocs/api/optim/index.html
Gradient Descent Optimizershttps://docs.pytorch.org/cppdocs/api/optim/gradient_descent.html
Adaptive Learning Rate Optimizershttps://docs.pytorch.org/cppdocs/api/optim/adaptive.html
Second-Order Optimizershttps://docs.pytorch.org/cppdocs/api/optim/second_order.html
Learning Rate Schedulershttps://docs.pytorch.org/cppdocs/api/optim/schedulers.html
Data Loading (torch::data)https://docs.pytorch.org/cppdocs/api/data/index.html
Datasetshttps://docs.pytorch.org/cppdocs/api/data/datasets.html
DataLoaderhttps://docs.pytorch.org/cppdocs/api/data/dataloader.html
Samplershttps://docs.pytorch.org/cppdocs/api/data/samplers.html
Transformshttps://docs.pytorch.org/cppdocs/api/data/transforms.html
Serialization (torch::serialize)https://docs.pytorch.org/cppdocs/api/serialize/index.html
Saving and Loadinghttps://docs.pytorch.org/cppdocs/api/serialize/save_load.html
Archiveshttps://docs.pytorch.org/cppdocs/api/serialize/archives.html
Checkpointshttps://docs.pytorch.org/cppdocs/api/serialize/checkpoints.html
Torch Library APIhttps://docs.pytorch.org/cppdocs/api/library/index.html
Operator Registrationhttps://docs.pytorch.org/cppdocs/api/library/registration.html
Custom Classeshttps://docs.pytorch.org/cppdocs/api/library/custom_classes.html
Library Versioninghttps://docs.pytorch.org/cppdocs/api/library/versioning.html
Torch Stable APIhttps://docs.pytorch.org/cppdocs/api/stable/index.html
Library Registration Macroshttps://docs.pytorch.org/cppdocs/api/stable/registration.html
Stable Operatorshttps://docs.pytorch.org/cppdocs/api/stable/operators.html
Utilitieshttps://docs.pytorch.org/cppdocs/api/stable/utilities.html
https://docs.pytorch.org/cppdocs/index.html
C++ API Referencehttps://docs.pytorch.org/cppdocs/api/index.html
C10: Core Utilitieshttps://docs.pytorch.org/cppdocs/api/c10/index.html
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#device-guards
CUDA Guardshttps://docs.pytorch.org/cppdocs/api/cuda/guards.html
XPU Supporthttps://docs.pytorch.org/cppdocs/api/xpu/index.html
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#deviceguard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuardE
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardEv
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardE6Device
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#PyTorchstructc10_1_1_device
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
implhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv4N3c1011DeviceGuard11DeviceGuardE6DevicePKN4impl24DeviceGuardImplInterfaceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardE6DevicePKN4impl24DeviceGuardImplInterfaceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuardD0Ev
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv4N3c1011DeviceGuard11DeviceGuardERK11DeviceGuard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardERK11DeviceGuard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv4N3c1011DeviceGuardE
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv4N3c1011DeviceGuardE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuardaSERK11DeviceGuard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv4N3c1011DeviceGuard11DeviceGuardERR11DeviceGuard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardERR11DeviceGuard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_device_guard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv4N3c1011DeviceGuardE
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv4N3c1011DeviceGuardE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuardaSERR11DeviceGuard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard12reset_deviceEN2at6DeviceE
implhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv4N3c1011DeviceGuard12reset_deviceEN2at6DeviceEPKN4impl24DeviceGuardImplInterfaceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard12reset_deviceEN2at6DeviceEPKN4impl24DeviceGuardImplInterfaceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard9set_indexE11DeviceIndex
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4NK3c1011DeviceGuard15original_deviceEv
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4NK3c1011DeviceGuard14current_deviceEv
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#optionaldeviceguard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardE
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_device_guard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_device_guard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_device_guard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
original_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard_1a289b40c082ebedd84b0d857d1c71c652
current_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard_1a415dd885488c757a9412d221c8f15d40
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#PyTorchstructc10_1_1_device
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_device_guard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_device_guard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_optional_device_guard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_device_guard
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#PyTorchclassc10_1_1_device_guard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardEv
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardE6Device
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#PyTorchstructc10_1_1_device
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardENSt8optionalI6DeviceEE
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#PyTorchstructc10_1_1_device
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
implhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardE6DevicePKN4impl24DeviceGuardImplInterfaceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardE6DevicePKN4impl24DeviceGuardImplInterfaceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardD0Ev
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardERK19OptionalDeviceGuard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardERK19OptionalDeviceGuard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardE
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardaSERK19OptionalDeviceGuard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardERR19OptionalDeviceGuard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardERR19OptionalDeviceGuard
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardE
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardaSERR19OptionalDeviceGuard
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard12reset_deviceEN2at6DeviceE
implhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard12reset_deviceEN2at6DeviceEPKN4impl24DeviceGuardImplInterfaceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard12reset_deviceEN2at6DeviceEPKN4impl24DeviceGuardImplInterfaceE
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4NK3c1019OptionalDeviceGuard15original_deviceEv
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4NK3c1019OptionalDeviceGuard14current_deviceEv
previous Device and DeviceType https://docs.pytorch.org/cppdocs/api/c10/device.html
next Streams https://docs.pytorch.org/cppdocs/api/c10/streams.html
PyData Sphinx Themehttps://pydata-sphinx-theme.readthedocs.io/en/stable/index.html
previous Device and DeviceType https://docs.pytorch.org/cppdocs/api/c10/device.html
next Streams https://docs.pytorch.org/cppdocs/api/c10/streams.html
DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#deviceguard
c10::DeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuardE
DeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardEv
DeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardE6Device
DeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardE6DevicePKN4impl24DeviceGuardImplInterfaceE
~DeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuardD0Ev
DeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardERK11DeviceGuard
operator=()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuardaSERK11DeviceGuard
DeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard11DeviceGuardERR11DeviceGuard
operator=()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuardaSERR11DeviceGuard
reset_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard12reset_deviceEN2at6DeviceE
reset_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard12reset_deviceEN2at6DeviceEPKN4impl24DeviceGuardImplInterfaceE
set_index()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1011DeviceGuard9set_indexE11DeviceIndex
original_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4NK3c1011DeviceGuard15original_deviceEv
current_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4NK3c1011DeviceGuard14current_deviceEv
OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#optionaldeviceguard
c10::OptionalDeviceGuardhttps://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardE
OptionalDeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardEv
OptionalDeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardE6Device
OptionalDeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardENSt8optionalI6DeviceEE
OptionalDeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardE6DevicePKN4impl24DeviceGuardImplInterfaceE
~OptionalDeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardD0Ev
OptionalDeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardERK19OptionalDeviceGuard
operator=()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardaSERK19OptionalDeviceGuard
OptionalDeviceGuard()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard19OptionalDeviceGuardERR19OptionalDeviceGuard
operator=()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuardaSERR19OptionalDeviceGuard
reset_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard12reset_deviceEN2at6DeviceE
reset_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4N3c1019OptionalDeviceGuard12reset_deviceEN2at6DeviceEPKN4impl24DeviceGuardImplInterfaceE
original_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4NK3c1019OptionalDeviceGuard15original_deviceEv
current_device()https://docs.pytorch.org/cppdocs/api/c10/guards.html#_CPPv4NK3c1019OptionalDeviceGuard14current_deviceEv
Show Source https://docs.pytorch.org/cppdocs/_sources/api/c10/guards.md.txt
ExecuTorchhttps://docs.pytorch.org/executorch
Helionhttps://docs.pytorch.org/helion
torchaohttps://docs.pytorch.org/ao
kinetohttps://github.com/pytorch/kineto
torchtitanhttps://github.com/pytorch/torchtitan
TorchRLhttps://docs.pytorch.org/rl
torchvisionhttps://docs.pytorch.org/vision
torchaudiohttps://docs.pytorch.org/audio
tensordicthttps://docs.pytorch.org/tensordict
PyTorch on XLA Deviceshttps://docs.pytorch.org/xla
View Docshttps://docs.pytorch.org/docs/stable/index.html
View Tutorialshttps://docs.pytorch.org/tutorials
View Resourceshttps://pytorch.org/resources
Privacy Policyhttps://www.linuxfoundation.org/privacy/
https://www.facebook.com/pytorch
https://twitter.com/pytorch
https://www.youtube.com/pytorch
https://www.linkedin.com/company/pytorch
https://pytorch.slack.com
https://pytorch.org/wechat
Policieshttps://www.linuxfoundation.org/legal/policies
Trademark Usagehttps://www.linuxfoundation.org/trademark-usage
Privacy Policyhttp://www.linuxfoundation.org/privacy
Cookies Policyhttps://opensource.fb.com/legal/cookie-policy
Sphinxhttps://www.sphinx-doc.org/
PyData Sphinx Themehttps://pydata-sphinx-theme.readthedocs.io/en/stable/index.html

Viewport: width=device-width, initial-scale=1


URLs of crawlers that visited me.