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

Add provisioner for new Runtime #2276

Closed
wants to merge 33 commits into from
Closed

Conversation

gcatron
Copy link
Contributor

@gcatron gcatron commented Jan 17, 2019

Description: This PR adds the Provisioner for the new runtime. This is an initial provisioner so it's rather straight forward. Later work can be done to improve the provisioning algorithm. This is almost ready, it needs to be updated to the new DAGNode when it get's merged from #2268 .
Testing: Added new unittest which uses the CPU backend and CPUDeviceManager.
Documentation: N/A
Related to #2045

gcatron and others added 4 commits January 16, 2019 16:12
…rintf-like formatting

STL is not very convenient if you want to produce a heavily-formatted string and `llvm::format` uses llvm streams to produce the output. The new `strFormat` function is useful if you need a convenient method to create a formatted `std::string`.

An example of `strFormat` use would be `std::string str = strformat("Happy %s Year %d", "New", 2019)`.
/// Returns a ResultCode indicating if the operation was a success.
ResultCode
provision(std::vector<DAGNode> &networks,
std::map<DeviceIDTy, std::unique_ptr<DeviceManager>> &devices,
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: Is it important that devices are a sorted map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't strictly need to be, but the consistent ordering is useful for the round robin provisioning.

Module &module);

private:
std::unique_ptr<Backend> backend_;
Copy link
Contributor

Choose a reason for hiding this comment

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

The provisioner owns the backend?

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, since the compilation happens in the Provisioner.
Is there significant cost in initializing a backend? Currently the Provisioner will initialize the backend for each device. This could be optimized to check first, or have a map of backends for each device type.

using namespace runtime;
using DeviceID = unsigned int;

void addNodes(std::queue<std::vector<DAGNode *>> &nextNodes,
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest giving a typename to "std::queue<std::vector<DAGNode *>>".

I am not sure why this is a queue. Isn't this the same as std::vector? Are you going to be processing this data structure inplace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's being used as a work queue in the provision function, This stores the next set of functions to be compiled and added to a device. I don't think a separate function is still necessary though.

std::unique_ptr<DeviceManager> device(new CPUDeviceManager);
devices.emplace(i, std::move(device));
}
auto result = provisioner.provision(networks, devices, *mod.get());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we moving the module to be owned by the provisioner? I think that it would make more sense for some external entity to own it and just pass a pointer. For example, our unit tests or ONNX-IFI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provisioner doesn't own the module. The module is provided to the HostManager by ONNX-IFI as a pointer and that gets passed along to the provisioner. This unit test is making a custom module to test the provisioner handling multiple functions in one graph. The device map will be owned by the host manager, the provisioner takes in a reference.

jackm321 and others added 8 commits January 20, 2019 18:52
*Description*: Implement RowwiseQuantizedSparseLengthsWeightedSum. Added support for both Interpreter and CPU backends.

*Testing*: Added unit tests for both RowwiseQuantizedSparseLengthsWeightedSum and RowwiseQuantizedSparseLengthsSum (implemented as the first but with weights as a float splat of 1.0).

*Documentation*: Added to Quantization.md

Related to pytorch#1698
@gcatron
Copy link
Contributor Author

gcatron commented Jan 22, 2019

ASAN is breaking because of the DAGNodes for the unit test, this will need to be updated after the Partitioner lands to match the new structure so I'll update and address the ASAN then.

@gcatron
Copy link
Contributor Author

gcatron commented Jan 24, 2019

hmm looks like I did some git mistakes, I'll move this to a clean branch. I rebased locally but then did a pull instead of a force push.... This pr can be closed the new PR is #2293.

@gcatron gcatron closed this Jan 28, 2019
@gcatron gcatron deleted the add_provisioner branch January 28, 2019 22:57
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.

9 participants