1 #include "caffe2/core/operator.h" 2 #include "caffe2/core/tensor.h" 3 #include "caffe2/core/types.h" 4 #include "caffe2/utils/proto_utils.h" 13 using TensorVector = std::vector<TensorCPU*>;
20 const NetDef& init_net,
21 const NetDef& run_net,
24 : order_(StorageOrder::NHWC),
28 if (!loadNNApiLibrary()) {
29 CAFFE_THROW(
"NNApi is not supported");
31 CAFFE_ENFORCE(ws_.RunNetOnce(init_net));
36 bool loadNNApiLibrary();
38 bool run(
const TensorVector& inputs, TensorVector* outputs);
51 uint32_t operand_idx{0};
52 std::unordered_map<std::string, uint32_t> operand_map_;
54 std::unordered_map<std::string, std::vector<uint32_t>> tensor_dims_;
65 std::unordered_map<std::string, OperatorType> operator_map_{
66 {
"AveragePool", AVERAGEPOOL},
70 {
"Softmax", SOFTMAX}};
83 void getConvPoolArgs(
const ArgumentHelper& helper, ConvPoolArgs& args);
85 uint32_t addScalarOperand(int32_t val);
87 uint32_t addFloatOperand(
float val);
89 uint32_t addTensorOperand(
90 const std::string& blob,
92 std::vector<uint32_t>& dims,
94 int32_t zero_point = 0);
97 void init(
const TensorVector& inputs, TensorVector* outputs);
99 void addConv(
const OperatorDef& op,
bool fuse_relu =
false);
102 const OperatorDef& op,
104 bool fuse_relu =
false);
106 void addRelu(
const OperatorDef& op);
108 void addSoftmax(
const OperatorDef& op);
struct ANeuralNetworksExecution ANeuralNetworksExecution
ANeuralNetworksExecution is an opaque type that can be used to apply a machine learning model to a se...
struct ANeuralNetworksCompilation ANeuralNetworksCompilation
ANeuralNetworksCompilation is an opaque type that can be used to compile a machine learning model...
PreferenceCode
Execution preferences.
A helper class to index into arguments.
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
OperandCode
Operand types.
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
struct ANeuralNetworksModel ANeuralNetworksModel
ANeuralNetworksModel is an opaque type that contains a description of the mathematical operations tha...
struct ANeuralNetworksEvent ANeuralNetworksEvent
ANeuralNetworksEvent is an opaque type that represents an event that will be signaled once an executi...
Prefer maximizing the throughput of successive frames, for example when processing successive frames ...
OperationCode
Operation types.