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
[Partitioner] Heterogeneous partition testing #3197
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -912,7 +912,29 @@ Partitioner::backendBasedPartition(Function *F, | |
for (auto &N : F->getNodes()) { | ||
for (auto &backend : backends) { | ||
// Find the first backend that supports this node. The order of backends | ||
// is important. | ||
// is important. The check flow is : | ||
|
||
// Step 1: If a node is in pre-defined non-supported nodes set, it can not | ||
// be assigned to this backend. Continue. | ||
const auto &nonSupportedNodesKinds = | ||
backendMap_[backend->getBackendName()].nonSupportedNodesKinds; | ||
if (nonSupportedNodesKinds.count(N.getKind())) { | ||
// This op is on the pre-defined non-supported op list: | ||
continue; | ||
} | ||
// Step 2: If the pre-defined supported nodes set is empty, it means all | ||
// nodes could be assigned to this backend. If the pre-defined supported | ||
// nodes set is not empty, we check that if the node from Step 1 is in | ||
// this set or not. If not, continue. | ||
const auto &supportedNodesKinds = | ||
backendMap_[backend->getBackendName()].supportedNodesKinds; | ||
if (!supportedNodesKinds.empty() && | ||
!supportedNodesKinds.count(N.getKind())) { | ||
// This op is not on the pre-definded supported op list: | ||
continue; | ||
} | ||
// Step 3: Check if the node is actually supported in this backend, if so, | ||
// assign it to this backend and break. Otherwise continue. | ||
// TODO: the logic here need to be improved. | ||
if (backend->shouldLower(&N) || backend->isOpSupported(N)) { | ||
// Put this node into a partition for this backend. | ||
|
@@ -981,6 +1003,10 @@ void Partitioner::getBackendMap( | |
// is the same. | ||
// TODO : will improve the algorithm for different memory size. | ||
backendInfo.memSize = deviceInfo_[i].availableMemory; | ||
backendInfo.nonSupportedNodesKinds = | ||
generateNodeKindsSet(deviceInfo_[i].nonSupportedNodes); | ||
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. Maybe |
||
backendInfo.supportedNodesKinds = | ||
generateNodeKindsSet(deviceInfo_[i].supportedNodes); | ||
if (hasBackends) { | ||
backendInfo.backend = backends_[i]; | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- name: Device1 | ||
backendName: CPU | ||
parameters: | | ||
"nonSupportedNodes":"AvgPool" | ||
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. Can you add 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. The "Device3" in this file has the "supportedNodes" params. Since there are many ops in resnet50, I just let Interpreter supports all. In unit test, we tested the supported nodes set. |
||
"deviceID" : "0" | ||
- name: Device2 | ||
backendName: CPU | ||
parameters: | | ||
"nonSupportedNodes":"AvgPool" | ||
- name: Device3 | ||
backendName: Interpreter | ||
parameters: | | ||
"supportedNodes":"" | ||
... |
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.
Maybe it's just my preference but here I would find it easier to read the "step N" comments inline with the code, rather than as a separate block that I need to scroll up to reference. And that way we could get rid of the "step N" tags themselves, which have to be kept up to date over time.
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.
Done!