ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnc::AclCppCodeGenerator Class Referencefinal

Class for the ACL C++ code generator. It is the entry point to the ACL C++ soft backend. More...

#include <AclCppGenerator.h>

Public Member Functions

 AclCppCodeGenerator (std::string output_dir, std::string artifact_name)
 
void run (mir::Graph *graph)
 Method represents the generation sequence: analysis, serialization, header/code generation, etc.
 

Detailed Description

Class for the ACL C++ code generator. It is the entry point to the ACL C++ soft backend.

Definition at line 31 of file AclCppGenerator.h.

Constructor & Destructor Documentation

◆ AclCppCodeGenerator()

nnc::AclCppCodeGenerator::AclCppCodeGenerator ( std::string  output_dir,
std::string  artifact_name 
)

Definition at line 31 of file AclCppGenerator.cpp.

32 : _output_dir(std::move(output_dir)), _artifact_name(std::move(artifact_name))
33{
34}

Member Function Documentation

◆ run()

void nnc::AclCppCodeGenerator::run ( mir::Graph graph)

Method represents the generation sequence: analysis, serialization, header/code generation, etc.

Parameters
graphMIR graph

Definition at line 36 of file AclCppGenerator.cpp.

37{
38 mir::Graph *g = data;
39 assert(g);
40
41 // Create a directory for generated artifact files.
42 fs::create_directory(_output_dir);
43
44 string base_path = _output_dir + "/" + _artifact_name;
45 string code_path = base_path + ".cpp";
46 string decl_path = base_path + ".h";
47 string par_path = base_path + ".par";
48
49 // Create the source and header files output streams.
50 ofstream code_out(code_path);
51
52 if (code_out.fail())
53 throw AclCppException("Can not open code output file: " + code_path);
54
55 ofstream decl_out(decl_path);
56
57 if (decl_out.fail())
58 throw AclCppException("Can not open declaration output file: " + decl_path);
59
60 ofstream par_out(par_path, ios_base::out | ios_base::binary);
61
62 if (par_out.fail())
63 throw AclCppException("Can not open parameter output file: " + par_path);
64
65 ArtifactGeneratorCppCode code_gen(code_out);
66 ArtifactGeneratorCppDecl decl_gen(decl_out);
67
68 // Generate the artifact.
69 AclCppOpGenerator op_generator(_artifact_name, par_out);
70 auto dom = op_generator.generate(g);
71 dom.accept(&code_gen);
72 dom.accept(&decl_gen);
73}

References nnc::ArtifactModule::accept(), and nnc::AclCppOpGenerator::generate().

Referenced by package.infer.session::inference().


The documentation for this class was generated from the following files: