52using std::make_unique;
62 for (uint32_t n = 0; n <
m->entity()->bag()->
size(); ++n)
64 auto bag =
m->entity()->bag()->at(n);
66 if (bag->isInput() && bag->isOutput())
77 BackendImpl(
const std::string &prefix) : _prefix{prefix}
104 pipeline.
append(make_unique<BagDuplicationPass>());
105 pipeline.
append(make_unique<FeatureUnificationPass>());
106 pipeline.
append(make_unique<AvgPoolLoweringPass>());
107 pipeline.
append(make_unique<IntrinsicSelectionPass>());
109 pipeline.
append(make_unique<DataLayoutConversionPass>());
110 pipeline.
append(make_unique<IndirectCopyEliminationPass>());
111 pipeline.
append(make_unique<IdenticalObjectReductionPass>());
112 pipeline.
append(make_unique<DuplicatedObjectReductionPass>());
113 pipeline.
append(make_unique<ConstantFoldingPass>());
118 pipeline.
append(make_unique<DeadObjectEliminationPass>());
120 pipeline.
append(make_unique<CopyLoweringPass>());
122 pipeline.
append(make_unique<ConcatLoweringPass>());
123 pipeline.
append(make_unique<BypassGenerationPass>());
124 pipeline.
append(make_unique<FreeInstrEliminationPass>());
127 pipeline.
append(make_unique<FreeOpEliminationPass>());
128 pipeline.
append(make_unique<DeadBagEliminationPass>());
130 pipeline.
append(make_unique<PhaseConstructionPass>());
133 for (uint32_t n = 0; n < pipeline.
size(); ++n)
135 const auto &pass = pipeline.
at(n);
149 const std::string data_var =
"data";
150 const std::string data_filename = _prefix +
".bin";
154 std::ofstream ofs{data_filename, std::ios::binary};
160 std::ofstream ofs{_prefix +
".embed.S"};
161 ofs <<
AsmCode{data_filename, data_var};
166 std::ofstream ofs{_prefix +
".cpp"};
176 return make_unique<::BackendImpl>(
cmdline.at(0));
Top-level element of coco IR which represents a neural network.
virtual void run(const SessionID &) const =0
uint32_t size(void) const
void append(std::unique_ptr< Pass > &&pass)
const Pass & at(uint32_t n) const
std::unique_ptr< enco::Backend > make_backend(const cmdline::View &cmdline)
void generate_global_data(std::ostream &os, enco::Code *code)
Generate 'Global' weight array.
Code * code(const SessionID &sess)
coco::Module * module(const SessionID &sess)
SessionID make_session(coco::Module *m, coco::Data *d)
bool validate(Code *code)
Core coco entity for constant weights.
virtual void compile(coco::Module *m, coco::Data *d)=0