1 #include "conv_op_shared.h" 2 #include "caffe2/core/context.h" 3 #include "caffe2/core/flags.h" 4 #include "caffe2/core/workspace.h" 7 caffe2_force_shared_col_buffer,
9 "Always use the shared col buffer");
14 void createSharedBuffer<CPUContext>(Workspace* ws) {
15 auto* mutexPtr = ws->CreateBlob(
"__CAFFE2_SHARED_CONV_BUFFER_CPU_MUTEX__")
16 ->GetMutable<std::unique_ptr<std::mutex>>();
17 mutexPtr->reset(
new std::mutex());
18 ws->CreateBlob(
"__CAFFE2_SHARED_CONV_BUFFER_CPU__");
22 void runWithSharedBuffer<CPUContext>(
24 std::function<void(Tensor* buffer)> f) {
25 auto* mutexBlob = ws->GetBlob(
"__CAFFE2_SHARED_CONV_BUFFER_CPU_MUTEX__");
26 CAFFE_ENFORCE(mutexBlob,
"Must call createSharedBuffer() first");
28 auto* mutexPtr = mutexBlob->GetMutable<std::unique_ptr<std::mutex>>();
29 std::lock_guard<std::mutex> g(**mutexPtr);
30 auto* buffer = BlobGetMutableTensor(
31 ws->GetBlob(
"__CAFFE2_SHARED_CONV_BUFFER_CPU__"), CPU);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...