fix the set dtype bug of uniform_random op,support set the dtype

fix the bug in inferVartype in the uniform_random op, add the support the set of dtype
revert-22778-infer_var_type
Zhong Hui 6 years ago committed by GitHub
parent 6bf26ef156
commit 9ec9fc0f36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14322,7 +14322,7 @@ def uniform_random(shape, dtype='float32', min=-1.0, max=1.0, seed=0):
helper = LayerHelper("uniform_random", **locals())
inputs = dict()
attrs = {'seed': seed, 'min': min, 'max': max}
attrs = {'seed': seed, 'min': min, 'max': max, 'dtype': dtype}
if in_dygraph_mode():
attrs['shape'] = shape
else:

@ -190,6 +190,12 @@ class TestUniformRandomOpError(unittest.TestCase):
self.assertRaises(TypeError, test_dtype)
def test_out_dtype():
out = fluid.layers.uniform_random(shape=[3, 4], dtype='float64')
self.assertEqual(out.dtype, fluid.core.VarDesc.VarType.FP64)
test_out_dtype()
class TestUniformRandomOpWithDiagInit(TestUniformRandomOp):
def init_attrs(self):

Loading…
Cancel
Save