René's URL Explorer Experiment


Title: Streams — PyTorch main documentation

Description: Stream API in PyTorch C++ — c10::Stream for asynchronous execution on devices.

Keywords:

direct link

Domain: docs.pytorch.org


Hey, it has json ld scripts:
    {
       "@context": "https://schema.org",
       "@type": "Article",
       "name": "Streams",
       "headline": "Streams",
       "description": "Stream API in PyTorch C++ \u2014 c10::Stream for asynchronous execution on devices.",
       "url": "/api/c10/streams.html",
       "articleBody": "Streams# c10::Stream is the device-agnostic base stream class. It provides a common interface for working with streams across different backends (CUDA, XPU, etc.). For backend-specific stream APIs, see CUDA Streams and XPU Support. Stream# class Stream# A stream is a software mechanism used to synchronize launched kernels without requiring explicit synchronizations between kernels. The basic model is that every kernel launch is associated with a stream: every kernel on the same stream is implicitly synchronized so that if I launch kernels A and B on the same stream, A is guaranteed to finish before B launches. If I want B to run concurrently with A, I must schedule it on a different stream. The Stream class is a backend agnostic value class representing a stream which I may schedule a kernel on. Every stream is associated with a device, which is recorded in stream, which is used to avoid confusion about which device a stream refers to. Streams are explicitly thread-safe, in the sense that it is OK to pass a Stream from one thread to another, and kernels queued from two different threads will still get serialized appropriately. (Of course, the time when the kernels get queued is undetermined unless you synchronize host side ;) Stream does NOT have a default constructor. Streams are for expert users; if you want to use Streams, we\u2019re going to assume you know how to deal with C++ template error messages if you try to resize() a vector of Streams. Known instances of streams in backends: cudaStream_t (CUDA) hipStream_t (HIP) cl_command_queue (OpenCL) (NB: Caffe2\u2019s existing OpenCL integration does NOT support command queues.) Because this class is device agnostic, it cannot provide backend-specific functionality (e.g., get the cudaStream_t of a CUDA stream.) There are wrapper classes which provide this functionality, e.g., CUDAStream. Public Types enum Unsafe# Values: enumerator UNSAFE# enum Default# Values: enumerator DEFAULT# Public Functions inline explicit Stream(Unsafe, Device device, StreamId id)# Unsafely construct a stream from a Device and a StreamId. In general, only specific implementations of streams for a backend should manufacture Stream directly in this way; other users should use the provided APIs to get a stream. In particular, we don\u2019t require backends to give any guarantees about non-zero StreamIds; they are welcome to allocate in whatever way they like. inline explicit Stream(Default, Device device)# Construct the default stream of a Device. The default stream is NOT the same as the current stream; default stream is a fixed stream that never changes, whereas the current stream may be changed by StreamGuard. inline bool operator==(const Stream \u0026other) const noexcept# inline bool operator!=(const Stream \u0026other) const noexcept# inline Device device() const noexcept# inline DeviceType device_type() const noexcept# inline DeviceIndex device_index() const noexcept# inline StreamId id() const noexcept# void *native_handle() const# template\u003ctypename T\u003einline void wait(const T \u0026event) const# bool query() const# void synchronize() const# bool is_capturing() const# inline uint64_t hash() const noexcept# inline struct StreamData3 pack3() const# Public Static Functions static inline Stream unpack3(StreamId stream_id, DeviceIndex device_index, DeviceType device_type)# Example: #include \u003cc10/core/Stream.h\u003e // Streams are typically obtained from backend-specific APIs auto cuda_stream = c10::cuda::getCurrentCUDAStream(); // c10::Stream provides the common interface c10::Device device = cuda_stream.device(); c10::DeviceType type = cuda_stream.device_type();",
       "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/streams.html"
       },
       "datePublished": "2023-01-01T00:00:00Z",
       "dateModified": "2023-01-01T00:00:00Z"
     }
 

docsearch:languageen
llm:site-typedocumentation
llm:frameworkPyTorch
llm:descriptionStream API in PyTorch C++ — c10::Stream for asynchronous execution on devices.
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/streams.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/streams.html#streams
CUDA Streamshttps://docs.pytorch.org/cppdocs/api/cuda/streams.html
XPU Supporthttps://docs.pytorch.org/cppdocs/api/xpu/index.html
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#stream
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106StreamE
Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#PyTorchclassc10_1_1_stream
Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#PyTorchclassc10_1_1_stream
Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#PyTorchclassc10_1_1_stream
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6UnsafeE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6Unsafe6UNSAFEE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream7DefaultE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream7Default7DEFAULTE
Unsafehttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6UnsafeE
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6StreamE6Unsafe6Device8StreamId
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#PyTorchstructc10_1_1_device
Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#PyTorchclassc10_1_1_stream
Defaulthttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream7DefaultE
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6StreamE7Default6Device
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#PyTorchstructc10_1_1_device
Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106StreamE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106StreameqERK6Stream
Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106StreamE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106StreamneERK6Stream
Devicehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c106DeviceE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream6deviceEv
DeviceTypehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c1010DeviceTypeE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream11device_typeEv
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream12device_indexEv
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream2idEv
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream13native_handleEv
Thttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4I0ENK3c106Stream4waitEvRK1T
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4I0ENK3c106Stream4waitEvRK1T
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream5queryEv
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream11synchronizeEv
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream12is_capturingEv
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream4hashEv
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream5pack3Ev
Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106StreamE
DeviceTypehttps://docs.pytorch.org/cppdocs/api/c10/device.html#_CPPv4N3c1010DeviceTypeE
#https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream7unpack3E8StreamId11DeviceIndex10DeviceType
previous Device Guards https://docs.pytorch.org/cppdocs/api/c10/guards.html
next Core Types https://docs.pytorch.org/cppdocs/api/c10/types.html
PyData Sphinx Themehttps://pydata-sphinx-theme.readthedocs.io/en/stable/index.html
previous Device Guards https://docs.pytorch.org/cppdocs/api/c10/guards.html
next Core Types https://docs.pytorch.org/cppdocs/api/c10/types.html
Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#stream
c10::Streamhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106StreamE
Unsafehttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6UnsafeE
UNSAFEhttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6Unsafe6UNSAFEE
Defaulthttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream7DefaultE
DEFAULThttps://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream7Default7DEFAULTE
Stream()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6StreamE6Unsafe6Device8StreamId
Stream()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream6StreamE7Default6Device
operator==()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106StreameqERK6Stream
operator!=()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106StreamneERK6Stream
device()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream6deviceEv
device_type()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream11device_typeEv
device_index()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream12device_indexEv
id()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream2idEv
native_handle()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream13native_handleEv
wait()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4I0ENK3c106Stream4waitEvRK1T
query()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream5queryEv
synchronize()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream11synchronizeEv
is_capturing()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream12is_capturingEv
hash()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream4hashEv
pack3()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4NK3c106Stream5pack3Ev
unpack3()https://docs.pytorch.org/cppdocs/api/c10/streams.html#_CPPv4N3c106Stream7unpack3E8StreamId11DeviceIndex10DeviceType
Show Source https://docs.pytorch.org/cppdocs/_sources/api/c10/streams.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.