You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/12/13 14:43:56 UTC

[GitHub] ZiyueHuang closed pull request #9057: fix multiple kTempSpace resources needed in a single operator

ZiyueHuang closed pull request #9057: fix multiple kTempSpace resources needed in a single operator
URL: https://github.com/apache/incubator-mxnet/pull/9057
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/executor/attach_op_resource_pass.cc b/src/executor/attach_op_resource_pass.cc
index 18feec7957..f5080d2f0f 100644
--- a/src/executor/attach_op_resource_pass.cc
+++ b/src/executor/attach_op_resource_pass.cc
@@ -38,7 +38,7 @@ Graph AttachOpResources(Graph g) {
   const auto& vdispatch = g.GetAttr<DispatchModeVector>("dispatch_mode");
   const auto& idx = g.indexed_graph();
   // Use global resource pool for each executor for now.
-  std::map<Context, Resource> cached_temp;
+  std::map<Context, std::vector<Resource> > cached_temp;
   // Resource allocation
   for (uint32_t nid = 0; nid < idx.num_nodes(); ++nid) {
     const auto& inode = idx[nid];
@@ -50,14 +50,21 @@ Graph AttachOpResources(Graph g) {
     if (fresource.count(op) != 0) {
       auto reqs = fresource[op](inode.source->attrs);
       // Get the resource of temporal space.
-      for (const ResourceRequest& req : reqs) {
+      for (size_t i=0; i < reqs.size(); i++) {
+        const ResourceRequest& req = reqs[i];
         if (req.type == ResourceRequest::kTempSpace) {
           if (cached_temp.count(ctx) != 0) {
-            requested.push_back(cached_temp.at(ctx));
+            if (i < cached_temp.at(ctx).size()) {
+              requested.push_back(cached_temp.at(ctx)[i]);
+            } else {
+              Resource r = ResourceManager::Get()->Request(ctx, req);
+              requested.push_back(r);
+              cached_temp[ctx].push_back(r);
+            }
           } else {
             Resource r = ResourceManager::Get()->Request(ctx, req);
             requested.push_back(r);
-            cached_temp[ctx] = r;
+            cached_temp[ctx] = std::vector<Resource>(1, r);
           }
         } else if (req.type == ResourceRequest::kRandom) {
           requested.push_back(ResourceManager::Get()->Request(ctx, req));


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services