Skip to content

Commit

Permalink
Merge branch 'develop' into doc-standard
Browse files Browse the repository at this point in the history
  • Loading branch information
samjwu committed Dec 5, 2023
2 parents cb6563d + e3e0054 commit 5907abd
Show file tree
Hide file tree
Showing 25 changed files with 396 additions and 616 deletions.
12 changes: 11 additions & 1 deletion docs/dev/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,36 @@ shape
-----

.. doxygenstruct:: migraphx::internal::shape
:members:
:undoc-members:

literal
-------

.. doxygenstruct:: migraphx::internal::literal
:members:
:undoc-members:

argument
--------

.. doxygenstruct:: migraphx::internal::argument
:members:
:undoc-members:

raw_data
--------

.. doxygenstruct:: migraphx::internal::raw_data
:members:
:undoc-members:

.. doxygenfunction:: migraphx::internal::visit_all
.. doxygenfunction:: template<class T, class ...Ts> auto migraphx::internal::visit_all(T &&x, Ts&&... xs)


tensor_view
-----------

.. doxygenstruct:: migraphx::internal::tensor_view
:members:
:undoc-members:
30 changes: 15 additions & 15 deletions docs/dev/dev_intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Directions for building MIGraphX from source can be found in the main README fil
Adding Two Literals
--------------------

A program is a collection of modules, which are collections of instructions to be executed when calling `eval <migraphx::program::eval>`.
Each instruction has an associated `operation <migraphx::operation>` which represents the computation to be performed by the instruction.
A program is a collection of modules, which are collections of instructions to be executed when calling :cpp:any:`eval <migraphx::internal::program::eval>`.
Each instruction has an associated :cpp:any:`operation <migraphx::internal::operation>` which represents the computation to be performed by the instruction.

We start with a snippet of the simple ``add_two_literals()`` function::

Expand All @@ -41,14 +41,14 @@ We start with a snippet of the simple ``add_two_literals()`` function::
auto result = p.eval({}).back();
std::cout << "add_two_literals: 1 + 2 = " << result << "\n";

We start by creating a simple ``migraphx::program`` object and then getting a pointer to the main module of it.
We start by creating a simple :cpp:any:`migraphx::program <migraphx::internal::program>` object and then getting a pointer to the main module of it.
The program is a collection of ``modules`` that start executing from the main module, so instructions are added to the modules rather than directly onto the program object.
We then use the `add_literal <migraphx::program::add_literal>` function to add an instruction that stores the literal number ``1`` while returning an `instruction_ref <migraphx::instruction_ref>`.
The returned `instruction_ref <migraphx::instruction_ref>` can be used in another instruction as an input.
We use the same `add_literal <migraphx::program::add_literal>` function to add a ``2`` to the program.
We then use the :cpp:any:`add_literal <migraphx::internal::program::add_literal>` function to add an instruction that stores the literal number ``1`` while returning an :cpp:any:`instruction_ref <migraphx::internal::instruction_ref>`.
The returned :cpp:any:`instruction_ref <migraphx::internal::instruction_ref>` can be used in another instruction as an input.
We use the same :cpp:any:`add_literal <migraphx::internal::program::add_literal>` function to add a ``2`` to the program.
After creating the literals, we then create the instruction to add the numbers together.
This is done by using the `add_instruction <migraphx::program::add_instruction>` function with the ``"add"`` `operation <migraphx::program::operation>` created by `make_op <migraphx::program::make_op>` along with the previous `add_literal` `instruction_ref <migraphx::instruction_ref>` for the input arguments of the instruction.
Finally, we can run this `program <migraphx::program>` by compiling it for the reference target (CPU) and then running it with `eval <migraphx::program::eval>`
This is done by using the :cpp:any:`add_instruction <migraphx::internal::program::add_instruction>` function with the ``"add"`` :cpp:any:`operation <migraphx::internal::program::operation>` created by :cpp:any:`make_op <migraphx::internal::program::make_op>` along with the previous `add_literal` :cpp:any:`instruction_ref <migraphx::internal::instruction_ref>` for the input arguments of the instruction.
Finally, we can run this :cpp:any:`program <migraphx::internal::program>` by compiling it for the reference target (CPU) and then running it with :cpp:any:`eval <migraphx::internal::program::eval>`
The result is then retreived and printed to the console.

We can compile the program for the GPU as well, but the file will have to be moved to the ``test/gpu/`` directory and the correct target must be included::
Expand Down Expand Up @@ -76,8 +76,8 @@ We can modify the program to take an input parameter ``x``, as seen in the ``add
p.compile(migraphx::ref::target{});

