kohillyang opened a new issue #18982:
URL: https://github.com/apache/incubator-mxnet/issues/18982


   ## Description
   Currently mxnet has several memory allocating strategies, like rounding 
strategy, Naive and Round. However, when the graph is static but the input 
shapes are dynamic, mxnet has to allocate memory in each step. I think these 
allocating strategies could cause much memory fragmentation and memory 
consuming, and causing allocating failing even though the memory is enough.
   Since in some cases the maximum memory for each tensor can be known if the 
users can give enough information. I think a memory allocating strategies which 
allocate the  maximum memory is needed for mxnet.
   
   For example:
   ```python
   class ExampleNet(nn.HybridBlock):
       def _init__(self):
           super(self, ExampleNet).__init(0
           self.conv = nn.Conv(20)
      def hybrid_forward(F, x):
           return self.conv(x);
   
   net.hybridize(max_shape=[(1, 3, 256, 256), ]) # Here the users can tell 
mxnet the maximum memory, then all tensors can be allocate directly.
   ```
   
   In some cases the HybridBlock may contains Block children, then the memory 
allocating strategy is not suitable for these cases because we need a full 
static graph, then a Error can be raised or It should be OK that allocate 
tensors whose shapes can be infered. 
    
   
   ## References
   - list reference and related literature
   - list known implementations
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to