MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / GetAccessStream

Function GetAccessStream

oneflow/core/framework/instructions_builder.cpp:696–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694
695template<typename T>
696Maybe<Symbol<Stream>> GetAccessStream(const T tensor) {
697 Symbol<Device> device = JUST(GetDevice(tensor));
698 // Do not use producer_stream or last_used_stream.
699 // Bug case when using producer_stream or last_used_stream:
700 //
701 // ```python
702 // tensor = oneflow.ones((1024, 1024, 1024), device='cuda').cpu()
703 // ndarray = tensor.numpy() # share memory
704 //
705 // ```
706 // `ndarray` may not be ones because instruction AccessBlobByCallback is prescheduled before
707 // oneflow.ones actually finished.
708 Symbol<Stream> stream = JUST(GetDefaultStreamByDevice(device));
709 return StreamGuard::TryConvertStream(stream);
710}
711
712} // namespace
713

Callers 2

AccessBlobByCallbackMethod · 0.85
SyncAccessSmallMemFunction · 0.85

Calls 1

GetDeviceFunction · 0.85

Tested by

no test coverage detected