|
5 | 5 | .. _contributing-to-migraphx: |
6 | 6 |
|
7 | 7 | ========================== |
8 | | -Contributing to MIGraphX |
| 8 | +Developing for MIGraphX |
9 | 9 | ========================== |
10 | 10 |
|
11 | | -This document explains the internal implementation of some commonly used MIGraphX APIs. You can utilize the information provided in this document and other documents under "Contributing to MIGraphX" section to contribute to the MIGraphX API implementation. |
12 | | -Here is how some basic operations in the MIGraphX framework are performed. |
| 11 | +This document is intended for anyone who wants to contribute to MIGraphX. This document covers some basic operations that can be used to develop for MIGraphX. The complete source code for the example shown here can be found at `ref_dev_examples.cpp <https://github.com/ROCm/AMDMIGraphX/blob/develop/test/ref_dev_examples.cpp>`_ on the MIGraphX repository. |
13 | 12 |
|
14 | | -Performing basic operations |
| 13 | +More examples can be found on `the MIGraphX GitHub repository <https://github.com/ROCmSoftwarePlatform/AMDMIGraphX/tree/develop/examples/migraphx>`_. |
| 14 | + |
| 15 | + |
| 16 | +Adding two literals |
15 | 17 | ---------------------------- |
16 | 18 |
|
17 | 19 | A program is a collection of modules, which are collections of instructions to be executed when calling :cpp:any:`eval <migraphx::internal::program::eval>`. |
18 | 20 | Each instruction has an associated :cpp:any:`operation <migraphx::internal::operation>` which represents the computation to be performed by the instruction. |
19 | 21 |
|
20 | | -The following code snippets demonstrate some basic operations using MIGraphX. |
21 | | - |
22 | | -Adding literals |
23 | | -****************** |
| 22 | +We start with a snippet of the simple ``add_two_literals()`` function:: |
24 | 23 |
|
25 | | -Here is a ``add_two_literals()`` function:: |
26 | 24 |
|
27 | 25 | // create the program and get a pointer to the main module |
28 | 26 | migraphx::program p; |
@@ -55,7 +53,7 @@ To compile the program for the GPU, move the file to ``test/gpu/`` directory and |
55 | 53 | #include <migraphx/gpu/target.hpp> |
56 | 54 |
|
57 | 55 | Adding Parameters |
58 | | -******************* |
| 56 | +---------------------------- |
59 | 57 |
|
60 | 58 | While the ``add_two_literals()`` function above demonstrates add operation on constant values ``1`` and ``2``, |
61 | 59 | the following program demonstrates how to pass a parameter (``x``) to a module using ``add_parameter()`` function . |
@@ -86,7 +84,7 @@ To map the parameter ``x`` to an :cpp:any:`argument <migraphx::internal::argumen |
86 | 84 | EXPECT(result.at<int>() == 6); |
87 | 85 |
|
88 | 86 | Handling Tensor Data |
89 | | -********************** |
| 87 | +---------------------------- |
90 | 88 |
|
91 | 89 | The above two examples demonstrate scalar operations. To describe multi-dimensional tensors, use the :cpp:any:`shape <migraphx::internal::shape>` class to compute a simple convolution as shown below:: |
92 | 90 |
|
@@ -132,30 +130,24 @@ By default, the buffers are allocated on the CPU when compiling for CPU and on t |
132 | 130 | To locate the buffers on the CPU even when compiling for GPU, set the option ``offload_copy=true``. |
133 | 131 |
|
134 | 132 | Importing From ONNX |
135 | | -********************** |
| 133 | +---------------------------- |
136 | 134 |
|
137 | 135 | To make it convenient to use neural networks directly from other frameworks, MIGraphX ONNX parser allows you to build a :cpp:any:`program <migraphx::internal::program>` directly from an ONNX file. |
138 | 136 | For usage, refer to the ``parse_onnx()`` function below:: |
139 | 137 |
|
140 | 138 | program p = migraphx::parse_onnx("model.onnx"); |
141 | 139 | p.compile(migraphx::gpu::target{}); |
142 | 140 |
|
143 | | -Sample programs |
144 | | ------------------ |
145 | | - |
146 | | -You can find all the MIGraphX examples in the `Examples <https://github.com/ROCmSoftwarePlatform/AMDMIGraphX/tree/develop/examples/migraphx>`_ directory. |
147 | 141 |
|
148 | | -Build MIGraphX source code |
149 | | -**************************** |
| 142 | +Build this example |
| 143 | +---------------------------- |
150 | 144 |
|
151 | | -To build a sample program `ref_dev_examples.cpp <https://github.com/ROCm/AMDMIGraphX/blob/develop/test/ref_dev_examples.cpp>`_, use: |
| 145 | +Build the `ref_dev_examples.cpp <https://github.com/ROCm/AMDMIGraphX/blob/develop/test/ref_dev_examples.cpp>`_ example with this command: |
152 | 146 |
|
153 | 147 | make -j$(nproc) test_ref_dev_examples |
154 | 148 |
|
155 | | -This creates an executable file ``test_ref_dev_examples`` in the ``bin/`` of the build directory. |
| 149 | +This creates the ``test_ref_dev_examples`` under ``bin/`` in the build directory. |
156 | 150 |
|
157 | 151 | To verify the build, use: |
158 | 152 |
|
159 | 153 | make -j$(nproc) check |
160 | | - |
161 | | -For detailed instructions on building MIGraphX from source, refer to the `README <https://github.com/ROCm/AMDMIGraphX#readme>`_ file. |
0 commit comments