-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[RELAY] [VIRTUALDEVICE] Change syntax for device planning and store parameter virtual devices in virtual_device_ field #10352
Merged
masahi
merged 32 commits into
apache:main
from
electriclilies:new-syntax-virtual-device
Feb 25, 2022
Merged
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
dc6053b
parent 33082e0032fb57b0516ad7e3eabd11fe0203437e
electriclilies 69acc6d
Change plan devices tests to use the new syntax for function parameters
electriclilies a92ab15
Fix free var problem
electriclilies 30fff16
Fix attribute parsing if there is virtual device; most device plannin…
electriclilies 167e4fd
fixed lambda lifting
electriclilies e3a2ec2
Debugging high order functions -- right now FunctionOnDevice and Bind…
electriclilies a95ae9d
tests pass wootgit status
electriclilies e62bce8
Remove FunctionOnDevice from device planner
electriclilies 904b93a
Don't use MaybeFunctionOnDevice in VM compiler
electriclilies 5224b64
Remove MaybeFunctionOnDevice from lambda lifter
electriclilies fd97879
Delete FunctionOnDevice and MaybeFunctionOnDevice!
electriclilies 3236a2d
Reomve GetFunctionResultVirtualDevice
electriclilies e269437
Remove GetFunctionParamVirtualDevice
electriclilies e642a5a
lint
electriclilies 6c6e5e5
lint
electriclilies a344e15
Python formatting
electriclilies 231d040
Remove FunctionOnDevice python test
electriclilies 0f5e6d2
Fix bug in binds & debug output
electriclilies f71601d
Fix text printer
electriclilies e8e5a09
lint
electriclilies ad4c97a
Remove function on device from fold constant tests
electriclilies 78d063e
Mark nits
electriclilies 1f10769
Revert behavior of bind
electriclilies b20dce7
clean up debug
electriclilies 8bacaba
Make ExprBinder public interface and use instead of Bind
electriclilies 41870f0
Fix lambda lift
electriclilies 3d346d9
This is broken but not sure how to fix
electriclilies c4939e6
passes all device planning tests yay!
electriclilies 001a063
Add substitution helper and use in device planner
electriclilies 2075dad
Remove unnecessary check
electriclilies 9dda0c1
Respond to comments
electriclilies 5bf526a
Update comment
electriclilies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,21 +252,16 @@ class VMFunctionCompiler : DeviceAwareExprFunctor<void(const Expr& n)> { | |
// Do that flattening on-the-fly here. | ||
Function inner_func = Downcast<Function>(func->body); | ||
std::vector<Var> params; | ||
std::vector<VirtualDevice> param_virtual_devices; | ||
params.reserve(func->params.size() + inner_func->params.size()); | ||
param_virtual_devices.reserve(func->params.size() + inner_func->params.size()); | ||
param_device_indexes.reserve(func->params.size() + inner_func->params.size()); | ||
for (size_t i = 0; i < func->params.size(); ++i) { | ||
params.emplace_back(func->params[i]); | ||
VirtualDevice param_virtual_device = GetFunctionParamVirtualDevice(func.get(), i); | ||
param_virtual_devices.push_back(param_virtual_device); | ||
param_device_indexes.push_back(GetDeviceIndex(param_virtual_device)); | ||
param_device_indexes.push_back(GetDeviceIndex(func->params[i]->virtual_device())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we get some payoff at last! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah!! |
||
} | ||
for (size_t i = 0; i < inner_func->params.size(); ++i) { | ||
params.emplace_back(inner_func->params[i]); | ||
VirtualDevice param_virtual_device = GetFunctionParamVirtualDevice(inner_func.get(), i); | ||
param_virtual_devices.push_back(param_virtual_device); | ||
param_device_indexes.push_back(GetDeviceIndex(param_virtual_device)); | ||
|
||
param_device_indexes.push_back(GetDeviceIndex(inner_func->params[i]->virtual_device())); | ||
} | ||
std::vector<TypeVar> type_params; | ||
type_params.reserve(func->type_params.size() + inner_func->type_params.size()); | ||
|
@@ -278,13 +273,12 @@ class VMFunctionCompiler : DeviceAwareExprFunctor<void(const Expr& n)> { | |
} | ||
Function flattened_func = Function(params, inner_func->body, inner_func->ret_type, | ||
type_params, func->attrs, func->span); | ||
VisitExpr(MaybeFunctionOnDevice(flattened_func, param_virtual_devices, | ||
GetFunctionResultVirtualDevice(inner_func.get()))); | ||
flattened_func->virtual_device_ = inner_func->virtual_device(); | ||
VisitExpr(flattened_func); | ||
} else { | ||
param_device_indexes.reserve(func->params.size()); | ||
for (size_t i = 0; i < func->params.size(); ++i) { | ||
param_device_indexes.push_back( | ||
GetDeviceIndex(GetFunctionParamVirtualDevice(func.get(), i))); | ||
param_device_indexes.push_back(GetDeviceIndex(func->params[i]->virtual_device())); | ||
} | ||
VisitExpr(func); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Any issue with this being used for both param- and let-bound vars even though we don't parse annots for let-bound vars?
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.
I guess for now, let-bound variables don't have their virtual devices set so it theoretically won't be triggered.. I haven't seen any issues in CI related to this but I could split the function into two if you'd like
Eventually we will annotate let-bound variables and at that point we will have to parse the fake attrs for let bound variables