// activation: none (constant)
std::unique_ptr<neurun::model::Model> model = nnfw::cpp14::make_unique<neurun::model::Model>();
+ // Add operands
+
operand::Shape shape{1, 2, 2, 1};
operand::TypeInfo type{DataType::INT32};
operand::Shape shape_scalar(0);
auto operand_lhs = model->operands.append(shape, type);
auto operand_rhs = model->operands.append(shape, type);
- auto input_set = operand::IndexSet{operand_lhs, operand_rhs};
auto operand_activation = model->operands.append(shape_scalar, type_scalar);
model->operands.at(operand_activation).usage(Usage::CONSTANT);
- operation::AddNode::Param param;
- param.activation_index = operand_activation;
- model->operands.at(operand_activation).usage(operand::Usage::CONSTANT);
model->operands.at(operand_activation)
.data(nnfw::cpp14::make_unique<operand::CachedData>(
reinterpret_cast<const uint8_t *>(&_activation_value), 4));
auto operand_result = model->operands.append(shape, type);
- auto output_set = operand::IndexSet{operand_result};
- model->operands.at(operand_result).usage(Usage::OPERATION_OUTPUT);
+ // Add operations
+
+ operation::AddNode::Param param;
+ param.activation_index = operand_activation;
+ auto input_set = operand::IndexSet{operand_lhs, operand_rhs};
+ auto output_set = operand::IndexSet{operand_result};
model->operations.append(
nnfw::cpp14::make_unique<operation::AddNode>(input_set, output_set, param));
+ // Identify model inputs and outputs
+
model->operands.at(operand_lhs).usage(Usage::MODEL_INPUT);
- model->operands.at(operand_rhs).usage(Usage::MODEL_INPUT);
model->inputs.append(operand_lhs);
+ model->operands.at(operand_rhs).usage(Usage::MODEL_INPUT);
model->inputs.append(operand_rhs);
+ model->operands.at(operand_result).usage(Usage::OPERATION_OUTPUT);
model->outputs.append(operand_result);
+
_graph = nnfw::cpp14::make_unique<::neurun::graph::Graph>(std::move(model));
_graph->finishBuilding();