Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
2fc6b715
Commit
2fc6b715
authored
Apr 14, 2023
by
Paul
Browse files
Merge
parents
5967d68d
118e05c7
Changes
177
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
172 additions
and
95 deletions
+172
-95
.github/workflows/ci.yaml
.github/workflows/ci.yaml
+18
-20
.github/workflows/history.yaml
.github/workflows/history.yaml
+5
-0
.github/workflows/performance.yaml
.github/workflows/performance.yaml
+5
-0
.github/workflows/sync-onnxrt-main.yaml
.github/workflows/sync-onnxrt-main.yaml
+41
-35
CMakeLists.txt
CMakeLists.txt
+6
-2
Dockerfile
Dockerfile
+1
-1
Jenkinsfile
Jenkinsfile
+6
-4
doc/src/driver/compile.rst
doc/src/driver/compile.rst
+4
-0
doc/src/driver/read.rst
doc/src/driver/read.rst
+9
-1
examples/migraphx/cpp_parse_load_save/CMakeLists.txt
examples/migraphx/cpp_parse_load_save/CMakeLists.txt
+1
-1
examples/migraphx/custom_op_miopen_kernel/CMakeLists.txt
examples/migraphx/custom_op_miopen_kernel/CMakeLists.txt
+1
-1
examples/migraphx/custom_op_rocblas_kernel/CMakeLists.txt
examples/migraphx/custom_op_rocblas_kernel/CMakeLists.txt
+1
-1
examples/migraphx/migraphx_driver/README.md
examples/migraphx/migraphx_driver/README.md
+13
-9
examples/vision/cpp_mnist/CMakeLists.txt
examples/vision/cpp_mnist/CMakeLists.txt
+1
-1
src/CMakeLists.txt
src/CMakeLists.txt
+8
-1
src/api/CMakeLists.txt
src/api/CMakeLists.txt
+5
-2
src/api/api.cpp
src/api/api.cpp
+0
-1
src/common.cpp
src/common.cpp
+18
-7
src/cpp_generator.cpp
src/cpp_generator.cpp
+28
-8
src/driver/CMakeLists.txt
src/driver/CMakeLists.txt
+1
-0
No files found.
.github/workflows/ci.yaml
View file @
2fc6b715
...
...
@@ -39,10 +39,8 @@ jobs:
-
name
:
Prepare timestamp
id
:
cache_timestamp
shell
:
cmake -P {0}
run
:
|
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
shell
:
bash
run
:
echo timestamp="$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
-
name
:
Cache files for tidy
uses
:
pat-s/always-upload-cache@v3.0.11
...
...
@@ -65,6 +63,7 @@ jobs:
-DMIGRAPHX_ENABLE_GPU=On \
-DMIGRAPHX_ENABLE_CPU=On \
-DMIGRAPHX_ENABLE_FPGA=On \
-DBUILD_DEV=On \
-DROCM_ENABLE_GH_ANNOTATIONS=On \
-DCLANG_TIDY_DEPEND_ON_TARGET=Off \
-DCLANG_TIDY_CACHE=/data/tidy-cache \
...
...
@@ -88,10 +87,8 @@ jobs:
-
name
:
Prepare timestamp
id
:
cache_timestamp
shell
:
cmake -P {0}
run
:
|
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
shell
:
bash
run
:
echo timestamp="$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
-
name
:
Cache files for cppcheck
uses
:
pat-s/always-upload-cache@v2.1.3
...
...
@@ -112,6 +109,7 @@ jobs:
cd build
CXX=/opt/rocm/llvm/bin/clang++ CC=/opt/rocm/llvm/bin/clang cmake \
-DCPPCHECK_BUILD_DIR=/data/cppcheck-cache \
-DBUILD_DEV=On \
-DROCM_ENABLE_GH_ANNOTATIONS=On \
..
make -j2 cppcheck
...
...
@@ -233,12 +231,11 @@ jobs:
python -m pip install --upgrade pip
pip install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
rbuild prepare -d cget -s gh
sudo apt-get install -y lld
-
name
:
Prepare timestamp
id
:
cache_timestamp
shell
:
cmake -P {0}
run
:
|
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
shell
:
bash
run
:
echo timestamp="$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
-
name
:
Cache files for ccache
# Ignore the failure of a step and avoid terminating the job.
...
...
@@ -262,10 +259,11 @@ jobs:
rbuild build -d cget -s gh -T check \
-DCMAKE_BUILD_TYPE=${{matrix.configuration}} \
-DMIGRAPHX_ENABLE_PYTHON=${{matrix.configuration == 'release' && 'On' || 'Off'}} \
-DBUILD_DEV=On \
-DCMAKE_CXX_FLAGS_DEBUG="-g1 -Os -fdebug-prefix-map=$PWD=. -fdebug-types-section -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=undefined" \
-DCMAKE_CXX_FLAGS_CODECOV="-g1 -Og -fdebug-prefix-map=$PWD=. -fdebug-types-section -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer" \
-DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=
go
ld' \
-DCMAKE_SHARED_LINKER_FLAGS='-fuse-ld=
go
ld'
-DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=
l
ld' \
-DCMAKE_SHARED_LINKER_FLAGS='-fuse-ld=
l
ld'
${{ github.workspace }}/cget/bin/ccache -s
-
name
:
Upload code coverage
...
...
@@ -329,12 +327,11 @@ jobs:
python -m pip install --upgrade pip
pip install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
rbuild prepare -d cget -s gh
sudo apt-get install -y lld
-
name
:
Prepare timestamp
id
:
cache_timestamp
shell
:
cmake -P {0}
run
:
|
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
shell
:
bash
run
:
echo timestamp="$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
-
name
:
Cache files for ccache
# Ignore the failure of a step and avoid terminating the job.
...
...
@@ -358,10 +355,11 @@ jobs:
rbuild build -d cget -s gh -T check \
-DCMAKE_BUILD_TYPE=${{matrix.configuration}} \
-DMIGRAPHX_ENABLE_PYTHON=${{matrix.configuration == 'release' && 'On' || 'Off'}} \
-DBUILD_DEV=On \
-DCMAKE_CXX_FLAGS_DEBUG="-g1 -Os -fdebug-prefix-map=$PWD=. -fdebug-types-section -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=undefined" \
-DCMAKE_CXX_FLAGS_CODECOV="-g1 -Og -fdebug-prefix-map=$PWD=. -fdebug-types-section -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer" \
-DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=
go
ld' \
-DCMAKE_SHARED_LINKER_FLAGS='-fuse-ld=
go
ld' \
-DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=
l
ld' \
-DCMAKE_SHARED_LINKER_FLAGS='-fuse-ld=
l
ld' \
-DMIGRAPHX_ENABLE_FPGA=On
${{ github.workspace }}/cget/bin/ccache -s
...
...
.github/workflows/history.yaml
View file @
2fc6b715
...
...
@@ -20,6 +20,10 @@ on:
description
:
Repository where benchmark utils are stored
required
:
true
default
:
"
ROCmSoftwarePlatform/migraphx-benchmark-utils"
organization
:
description
:
Organization based on which location of files will be different
required
:
true
default
:
"
AMD"
jobs
:
release
:
...
...
@@ -29,6 +33,7 @@ jobs:
end_date
:
${{ github.event.inputs.end_date || 'yyyy-mm-dd' }}
history_repo
:
${{ github.event.inputs.history_repo || 'ROCmSoftwarePlatform/migraphx-reports' }}
benchmark_utils_repo
:
${{ github.event.inputs.benchmark_utils_repo || 'ROCmSoftwarePlatform/migraphx-benchmark-utils' }}
organization
:
${{ github.event.inputs.organization || 'AMD' }}
secrets
:
gh_token
:
${{ secrets.MIGRAPHX_BOT_TOKEN }}
mail_user
:
${{ secrets.MAIL_USERNAME }}
...
...
.github/workflows/performance.yaml
View file @
2fc6b715
...
...
@@ -29,6 +29,10 @@ on:
description
:
Last N results
required
:
true
default
:
'
10'
model_timeout
:
description
:
If model in performance test script passes this threshold, it will be skipped
required
:
true
default
:
'
30m'
flags
:
description
:
-m for Max value; -s for Std dev; -r for Threshold file
required
:
true
...
...
@@ -46,6 +50,7 @@ jobs:
performance_reports_repo
:
${{ github.event.inputs.performance_reports_repo || 'ROCmSoftwarePlatform/migraphx-reports' }}
benchmark_utils_repo
:
${{ github.event.inputs.benchmark_utils_repo || 'ROCmSoftwarePlatform/migraphx-benchmark-utils' }}
organization
:
${{ github.event.inputs.organization || 'AMD' }}
model_timeout
:
${{ github.event.inputs.model_timeout || '30m' }}
secrets
:
gh_token
:
${{ secrets.MIGRAPHX_BOT_TOKEN }}
mail_user
:
${{ secrets.MAIL_USERNAME }}
...
...
.github/workflows/sync-onnxrt-main.yaml
View file @
2fc6b715
name
:
Onnxruntime main weekly sync
on
:
schedule
:
-
cron
:
"
05
17
*
*
1"
-
cron
:
'
07
17
*
*
5'
jobs
:
createPullRequest
:
name
:
Update and create pull request
runs-on
:
ubuntu-latest
sync
:
steps
:
-
name
:
get_date
run
:
echo todays_date="$(date +'%Y-%m-%d')" >> $GITHUB_ENV
-
name
:
extract_sha1
run
:
echo onnxsha="$(git ls-remote https://github.com/microsoft/onnxruntime.git HEAD | awk '{print $1}')" >> $GITHUB_ENV
-
name
:
echo_sha1
run
:
echo ${{ env.onnxsha }}
-
uses
:
actions/checkout@v3
with
:
ref
:
develop
path
:
../
get_date
:
steps
:
-
run
:
echo "::set-output name=date::$(date +'%Y-%m-%d')"
update_file
:
needs
:
[
sync get_date
]
steps
:
-
run
:
git clone https://github.com/microsoft/onnxruntime.git && cd onnxruntime && git rev-parse HEAD >> ../test/onnx/.onnxrt-commit
-
name
:
update_file
run
:
echo ${{ env.onnxsha }} > test/onnx/.onnxrt-commit
Add_commit
:
needs
:
update_file
steps
:
-
name
:
Add & Commit
uses
:
EndBug/add-and-commit@v9.1.1
-
name
:
Make changes to pull request
uses
:
peter-evans/create-pull-request@v4
with
:
new_branch
:
onnxruntime-sync-${{ steps.date.outputs.date }}
add
:
../test/onnx/.onnxrt-commit
message
:
Update Onnxruntime commit to latest release
default_author
:
github_actions
push
:
true
PR
:
needs
:
Add_commit
steps
:
-
name
:
GitHub Action for creating Pull Requests
uses
:
devops-infra/action-pull-request@v0.5.3
with
:
github_token
:
${{ secrets.GITHUB_TOKEN }}
title
:
Sync Onnxruntime main
reviewer
:
pfultz2, causten
assignee
:
TedThemistokleous
label
:
automatic, onnxruntime
target_branch
:
develop
token
:
${{ secrets.GITHUB_TOKEN }}
commit-message
:
Update onnxruntime main ${{ env.onnxsha }}
committer
:
Github <noreply@github.com>
author
:
${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff
:
false
branch
:
onnxruntime-sync-${{ env.todays_date }}
delete-branch
:
true
title
:
'
Onnxruntime
Weekly
Sync
${{
env.todays_date
}}'
body
:
|
Update CI point for Onnxruntime builds
- Updated with changes from ${{ env.todays_date }}
- Auto-generated by [create-pull-request][1]
- Update .onnxrt-commit to ${{ env.onnxsha }}
[1]: https://github.com/peter-evans/create-pull-request
labels
:
|
onnxruntime
dependancies
automated
assignees
:
TedThemistokleous
reviewers
:
TedThemistokleous causten
draft
:
false
base
:
develop
\ No newline at end of file
CMakeLists.txt
View file @
2fc6b715
...
...
@@ -46,6 +46,8 @@ else()
set
(
CMAKE_INSTALL_PREFIX
"/opt/rocm"
CACHE PATH
""
)
endif
()
set
(
CMAKE_BUILD_RPATH
"
${
CMAKE_BINARY_DIR
}
/lib"
)
project
(
migraphx
)
find_package
(
ROCM REQUIRED
)
...
...
@@ -65,8 +67,10 @@ set(CMAKE_EXTRA_INCLUDE_FILES)
include
(
ROCMSetupVersion
)
rocm_setup_version
(
VERSION 2.6
)
set
(
MIGRAPHX_SO_VERSION
${
PROJECT_VERSION_MAJOR
}
.
${
PROJECT_VERSION_MINOR
}
)
option
(
BUILD_DEV
"Build for development purpose only"
OFF
)
rocm_setup_version
(
VERSION 2.6.0
)
set
(
MIGRAPHX_SO_VERSION
${
PROJECT_VERSION_MAJOR
}
.
${
PROJECT_VERSION_MINOR
}
.
${
PROJECT_VERSION_PATCH
}
)
option
(
BUILD_SHARED_LIBS
"Build as a shared library"
ON
)
...
...
Dockerfile
View file @
2fc6b715
...
...
@@ -110,7 +110,7 @@ RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXR
ADD
tools/build_and_test_onnxrt.sh /onnxruntime/build_and_test_onnxrt.sh
RUN
cget
-p
/usr/local
install
ROCmSoftwarePlatform/rocMLIR@
78b706fe9879587ab98b6614ae539265374a3fa
e
-DBUILD_MIXR_TARGET
=
On
-DLLVM_ENABLE_ZSTD
=
Off
-DLLVM_ENABLE_THREADS
=
Off
RUN
cget
-p
/usr/local
install
ROCmSoftwarePlatform/rocMLIR@
acb727b348086b58a7f261b32c0e4f0686a4c0e
e
-DBUILD_MIXR_TARGET
=
On
-DLLVM_ENABLE_ZSTD
=
Off
-DLLVM_ENABLE_THREADS
=
Off
ENV
MIOPEN_FIND_DB_PATH=/tmp/miopen/find-db
ENV
MIOPEN_USER_DB_PATH=/tmp/miopen/user-db
...
...
Jenkinsfile
View file @
2fc6b715
...
...
@@ -28,7 +28,7 @@ def rocmtestnode(Map conf) {
rm -rf build
mkdir build
cd build
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ${flags} ..
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DBUILD_DEV=On
${flags} ..
make -j\$(nproc) generate all doc package check VERBOSE=1
"""
echo
cmd
...
...
@@ -116,10 +116,12 @@ rocmtest clang_debug: rocmnode('vega') { cmake_build ->
}
},
mlir_debug:
rocmnode
(
'vega'
)
{
cmake_build
->
stage
(
'MLIR Debug'
)
{
withEnv
([
'MIGRAPHX_ENABLE_MLIR=1'
])
{
def
sanitizers
=
"undefined"
def
debug_flags
=
"-g -O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build
(
flags:
"-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_MLIR=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}'"
)
}
}
},
clang_asan:
rocmnode
(
'nogpu'
)
{
cmake_build
->
stage
(
'Clang ASAN'
)
{
def
sanitizers
=
"undefined,address"
...
...
doc/src/driver/compile.rst
View file @
2fc6b715
...
...
@@ -32,6 +32,10 @@ Disable fast math optimization
Perform an exhaustive search to find the fastest version of generated kernels for selected backend
.. options:: --split-single-dyn-dim
Enable the split single dynamic dimension pass
.. option:: --fp16
Quantize for fp16
...
...
doc/src/driver/read.rst
View file @
2fc6b715
...
...
@@ -24,7 +24,7 @@ Load as MIGraphX JSON
.. option:: --batch [unsigned int] (Default: 1)
Set batch size for model
For a static model, set batch size. For a dynamic batch model, sets the batch size at runtime.
.. option:: --nhwc
...
...
@@ -46,6 +46,14 @@ Trim instructions from the end (Default: 0)
Dim of a parameter (format: "@name d1 d2 dn")
.. options:: --dyn-input-dim [std::vector<std::string>]
Set dynamic dimensions of a parameter using JSON formatting (format "@name" "dynamic_dimension_json")
.. options:: --default-dyn-dim
Set the default dynamic dimension (format {min:x, max:y, optimals:[o1,o2,...]})
.. option:: --optimize, -O
Optimize when reading
...
...
examples/migraphx/cpp_parse_load_save/CMakeLists.txt
View file @
2fc6b715
...
...
@@ -27,7 +27,7 @@ project (PLS)
set
(
CMAKE_CXX_STANDARD 14
)
set
(
EXAMPLE parse_load_save
)
list
(
APPEND CMAKE_PREFIX_PATH
/opt/rocm/hip
/opt/rocm
)
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm
)
find_package
(
migraphx
)
message
(
"source file: "
${
EXAMPLE
}
.cpp
" ---> bin: "
${
EXAMPLE
}
)
...
...
examples/migraphx/custom_op_miopen_kernel/CMakeLists.txt
View file @
2fc6b715
...
...
@@ -27,7 +27,7 @@ project (custom_miopen_kernel)
set
(
CMAKE_CXX_STANDARD 14
)
set
(
EXAMPLE custom_op_miopen_kernel
)
list
(
APPEND CMAKE_PREFIX_PATH
/opt/rocm/hip
/opt/rocm
)
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm
)
find_package
(
migraphx REQUIRED
)
find_package
(
miopen REQUIRED
)
...
...
examples/migraphx/custom_op_rocblas_kernel/CMakeLists.txt
View file @
2fc6b715
...
...
@@ -28,7 +28,7 @@ set (CMAKE_CXX_STANDARD 14)
set
(
EXAMPLE custom_op_rocblas_kernel
)
list
(
APPEND CMAKE_PREFIX_PATH
/opt/rocm/hip
/opt/rocm
)
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm
)
find_package
(
migraphx REQUIRED
)
find_package
(
rocblas REQUIRED
)
...
...
examples/migraphx/migraphx_driver/README.md
View file @
2fc6b715
...
...
@@ -29,7 +29,7 @@ See below for a comprehensive list of commands and option arguments, as well as
| --tf | Load file as a tensorflow graph |
| --migraphx | Load file as a migraphx graph |
| --migraphx-json | Load file as a migraphx JSON graph |
| --batch |
Set batch size for the model
|
| --batch |
For a static model, set batch size. For a dynamic batch model, sets the batch size at runtime.
|
| --nhwc | Treat tensorflow format as nhwc |
| --nchw | Treat tensorflow format as nchw |
| --skip-unknown-operators | Skip unknown operators when parsing and continue to parse |
...
...
@@ -44,12 +44,16 @@ See below for a comprehensive list of commands and option arguments, as well as
| --output
\|
-o | Output to file |
| --fill0 | Fill parameter with 0s |
| --fill1 | Fill parameter with 1s |
| --input-dim | Set static dimensions of a parameter |
| --dyn-input-dim | Set dynamic dimensions of a parameter |
| --default-dyn-dim | Set default dynamic dimension |
| --gpu | Compile on the gpu |
| --cpu | Compile on the cpu |
| --ref | Compile on the reference implementation |
| --enable-offload-copy | Enable implicit offload copying |
| --disable-fast-math | Disable fast math optimization |
| --exhaustive-tune | Enable exhaustive search to find fastest kernel |
| --split-single-dyn-dim | Enable split_single_dyn_dim compiler pass |
| --fp16 | Quantize for fp16 |
| --int8 | Quantize for int8 |
| --tolerance | Tolerance for errors |
...
...
@@ -88,7 +92,7 @@ batch_norm_inference
broadcast
capture
ceil
check_context::migraphx::
version_1::
gpu::context
check_context::migraphx::gpu::context
clip
concat
contiguous
...
...
@@ -304,7 +308,7 @@ $ /opt/rocm/bin/migraphx-driver run --onnx simple_graph.onnx
```
Compiling ...
Reading: simple_graph.onnx
@0 = check_context::migraphx::
version_1::
gpu::context -> float_type, {}, {}
@0 = check_context::migraphx::gpu::context -> float_type, {}, {}
@1 = hip::hip_allocate_memory[shape=float_type, {256}, {1},id=scratch] -> float_type, {256}, {1}
@2 = hip::hip_copy_literal[id=@literal:1] -> float_type, {784, 128}, {128, 1}
x:0 = @param:x:0 -> float_type, {1, 28, 28}, {784, 28, 1}
...
...
@@ -327,7 +331,7 @@ x:0 = @param:x:0 -> float_type, {1, 28, 28}, {784, 28, 1}
@18 = @return(@17)
Allocating params ...
@0 = check_context::migraphx::
version_1::
gpu::context -> float_type, {}, {}
@0 = check_context::migraphx::gpu::context -> float_type, {}, {}
@1 = hip::hip_allocate_memory[shape=float_type, {256}, {1},id=scratch] -> float_type, {256}, {1}
@2 = hip::hip_copy_literal[id=@literal:1] -> float_type, {784, 128}, {128, 1}
x:0 = @param:x:0 -> float_type, {1, 28, 28}, {784, 28, 1}
...
...
@@ -399,7 +403,7 @@ $ /opt/rocm/bin/migraphx-driver compile --gpu --fp16 simple_graph.pb
```
Compiling ...
Reading: simple_graph.pb
@0 = check_context::migraphx::
version_1::
gpu::context -> float_type, {}, {}
@0 = check_context::migraphx::gpu::context -> float_type, {}, {}
@1 = hip::hip_allocate_memory[shape=float_type, {456}, {1},id=scratch] -> float_type, {456}, {1}
@2 = hip::hip_copy_literal[id=@literal:0] -> half_type, {784, 128}, {128, 1}
@3 = load[offset=256,end=1824](@1) -> half_type, {1, 28, 28}, {784, 28, 1}
...
...
@@ -502,7 +506,7 @@ x = @param:x -> float_type, {1, 28, 28}, {784, 28, 1}
@18 = ref::softmax[axis=1](@17) -> float_type, {1, 10}, {10, 1}
@19 = ref::identity(@18) -> float_type, {1, 10}, {10, 1}
@0 = check_context::migraphx::
version_1::
gpu::context -> float_type, {}, {}
@0 = check_context::migraphx::gpu::context -> float_type, {}, {}
@1 = hip::hip_allocate_memory[shape=float_type, {256}, {1},id=scratch] -> float_type, {256}, {1}
@2 = hip::hip_copy_literal[id=@literal:3] -> float_type, {784, 128}, {128, 1}
x = @param:x -> float_type, {1, 28, 28}, {784, 28, 1}
...
...
@@ -538,7 +542,7 @@ $ /opt/rocm/bin/migraphx-driver perf simple_graph.pb
```
Compiling ...
Reading: simple_graph.pb
@0 = check_context::migraphx::
version_1::
gpu::context -> float_type, {}, {}
@0 = check_context::migraphx::gpu::context -> float_type, {}, {}
@1 = hip::hip_allocate_memory[shape=float_type, {256}, {1},id=scratch] -> float_type, {256}, {1}
@2 = hip::hip_copy_literal[id=@literal:3] -> float_type, {784, 128}, {128, 1}
@3 = load[offset=0,end=512](@1) -> float_type, {1, 128}, {128, 1}
...
...
@@ -561,7 +565,7 @@ output = @param:output -> float_type, {1, 10}, {10, 1}
Allocating params ...
Running performance report ...
@0 = check_context::migraphx::
version_1::
gpu::context -> float_type, {}, {}: 0.00057782ms, 1%
@0 = check_context::migraphx::gpu::context -> float_type, {}, {}: 0.00057782ms, 1%
@1 = hip::hip_allocate_memory[shape=float_type, {256}, {1},id=scratch] -> float_type, {256}, {1}: 0.000295ms, 1%
@2 = hip::hip_copy_literal[id=@literal:3] -> float_type, {784, 128}, {128, 1}: 0.00027942ms, 1%
@3 = load[offset=0,end=512](@1) -> float_type, {1, 128}, {128, 1}: 0.000232ms, 1%
...
...
@@ -591,7 +595,7 @@ hip::hip_copy_literal: 0.00186824ms, 1%
load: 0.0016288ms, 1%
@param: 0.0013428ms, 1%
broadcast: 0.00118042ms, 1%
check_context::migraphx::
version_1::
gpu::context: 0.00057782ms, 1%
check_context::migraphx::gpu::context: 0.00057782ms, 1%
reshape: 0.00033842ms, 1%
hip::hip_allocate_memory: 0.000295ms, 1%
...
...
examples/vision/cpp_mnist/CMakeLists.txt
View file @
2fc6b715
...
...
@@ -27,7 +27,7 @@ project (CAI)
set
(
CMAKE_CXX_STANDARD 14
)
set
(
EXAMPLE mnist_inference
)
list
(
APPEND CMAKE_PREFIX_PATH
/opt/rocm/hip
/opt/rocm
)
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm
)
find_package
(
migraphx
)
message
(
"source file: "
${
EXAMPLE
}
.cpp
" ---> bin: "
${
EXAMPLE
}
)
...
...
src/CMakeLists.txt
View file @
2fc6b715
...
...
@@ -50,6 +50,7 @@ add_library(migraphx
env.cpp
file_buffer.cpp
fuse_pointwise.cpp
fuse_reduce.cpp
generate.cpp
inline_module.cpp
insert_pad.cpp
...
...
@@ -73,6 +74,7 @@ add_library(migraphx
process.cpp
program.cpp
propagate_constant.cpp
promote_literals.cpp
quantization.cpp
quantize_fp16.cpp
quantize_int8.cpp
...
...
@@ -91,6 +93,7 @@ add_library(migraphx
shape.cpp
simplify_algebra.cpp
simplify_reshapes.cpp
split_single_dyn_dim.cpp
tmp_dir.cpp
value.cpp
verify_args.cpp
...
...
@@ -251,7 +254,7 @@ find_package(PkgConfig)
pkg_check_modules
(
SQLITE3 REQUIRED IMPORTED_TARGET sqlite3
)
target_link_libraries
(
migraphx PRIVATE PkgConfig::SQLITE3
)
find_package
(
msgpackc-cxx
)
find_package
(
msgpackc-cxx
QUIET
)
if
(
NOT msgpackc-cxx_FOUND
)
find_package
(
msgpack REQUIRED
)
endif
()
...
...
@@ -292,6 +295,10 @@ if(HAVE_HALF_EXPR)
target_compile_definitions
(
migraphx PUBLIC -DHAS_HALF_V1
)
endif
()
if
(
BUILD_DEV
)
target_compile_definitions
(
migraphx PUBLIC -DBUILD_DEV
)
endif
()
rocm_export_targets
(
TARGETS migraphx::migraphx_c
NAMESPACE migraphx::
...
...
src/api/CMakeLists.txt
View file @
2fc6b715
...
...
@@ -26,10 +26,13 @@ add_library(migraphx_c
api.cpp
)
set_target_properties
(
migraphx_c PROPERTIES EXPORT_NAME c
)
# migraphx_c is stable API interface library. SO version of this should be
# bumped when binary compatibility is broken.
rocm_set_soversion
(
migraphx_c 3.0
)
rocm_clang_tidy_check
(
migraphx_c
)
target_link_libraries
(
migraphx_c PRIVATE migraphx migraphx_tf migraphx_onnx
migraphx_all_targets
)
target_link_libraries
(
migraphx_c PRIVATE migraphx migraphx_tf migraphx_onnx
)
rocm_install_targets
(
TARGETS migraphx_c
...
...
src/api/api.cpp
View file @
2fc6b715
...
...
@@ -32,7 +32,6 @@
#include <migraphx/register_target.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/quantization.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/load_save.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/register_op.hpp>
...
...
src/common.cpp
View file @
2fc6b715
...
...
@@ -89,8 +89,8 @@ std::vector<shape::dynamic_dimension> compute_broadcasted_dyn_dims(shape s0, sha
}
else
if
(
a
==
1
or
b
==
1
)
{
// setting opt
to 0
, may need to be changed
return
shape
::
dynamic_dimension
{
std
::
max
(
a
.
min
,
b
.
min
),
std
::
max
(
a
.
max
,
b
.
max
)
,
0
};
// setting opt
imals to empty
, may need to be changed
return
shape
::
dynamic_dimension
{
std
::
max
(
a
.
min
,
b
.
min
),
std
::
max
(
a
.
max
,
b
.
max
)};
}
else
{
...
...
@@ -148,10 +148,8 @@ shape common_shape(const std::vector<shape>& shapes)
return
{
compute_common_types
(
shapes
),
compute_common_lens
(
shapes
)};
}
instruction_ref
insert_common_op
(
module
&
m
,
instruction_ref
ins
,
const
operation
&
op
,
std
::
vector
<
instruction_ref
>
inputs
)
std
::
vector
<
instruction_ref
>
insert_common_args
(
module
&
m
,
instruction_ref
ins
,
std
::
vector
<
instruction_ref
>
inputs
)
{
if
(
std
::
any_of
(
inputs
.
cbegin
(),
inputs
.
cend
(),
[](
auto
input
)
{
return
input
->
get_shape
().
dynamic
();
}))
...
...
@@ -210,7 +208,20 @@ instruction_ref insert_common_op(module& m,
return
input
;
});
}
return
m
.
insert_instruction
(
ins
,
op
,
inputs
);
return
inputs
;
}
std
::
vector
<
instruction_ref
>
add_common_args
(
module
&
m
,
std
::
vector
<
instruction_ref
>
inputs
)
{
return
insert_common_args
(
m
,
m
.
end
(),
std
::
move
(
inputs
));
}
instruction_ref
insert_common_op
(
module
&
m
,
instruction_ref
ins
,
const
operation
&
op
,
std
::
vector
<
instruction_ref
>
inputs
)
{
return
m
.
insert_instruction
(
ins
,
op
,
insert_common_args
(
m
,
ins
,
std
::
move
(
inputs
)));
}
instruction_ref
add_common_op
(
module
&
m
,
const
operation
&
op
,
std
::
vector
<
instruction_ref
>
inputs
)
...
...
src/cpp_generator.cpp
View file @
2fc6b715
...
...
@@ -106,6 +106,13 @@ cpp_generator::function& cpp_generator::function::set_generic_types(const module
return
*
this
;
}
cpp_generator
::
function
&
cpp_generator
::
function
::
add_generic_param
(
const
std
::
string
&
pname
)
{
params
.
push_back
({
pname
,
"T"
+
pname
});
tparams
.
push_back
(
"class T"
+
pname
);
return
*
this
;
}
struct
cpp_generator_impl
{
std
::
stringstream
fs
{};
...
...
@@ -182,7 +189,8 @@ std::string cpp_generator::generate_point_op(const operation& op,
std
::
string
cpp_generator
::
str
()
const
{
return
impl
->
fs
.
str
();
}
cpp_generator
::
function
cpp_generator
::
generate_module
(
const
module
&
m
)
cpp_generator
::
function
cpp_generator
::
generate_module
(
const
module
&
m
,
const
generate_module_callback
&
g
)
{
function
f
;
auto
name
=
transform_string
(
m
.
name
(),
[](
char
c
)
{
...
...
@@ -195,13 +203,7 @@ cpp_generator::function cpp_generator::generate_module(const module& m)
if
(
ins
->
name
()
==
"@literal"
)
return
shape
::
cpp_type
(
ins
->
get_shape
().
type
())
+
"("
+
ins
->
get_literal
().
to_string
()
+
")"
;
std
::
vector
<
std
::
string
>
args
;
std
::
transform
(
ins
->
inputs
().
begin
(),
ins
->
inputs
().
end
(),
std
::
back_inserter
(
args
),
[
&
](
auto
i
)
{
return
names
.
at
(
i
);
});
auto
s
=
this
->
generate_point_op
(
ins
->
get_operator
(),
args
);
auto
s
=
g
(
ins
,
names
);
if
(
impl
->
fresult
)
return
impl
->
fresult
(
ins
->
get_shape
())
+
'('
+
s
+
')'
;
else
...
...
@@ -210,6 +212,24 @@ cpp_generator::function cpp_generator::generate_module(const module& m)
return
f
;
}
std
::
vector
<
std
::
string
>
cpp_generator
::
to_args
(
const
std
::
vector
<
instruction_ref
>&
inputs
,
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
)
{
std
::
vector
<
std
::
string
>
args
;
std
::
transform
(
inputs
.
begin
(),
inputs
.
end
(),
std
::
back_inserter
(
args
),
[
&
](
auto
i
)
{
return
names
.
at
(
i
);
});
return
args
;
}
cpp_generator
::
function
cpp_generator
::
generate_module
(
const
module
&
m
)
{
return
this
->
generate_module
(
m
,
[
&
](
auto
ins
,
const
auto
&
names
)
{
return
this
->
generate_point_op
(
ins
->
get_operator
(),
to_args
(
ins
->
inputs
(),
names
));
});
}
std
::
string
cpp_generator
::
create_function
(
const
cpp_generator
::
function
&
f
)
{
impl
->
function_count
++
;
...
...
src/driver/CMakeLists.txt
View file @
2fc6b715
...
...
@@ -42,6 +42,7 @@ add_custom_command(
)
set_directory_properties
(
PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/driver
)
rocm_clang_tidy_check
(
driver
)
target_link_libraries
(
driver migraphx_all_targets migraphx_onnx migraphx_tf
)
rocm_install_targets
(
...
...
Prev
1
2
3
4
5
…
9
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment