Skip to content

Commit

Permalink
Add support for UINT Generation (#695)
Browse files Browse the repository at this point in the history
Support for integer random number generation
  • Loading branch information
tylera-nvidia authored Aug 13, 2024
1 parent 159a0ce commit c879d5d
Show file tree
Hide file tree
Showing 3 changed files with 377 additions and 344 deletions.
28 changes: 19 additions & 9 deletions docs_input/api/random/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
Random Number Generation
########################

MatX provides the capability to generate random numbers on the host and device using the ``random()`` operator. ``random()``
uses cuRAND on the device to generate random numbers from device code.
MatX provides the capability to generate random numbers on the host and device using the ``random()`` and ``randomi()``
operators. both host and device generation is supported through the cuRAND library.


- ``random()`` only generates random distribution for *float* data types
- ``randomi()`` only generates random disitrubtions for *integral* data types

Please see the documentation for each function for a full list of supported types

Currently `random` only works on 32 and 64-bit floating point types for both real and complex.

.. note::
randomGenerator_t has been deprecated after release 0.5.0. Please use the ``random()`` operator instead

.. doxygenfunction:: matx::random(ShapeType &&s, Distribution_t dist, uint64_t seed = 0, LowerType alpha = 1, LowerType beta = 0)
.. doxygenfunction:: matx::random(const index_t (&s)[RANK], Distribution_t dist, uint64_t seed = 0, LowerType alpha = 1, LowerType beta = 0)
.. doxygenfunction:: matx::random(ShapeType &&s, Distribution_t dist, uint64_t seed = 0,LowerType alpha = 1, LowerType beta = 0)
.. doxygenfunction:: matx::random(const index_t (&s)[RANK], Distribution_t dist, uint64_t seed = 0,LowerType alpha = 1, LowerType beta = 0)
.. doxygenfunction:: matx::randomi(ShapeType &&s, uint64_t seed = 0, LowerType min = 0, LowerType max = 100)
.. doxygenfunction:: matx::randomi(const index_t (&s)[RANK], uint64_t seed = 0, LowerType min = 0, LowerType max = 100)

Examples
~~~~~~~~
Expand All @@ -22,3 +25,10 @@ Examples
:start-after: example-begin random-test-1
:end-before: example-end random-test-1
:dedent:


.. literalinclude:: ../../../test/00_tensor/ViewTests.cu
:language: cpp
:start-after: example-begin randomi-test-1
:end-before: example-end randomi-test-1
:dedent:
Loading

0 comments on commit c879d5d

Please sign in to comment.