{
using namespace neurun::model;
- _map[ANEURALNETWORKS_DEPTHWISE_CONV_2D] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_DEPTHWISE_CONV_2D] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert((init_param.input_count == 8 || init_param.input_count == 11) &&
init_param.output_count == 1);
return new operation::DepthwiseConv2DNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_MAX_POOL_2D] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_MAX_POOL_2D] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 7 || init_param.input_count == 10);
assert(init_param.output_count == 1);
return new operation::MaxPool2DNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_AVERAGE_POOL_2D] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_AVERAGE_POOL_2D] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
// TODO We may reuse code here for MAX_POOL_2D. Seems like these two are identical
assert(init_param.input_count == 7 || init_param.input_count == 10);
assert(init_param.output_count == 1);
return new operation::AvgPool2DNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_CONCATENATION] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_CONCATENATION] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count >= 2); // At least one one input tensor and axis
assert(init_param.output_count == 1);
return new operation::ConcatNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_RESHAPE] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_RESHAPE] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
// Each input should be interpreted as follows:
return new operation::ReshapeNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_FULLY_CONNECTED] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_FULLY_CONNECTED] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 4 && init_param.output_count == 1);
// Each input should be interpreted as follows:
return new operation::FullyConnectedNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_SOFTMAX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_SOFTMAX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
// Each input should be interpreted as follows:
return new operation::SoftmaxNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_CAST_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_CAST_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::CastNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_CONV_2D] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_CONV_2D] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
using neurun::model::operation::Conv2DNode;
// inputCount is either 7 or 10 acccording to NN API specification.
return new Conv2DNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_ADD] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_ADD] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 3);
assert(init_param.output_count == 1);
return new operation::AddNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_REDUCE_SUM_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_REDUCE_SUM_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2);
assert(init_param.output_count == 1);
return new operation::ReduceSumNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_SUB] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_SUB] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 3);
assert(init_param.output_count == 1);
return new operation::SubNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_STRIDED_SLICE] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_STRIDED_SLICE] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 7 && init_param.output_count == 1);
operand::IndexSet inputs{init_param.inputs[0]};
return new operation::StridedSliceNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_TRANSPOSE] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_TRANSPOSE] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
// TODO make this work with init_param.input_count == 1 (when permutation vector is optional)
// Inputs
return new operation::TransposeNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_MUL] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_MUL] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 3 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::MulNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_SQUEEZE] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_SQUEEZE] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 || init_param.input_count == 2);
assert(init_param.output_count == 1);
return new operation::SqueezeNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_TANH] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_TANH] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::TanhNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_LOGISTIC] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_LOGISTIC] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::LogisticNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_DIV] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_DIV] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 3 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::DivNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_EXP_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_EXP_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ExpNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_REDUCE_MAX_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_REDUCE_MAX_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ReduceMaxNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_NOT_EQUAL_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_NOT_EQUAL_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ComparisonNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_LOGICAL_AND_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_LOGICAL_AND_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::LogicalAndNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_RSQRT_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_RSQRT_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::RSQRTNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_RELU] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_RELU] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ReLUNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_RESIZE_BILINEAR] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_RESIZE_BILINEAR] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 3 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ResizeBilinearNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_RELU1] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_RELU1] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ReLU1Node{inputs, outputs};
};
- _map[ANEURALNETWORKS_RELU6] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_RELU6] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ReLU6Node{inputs, outputs};
};
- _map[ANEURALNETWORKS_FLOOR] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_FLOOR] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::FloorNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_SPACE_TO_DEPTH] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_SPACE_TO_DEPTH] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::SpaceToDepthNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_L2_POOL_2D] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_L2_POOL_2D] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 10 || init_param.input_count == 7);
assert(init_param.output_count == 1);
return new operation::L2Pool2DNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_EMBEDDING_LOOKUP] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_EMBEDDING_LOOKUP] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::EmbeddingLookupNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_L2_NORMALIZATION] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_L2_NORMALIZATION] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::L2NormalizationNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_HASHTABLE_LOOKUP] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_HASHTABLE_LOOKUP] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 3 && init_param.output_count == 2);
// Each output should be interpreted as follows:
return new operation::HashtableLookupNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_PRELU_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_PRELU_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::PReLUNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_TRANSPOSE_CONV_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_TRANSPOSE_CONV_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 6 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::TransposeConvNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_SQRT_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_SQRT_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::SQRTNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_LOGICAL_OR_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_LOGICAL_OR_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::LogicalOrNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_LOGICAL_NOT_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_LOGICAL_NOT_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::LogicalNotNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_EQUAL_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_EQUAL_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ComparisonNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_SQUARED_DIFFERENCE_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_SQUARED_DIFFERENCE_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::SquaredDifferenceNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_TOPK_V2_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_TOPK_V2_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 2);
// Each output should be interpreted as follows:
return new operation::TopKV2Node{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_GATHER_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_GATHER_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 3 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::GatherNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_NEG_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_NEG_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::NegNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_ABS_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_ABS_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::AbsNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_ARGMAX_EX] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_ARGMAX_EX] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 2 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::ArgMaxNode{inputs, outputs, param};
};
- _map[ANEURALNETWORKS_DEQUANTIZE] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_DEQUANTIZE] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 1 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
return new operation::DequantizeNode{inputs, outputs};
};
- _map[ANEURALNETWORKS_MEAN] = [](const OperationFactory::Param &init_param) {
+ _map[ANEURALNETWORKS_MEAN] = [](const OperationFactory::Param &init_param,
+ neurun::model::operand::Set &) {
assert(init_param.input_count == 3 && init_param.output_count == 1);
operand::IndexSet outputs{init_param.outputs[0]};
}
neurun::model::operation::Node *OperationFactory::create(ANeuralNetworksOperationType type,
- const OperationFactory::Param ¶m)
+ const OperationFactory::Param ¶m,
+ neurun::model::operand::Set &operands)
{
- return _map.at(type)(param);
+ return _map.at(type)(param, operands);
}