Caffe2 - C++ API
A deep learning, cross platform ML framework
mpscnn_context.h
1 
2 #pragma once
3 
4 #import <Metal/MTLBuffer.h>
5 #import <Metal/MTLDevice.h>
6 #import <Metal/MTLLibrary.h>
7 
8 #include <array>
9 #include <mutex>
10 #include <string>
11 #include <thread>
12 #include <unordered_map>
13 
14 namespace caffe2 {
15 
16 struct MPSCNNContext {
17  public:
18  id<MTLDevice> device;
19  id<MTLCommandQueue> commandQueue;
20  id<MTLLibrary> library;
21 
22  id<MTLComputePipelineState> getPipelineState(NSString* kernel);
23  id<MTLComputePipelineState> getSpecializedPipelineState(NSString* kernel,
24  const std::vector<ushort>& constants);
25 
26  private:
27  std::mutex pipelineCacheMutex_;
28  std::unordered_map<std::string, id<MTLComputePipelineState>> pipelineCache_;
29 };
30 
31 // get the singleton instance.
32 MPSCNNContext& getMPSCNNContext();
33 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13