Skip to content

Commit

Permalink
Compile unittests with onnx2c.
Browse files Browse the repository at this point in the history
And and compiler and link in the generated unit test network
as a separate object.

This to better mimic how the user uses onnx2c.
  • Loading branch information
kraiskil committed Jan 29, 2024
1 parent 9f775b1 commit 69e7615
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 91 deletions.
2 changes: 1 addition & 1 deletion src/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Graph {
void print_tensor(const Tensor *, std::ostream &dst);
void print_functions(std::ostream &destination);
void print_includes(std::ostream &dst);
void print_interface_function(std::ostream &dst);
void print_interface_function(std::ostream &dst, bool print_definition=true);

/* Create the onnx2c graph elements from the ONNX graph */
void processGraph(
Expand Down
11 changes: 9 additions & 2 deletions src/graph_print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void Graph::print_includes(std::ostream &dst)
}
}

void Graph::print_interface_function(std::ostream &dst)
void Graph::print_interface_function(std::ostream &dst, bool definition)
{
bool isfirst = true;
// TODO: take the interface function name from the ONNX file name
Expand Down Expand Up @@ -162,7 +162,14 @@ void Graph::print_interface_function(std::ostream &dst)
}
}

dst << ") {" << std::endl;
dst << ")";
if( !definition ) { // not definition, i.e. decalaration
dst << ";" << std::endl;
return;
}

// else: definition - print the rest
dst << "{" << std::endl;

// since nodes were resolved from graph inputs in the order there were
// node inputs resolved, the nodes vector is now sorted in order so that
Expand Down
Loading

0 comments on commit 69e7615

Please sign in to comment.