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

Add get_input() to DLR #44

Merged
merged 11 commits into from Apr 9, 2019
Merged

Add get_input() to DLR #44

merged 11 commits into from Apr 9, 2019

Conversation

hcho3
Copy link
Contributor

@hcho3 hcho3 commented Apr 5, 2019

We need the ability to get the current value of an input when using the _assign operator in NNVM.

@wweic
Copy link
Contributor

wweic commented Apr 6, 2019

@hcho3 code looks good! Please add a unit test.

Copy link

@zhiics zhiics left a comment

Choose a reason for hiding this comment

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

Could you please explain a bit why GetInput is needed? Shouldn't users already know the input?

src/dlr.cc Show resolved Hide resolved
@hcho3
Copy link
Contributor Author

hcho3 commented Apr 6, 2019

Still need to test a few things. I'll take off "Draft" status once this PR is ready.

@hcho3
Copy link
Contributor Author

hcho3 commented Apr 6, 2019

@zhiics No, since the value of the input changes when the _assign operator is used. See this snippet:
https://github.com/dmlc/tvm/blob/39c8bc2a3da62701f28488920d63fdd2895fe060/nnvm/tests/python/compiler/test_top_assign.py#L21-L34

cc @kevinthesun

@zhiics
Copy link

zhiics commented Apr 6, 2019

@hcho3 I see. Thanks.

@hcho3
Copy link
Contributor Author

hcho3 commented Apr 7, 2019

The current logic for getting input names assumes that inputs always precede parameters, but it is not always true. One model I am looking at actually has some parameters before the input:

hybridsequential0_aux4
hybridsequential0_aux3
hybridsequential0_aux2
hybridsequential0_aux1
hybridsequential0_aux0
data
...

EDIT. Fixed by commit fb87ad4

@hcho3
Copy link
Contributor Author

hcho3 commented Apr 7, 2019

Also, std::set_difference assumes that both sets are sorted, but neither input_names nor weight_names are not sorted:

neo-ai-dlr/src/dlr.cc

Lines 196 to 203 in 0ce46d9

std::vector<std::string> input_names;
for (int i = 0; i < num_inputs_; i++) {
input_names.push_back(tvm_graph_runtime_->GetInputName(i));
}
std::vector<std::string> weight_names = tvm_graph_runtime_->GetWeightNames();
std::set_difference(input_names.begin(), input_names.end(),
weight_names.begin(), weight_names.end(),
std::inserter(input_names_, input_names_.begin()));

EDIT. Fixed by commit fb87ad4

@hcho3 hcho3 marked this pull request as ready for review April 9, 2019 03:28
@hcho3 hcho3 requested review from wweic and zhiics April 9, 2019 03:28
@hcho3
Copy link
Contributor Author

hcho3 commented Apr 9, 2019

@wweic @ziyu-guo @zhiics I added a small unit test. Please review.

Copy link
Contributor

@ziyu-guo ziyu-guo left a comment

Choose a reason for hiding this comment

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

LGTM

@hcho3 hcho3 merged commit 1ade020 into neo-ai:master Apr 9, 2019
@hcho3 hcho3 deleted the get_input branch April 15, 2019 21:09
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.

None yet

5 participants