Making Randomizable transform threadsafe by having randomize() return the required random value #6951
-
Hi, For context, I am using CacheDataset with ThreadDataloader. I have a random transform class I noticed that the abstract I thought I could solve this by making the randomize() method return the random value instead of storing it in a class attribute and using it directly. Would this approach make this Randomizable transform threadsafe? Maybe there is some aspect of randomness that I am missing. Also, is there some simple way of making Randomizable methods threadsafe? In the documentation for Transforms, it mentions "When used from a multi-process context, transform’s instance variables are read-only. thread-unsafe transforms should inherit Any comments would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
thanks for looking into this, in some use cases we want to generate the randomised factor once and apply it across different modalities/image-label pairs consistently, the class attributes are used to synchronise these.. |
Beta Was this translation helpful? Give feedback.
Yes, I think that'll be thread-safe.