You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by la...@apache.org on 2020/09/03 16:25:53 UTC

[incubator-mxnet] branch v1.x updated: fix block.export (#17970) (#19075)

This is an automated email from the ASF dual-hosted git repository.

lausen pushed a commit to branch v1.x
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/v1.x by this push:
     new 748eebd  fix block.export (#17970) (#19075)
748eebd is described below

commit 748eebd7475b3052d5cc966765c6913cb181ad4f
Author: James Mracek <ja...@adroll.com>
AuthorDate: Thu Sep 3 09:21:50 2020 -0700

    fix block.export (#17970) (#19075)
    
    This PR cherry-picks commit 5122d32 into the v1.x branch. This is to enable the export of models where dangling layers are optimized out during symbol export. For more information, see here and here.
---
 python/mxnet/gluon/block.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py
index 9772e23..41ef2cb 100644
--- a/python/mxnet/gluon/block.py
+++ b/python/mxnet/gluon/block.py
@@ -1238,8 +1238,11 @@ class HybridBlock(Block):
                 if name in arg_names:
                     arg_dict['arg:{}'.format(name)] = param._reduce()
                 else:
-                    assert name in aux_names
-                    arg_dict['aux:{}'.format(name)] = param._reduce()
+                    if name not in aux_names:
+                        warnings.warn('Parameter "{name}" is not found in the graph. '
+                                      .format(name=name), stacklevel=3)
+                    else:
+                        arg_dict['aux:%s'%name] = param._reduce()
         save_fn = _mx_npx.save if is_np_array() else ndarray.save
         save_fn('%s-%04d.params'%(path, epoch), arg_dict)