//
// ANeuralNetworksModel
//
-ANeuralNetworksModel::ANeuralNetworksModel() : _model{new neurun::graph::Graph}
+ANeuralNetworksModel::ANeuralNetworksModel()
+ : _model{new neurun::graph::Graph}, _optional_operands{}
{
// DO NOTHING
}
return ANEURALNETWORKS_BAD_STATE;
}
+ fillOptionalOperand();
+
_model->finishBuilding();
return ANEURALNETWORKS_NO_ERROR;
}
+
+void ANeuralNetworksModel::fillOptionalOperand(void)
+{
+ _model->operations().iterate(
+ [&](const ::neurun::graph::operation::Index &, ::neurun::graph::operation::Node &node) {
+ for (auto input : node.getInputs())
+ {
+ // TODO fill default value for optional operands
+ if (_optional_operands.find(input) != _optional_operands.end())
+ {
+ throw std::runtime_error{"Optional operand is not supported yet"};
+ }
+ }
+ });
+}
neurun::graph::Graph &deref(void) { return *_model; }
ResultCode finish();
bool isFinished() { return !_model->isBuildingPhase(); }
-
-public:
void release(std::shared_ptr<neurun::graph::Graph> &model) { model = _model; }
+ void setOptionalOperand(const neurun::graph::operand::Index idx)
+ {
+ _optional_operands.insert(idx);
+ }
+
+private:
+ void fillOptionalOperand(void);
private:
std::shared_ptr<neurun::graph::Graph> _model;
+ std::unordered_set<neurun::graph::operand::Index> _optional_operands;
};
#endif // __MODEL_H__