-
Notifications
You must be signed in to change notification settings - Fork 699
[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
[Placeholder] Add support for Placeholders in the execution engine #1586
Conversation
83fe44e
to
251a6c0
Compare
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.
251a6c0
to
e710f16
Compare
There was a problem hiding this 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.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
lib/Graph/Graph.cpp
Outdated
@@ -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.
This comment was marked as off-topic.
Sorry, something went wrong.
lib/Graph/Graph.cpp
Outdated
" 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.
This comment was marked as off-topic.
Sorry, something went wrong.
…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.
e710f16
to
bdae151
Compare
@jfix71 Thank you for the review. I added support for runBatch with the commit:
|
There was a problem hiding this 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!
tests/unittests/BackendTest.cpp
Outdated
@@ -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.
This comment was marked as off-topic.
Sorry, something went wrong.
tests/unittests/BackendTest.cpp
Outdated
EXPECT_TRUE(res.isEqual(data)); | ||
} | ||
|
||
TEST(Placeholder, runBatchTest) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
546c2ef
to
ebaba33
Compare
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).
ebaba33
to
083e983
Compare
@jfix71 Thank you! I'll update the doxygen comments and wait for the tests to pass before landing. |
…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.
…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.
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