return ANEURALNETWORKS_UNEXPECTED_NULL;
}
+ const ANeuralNetworksOperationType FIRST_OPERATION = ANEURALNETWORKS_ADD;
+ const ANeuralNetworksOperationType LAST_OPERATION = ANEURALNETWORKS_TRANSPOSE;
+ if ((type < FIRST_OPERATION) || (type > LAST_OPERATION))
+ {
+ return ANEURALNETWORKS_BAD_DATA;
+ }
+
if (model->isFinished())
{
return ANEURALNETWORKS_BAD_STATE;
auto node_param =
neurun::graph::operation::Node::InitParam{inputCount, inputs, outputCount, outputs};
- switch (type)
+ try
{
- case ANEURALNETWORKS_CONV_2D:
+ switch (type)
{
- // inputCount is either 7 or 10 acccording to NN API specification.
- // - Padding is implicit when inputCount is 7
- // - Padding is explicit when inputCount is 10
- assert(inputCount == 7 || inputCount == 10);
- assert(outputCount == 1);
-
- if (inputCount == 7)
+ case ANEURALNETWORKS_CONV_2D:
{
- using GraphNode = neurun::graph::operation::Conv2DNode;
-
- graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
+ // inputCount is either 7 or 10 acccording to NN API specification.
+ // - Padding is implicit when inputCount is 7
+ // - Padding is explicit when inputCount is 10
+ assert(inputCount == 7 || inputCount == 10);
+ assert(outputCount == 1);
+
+ if (inputCount == 7)
+ {
+ using GraphNode = neurun::graph::operation::Conv2DNode;
+
+ graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
+ }
+ else
+ {
+ throw std::runtime_error{"Explicit padding in Conv2D is not supported, yet"};
+ }
+
+ break;
}
- else
+ case ANEURALNETWORKS_MAX_POOL_2D:
{
- throw std::runtime_error{"Explicit padding in Conv2D is not supported, yet"};
+ // inputCount is either 7 or 10 acccording to NN API specification.
+ // - Padding is implicit when inputCount is 7
+ // - Padding is explicit when inputCount is 10
+ assert(inputCount == 7 || inputCount == 10);
+ assert(outputCount == 1);
+
+ if (inputCount == 7)
+ {
+ using GraphNode = neurun::graph::operation::MaxPool2DNode;
+
+ graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
+ }
+ else
+ {
+ throw std::runtime_error{"Explicit padding in MaxPool2D is not supported, yet"};
+ }
+
+ break;
}
-
- break;
- }
- case ANEURALNETWORKS_MAX_POOL_2D:
- {
- // inputCount is either 7 or 10 acccording to NN API specification.
- // - Padding is implicit when inputCount is 7
- // - Padding is explicit when inputCount is 10
- assert(inputCount == 7 || inputCount == 10);
- assert(outputCount == 1);
-
- if (inputCount == 7)
+ case ANEURALNETWORKS_AVERAGE_POOL_2D:
{
- using GraphNode = neurun::graph::operation::MaxPool2DNode;
-
- graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
+ // inputCount is either 7 or 10 acccording to NN API specification.
+ // - Padding is implicit when inputCount is 7
+ // - Padding is explicit when inputCount is 10
+ assert(inputCount == 7 || inputCount == 10);
+ assert(outputCount == 1);
+
+ if (inputCount == 7)
+ {
+ using GraphNode = neurun::graph::operation::AvgPool2DNode;
+
+ graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
+ }
+ else
+ {
+ throw std::runtime_error{"Explicit padding in AvgPool2D is not supported, yet"};
+ }
+
+ break;
}
- else
+ case ANEURALNETWORKS_CONCATENATION:
{
- throw std::runtime_error{"Explicit padding in MaxPool2D is not supported, yet"};
- }
+ using GraphNode = neurun::graph::operation::ConcatNode;
- break;
- }
- case ANEURALNETWORKS_AVERAGE_POOL_2D:
- {
- // inputCount is either 7 or 10 acccording to NN API specification.
- // - Padding is implicit when inputCount is 7
- // - Padding is explicit when inputCount is 10
- assert(inputCount == 7 || inputCount == 10);
- assert(outputCount == 1);
+ graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
- if (inputCount == 7)
+ break;
+ }
+ case ANEURALNETWORKS_RESHAPE:
{
- using GraphNode = neurun::graph::operation::AvgPool2DNode;
+ using GraphNode = neurun::graph::operation::ReshapeNode;
graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
+
+ break;
}
- else
+ case ANEURALNETWORKS_FULLY_CONNECTED:
{
- throw std::runtime_error{"Explicit padding in AvgPool2D is not supported, yet"};
- }
-
- break;
- }
- case ANEURALNETWORKS_CONCATENATION:
- {
- using GraphNode = neurun::graph::operation::ConcatNode;
-
- graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
-
- break;
- }
- case ANEURALNETWORKS_RESHAPE:
- {
- using GraphNode = neurun::graph::operation::ReshapeNode;
+ using GraphNode = neurun::graph::operation::FullyConnectedNode;
- graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
-
- break;
- }
- case ANEURALNETWORKS_FULLY_CONNECTED:
- {
- using GraphNode = neurun::graph::operation::FullyConnectedNode;
-
- graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
+ graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
- break;
- }
- case ANEURALNETWORKS_SOFTMAX:
- {
- using GraphNode = neurun::graph::operation::SoftmaxNode;
+ break;
+ }
+ case ANEURALNETWORKS_SOFTMAX:
+ {
+ using GraphNode = neurun::graph::operation::SoftmaxNode;
- graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
+ graph.addOperation(nnfw::cpp14::make_unique<GraphNode>(node_param));
- break;
- }
- default:
- throw std::runtime_error{"Not supported operation"};
- };
+ break;
+ }
+ default:
+ throw std::runtime_error{"Not supported operation"};
+ };
+ }
+ catch (const std::exception &e)
+ {
+ return ANEURALNETWORKS_BAD_STATE;
+ }
return ANEURALNETWORKS_NO_ERROR;
}
return ANEURALNETWORKS_BAD_STATE;
}
+ const ANeuralNetworksOperationTypeEx FIRST_OPERATION = ANEURALNETWORKS_GATHER_EX;
+ const ANeuralNetworksOperationTypeEx LAST_OPERATION = ANEURALNETWORKS_PRELU_EX;
+ if ((type < FIRST_OPERATION) || (type > LAST_OPERATION))
+ {
+ return ANEURALNETWORKS_BAD_DATA;
+ }
+
for (uint32_t i = 0; i < outputCount; i++)
{
const ::neurun::graph::operand::Index ind{outputs[i]};
return ANEURALNETWORKS_BAD_DATA;
}
- switch (type)
+ try
{
- default:
- throw std::runtime_error{"Not supported operation"};
+ switch (type)
+ {
+ default:
+ throw std::runtime_error{"Not supported operation"};
+ }
+ }
+ catch (const std::exception &e)
+ {
+ return ANEURALNETWORKS_BAD_STATE;
}
+
+ return ANEURALNETWORKS_NO_ERROR;
}
int ANeuralNetworksModel_identifyInputsAndOutputs(ANeuralNetworksModel *model, uint32_t inputCount,