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/10/20 14:48:56 UTC

[GitHub] chenbiaolong opened a new issue #8360: How to bind different input shape to executor in c++?

chenbiaolong opened a new issue #8360: How to bind different input shape to executor in c++?
URL: https://github.com/apache/incubator-mxnet/issues/8360
 
 
   I build a cnn network to extract images feature, however my input images do not have same shape,eg:
   [batch, 1, 32, width], `batch` and `width` can change at each forward. so how can I bind different input data to an executor? One solution is rebind executor every time I run forward, but it cost too much time. Any example code solve this problem? my code now:
   ```
    int MXNetInference::GetOutputTensor(
                       const std::map<std::string, mxnet::cpp::NDArray>& inputs,
                       std::vector<mxnet::cpp::NDArray>& outputs) {
           for(auto& input: inputs) {
               args_map_[input.first] = input.second.Copy(*global_ctx_);
               NDArray::WaitAll();
           }
           /*bind the excutor*/
           executor_.reset(net_.SimpleBind(*global_ctx_, args_map_, map<string, NDArray>(),
                   map<string, mxnet::cpp::OpReqType>(), aux_map_));
           executor_->Forward(false);
           /*print out the features*/
           std::vector<NDArray> results = executor_->outputs;
           for(auto& result: results) {
               NDArray array = result.Copy(Context(kCPU, 0));
               NDArray::WaitAll();
               outputs.push_back(array);
           }
           return 0;
       }
   ```
   

----------------------------------------------------------------
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