diff --git a/dnn/scripts/opr_param_defs.py b/dnn/scripts/opr_param_defs.py index 38dfe14b053fa858e0a48bfc2e22939809da3a9e..f1aa516c10cce4fab3a580f9ef039c6976d05d11 100755 --- a/dnn/scripts/opr_param_defs.py +++ b/dnn/scripts/opr_param_defs.py @@ -745,13 +745,20 @@ pdef('Sleep').add_fields('float32', Doc('time', 'time to sleep in seconds'), 0) 'dtype', Doc('dtype', 'data type of output value'), 'DTypeEnum::Float32')) -(pdef('UniformRNG'). +(pdef('UniformRNG', version=0, is_legacy=True). + add_fields('uint64', 'seed', 0)) + +(pdef('UniformRNG', version=1). add_fields('uint64', 'seed', 0). add_fields( 'dtype', Doc('dtype', 'The dtype of output Tensor. Only support Float32.'), 'DTypeEnum::Float32')) -(pdef('GaussianRNG'). +(pdef('GaussianRNG', version=0, is_legacy=True). + add_fields('uint64', 'seed', 0). + add_fields('float32', 'mean', 0, 'std', 1)) + +(pdef('GaussianRNG', version=1). add_fields('uint64', 'seed', 0). add_fields('float32', 'mean', 0, 'std', 1). add_fields( diff --git a/src/opr/impl/rand.oprdecl b/src/opr/impl/rand.oprdecl index 860095c188f811b6c3e3d17f3cefaed9ceb51b75..763fcd1f60e3004fe4cad0dace4ba87c12de40a6 100644 --- a/src/opr/impl/rand.oprdecl +++ b/src/opr/impl/rand.oprdecl @@ -1,12 +1,12 @@ decl_opr('UniformRNG', pyname='_uniform_rng', inputs=['shape'], params='UniformRNG', - canonize_input_vars='canonize_shape_input') + canonize_input_vars='canonize_shape_input', version=1) decl_opr('GaussianRNG', pyname='_gaussian_rng', inputs=['shape'], params='GaussianRNG', - canonize_input_vars='canonize_shape_input') + canonize_input_vars='canonize_shape_input', version=1) inputs = [ Doc('shape', diff --git a/src/opr/impl/rand.sereg.h b/src/opr/impl/rand.sereg.h index 315b6975631a8b7d380b32f2b7439b3ba2c21b0a..8c5c6c22abea01bea281578bae6548ffcac34f4f 100644 --- a/src/opr/impl/rand.sereg.h +++ b/src/opr/impl/rand.sereg.h @@ -13,18 +13,21 @@ #include "megbrain/serialization/sereg.h" namespace mgb { + + namespace opr { - MGB_SEREG_OPR(UniformRNG, 1); - MGB_SEREG_OPR(GaussianRNG, 1); - MGB_SEREG_OPR(GammaRNG, 2); - MGB_SEREG_OPR(PoissonRNG, 1); - MGB_SEREG_OPR(PermutationRNG, 1); - MGB_SEREG_OPR(BetaRNG, 2); +using UniformRNGV1 = opr::UniformRNG; +MGB_SEREG_OPR(UniformRNGV1, 1); +using GaussianRNGV1 = opr::GaussianRNG; +MGB_SEREG_OPR(GaussianRNGV1, 1); +MGB_SEREG_OPR(GammaRNG, 2); +MGB_SEREG_OPR(PoissonRNG, 1); +MGB_SEREG_OPR(PermutationRNG, 1); +MGB_SEREG_OPR(BetaRNG, 2); } // namespace opr } // namespace mgb - // vim: ft=cpp syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}