diff --git a/python/oneflow/nn/modules/constant.py b/python/oneflow/nn/modules/constant.py index cd135894cbd..c2ac7762344 100644 --- a/python/oneflow/nn/modules/constant.py +++ b/python/oneflow/nn/modules/constant.py @@ -44,8 +44,8 @@ def __init__( self.device = flow.device(self.device) self.requires_grad = requires_grad size = _single(size) - assert ( - all(s >= 0 for s in size) + assert all( + s >= 0 for s in size ), f"Trying to create tensor with negative dimension: {size}" if dtype is None: dtype = flow.get_default_dtype()