#include "CppGen/Global.h"
+#include "Dims.h"
+
#include <pp/LinearDocument.h>
#include <pp/MultiLineTextUtils.h>
{
net_def.append("struct ", name, " {");
net_def.indent();
+ net_def.append("struct Shape { uint32_t rank; const uint32_t *dims; };");
net_def.append("struct Input {");
net_def.indent();
net_def.append("const char *name;");
net_def.append("const uint8_t *ptr;");
net_def.append("unsigned len;");
+ net_def.append("Shape shape;");
net_def.unindent();
net_def.append("};");
net_def.append("struct Output {");
net_def.append("const char *name;");
net_def.append("uint8_t *ptr;");
net_def.append("unsigned len;");
+ net_def.append("Shape shape;");
net_def.unindent();
net_def.append("};");
net_def.append();
for (uint32_t n = 0; n < m->input()->size(); ++n)
{
auto input = m->input()->at(n);
+ auto dims = as_dims(input->shape());
auto name_var = global.constant(input->name());
+ auto dims_var = global.constant<uint32_t>(dims);
net_ctor.append("inputs.at(", n, ").name = ", name_var, ";");
+ net_ctor.append("inputs.at(", n, ").shape.rank = ", dims.size(), ";");
+ net_ctor.append("inputs.at(", n, ").shape.dims = ", dims_var, ";");
}
// Initialize output metadata
for (uint32_t n = 0; n < m->output()->size(); ++n)
{
auto output = m->output()->at(n);
+ auto dims = as_dims(output->shape());
auto name_var = global.constant(output->name());
+ auto dims_name = global.constant<uint32_t>(dims);
net_ctor.append("outputs.at(", n, ").name = ", name_var, ";");
+ net_ctor.append("outputs.at(", n, ").shape.rank = ", dims.size(), ";");
+ net_ctor.append("outputs.at(", n, ").shape.dims = ", dims_name, ";");
}
// TODO Implement this