-
Notifications
You must be signed in to change notification settings - Fork 700
[WIP] Add Provisioner #2159
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
Closed
Closed
[WIP] Add Provisioner #2159
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
98dd707
Runtime Provisioner Interface
gcatron d241bd1
mend
gcatron fcfd3e9
Work on implementation
gcatron c33ccc4
work on provisioner
gcatron 67d57b8
Adding logic for addNetwork on DM
gcatron 337f5f5
added callback
gcatron f770ac6
work on provisioner and backends to support compile without collectin…
gcatron 52de7fd
added line ending
gcatron 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/** | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef GLOW_RUNTIME_PROVISIONER_H | ||
#define GLOW_RUNTIME_PROVISIONER_H | ||
|
||
// #include "glow/Runtime/RuntimeTypes.h" | ||
|
||
////////////////////////////////////////////////////////// | ||
#include "glow/Backends/Backend.h" | ||
#include "glow/Backends/BackendUtils.h" | ||
#include "glow/Backends/CompiledFunction.h" | ||
#include "glow/Graph/Graph.h" | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
namespace glow { | ||
namespace runtime { | ||
|
||
using NetworkIDty = size_t; | ||
using DeviceIDty = size_t; | ||
|
||
/// Enum to communicate results when communicating with device at initialization | ||
/// and runtime. | ||
enum ResultCode { READY, EXECUTED, FAILED, CANCELLED }; | ||
|
||
/// Data structure that contains device constraint information for each device. | ||
/// Used to communicate memory constraints and later costs to the Partitioner. | ||
struct DeviceInfo { | ||
/// Available memory on device in bytes. | ||
uint64_t availableMemory; | ||
}; | ||
|
||
/// Individual Node in the DAG for a given network. This contains all the | ||
/// information needed to run the sub-network at inference time. | ||
struct DAGNode { | ||
/// The children of this node, these are nodes that depend on the current | ||
/// node. | ||
std::vector<DAGNode> children; | ||
/// Pointers to the parents of this node. This is used by the executor for | ||
/// determining if a given node has all dependencies met. | ||
std::vector<DAGNode *> parents; | ||
/// ID of the deviceManager that this network is assigned to. | ||
DeviceIDty deviceID; | ||
/// The logicalDevice is an output of the Partitioner to indicate that two | ||
/// networks should be assigned to the same device. | ||
DeviceIDty logicalDevice; | ||
/// Name assigned to the sub-network, this is the id that will be passed to | ||
/// the DeviceManager when requesting a run of the network. | ||
std::string name; | ||
/// Runtime bundle containing all the symbol information for this network at | ||
/// runtime. | ||
RuntimeBundle runtimeBundle; | ||
}; | ||
|
||
} // namespace runtime | ||
} // namespace glow | ||
/////////////////////////////////////////////// | ||
|
||
#include <unordered_map> | ||
#include <vector> | ||
|
||
namespace glow { | ||
namespace runtime { | ||
|
||
class DeviceManager; | ||
/// The Provisioner is responsible for assigning networks to an actual device. | ||
/// It is a stateless class, relying on information being passed in by the | ||
/// caller. | ||
class Provisioner final { | ||
public: | ||
Provisioner(); | ||
~Provisioner(); | ||
/// Walks \p networks and assigns each module to a DeviceManager in \p | ||
/// devices. The Provisioner calls the addNetwork method for each | ||
/// DeviceManager and uses the returned networkID to populate \p runDAG. | ||
/// Returns a ResultCode indicating if the operation was a success. | ||
ResultCode provision(std::vector<DAGNode> &networks, | ||
std::unordered_map<DeviceIDty, DeviceManager> &devices, | ||
Module &module); | ||
|
||
private: | ||
std::unique_ptr<Backend> backend_; | ||
}; | ||
} // namespace runtime | ||
} // namespace glow | ||
|
||
#endif // GLOW_RUNTIME_PROVISIONER_H |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
And here?