Skip to content
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

[WIP] Adding RuntimeTypes.h #2161

Closed
wants to merge 8 commits into from

Conversation

gcatron
Copy link
Contributor

@gcatron gcatron commented Dec 11, 2018

Description: Adds RuntimeTypes.h which contains data structures common to the Runtime Components.
Testing: Not yet
Documentation: NA
Related to #2045

/// Mapping of Module * to a vector of it's dependancies.
std::unordered_map<Module *, std::vector<Module *>> dependencies;
/// Mapping of Module * to a vector of networks that depend on it.
std::unordered_map<Module *, std::vector<Module *>> dependents;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a revert DAG ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, after talking with @SplitInfinity we decided it would be helpful to have both directions. If it turns out this can be removed we can pull it later.

/// Mapping of Module * to a vector of output placeholder names for the
/// network.
std::unordered_map<Module *, std::vector<std::string>> outputs;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Each module contains its placeholder and constants. So what the input and output for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are for runtime, at runtime the modules are no longer around but the executor will need to know how to pass inputs and outputs when executing the network.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed from DependencyDAG, they will by generated by the HM and added to the executionDAG.

/// Total useable memory on device in MB
double maximumUsableMemory;
};

Copy link
Contributor

Choose a reason for hiding this comment

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

For Partitioner, we need the DeviceInfo contains: memory, number of devices, later the communication constraints.

Copy link
Contributor Author

@gcatron gcatron Dec 11, 2018

Choose a reason for hiding this comment

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

Would the communication contraints be at a system level or device level? The thought here is the Partitioner would be given a vector of these DeviceInfo objects, one per device. Number of devices would be the length of the vector.

Copy link
Contributor

Choose a reason for hiding this comment

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

"Would the communication contraints be at a system level or device level?"
-- device level. Should be device specific.
It is OK to put it here, but for Partitioner, I don't think we need "double availableMemory;". Please correct me if I miss anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct, we don't need availableMemory right now for Partitioner, but it could be used for provisioner and potentially later in Partitioner.


/// Data structure containing the output from the Partitioner. It is consumed by
/// the Provisioner and used to generate an executionDAG.
struct DependancyDAG {
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the spelling "dependency", but Wiktionary informs me that "dependancy" is an acceptable if archaic form. So thou mayest leave the spelling alone if thou whilst :-D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch I prefer dependency myself, consider it changed.


struct DeviceMemoryInfo {
/// Available memory on device in MB
double availableMemory;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use size_t for memory, since it's not really a floating-point quantity. I also have a slight preference for bytes (rather than a bigger unit like MB), but I also know it's kind of annoying to look at quantities like 536,870,912 instead of "512", so your discretion there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, size_t might be a little awkward since it's based on the host's address space. In practice I don't think it would ever matter, but maybe a uint64_t would be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to uint64_t.

namespace glow {
namespace runtime {

using NetworkID = size_t;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not the device id. It is the device id type. Please call it NetworkIDTy

/// and runtime.
enum ResultCode { READY, EXECUTED, FAILED, CANCELLED };

struct DeviceMemoryInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

oxygen.

@gcatron gcatron force-pushed the create_runtime_types branch from e1637c3 to a7bfe84 Compare December 28, 2018 00:52
/// 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
Copy link
Contributor

Choose a reason for hiding this comment

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

So, after graph partitioning, each function should have a DAGNode, right? Please correct me if I misunderstand something... If so, we should have some field in this struct to point the function ? or the "name" in DAGNode is the function name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct, name in the DAGNode is the function name.

@beicy
Copy link
Contributor

beicy commented Dec 28, 2018

Looks like ci failed due to the head file is not used by any other file... Anyway to avoid this failure?

@@ -30,6 +30,10 @@ struct RuntimeSymbolInfo {
size_t offset;
/// Type of symbol.
Type type;
/// Is the symbol an input for the function.
Copy link
Contributor

Choose a reason for hiding this comment

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

please run "format.sh fix"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Format.sh fix didn't change anything? Is it the indentation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I would like the indentation should be the consistent with the rest of file.

/// 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

The "children" is with the type of "std::vector" and "parents" is with the type of "std::vector<DAGNode*>". Actually, this would cause some complexity when creating the DAGNode. For each DAGNode of each sub-function, if we declare it as a local var, we have no idea how to push_back its pointer to its children's "parents" filed. If we new a DAGNode for each function, the "children" field is improper. After discussed with @gcatron , can we use "std::vector<DAGNode*> children;" instead of "std::vector children;", and add an Destructor of DAGNode? @nickgg

@stale
Copy link

stale bot commented Jan 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Jan 20, 2019

This PR has been automatically closed due to being stale for 5 days. Thank you for your contributions and feel free to reopen it in case of further progress.

@stale stale bot closed this Jan 20, 2019
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.

5 participants