I synced with @goldsborough and here is the answer on thread safety:
net->forward()
is just an interface, and user could put whatever they want into that method. So technically, there’s no guarantee that it is thread safe, unless we know for sure that it doesn’t mutate any field of the net
in place.
i.e. if net
contains a weight_
tensor, and one thread does mul_()
and another reads from it at the same time, there’s a race. We could make the access to this mul_()
call thread-safe by having a lock, but it’s something that user has to add on their own.