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

[BYOC][JSON] Support input nodes with multiple entries #6368

Merged
merged 2 commits into from
Sep 1, 2020

Conversation

trevor-m
Copy link
Contributor

@trevor-m trevor-m commented Aug 31, 2020

Sometimes input nodes will have multiple data entries. The graph runtime will give a separate arg for each entry. The previous code assumed each input node would have 1 entry at index 0 which would correspond with a single arg.

Note that each custom runtime will also have the handle these types of inputs in a similar way.

Example JSON representation which would fail before but works with this PR. This assert would fail because the function has 3 args but 2 input + output nodes. See how op input has two entries for dtype and shape.

{
  "nodes": [
    {
      "op": "input", 
      "name": "tensorrt_0_i0", 
      "attrs": {
        "dtype": [
          [
            "float32", 
            "float32"
          ]
        ], 
        "shape": [
          [
            [1, 2, 6, 6], 
            [1, 3, 6, 6]
          ]
        ]
      }
    }, 
    {
      "op": "kernel", 
      "name": "concatenate", 
      "inputs": [[
          0, 
          0, 
          0], [
          0, 
          1, 
          0]], 
      "attrs": {
        "num_outputs": "1", 
        "num_inputs": "2", 
        "dtype": [
          [
            "float32"
          ]
        ], 
        "axis": [
          [
            "1"
          ]
        ], 
        "shape": [
          [
            [1, 5, 6, 6]
          ]
        ]
      }
    }
  ], 
  "arg_nodes": [0], 
  "heads": [[
      1, 
      0, 
      0]], 
  "node_row_ptr": [0, 2, 3]
}

@trevor-m
Copy link
Contributor Author

@zhiics @comaniac Could you please take a look? Thanks!

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

LGTM. Just a nit.

input_var_idx_.push_back(nid);
CHECK_EQ(nodes_[nid].GetOpShape().size(), nodes_[nid].GetOpDataType().size());
for (size_t j = 0; j < nodes_[nid].GetOpShape().size(); ++j) {
input_var_idx_.push_back(EntryID(nid, j));
Copy link
Contributor

Choose a reason for hiding this comment

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

By doing so, input_var_idx_ is not keeping index but entry ID. I'd suggest renaming it to be clearer.

@zhiics zhiics merged commit b8f37ee into apache:master Sep 1, 2020
@zhiics
Copy link
Member

zhiics commented Sep 1, 2020

Thanks @trevor-m @comaniac

kevinthesun pushed a commit to kevinthesun/tvm that referenced this pull request Sep 17, 2020
* Support input nodes with multiple data entries

* Rename input_var_idx_ to input_var_eid_
kevinthesun pushed a commit to kevinthesun/tvm that referenced this pull request Sep 18, 2020
* Support input nodes with multiple data entries

* Rename input_var_idx_ to input_var_eid_
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Sep 18, 2020
* Support input nodes with multiple data entries

* Rename input_var_idx_ to input_var_eid_
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.

3 participants