This adds a parameter of type ``int32``, and compiles it for the CPU.
To run the program, we need to pass the parameter as a ``parameter_map`` when we call `eval <migraphx::program::eval>`.
We create the ``parameter_map`` by setting the ``x`` key to an `argument <migraphx::argument>` object with an ``int`` data type::
To run the program, we need to pass the parameter as a ``parameter_map`` when we call :cpp:any:`eval <migraphx::internal::program::eval>`.
We create the ``parameter_map`` by setting the ``x`` key to an :cpp:any:`argument <migraphx::internal::argument>` object with an ``int`` data type::

// create a parameter_map object for passing a value to the "x" parameter
std::vector<int> data = {4};
Expand All @@ -92,7 +92,7 @@ We create the ``parameter_map`` by setting the ``x`` key to an `argument <migrap
Handling Tensor Data
---------------------

In the previous examples we have only been dealing with scalars, but the `shape <migraphx::shape>` class can describe multi-dimensional tensors.
In the previous examples we have only been dealing with scalars, but the :cpp:any:`shape <migraphx::internal::shape>` class can describe multi-dimensional tensors.
For example, we can compute a simple convolution::

migraphx::program p;
Expand All @@ -109,7 +109,7 @@ For example, we can compute a simple convolution::

Here we create two parameters for both the ``input`` and ``weights``.
In the previous examples, we created simple literals, however, most programs will take data from allocated buffers (usually on the GPU).
In this case, we can create `argument <migraphx::argument>` objects directly from the pointers to the buffers::
In this case, we can create :cpp:any:`argument <migraphx::internal::argument>` objects directly from the pointers to the buffers::

// Compile the program
p.compile(migraphx::ref::target{});
Expand All @@ -133,8 +133,8 @@ In this case, we can create `argument <migraphx::argument>` objects directly fro

EXPECT(migraphx::verify::verify_rms_range(results_vector, sol));

An `argument <migraphx::argument>` can handle memory buffers from either the GPU or the CPU.
By default when running the `program <migraphx::program>`, buffers are allocated on the corresponding target.
An :cpp:any:`argument <migraphx::internal::argument>` can handle memory buffers from either the GPU or the CPU.
By default when running the :cpp:any:`program <migraphx::internal::program>`, buffers are allocated on the corresponding target.
When compiling for the CPU, the buffers by default will be allocated on the CPU.
When compiling for the GPU, the buffers by default will be allocated on the GPU.
With the option ``offload_copy=true`` set while compiling for the GPU, the buffers will be located on the CPU.
Expand All @@ -143,7 +143,7 @@ With the option ``offload_copy=true`` set while compiling for the GPU, the buffe
Importing From ONNX
--------------------

A `program <migraphx::program>` can be built directly from an onnx file using the MIGraphX ONNX parser.
A :cpp:any:`program <migraphx::internal::program>` can be built directly from an onnx file using the MIGraphX ONNX parser.
This makes it easier to use neural networks directly from other frameworks.
In this case, there is an ``parse_onnx`` function::

Expand Down
4 changes: 4 additions & 0 deletions docs/dev/operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ operation
---------

.. doxygenstruct:: migraphx::internal::operation
:members:
:undoc-members:

.. doxygenfunction:: migraphx::internal::is_context_free

Expand All @@ -14,3 +16,5 @@ operators
---------

.. doxygennamespace:: migraphx::internal::op
:members:
:undoc-members:
29 changes: 24 additions & 5 deletions docs/dev/pass.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,82 @@ pass
----

.. doxygenstruct:: migraphx::internal::pass
:members:
:undoc-members:

dead_code_elimination
---------------------

.. doxygenstruct:: migraphx::internal::dead_code_elimination
:members:
:undoc-members:

eliminate_common_subexpression
------------------------------

.. doxygenstruct:: migraphx::internal::eliminate_common_subexpression
:members:
:undoc-members:

eliminate_concat
----------------

.. doxygenstruct:: migraphx::internal::eliminate_concat
:members:
:undoc-members:

eliminate_contiguous
--------------------

.. doxygenstruct:: migraphx::internal::eliminate_contiguous
:members:
:undoc-members:

eliminate_identity
------------------

.. doxygenstruct:: migraphx::internal::eliminate_identity
:members:
:undoc-members:

eliminate_pad
-------------

.. doxygenstruct:: migraphx::internal::eliminate_pad
:members:
:undoc-members:

propagate_constant
------------------

.. doxygenstruct:: migraphx::internal::propagate_constant

rewrite_batchnorm
-----------------

.. doxygenstruct:: migraphx::internal::rewrite_batchnorm
:members:
:undoc-members:

rewrite_rnn
-----------

.. doxygenstruct:: migraphx::internal::rewrite_rnn
:members:
:undoc-members:

schedule
--------

.. doxygenstruct:: migraphx::internal::schedule
:members:
:undoc-members:

simplify_algebra
----------------

.. doxygenstruct:: migraphx::internal::simplify_algebra
:members:
:undoc-members:

simplify_reshapes
-----------------

.. doxygenstruct:: migraphx::internal::simplify_reshapes
:members:
:undoc-members:
4 changes: 4 additions & 0 deletions docs/dev/program.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ instruction
-----------

.. doxygenstruct:: migraphx::internal::instruction
:members:
:undoc-members:

instruction_ref
---------------
Expand All @@ -17,6 +19,8 @@ program
-------

.. doxygenstruct:: migraphx::internal::program
:members:
:undoc-members:

parse_onnx
----------
Expand Down
6 changes: 6 additions & 0 deletions docs/dev/targets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ target
------

.. doxygenstruct:: migraphx::internal::target
:members:
:undoc-members:

gpu::target
-----------

.. doxygenstruct:: migraphx::internal::gpu::target
:members:
:undoc-members:

cpu::target
-----------

.. doxygenstruct:: migraphx::internal::cpu::target
:members:
:undoc-members:

9 changes: 8 additions & 1 deletion docs/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ MACRO_EXPANSION = YES

OUTPUT_DIRECTORY = ../_build/doxygen

PREDEFINED = DOXYGEN
PREDEFINED = \
DOXYGEN \
MIGRAPHX_EXPORT= \
MIGRAPHX_API_EXPORT= \
MIGRAPHX_GPU_EXPORT= \
MIGRAPHX_CPU_EXPORT= \
MIGRAPHX_ONNX_EXPORT= \
MIGRAPHX_TF_EXPORT= \

PROJECT_NAME = MIGraphX

Expand Down
30 changes: 26 additions & 4 deletions docs/reference/cpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,65 @@ shape
.. doxygenenum:: migraphx_shape_datatype_t

.. doxygenstruct:: migraphx::shape
:members:
:undoc-members:

argument
--------

.. doxygenstruct:: migraphx::argument
:members:
:undoc-members:

target
------

.. doxygenstruct:: migraphx::target
:members:
:undoc-members:

program
-------

.. doxygenstruct:: migraphx::program_parameter_shapes
:members:
:undoc-members:

.. doxygenstruct:: migraphx::program_parameters
:members:
:undoc-members:

.. doxygenstruct:: migraphx_compile_options
:members:
:undoc-members:

.. doxygenstruct:: migraphx::program
:members:
:undoc-members:

quantize
--------

.. doxygenstruct:: migraphx::quantize_op_names
:members:
:undoc-members:

.. doxygenfunction:: migraphx::quantize_fp16(const program&)

.. doxygenfunction:: migraphx::quantize_fp16(const program&, const quantize_op_names&)

.. doxygenstruct:: migraphx::quantize_int8_options
:members:
:undoc-members:

.. doxygenfunction:: migraphx::quantize_int8
.. doxygenfunction::migraphx::quantize_int8
parse_onnx
----------

.. doxygenstruct:: migraphx::onnx_options
:members:
:undoc-members:

.. doxygenfunction:: migraphx::parse_onnx(const char *)

Expand All @@ -63,16 +83,18 @@ parse_onnx
load
----

.. doxygenstruct:: migraphx_file_options
.. doxygenstruct:: migraphx::file_options
:members:
:undoc-members:

.. doxygenfunction:: migraphx::load(const char *)

.. doxygenfunction:: migraphx::load(const char *, migraphx_file_options)
.. doxygenfunction:: migraphx::load(const char *, const file_options&)

save
----

.. doxygenfunction:: migraphx::save(const program&, const char *)

.. doxygenfunction:: migraphx::save(const program&, const char *, migraphx_file_options)
.. doxygenfunction:: migraphx::save(const program&, const char *, const file_options&)

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ pybind/pybind11@d159a563383d10c821ba7b2a71905d1207db6de4 --build
msgpack/[email protected] -DMSGPACK_BUILD_TESTS=Off
sqlite3@3.43.2 -DCMAKE_POSITION_INDEPENDENT_CODE=On
ROCmSoftwarePlatform/composable_kernel@70eefcf4f263aa5c25f3c9ff0db8f6f199ef0fb9 -DCK_BUILD_JIT_LIB=On -DCMAKE_POSITION_INDEPENDENT_CODE=On
ROCmSoftwarePlatform/rocMLIR@9e66e8050209f03349a41b6b497f0da2b285a53b -DBUILD_FAT_LIBROCKCOMPILER=On
ROCmSoftwarePlatform/rocMLIR@a6880f1e6daec99876cd6a4820fbc69c57216401 -DBUILD_FAT_LIBROCKCOMPILER=On
Loading

0 comments on commit 5907abd

Please sign in to comment.