Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experimental] ONNI v2 #91

Merged
merged 10 commits into from
Oct 10, 2018
Merged

[Experimental] ONNI v2 #91

merged 10 commits into from
Oct 10, 2018

Conversation

a127a127
Copy link
Contributor

@a127a127 a127a127 commented Oct 2, 2018

Ready for review:

  • Refactor Interpreter to an InterpreterPass.
  • Add Two passes for onni:
    1. CountOperatorPass: Operator counts statistics
    2. OnnxOptPass: Run onnx optimizer
  • Add more verbose level for debugging or benchmarking
    1. level 1:
      Print memory usage and overall time.
    2. level 2:
      Print the final ONNC IR before inference.
    3. level 3:
      Print the operator counts.
      Print the per layer inference time.
    4. level 4:
      Print internal memory layout.
  • Add two flags:
    1. --dry-run: Do not do the inference, just print statistics.
    2. --onnx-opt: Enable onnx optimizer
  • Do not allocate input memory for interpreter.

@a127a127 a127a127 requested review from cycheng and LuisHsu October 2, 2018 09:59
uint64_t max_size = 0;
for (ComputeOperand *co : pModule.getComputeOperands()) {
if (ComputeMemOperand *mem = dyn_cast<ComputeMemOperand>(co)) {
Value *v = co->getValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about mem->getValue();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok~

if (ComputeMemOperand *mem = dyn_cast<ComputeMemOperand>(co)) {
Value *v = co->getValue();
if (mem->isInput()) {
// XXX: Multiple inputs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use assert? assert(inputNum == 1 && "TODO: Support multiple inputs);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good advice!

// TODO: Refactor this. We need a table printer.
size_t val_len = 8;
for (ComputeOperator &cm : *pModule.getRootComputeGraph()) {
if (dyn_cast<InputOperator>(&cm)) continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about add a function:
bool skipInMemStatistics(ComputeOperator *pCm) {
if (isa(pCm) ||
isa<...> || isa<...>)
return true;
return false;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok~

@@ -27,6 +30,9 @@ Pass::ReturnType CountOperatorsPass::runOnModule(Module &pModule)
uint64_t total = 0;

for (ComputeOperator &cm : *pModule.getRootComputeGraph()) {
if (dyn_cast<InputOperator>(&cm)) continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with a function? IsIOWOperator() or SkipInCountStatistics()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's Great! Thanks a lot!

@cycheng
Copy link
Contributor

cycheng commented Oct 4, 2018

LTGM! (But please keep fixing TODO list ;P)

Copy link
Collaborator

@LuisHsu LuisHsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor Author

@a127a127 a127a127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much!

if (ComputeMemOperand *mem = dyn_cast<ComputeMemOperand>(co)) {
Value *v = co->getValue();
if (mem->isInput()) {
// XXX: Multiple inputs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good advice!

uint64_t max_size = 0;
for (ComputeOperand *co : pModule.getComputeOperands()) {
if (ComputeMemOperand *mem = dyn_cast<ComputeMemOperand>(co)) {
Value *v = co->getValue();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok~

// TODO: Refactor this. We need a table printer.
size_t val_len = 8;
for (ComputeOperator &cm : *pModule.getRootComputeGraph()) {
if (dyn_cast<InputOperator>(&cm)) continue;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok~

@@ -27,6 +30,9 @@ Pass::ReturnType CountOperatorsPass::runOnModule(Module &pModule)
uint64_t total = 0;

for (ComputeOperator &cm : *pModule.getRootComputeGraph()) {
if (dyn_cast<InputOperator>(&cm)) continue;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's Great! Thanks a lot!

@lubatang lubatang merged commit 6c618f8 into ONNC:master Oct 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants