Skip to content

Commit

Permalink
Add compile_fbs() in generate_code.py, change shaper of min/maximum t…
Browse files Browse the repository at this point in the history
…o eltwise
  • Loading branch information
daquexian committed Nov 2, 2019
1 parent e637232 commit e0dd8ab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dnnlibrary/ModelBuilderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ ModelBuilder::Index ModelBuilder::AddMinimum(const std::string &input1,
imm_blob_inputs_.insert(input2);
const auto input2_idx = operand_indexes_.at(input2);
input_indexes.push_back(input2_idx);
shaper_.Identity(input1, input2, output);
shaper_.Eltwise(input1, input2, output);
const OperandType operand_type =
GetOperandType(operand_types_.at(input1).type, shaper_[output]);
const auto output_idx =
Expand All @@ -655,7 +655,7 @@ ModelBuilder::Index ModelBuilder::AddMaximum(const std::string &input1,
imm_blob_inputs_.insert(input2);
const auto input2_idx = operand_indexes_.at(input2);
input_indexes.push_back(input2_idx);
shaper_.Identity(input1, input2, output);
shaper_.Eltwise(input1, input2, output);
const OperandType operand_type =
GetOperandType(operand_types_.at(input1).type, shaper_[output]);
const auto output_idx =
Expand Down
8 changes: 7 additions & 1 deletion generate_code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import subprocess
import yaml
from enum import Enum
from typing import Tuple
Expand All @@ -13,10 +14,13 @@ class Target(Enum):


def clang_format(filename: str):
import subprocess
subprocess.run(['clang-format', '-i', filename])


def compile_fbs():
subprocess.run(['flatc', '--cpp', '--scoped-enums', '-o', 'include/common/', 'common/daq.fbs'])


def cogout(txt):
print(txt, end='', file=str_io)

Expand Down Expand Up @@ -306,6 +310,8 @@ def generate_fbs():
for i, op in enumerate(cfg):
cogoutl(f" {op['dnn']},")
update_code('common/daq.fbs', 'Auto generated layer types', reformat=False)
compile_fbs()



def generate_model_builder():
Expand Down
4 changes: 2 additions & 2 deletions ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,12 @@
-
name: Minimum
base_input_num: 2
shaper: Identity
shaper: Eltwise
api: 29
-
name: Maximum
base_input_num: 2
shaper: Identity
shaper: Eltwise
api: 29
-
name: Log
Expand Down
4 changes: 2 additions & 2 deletions tools/onnx2daq/OnnxConverterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ void OnnxConverter::AddLayerMinimum(const std::string &input1,
}
}

shaper_.Identity(m(input1), m(input2), output);
shaper_.Eltwise(m(input1), m(input2), output);
const auto param = DNN::CreateMinimumDirect(
builder_, m(input1).c_str(), m(input2).c_str(), output.c_str());
const auto layer =
Expand Down Expand Up @@ -838,7 +838,7 @@ void OnnxConverter::AddLayerMaximum(const std::string &input1,
}
}

shaper_.Identity(m(input1), m(input2), output);
shaper_.Eltwise(m(input1), m(input2), output);
const auto param = DNN::CreateMaximumDirect(
builder_, m(input1).c_str(), m(input2).c_str(), output.c_str());
const auto layer = DNN::CreateLayer(builder_, DNN::LayerType::Maximum, 0, 0,
Expand Down

0 comments on commit e0dd8ab

Please sign in to comment.