Skip to content

[Placeholder] Add support for Placeholders in the execution engine #1586

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

Merged
merged 4 commits into from
Sep 6, 2018

Conversation

nadavrot
Copy link
Contributor

@nadavrot nadavrot commented Sep 6, 2018

Description:

Implement the logic for executing Placeholders in the execution engine. This commit changes the backend interface and adds the ability to pass Placeholder variables in addition to Variables.

This change breaks the out-of-tree backends.

This is the first step in adding support for placeholder variables in the execution engine. The commit adds support to the interpreter but not to the OpenCL and CPU backends. The support in the interpreter is single threaded at the moment.

In the next few PRs I'll complete the execution engine support in different backends for across all node kinds (SaveNode, for example).

Testing: Ran tests locally and added a new test.

Documentation: No functional changes to document.

issue #1334

Fix an assertion error in the scheduler. The scheduler needs to count the placeholders in addition to variables when examining the graph.

The test case will land in the following commit with another fix.
Implement the IRGen bits that are needed for Placeholder. The logic is identical to the Variable, except for the access control parts which are defaulted to Public.

The next commit will include the test case for this change.
@nadavrot nadavrot force-pushed the placeholder_execution_engine branch from 251a6c0 to e710f16 Compare September 6, 2018 06:51
Copy link
Contributor

@jfix71 jfix71 left a comment

Choose a reason for hiding this comment

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

Cool!

// This is a placeholder that we need to make concrete during the execution
// of the program.
placeholders.push_back(cast<Placeholder>(vars[i]));
tensors.push_back(inputs[i]);

This comment was marked as off-topic.

This comment was marked as off-topic.

@@ -2106,6 +2106,24 @@ static void verifyNodeInput(const Node &N, size_t idx) {
"Any node referencing another node N be in the use-list of the node N");
}

/// \returns True if \p n is a storage node (variable of placeholder) of the

This comment was marked as off-topic.

" nodes should be part of the graph");
bool foundNode =
std::find(nodes_.begin(), nodes_.end(), *input) != nodes_.end();
bool foundStorage = isGraphStorageNode(input, this);

This comment was marked as off-topic.

…xecution engine.

Implement the logic for executing Placeholders in the execution engine.
This commit changes the backend interface and adds the ability to pass
Placeholder variables in addition to Variables. This change breaks the
out-of-tree backends.

This is the first step in adding support for placeholder variables in
the execution engine. The commit adds support to the interpreter but not
to the OpenCL and CPU backends. The support in the interpreter is single
threaded at the moment.
@nadavrot nadavrot force-pushed the placeholder_execution_engine branch from e710f16 to bdae151 Compare September 6, 2018 18:25
@nadavrot
Copy link
Contributor Author

nadavrot commented Sep 6, 2018

@jfix71 Thank you for the review. I added support for runBatch with the commit:

Add support for the runBatch interface. This commit implements the parts
of runBatch that copy parts of the tensors into the placeholder. The
implementation is zero-copy because we use tensor views.  I hope that
this is a temporary solution and that we'll get rid of runBatch soon
(see #1587).

Copy link
Contributor

@jfix71 jfix71 left a comment

Choose a reason for hiding this comment

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

LGTM other than 2 nits, thanks!

@@ -173,6 +173,55 @@ TEST_P(BackendTest, decoupleCodegenFromGraph) {
EXPECT_NEAR(HX.at({2}), 9, 1E-5);
}

TEST(Placeholder, simplePlaceholderValue) {

This comment was marked as off-topic.

EXPECT_TRUE(res.isEqual(data));
}

TEST(Placeholder, runBatchTest) {

This comment was marked as off-topic.

@nadavrot nadavrot force-pushed the placeholder_execution_engine branch from 546c2ef to ebaba33 Compare September 6, 2018 20:35
Add support for the runBatch interface. This commit implements the parts
of runBatch that copy parts of the tensors into the placeholder. The
implementation is zero-copy because we use tensor views.  I hope that
this is a temporary solution and that we'll get rid of runBatch soon
(see pytorch#1587).
@nadavrot nadavrot force-pushed the placeholder_execution_engine branch from ebaba33 to 083e983 Compare September 6, 2018 20:36
@nadavrot
Copy link
Contributor Author

nadavrot commented Sep 6, 2018

@jfix71 Thank you! I'll update the doxygen comments and wait for the tests to pass before landing.

@nadavrot nadavrot merged commit dce7102 into pytorch:master Sep 6, 2018
nadavrot added a commit to nadavrot/glow that referenced this pull request Sep 7, 2018
…ngine pytorch#1586

This commit reverts the parts of the PR pytorch#1586 that pass the placeholder
variables in the run command of the execution engine. At first I thought
that this would allow to eliminate the variables from the high-level
parts of the compilation, but I realized that we need to start with
fixing all of the backends and add support to the compiled function.
nadavrot added a commit that referenced this pull request Sep 7, 2018
…ngine #1586

This commit reverts the parts of the PR #1586 that pass the placeholder
variables in the run command of the execution engine. At first I thought
that this would allow to eliminate the variables from the high-level
parts of the compilation, but I realized that we need to start with
fixing all of the backends and add support to the compiled function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants