Skip to content

Commit 766da2e

Browse files
committed
Closes: #121
1 parent 37fd661 commit 766da2e

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ CPP_FLAGS=-Wall -std=c++17 -fPIC -D_DEBUG -g -lmcheck
9999
endif
100100

101101
ifneq (,$(findstring $(PROF),yY))
102-
CPP_FLAGS=-pg -Wall -std=c++17 -fPIC
102+
CPP_FLAGS=-pg -g -Wall -std=c++17 -fPIC
103103
endif
104104

deepC/compiler/read_onnx.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def main():
508508
if len(sys.argv) >= 3:
509509
bundle_dir = sys.argv[2]
510510
else:
511-
bundle_dir = os.path.dirname(onnx_filename);
511+
bundle_dir = os.path.dirname(onnx_file);
512512

513513
parser = pbReader()
514514
parser.main(onnx_file, bundle_dir, checker=False, optimize=False)

include/graph/graph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class graph {
115115
}
116116
~graph() { destroy(); }
117117
void setName(std::string name) { _name = name; }
118+
std::string getName() { return _name; }
118119

119120
size_t nNodes() { return _nodes.size(); }
120121
/*<! reset all existing marks on the graph nodes */

src/codegen/cppCodeGen.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <unistd.h>
3131

3232
bool dnnc::cppCodeGen::write() {
33+
// std::cout << "DBG: " << _graph.getName() << " \n\t";
3334

3435
inferDataType typeInference(_graph);
3536
typeInference.main();
@@ -352,13 +353,15 @@ std::string dnnc::cppCodeGen::write(opNode &computeNode) {
352353
return code;
353354
}
354355

355-
if (ins.size() == 0 && outs.size() == 1) {
356+
std::vector<std::string> nodeIns = computeNode.inputs();
357+
std::vector<std::string> nodeOuts = computeNode.outputs();
358+
if (nodeIns.size() == 0) {
356359
code = writeConstantOperator(computeNode, outs);
357-
} else if (ins.size() == 1 && outs.size() == 1) {
360+
} else if (nodeIns.size() == 1 && nodeOuts.size() == 1) {
358361
code = writeUnaryOperator(computeNode, ins, outs);
359-
} else if (ins.size() == 2 && outs.size() == 1) {
362+
} else if (nodeIns.size() == 2 && nodeOuts.size() == 1) {
360363
code = writeBinaryOperator(computeNode, ins, outs);
361-
} else if (ins.size() == 3 && outs.size() == 1) {
364+
} else if (nodeIns.size() == 3 && nodeOuts.size() == 1) {
362365
code = writeTernaryOperator(computeNode, ins, outs);
363366
} else {
364367
code = writeCustomOperator(computeNode, ins, outs);
@@ -368,6 +371,7 @@ std::string dnnc::cppCodeGen::write(opNode &computeNode) {
368371

369372
std::string dnnc::cppCodeGen::writeConstantOperator(opNode &computeNode,
370373
std::vector<node *> &outs) {
374+
// std::cout << "DBG: " << outs.size() << "\n";
371375
std::string code;
372376

373377
assert(outs.size() == 1);
@@ -411,6 +415,8 @@ std::string dnnc::cppCodeGen::writeConstantOperator(opNode &computeNode,
411415
std::string dnnc::cppCodeGen::writeUnaryOperator(opNode &computeNode,
412416
std::vector<node *> &ins,
413417
std::vector<node *> &outs) {
418+
// std::cout << "DBG: " << computeNode.name() << " " << ins.size() << " " <<
419+
// outs.size() << "\n";
414420
std::string code;
415421

416422
assert(ins.size() == 1 && outs.size() == 1);
@@ -455,6 +461,8 @@ std::string dnnc::cppCodeGen::writeUnaryOperator(opNode &computeNode,
455461
std::string dnnc::cppCodeGen::writeBinaryOperator(opNode &computeNode,
456462
std::vector<node *> &ins,
457463
std::vector<node *> &outs) {
464+
// std::cout << "DBG: " << computeNode.name() << " " << ins.size() << " " <<
465+
// outs.size() << "\n";
458466
std::string code;
459467

460468
assert(ins.size() == 2 && outs.size() == 1);
@@ -500,6 +508,8 @@ std::string dnnc::cppCodeGen::writeBinaryOperator(opNode &computeNode,
500508
std::string dnnc::cppCodeGen::writeTernaryOperator(opNode &computeNode,
501509
std::vector<node *> &ins,
502510
std::vector<node *> &outs) {
511+
// std::cout << "DBG: " << computeNode.name() << " " << ins.size() << " " <<
512+
// outs.size() << "\n";
503513
std::string code;
504514

505515
assert(ins.size() == 3 && outs.size() == 1);
@@ -552,7 +562,6 @@ std::string dnnc::cppCodeGen::writeCustomOperator(opNode &computeNode,
552562
std::string code =
553563
_tab + "// operator " + opCode + " is not supported yet.\n";
554564
code += _tab + "// Please file a enhancement request at \n";
555-
code += _tab +
556-
"// https://github.com/ai-techsystems/dnnCompiler/issues \n";
565+
code += _tab + "// https://github.com/ai-techsystems/deepC/issues \n";
557566
return code;
558567
}

test/parser/unitOperators.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ def find(self, pattern, path):
1515
return result
1616

1717
def test_readAllOnnxFiles(self):
18-
# mute stdout
19-
sys_stdout = sys.stdout
20-
f = open(os.devnull, 'w')
21-
sys.stdout = f
18+
debug = False;
19+
if debug == False :
20+
# mute stdout
21+
sys_stdout = sys.stdout
22+
f = open(os.devnull, 'w')
23+
sys.stdout = f
2224

2325
onnx_files = self.find('*.onnx', 'parser')
2426
for onnx_file in onnx_files:
27+
if ( debug ):
28+
print("testing ", onnx_file, flush=True)
2529
cpp_file = os.path.splitext(os.path.basename(onnx_file))[0]+'.cpp'
2630
bundle_dir = os.path.dirname(onnx_file);
2731
parser = read_onnx.pbReader()
@@ -35,7 +39,8 @@ def test_readAllOnnxFiles(self):
3539
os.remove(cpp_file)
3640

3741
# unmute stdout
38-
sys.stdout = sys_stdout
42+
if debug == False :
43+
sys.stdout = sys_stdout
3944

4045
print("read %d files." %len(onnx_files))
4146
assert(len(onnx_files)==130)

0 commit comments

Comments
 (0)