#include "internal/Padding.h"
#include "internal/IInitializerGenerator.h"
#include "internal/IStageGenerator.h"
+#include "util/EnvVar.h"
#include "compilation.h"
#include "model.h"
public:
BackendResolver(::internal::BackendManager &backend_manager)
{
- auto acl_gen = backend_manager.get("arm_compute");
- // auto cpu_gen = backend_manager.get("cpu"); // Unused for now
-
- // TODO Set generator map according to environment variable
- _gen_map[typeid(::internal::tflite::op::Conv2D::implicit::Node)] = acl_gen;
- _gen_map[typeid(::internal::tflite::op::MaxPool2D::implicit::Node)] = acl_gen;
- _gen_map[typeid(::internal::tflite::op::AvgPool2D::implicit::Node)] = acl_gen;
- _gen_map[typeid(::internal::tflite::op::Concat::Node)] = acl_gen;
- _gen_map[typeid(::internal::tflite::op::FullyConnected::Node)] = acl_gen;
- _gen_map[typeid(::internal::tflite::op::Reshape::Node)] = acl_gen;
- _gen_map[typeid(::internal::tflite::op::Softmax::Node)] = acl_gen;
+#define OP(InternalName, NnApiName) \
+ { \
+ const auto &backend_str = \
+ ::nnfw::util::EnvVar{std::string("OP_BACKEND_") + #NnApiName}.asString("arm_compute"); \
+ auto backend = backend_manager.get(backend_str); \
+ _gen_map[typeid(::internal::tflite::op::InternalName::Node)] = backend; \
+ }
+
+#include "internal/op/Op.lst"
+#undef OP
}
std::shared_ptr<::internal::IInitializerGenerator>
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OP
+#error Define OP before including this file
+#endif
+
+// NOTE The relation between "Internal Name" and "NN API Name" is "1 : N".
+
+// Internal Name | NN API Name
+OP(Conv2D::implicit , CONV_2D)
+OP(AvgPool2D::implicit , AVERAGE_POOL_2D)
+OP(MaxPool2D::implicit , MAX_POOL_2D)
+OP(Concat , CONCATENATION)
+OP(FullyConnected , FULLY_CONNECTED)
+OP(Reshape , RESHAPE)
+OP(Softmax , SOFTMAX)