Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed May 29, 2019
1 parent 3e9893d commit 1d88dae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
15 changes: 15 additions & 0 deletions python/mxnet/gluon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class requests_failed_to_import(object):
import numpy as np

from .. import ndarray
from ..util import is_np_shape

def split_data(data, num_slice, batch_axis=0, even_split=True):
"""Splits an NDArray into `num_slice` slices along `batch_axis`.
Expand Down Expand Up @@ -412,3 +413,17 @@ def __enter__(self):

def __exit__(self, ptype, value, trace):
self.detach()

def shape_is_known(shape):
"""Check whether a shape is completely known w/ or w/o np semantics."""
if shape is None:
return False
unknown_dim_size = -1 if is_np_shape() else 0
if len(shape) == 0:
return unknown_dim_size == -1
for dim_size in shape:
if dim_size == unknown_dim_size:
return False
assert dim_size > unknown_dim_size, "shape dimension size cannot be less than {}, while " \
"received {}".format(unknown_dim_size, dim_size)
return True
14 changes: 0 additions & 14 deletions python/mxnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,3 @@ def _with_np_shape(*args, **kwargs):
return func(*args, **kwargs)

return _with_np_shape

def shape_is_known(shape):
"""Check whether a shape is completely known w/ or w/o np semantics."""
if shape is None:
return False
unknown_dim_size = -1 if is_np_shape() else 0
if len(shape) == 0:
return unknown_dim_size == -1
for dim_size in shape:
if dim_size == unknown_dim_size:
return False
assert dim_size > unknown_dim_size, "shape dimension size cannot be less than {}, while " \
"received {}".format(unknown_dim_size, dim_size)
return True

0 comments on commit 1d88dae

Please sign in to comment.