diff --git a/dali/operators/random/rng_base.cc b/dali/operators/random/rng_base.cc index faa02755c4..f37170a4a0 100644 --- a/dali/operators/random/rng_base.cc +++ b/dali/operators/random/rng_base.cc @@ -24,6 +24,10 @@ It should be added as parent to all RNG operators.)code") .AddOptionalArg>("shape", R"code(Shape of the output data.)code", nullptr, true) .AddOptionalArg("dtype", - R"code(Output data type.)code", nullptr); + R"code(Output data type. + +.. note:: + The generated numbers are converted to the output data type, rounding and clamping if necessary. +)code", nullptr); } // namespace dali diff --git a/dali/operators/random/uniform_distribution_cpu.cc b/dali/operators/random/uniform_distribution_cpu.cc index 1fd89d544f..97f571fa4e 100644 --- a/dali/operators/random/uniform_distribution_cpu.cc +++ b/dali/operators/random/uniform_distribution_cpu.cc @@ -21,6 +21,10 @@ namespace dali { DALI_SCHEMA(random__Uniform) .DocStr(R"code(Generates random numbers following a uniform distribution. +It can be configured to produce a continuous uniform distribution in the ``range`` [min, max), +or a discrete uniform distribution where any of the specified ``values`` [v0, v1, ..., vn] occur +with equal probability. + The shape of the generated data can be either specified explicitly with a ``shape`` argument, or chosen to match the shape of the input, if provided. If none are present, a scalar is generated. @@ -30,10 +34,15 @@ generated. .AddOptionalArg("range", R"code(Range ``[min, max)`` of a continuous uniform distribution. -This argument is mutually exclusive with ``values``.)code", +This argument is mutually exclusive with ``values``. + +.. warning:: + When specifying an integer type as ``dtype``, the generated numbers can go outside + the specified range, due to rounding. +)code", std::vector{-1.0f, 1.0f}, true) .AddOptionalArg>("values", - R"code(The discrete values produced by a discrete uniform distribution. + R"code(The discrete values [v0, v1, ..., vn] produced by a discrete uniform distribution. This argument is mutually exclusive with ``range``.)code", nullptr, true) @@ -45,6 +54,10 @@ DALI_REGISTER_OPERATOR(random__Uniform, UniformDistribution, CPU); DALI_SCHEMA(Uniform) .DocStr(R"code(Generates random numbers following a uniform distribution. +It can be configured to produce a continuous uniform distribution in the ``range`` [min, max), +or a discrete uniform distribution where any of the specified ``values`` [v0, v1, ..., vn] occur +with equal probability. + The shape of the generated data can be either specified explicitly with a ``shape`` argument, or chosen to match the shape of the input, if provided. If none are present, a scalar is generated. @@ -54,10 +67,15 @@ generated. .AddOptionalArg("range", R"code(Range ``[min, max)`` of a continuous uniform distribution. -This argument is mutually exclusive with ``values``.)code", +This argument is mutually exclusive with ``values``. + +.. warning:: + When specifying an integer type as ``dtype``, the generated numbers can go outside + the specified range, due to rounding. +)code", std::vector{-1.0f, 1.0f}, true) .AddOptionalArg>("values", - R"code(The discrete values produced by a discrete uniform distribution. + R"code(The discrete values [v0, v1, ..., vn] produced by a discrete uniform distribution. This argument is mutually exclusive with ``range``.)code", nullptr, true)