321{
322 auto res = make_unique<SubnetStructImpl>();
323
324 auto mname = res->model();
325 auto cname = res->compilation();
326
327 res->def()->append("ANeuralNetworksModel *", mname, ";");
328 res->def()->append("ANeuralNetworksCompilation *", cname, ";");
329
330 res->ctor()->append("ANeuralNetworksModel_create(&", mname, ");");
331 res->dtor()->append("ANeuralNetworksModel_free(", mname, ");");
332
334
335 if (
auto scalar =
dynamic_cast<const ann::ScalarOperand *
>(
info))
336 {
337 res->ctor() << ScalarOperandDecl{mname, scalar->dtype()};
338 }
340 {
341 res->ctor() << TensorOperandDecl{mname,
tensor->dtype(),
tensor->shape()};
342 }
343 else
344 {
345 throw std::runtime_error{"Unsupported"};
346 }
347
348 if (_weighted.find(
info) != _weighted.end())
349 {
350 const auto &base_exp = _base_exprs.at(info);
351 const auto &size_exp = _size_exprs.at(info);
352
353 res->ctor() << WeightDecl{mname, id, base_exp, size_exp};
354 }
355 });
356
358 {
360 res->ctor() << OperationDecl{mname, op};
361 }
362
363
364 res->ctor() << ArgumentDecl{mname, binder};
365
366
367 res->ctor()->append("ANeuralNetworksModel_finish(", mname, ");");
368
369
370 res->ctor()->append("ANeuralNetworksCompilation_create(", mname, ", &", cname, ");");
371 res->dtor()->append("ANeuralNetworksCompilation_free(", cname, ");");
372
373
374 res->ctor()->append("ANeuralNetworksCompilation_finish(", cname, ");");
375
376 return res;
377}
const ann::Module * module(void) const
OperationInventory * operation(void)
OperandInventory * operand(void)
void each(Callable &&cb) const
const Operation * at(uint32_t n) const
uint32_t count(void) const
volatile const char info[]
Plain (non-qunatized) Tensor Operand.