# Are torch.transform done in parralel?

**URL:** <https://discuss.pytorch.org/t/are-torch-transform-done-in-parralel/197859>\
**Category:** Uncategorized\
**Created:** [February 28, 2024, 9:57am UTC](https://discuss.pytorch.org/t/are-torch-transform-done-in-parralel/197859 "2024-02-28T09:57:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [February 28, 2024, 7:25pm UTC](https://discuss.pytorch.org/t/are-torch-transform-done-in-parralel/197859/2 "2024-02-28T19:25:13Z")

</div>

> [@Agar](#):
>
> (A&B over sample 1) then (A&B over sample 2).

Each sample will be loaded and processed in the `Dataset. __getitem__ `.  
The common approach is to load and transform a single sample so the transformations would be performed sequentially in the main processes given you are using `num_workers=0`.  
`torchvision.transforms` also accept tensors and you could use a [`BatchSampler`](https://discuss.pytorch.org/t/how-to-use-batchsampler-with-getitem-dataset/78788/4) if you want to load and process multiple tensors at once.  
If you use `num_workers>0` each process will process and create its own batch.

> [@Agar](#):
>
> Are samples passed one by one over the entire network, or are they sent in a queue layer by layer ?

Samples are passed as a batch to the model and all layers accept batched inputs thus processing all samples at once.

---

_[View the full topic](https://discuss.pytorch.org/t/are-torch-transform-done-in-parralel/197859)._
