};
/*
- * (Partial) List of runtime's operations
- */
-typedef enum {
- NNFW_OP_AddNode,
- NNFW_OP_SubNode,
- NNFW_OP_Conv2DNode,
- NNFW_OP_DepthwiseConv2DNode,
- NNFW_OP_AvgPool2DNode,
- NNFW_OP_MaxPool2DNode,
- NNFW_OP_ConcatNode,
- NNFW_OP_FullyConnectedNode,
- NNFW_OP_ReshapeNode,
- NNFW_OP_MulNode,
- NNFW_OP_SoftmaxNode,
- NNFW_OP_TanhNode,
- NNFW_OP_DivNode,
- NNFW_OP_TransposeNode,
- NNFW_OP_RSQRTNode,
- NNFW_OP_ReLUNode,
- NNFW_OP_ReLU6Node,
- NNFW_OP_TransposeConvNode,
- NNFW_OP_SQRTNode,
- NNFW_OP_SquaredDifferenceNode,
- NNFW_OP_MeanNode,
- NNFW_OP_CustomNode,
-} NNFW_OP;
-
-/*
- * List of available backends
- */
-typedef enum {
- NNFW_BACKEND_ACL_CL, // ARM Compute Library's OpenCL backend
- NNFW_BACKEND_ACL_NEON, // ARM Compute Library's NEON backend
- NNFW_BACKEND_CPU, // cpu backend
- NNFW_BACKEND_SRCN, // Samsung SRC-N's backend
-} NNFW_BACKEND;
-
-/*
* Create a new session instance
*
* @param[out] session the session to be created
* @param[in] session session to which a default backend is set
* @param[in] backend default backend
*/
-NNFW_STATUS nnfw_set_default_backend(nnfw_session *session, NNFW_BACKEND backend);
+NNFW_STATUS nnfw_set_default_backend(nnfw_session *session, const char *backend);
/*
* Set the operation's backend
*
* @return NNFW_STATUS_NO_ERROR if successful
*/
-NNFW_STATUS nnfw_set_op_backend(nnfw_session *session, NNFW_OP op, NNFW_BACKEND backend);
+NNFW_STATUS nnfw_set_op_backend(nnfw_session *session, const char *op, const char *backend);
#ifdef __cplusplus
}
* @param[in] session session to which a default backend is set
* @param[in] backend default backend
*/
-NNFW_STATUS nnfw_set_default_backend(nnfw_session *session, NNFW_BACKEND backend)
+NNFW_STATUS nnfw_set_default_backend(nnfw_session *session, const char *backend)
{
return session->set_default_backend(backend);
}
*
* @return NNFW_STATUS_NO_ERROR if successful
*/
-NNFW_STATUS nnfw_set_op_backend(nnfw_session *session, NNFW_OP op, NNFW_BACKEND backend)
+NNFW_STATUS nnfw_set_op_backend(nnfw_session *session, const char *op, const char *backend)
{
return session->set_op_backend(op, backend);
}
return NNFW_STATUS_NO_ERROR;
}
-static std::string get_backend_string(NNFW_BACKEND backend)
-{
- static std::unordered_map<NNFW_BACKEND, std::string> backend_map = {
- {NNFW_BACKEND_ACL_CL, "acl_cl"},
- {NNFW_BACKEND_ACL_NEON, "acl_neon"},
- {NNFW_BACKEND_CPU, "cpu"},
- {NNFW_BACKEND_SRCN, "srcn"},
- };
-
- auto b = backend_map.find(backend);
-
- if (b == backend_map.end())
- {
- // this return value is handled by a caller to return error code
- return std::string("");
- }
- else
- {
- return b->second;
- }
-}
-
-static std::string get_op_backend_string(NNFW_OP op)
+static std::string get_op_backend_string(std::string op)
{
// TODO: Provide complete set of operations
- static std::unordered_map<NNFW_OP, std::string> operation_map = {
- {NNFW_OP_TransposeConvNode, "OP_BACKEND_TransposeConvNode"},
- {NNFW_OP_Conv2DNode, "OP_BACKEND_Conv2DNode"},
- {NNFW_OP_DepthwiseConv2DNode, "OP_BACKEND_DepthwiseConv2DNode"},
- {NNFW_OP_MeanNode, "OP_BACKEND_MeanNode"},
- {NNFW_OP_AvgPool2DNode, "OP_BACKEND_AvgPool2DNode"},
- {NNFW_OP_MaxPool2DNode, "OP_BACKEND_MaxPool2DNode"},
+ static std::unordered_map<std::string, std::string> operation_map = {
+ {"TRANSPOSE_CONV", "OP_BACKEND_TransposeConvNode"},
+ {"CONV_2D", "OP_BACKEND_Conv2DNode"},
+ {"DEPTHWISE_CONV_2D", "OP_BACKEND_DepthwiseConv2DNode"},
+ {"MEAN", "OP_BACKEND_MeanNode"},
+ {"AVERAGE_POOL_2D", "OP_BACKEND_AvgPool2DNode"},
+ {"MAX_POOL_2D", "OP_BACKEND_MaxPool2DNode"},
};
auto n = operation_map.find(op);
}
}
-NNFW_STATUS nnfw_session::set_default_backend(NNFW_BACKEND backend)
+NNFW_STATUS nnfw_session::set_default_backend(std::string backend)
{
try
{
- std::string bs = get_backend_string(backend);
- if (bs.empty())
- {
- return NNFW_STATUS_ERROR;
- }
- else
- {
- _source->set("OP_BACKEND_ALLOPS", bs);
- }
+ _source->set("OP_BACKEND_ALLOPS", backend);
}
catch (...)
{
return NNFW_STATUS_NO_ERROR;
}
-NNFW_STATUS nnfw_session::set_op_backend(NNFW_OP op, NNFW_BACKEND backend)
+NNFW_STATUS nnfw_session::set_op_backend(std::string op, std::string backend)
{
try
{
- std::string key, value;
- value = get_backend_string(backend);
- key = get_op_backend_string(op);
+ auto key = get_op_backend_string(op);
- if (key.empty() || value.empty())
+ if (key.empty())
{
return NNFW_STATUS_ERROR;
}
- _source->set(key, value);
+ _source->set(key, backend);
}
catch (...)
{