{"TRANSPOSE_CONV", "OP_BACKEND_TransposeConv"}, {"CONV_2D", "OP_BACKEND_Conv2D"},
{"DEPTHWISE_CONV_2D", "OP_BACKEND_DepthwiseConv2D"}, {"MEAN", "OP_BACKEND_Mean"},
{"AVERAGE_POOL_2D", "OP_BACKEND_AvgPool2D"}, {"MAX_POOL_2D", "OP_BACKEND_MaxPool2D"},
- };
+ {"INSTANCE_NORM", "OP_BACKEND_InstanceNorm"}, {"ADD", "OP_BACKEND_Add"}};
auto n = operation_map.find(op);
#include <cstdlib>
#include <iostream>
#include <stdexcept>
+#include <unordered_map>
#define NNPR_ENSURE_STATUS(a) \
do \
static const char *h5_value_grpname = "value";
+NNFW_STATUS resolve_op_backend(nnfw_session *session)
+{
+ static std::unordered_map<std::string, std::string> operation_map = {
+ {"TRANSPOSE_CONV", "OP_BACKEND_TransposeConv"}, {"CONV_2D", "OP_BACKEND_Conv2D"},
+ {"DEPTHWISE_CONV_2D", "OP_BACKEND_DepthwiseConv2D"}, {"MEAN", "OP_BACKEND_Mean"},
+ {"AVERAGE_POOL_2D", "OP_BACKEND_AvgPool2D"}, {"MAX_POOL_2D", "OP_BACKEND_MaxPool2D"},
+ {"INSTANCE_NORM", "OP_BACKEND_InstanceNorm"}, {"ADD", "OP_BACKEND_Add"}};
+
+ for (auto i : operation_map)
+ {
+ char *default_backend = std::getenv(i.second.c_str());
+ if (default_backend)
+ {
+ NNFW_STATUS return_result = nnfw_set_op_backend(session, i.first.c_str(), default_backend);
+ if (return_result == NNFW_STATUS_ERROR)
+ return return_result;
+ }
+ }
+
+ return NNFW_STATUS_NO_ERROR;
+}
+
int main(const int argc, char **argv)
{
NNPackageRun::Args args(argc, argv);
char *default_backend = std::getenv("OP_BACKEND_ALLOPS");
if (default_backend)
NNPR_ENSURE_STATUS(nnfw_set_default_backend(session, default_backend));
+ NNPR_ENSURE_STATUS(resolve_op_backend(session));
+
NNPR_ENSURE_STATUS(nnfw_load_model_from_file(session, nnpackage_path.c_str()));
uint32_t num_inputs;