diff --git a/.github/workflows/gh-pages-releases.yml b/.github/workflows/gh-pages-releases.yml
index 979220f5..b27fbf50 100644
--- a/.github/workflows/gh-pages-releases.yml
+++ b/.github/workflows/gh-pages-releases.yml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
# Don't run this in everyone's forks.
- if: github.repository == 'nod-ai/SHARK'
+ if: github.repository == 'nod-ai/AMDSHARK'
steps:
- name: Checking out repository
@@ -18,7 +18,7 @@ jobs:
with:
token: ${{ secrets.NODAI_INVOCATION_TOKEN }}
- name: Run scrape releases script
- run: python ./build_tools/scrape_releases.py nod-ai SHARK > /tmp/index.html
+ run: python ./build_tools/scrape_releases.py nod-ai AMDSHARK > /tmp/index.html
shell: bash
- run: git fetch --all
- run: git switch github-pages
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 451f9b3f..9d32f645 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -40,9 +40,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.NODAI_INVOCATION_TOKEN }}
with:
tag: ${{ env.tag_name }}
- name: nod.ai SHARK ${{ env.tag_name }}
+ name: nod.ai AMDSHARK ${{ env.tag_name }}
body: |
- Automatic snapshot release of nod.ai SHARK.
+ Automatic snapshot release of nod.ai AMDSHARK.
draft: true
prerelease: true
@@ -51,12 +51,12 @@ jobs:
run: |
./setup_venv.ps1
python process_skipfiles.py
- $env:SHARK_PACKAGE_VERSION=${{ env.package_version }}
+ $env:AMDSHARK_PACKAGE_VERSION=${{ env.package_version }}
pip install -e .
pip freeze -l
- pyinstaller .\apps\shark_studio\shark_studio.spec
- mv ./dist/nodai_shark_studio.exe ./dist/nodai_shark_studio_${{ env.package_version_ }}.exe
- signtool sign /f c:\g\shark_02152023.cer /fd certHash /csp "eToken Base Cryptographic Provider" /k "${{ secrets.CI_CERT }}" ./dist/nodai_shark_studio_${{ env.package_version_ }}.exe
+ pyinstaller .\apps\amdshark_studio\amdshark_studio.spec
+ mv ./dist/nodai_amdshark_studio.exe ./dist/nodai_amdshark_studio_${{ env.package_version_ }}.exe
+ signtool sign /f c:\g\amdshark_02152023.cer /fd certHash /csp "eToken Base Cryptographic Provider" /k "${{ secrets.CI_CERT }}" ./dist/nodai_amdshark_studio_${{ env.package_version_ }}.exe
- name: Upload Release Assets
id: upload-release-assets
diff --git a/.github/workflows/test-studio.yml b/.github/workflows/test-studio.yml
index 3654cad7..3ccda0b5 100644
--- a/.github/workflows/test-studio.yml
+++ b/.github/workflows/test-studio.yml
@@ -1,19 +1,19 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
-name: Validate Shark Studio
+name: Validate AMDShark Studio
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- - 'shark/examples/**'
+ - 'amdshark/examples/**'
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'
- - 'shark/examples/**'
+ - 'amdshark/examples/**'
workflow_dispatch:
# Ensure that only a single job or workflow using the same
@@ -66,7 +66,7 @@ jobs:
run: |
# black format check
black --version
- black --check apps/shark_studio
+ black --check apps/amdshark_studio
# stop the build if there are Python syntax errors or undefined names
flake8 . --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
@@ -77,9 +77,9 @@ jobs:
if: matrix.suite == 'cpu'
run: |
cd $GITHUB_WORKSPACE
- python${{ matrix.python-version }} -m venv shark.venv
- source shark.venv/bin/activate
+ python${{ matrix.python-version }} -m venv amdshark.venv
+ source amdshark.venv/bin/activate
pip install -r requirements.txt --no-cache-dir
pip install -e .
# Disabled due to hang when exporting test llama2
- # python apps/shark_studio/tests/api_test.py
+ # python apps/amdshark_studio/tests/api_test.py
diff --git a/.gitignore b/.gitignore
index 7d6a0d42..4fdb16aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -164,15 +164,15 @@ cython_debug/
# vscode related
.vscode
-# Shark related artifacts
+# AMDShark related artifacts
*venv/
-shark_tmp/
+amdshark_tmp/
*.vmfb
.use-iree
tank/dict_configs.py
*.csv
reproducers/
-apps/shark_studio/web/configs
+apps/amdshark_studio/web/configs
# ORT related artefacts
cache_models/
@@ -189,7 +189,7 @@ variants.json
# models folder
apps/stable_diffusion/web/models/
-# model artifacts (SHARK)
+# model artifacts (AMDSHARK)
*.tempfile
*.mlir
*.vmfb
diff --git a/.gitmodules b/.gitmodules
index 5a3795a8..021ed197 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +1,4 @@
-[submodule "inference/thirdparty/shark-runtime"]
- path = inference/thirdparty/shark-runtime
+[submodule "inference/thirdparty/amdshark-runtime"]
+ path = inference/thirdparty/amdshark-runtime
url =https://github.com/nod-ai/SRT.git
- branch = shark-06032022
+ branch = amdshark-06032022
diff --git a/README.md b/README.md
index 06b61daa..7441051d 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
-# SHARK
+# AMDSHARK
High Performance Machine Learning Distribution
NOTE: This project is not currently maintained.
-*The latest versions of this project are developments towards a refactor on top of IREE-Turbine. Until further notice, make sure you use an .exe release or a checkout of the `SHARK-1.0` branch, for a working SHARK-Studio*
+*The latest versions of this project are developments towards a refactor on top of IREE-Turbine. Until further notice, make sure you use an .exe release or a checkout of the `AMDSHARK-1.0` branch, for a working AMDSHARK-Studio*
-[](https://github.com/nod-ai/SHARK-Studio/actions/workflows/nightly.yml)
+[](https://github.com/nod-ai/AMDSHARK-Studio/actions/workflows/nightly.yml)
Prerequisites - Drivers
@@ -25,11 +25,11 @@ Other users please ensure you have your latest vendor drivers and Vulkan SDK fro
-### Quick Start for SHARK Stable Diffusion for Windows 10/11 Users
+### Quick Start for AMDSHARK Stable Diffusion for Windows 10/11 Users
-Install the Driver from [Prerequisites](https://github.com/nod-ai/SHARK-Studio#install-your-hardware-drivers) above
+Install the Driver from [Prerequisites](https://github.com/nod-ai/AMDSHARK-Studio#install-your-hardware-drivers) above
-Download the [stable release](https://github.com/nod-ai/SHARK-Studio/releases/latest) or the most recent [SHARK 1.0 pre-release](https://github.com/nod-ai/SHARK-Studio/releases).
+Download the [stable release](https://github.com/nod-ai/AMDSHARK-Studio/releases/latest) or the most recent [AMDSHARK 1.0 pre-release](https://github.com/nod-ai/AMDSHARK-Studio/releases).
Double click the .exe, or [run from the command line](#running) (recommended), and you should have the [UI](http://localhost:8080/) in the browser.
@@ -67,16 +67,16 @@ Enjoy.
## Check out the code
```shell
-git clone https://github.com/nod-ai/SHARK.git
-cd SHARK
+git clone https://github.com/nod-ai/AMDSHARK.git
+cd AMDSHARK
```
## Switch to the Correct Branch (IMPORTANT!)
-Currently SHARK is being rebuilt for [Turbine](https://github.com/iree-org/iree-turbine) on the `main` branch. For now you are strongly discouraged from using `main` unless you are working on the rebuild effort, and should not expect the code there to produce a working application for Image Generation, So for now you'll need switch over to the `SHARK-1.0` branch and use the stable code.
+Currently AMDSHARK is being rebuilt for [Turbine](https://github.com/iree-org/iree-turbine) on the `main` branch. For now you are strongly discouraged from using `main` unless you are working on the rebuild effort, and should not expect the code there to produce a working application for Image Generation, So for now you'll need switch over to the `AMDSHARK-1.0` branch and use the stable code.
```shell
-git checkout SHARK-1.0
+git checkout AMDSHARK-1.0
```
The following setup instructions assume you are on this branch.
@@ -92,7 +92,7 @@ The following setup instructions assume you are on this branch.
set-executionpolicy remotesigned
```
-#### Setup venv and install necessary packages (torch-mlir, nodLabs/Shark, ...)
+#### Setup venv and install necessary packages (torch-mlir, nodLabs/AMDShark, ...)
```powershell
./setup_venv.ps1 #You can re-run this script to get the latest version
```
@@ -101,20 +101,20 @@ set-executionpolicy remotesigned
```shell
./setup_venv.sh
-source shark1.venv/bin/activate
+source amdshark1.venv/bin/activate
```
### Run Stable Diffusion on your device - WebUI
#### Windows 10/11 Users
```powershell
-(shark1.venv) PS C:\g\shark> cd .\apps\stable_diffusion\web\
-(shark1.venv) PS C:\g\shark\apps\stable_diffusion\web> python .\index.py
+(amdshark1.venv) PS C:\g\amdshark> cd .\apps\stable_diffusion\web\
+(amdshark1.venv) PS C:\g\amdshark\apps\stable_diffusion\web> python .\index.py
```
#### Linux / macOS Users
```shell
-(shark1.venv) > cd apps/stable_diffusion/web
-(shark1.venv) > python index.py
+(amdshark1.venv) > cd apps/stable_diffusion/web
+(amdshark1.venv) > python index.py
```
#### Access Stable Diffusion on http://localhost:8080/?__theme=dark
@@ -128,7 +128,7 @@ source shark1.venv/bin/activate
#### Windows 10/11 Users
```powershell
-(shark1.venv) PS C:\g\shark> python .\apps\stable_diffusion\scripts\main.py --app="txt2img" --precision="fp16" --prompt="tajmahal, snow, sunflowers, oil on canvas" --device="vulkan"
+(amdshark1.venv) PS C:\g\amdshark> python .\apps\stable_diffusion\scripts\main.py --app="txt2img" --precision="fp16" --prompt="tajmahal, snow, sunflowers, oil on canvas" --device="vulkan"
```
#### Linux / macOS Users
@@ -156,7 +156,7 @@ Here are some samples generated:

-Find us on [SHARK Discord server](https://discord.gg/RUqY2h2s9u) if you have any trouble with running it on your hardware.
+Find us on [AMDSHARK Discord server](https://discord.gg/RUqY2h2s9u) if you have any trouble with running it on your hardware.
@@ -168,8 +168,8 @@ This step sets up a new VirtualEnv for Python
```shell
python --version #Check you have 3.11 on Linux, macOS or Windows Powershell
-python -m venv shark_venv
-source shark_venv/bin/activate # Use shark_venv/Scripts/activate on Windows
+python -m venv amdshark_venv
+source amdshark_venv/bin/activate # Use amdshark_venv/Scripts/activate on Windows
# If you are using conda create and activate a new conda env
@@ -179,15 +179,15 @@ python -m pip install --upgrade pip
*macOS Metal* users please install https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.dmg and enable "System wide install"
-### Install SHARK
+### Install AMDSHARK
-This step pip installs SHARK and related packages on Linux Python 3.8, 3.10 and 3.11 and macOS / Windows Python 3.11
+This step pip installs AMDSHARK and related packages on Linux Python 3.8, 3.10 and 3.11 and macOS / Windows Python 3.11
```shell
-pip install nodai-shark -f https://nod-ai.github.io/SHARK/package-index/ -f https://llvm.github.io/torch-mlir/package-index/ -f https://nod-ai.github.io/SRT/pip-release-links.html --extra-index-url https://download.pytorch.org/whl/nightly/cpu
+pip install nodai-amdshark -f https://nod-ai.github.io/AMDSHARK/package-index/ -f https://llvm.github.io/torch-mlir/package-index/ -f https://nod-ai.github.io/SRT/pip-release-links.html --extra-index-url https://download.pytorch.org/whl/nightly/cpu
```
-### Run shark tank model tests.
+### Run amdshark tank model tests.
```shell
pytest tank/test_models.py
```
@@ -196,7 +196,7 @@ See tank/README.md for a more detailed walkthrough of our pytest suite and CLI.
### Download and run Resnet50 sample
```shell
-curl -O https://raw.githubusercontent.com/nod-ai/SHARK/main/shark/examples/shark_inference/resnet50_script.py
+curl -O https://raw.githubusercontent.com/nod-ai/AMDSHARK/main/amdshark/examples/amdshark_inference/resnet50_script.py
#Install deps for test script
pip install --pre torch torchvision torchaudio tqdm pillow gsutil --extra-index-url https://download.pytorch.org/whl/nightly/cpu
python ./resnet50_script.py --device="cpu" #use cuda or vulkan or metal
@@ -204,7 +204,7 @@ python ./resnet50_script.py --device="cpu" #use cuda or vulkan or metal
### Download and run BERT (MiniLM) sample
```shell
-curl -O https://raw.githubusercontent.com/nod-ai/SHARK/main/shark/examples/shark_inference/minilm_jit.py
+curl -O https://raw.githubusercontent.com/nod-ai/AMDSHARK/main/amdshark/examples/amdshark_inference/minilm_jit.py
#Install deps for test script
pip install transformers torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu
python ./minilm_jit.py --device="cpu" #use cuda or vulkan or metal
@@ -222,34 +222,34 @@ Set `USE_IREE=1` to use upstream IREE
# PYTHON=python3.11 VENV_DIR=0617_venv IMPORTER=1 ./setup_venv.sh
```
-### Run any of the hundreds of SHARK tank models via the test framework
+### Run any of the hundreds of AMDSHARK tank models via the test framework
```shell
-python -m shark.examples.shark_inference.resnet50_script --device="cpu" # Use gpu | vulkan
+python -m amdshark.examples.amdshark_inference.resnet50_script --device="cpu" # Use gpu | vulkan
# Or a pytest
pytest tank/test_models.py -k "MiniLM"
```
-### How to use your locally built IREE / Torch-MLIR with SHARK
+### How to use your locally built IREE / Torch-MLIR with AMDSHARK
If you are a *Torch-mlir developer or an IREE developer* and want to test local changes you can uninstall
the provided packages with `pip uninstall torch-mlir` and / or `pip uninstall iree-compiler iree-runtime` and build locally
with Python bindings and set your PYTHONPATH as mentioned [here](https://github.com/iree-org/iree/tree/main/docs/api_docs/python#install-iree-binaries)
for IREE and [here](https://github.com/llvm/torch-mlir/blob/main/development.md#setup-python-environment-to-export-the-built-python-packages)
for Torch-MLIR.
-How to use your locally built Torch-MLIR with SHARK:
+How to use your locally built Torch-MLIR with AMDSHARK:
```shell
-1.) Run `./setup_venv.sh in SHARK` and activate `shark.venv` virtual env.
+1.) Run `./setup_venv.sh in AMDSHARK` and activate `amdshark.venv` virtual env.
2.) Run `pip uninstall torch-mlir`.
3.) Go to your local Torch-MLIR directory.
4.) Activate mlir_venv virtual envirnoment.
5.) Run `pip uninstall -r requirements.txt`.
6.) Run `pip install -r requirements.txt`.
7.) Build Torch-MLIR.
-8.) Activate shark.venv virtual environment from the Torch-MLIR directory.
+8.) Activate amdshark.venv virtual environment from the Torch-MLIR directory.
8.) Run `export PYTHONPATH=`pwd`/build/tools/torch-mlir/python_packages/torch_mlir:`pwd`/examples` in the Torch-MLIR directory.
-9.) Go to the SHARK directory.
+9.) Go to the AMDSHARK directory.
```
-Now the SHARK will use your locally build Torch-MLIR repo.
+Now the AMDSHARK will use your locally build Torch-MLIR repo.
## Benchmarking Dispatches
@@ -263,10 +263,10 @@ pytest -k "MiniLM and torch and static and cuda" --benchmark_dispatches=All -s -
```
The given command will populate `//` with an `ordered_dispatches.txt` that lists and orders the dispatches and their latencies, as well as folders for each dispatch that contain .mlir, .vmfb, and results of the benchmark for that dispatch.
-if you want to instead incorporate this into a python script, you can pass the `dispatch_benchmarks` and `dispatch_benchmarks_dir` commands when initializing `SharkInference`, and the benchmarks will be generated when compiled. E.G:
+if you want to instead incorporate this into a python script, you can pass the `dispatch_benchmarks` and `dispatch_benchmarks_dir` commands when initializing `AMDSharkInference`, and the benchmarks will be generated when compiled. E.G:
```
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
mlir_model,
device=args.device,
mlir_dialect="tm_tensor",
@@ -285,34 +285,34 @@ Output will include:
- A .txt file containing benchmark output
-See tank/README.md for further instructions on how to run model tests and benchmarks from the SHARK tank.
+See tank/README.md for further instructions on how to run model tests and benchmarks from the AMDSHARK tank.
API Reference
-### Shark Inference API
+### AMDShark Inference API
```
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_importer import AMDSharkImporter
-# SharkImporter imports mlir file from the torch, tensorflow or tf-lite module.
+# AMDSharkImporter imports mlir file from the torch, tensorflow or tf-lite module.
-mlir_importer = SharkImporter(
+mlir_importer = AMDSharkImporter(
torch_module,
(input),
frontend="torch", #tf, #tf-lite
)
torch_mlir, func_name = mlir_importer.import_mlir(tracing_required=True)
-# SharkInference accepts mlir in linalg, mhlo, and tosa dialect.
+# AMDSharkInference accepts mlir in linalg, mhlo, and tosa dialect.
-from shark.shark_inference import SharkInference
-shark_module = SharkInference(torch_mlir, device="cpu", mlir_dialect="linalg")
-shark_module.compile()
-result = shark_module.forward((input))
+from amdshark.amdshark_inference import AMDSharkInference
+amdshark_module = AMDSharkInference(torch_mlir, device="cpu", mlir_dialect="linalg")
+amdshark_module.compile()
+result = amdshark_module.forward((input))
```
@@ -320,7 +320,7 @@ result = shark_module.forward((input))
### Example demonstrating running MHLO IR.
```
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
import numpy as np
mhlo_ir = r"""builtin.module {
@@ -333,22 +333,22 @@ mhlo_ir = r"""builtin.module {
arg0 = np.ones((1, 4)).astype(np.float32)
arg1 = np.ones((4, 1)).astype(np.float32)
-shark_module = SharkInference(mhlo_ir, device="cpu", mlir_dialect="mhlo")
-shark_module.compile()
-result = shark_module.forward((arg0, arg1))
+amdshark_module = AMDSharkInference(mhlo_ir, device="cpu", mlir_dialect="mhlo")
+amdshark_module.compile()
+result = amdshark_module.forward((arg0, arg1))
```
## Examples Using the REST API
-* [Setting up SHARK for use with Blender](./docs/shark_sd_blender.md)
-* [Setting up SHARK for use with Koboldcpp](./docs/shark_sd_koboldcpp.md)
+* [Setting up AMDSHARK for use with Blender](./docs/amdshark_sd_blender.md)
+* [Setting up AMDSHARK for use with Koboldcpp](./docs/amdshark_sd_koboldcpp.md)
## Supported and Validated Models
-SHARK is maintained to support the latest innovations in ML Models:
+AMDSHARK is maintained to support the latest innovations in ML Models:
-| TF HuggingFace Models | SHARK-CPU | SHARK-CUDA | SHARK-METAL |
+| TF HuggingFace Models | AMDSHARK-CPU | AMDSHARK-CUDA | AMDSHARK-METAL |
|---------------------|----------|----------|-------------|
| BERT | :green_heart: | :green_heart: | :green_heart: |
| DistilBERT | :green_heart: | :green_heart: | :green_heart: |
@@ -358,12 +358,12 @@ SHARK is maintained to support the latest innovations in ML Models:
| Vision Transformer | :green_heart: | :green_heart: | :green_heart: |
| ResNet50 | :green_heart: | :green_heart: | :green_heart: |
-For a complete list of the models supported in SHARK, please refer to [tank/README.md](https://github.com/nod-ai/SHARK-Studio/blob/main/tank/README.md).
+For a complete list of the models supported in AMDSHARK, please refer to [tank/README.md](https://github.com/nod-ai/AMDSHARK-Studio/blob/main/tank/README.md).
## Communication Channels
-* [SHARK Discord server](https://discord.gg/RUqY2h2s9u): Real time discussions with the SHARK team and other users
-* [GitHub issues](https://github.com/nod-ai/SHARK-Studio/issues): Feature requests, bugs etc
+* [AMDSHARK Discord server](https://discord.gg/RUqY2h2s9u): Real time discussions with the AMDSHARK team and other users
+* [GitHub issues](https://github.com/nod-ai/AMDSHARK-Studio/issues): Feature requests, bugs etc
## Related Projects
@@ -385,10 +385,10 @@ For a complete list of the models supported in SHARK, please refer to [tank/READ
* Torch-MLIR Github issues [here](https://github.com/llvm/torch-mlir/issues)
* [`torch-mlir` section](https://llvm.discourse.group/c/projects-that-want-to-become-official-llvm-projects/torch-mlir/41) of LLVM Discourse
* Weekly meetings on Mondays 9AM PST. See [here](https://discourse.llvm.org/t/community-meeting-developer-hour-refactoring-recurring-meetings/62575) for more information.
-* [MLIR topic within LLVM Discourse](https://llvm.discourse.group/c/llvm-project/mlir/31) SHARK and IREE is enabled by and heavily relies on [MLIR](https://mlir.llvm.org).
+* [MLIR topic within LLVM Discourse](https://llvm.discourse.group/c/llvm-project/mlir/31) AMDSHARK and IREE is enabled by and heavily relies on [MLIR](https://mlir.llvm.org).
## License
-nod.ai SHARK is licensed under the terms of the Apache 2.0 License with LLVM Exceptions.
+nod.ai AMDSHARK is licensed under the terms of the Apache 2.0 License with LLVM Exceptions.
See [LICENSE](LICENSE) for more information.
diff --git a/amdshark/__init__.py b/amdshark/__init__.py
new file mode 100644
index 00000000..d75e8480
--- /dev/null
+++ b/amdshark/__init__.py
@@ -0,0 +1,28 @@
+import importlib
+import logging
+
+from torch._dynamo import register_backend
+
+log = logging.getLogger(__name__)
+
+
+@register_backend
+def amdshark(model, inputs, *, options):
+ try:
+ from amdshark.dynamo_backend.utils import AMDSharkBackend
+ except ImportError:
+ log.exception(
+ "Unable to import AMDSHARK - High Performance Machine Learning Distribution"
+ "Please install the right version of AMDSHARK that matches the PyTorch version being used. "
+ "Refer to https://github.com/nod-ai/AMDSHARK-Studio/ for details."
+ )
+ raise
+ return AMDSharkBackend(model, inputs, options)
+
+
+def has_amdshark():
+ try:
+ importlib.import_module("amdshark")
+ return True
+ except ImportError:
+ return False
diff --git a/shark/shark_benchmark_runner.py b/amdshark/amdshark_benchmark_runner.py
similarity index 86%
rename from shark/shark_benchmark_runner.py
rename to amdshark/amdshark_benchmark_runner.py
index 4d87d788..ba41e37c 100644
--- a/shark/shark_benchmark_runner.py
+++ b/amdshark/amdshark_benchmark_runner.py
@@ -12,17 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from shark.shark_runner import SharkRunner
-from shark.iree_utils.compile_utils import (
+from amdshark.amdshark_runner import AMDSharkRunner
+from amdshark.iree_utils.compile_utils import (
export_iree_module_to_vmfb,
load_flatbuffer,
get_iree_runtime_config,
)
-from shark.iree_utils.benchmark_utils import (
+from amdshark.iree_utils.benchmark_utils import (
build_benchmark_args,
run_benchmark_module,
)
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
from datetime import datetime
import time
from typing import Optional
@@ -67,8 +67,8 @@ def check_requirements(frontend):
return has_pkgs
-class SharkBenchmarkRunner(SharkRunner):
- # SharkRunner derived class with Benchmarking capabilities.
+class AMDSharkBenchmarkRunner(AMDSharkRunner):
+ # AMDSharkRunner derived class with Benchmarking capabilities.
def __init__(
self,
mlir_module: bytes,
@@ -76,8 +76,8 @@ class SharkBenchmarkRunner(SharkRunner):
mlir_dialect: str = "linalg",
extra_args: list = [],
):
- self.device = shark_args.device if device == "none" else device
- self.enable_tf32 = shark_args.enable_tf32
+ self.device = amdshark_args.device if device == "none" else device
+ self.enable_tf32 = amdshark_args.enable_tf32
self.frontend_model = None
self.vmfb_file = None
self.mlir_dialect = mlir_dialect
@@ -86,12 +86,12 @@ class SharkBenchmarkRunner(SharkRunner):
self.temp_file_to_unlink = None
if not os.path.isfile(mlir_module):
print(
- "Warning: Initializing SharkRunner with a mlir string/bytecode object will duplicate the model in RAM at compile time. To avoid this, initialize SharkInference with a path to a MLIR module on your hard disk instead."
+ "Warning: Initializing AMDSharkRunner with a mlir string/bytecode object will duplicate the model in RAM at compile time. To avoid this, initialize AMDSharkInference with a path to a MLIR module on your hard disk instead."
)
self.compile_str = True
else:
self.compile_str = False
- SharkRunner.__init__(
+ AMDSharkRunner.__init__(
self,
mlir_module,
device,
@@ -157,13 +157,13 @@ class SharkBenchmarkRunner(SharkRunner):
frontend_model.cpu()
input.cpu()
- for i in range(shark_args.num_warmup_iterations):
+ for i in range(amdshark_args.num_warmup_iterations):
frontend_model.forward(input)
if device == "cuda":
torch.cuda.reset_peak_memory_stats()
begin = time.time()
- for i in range(shark_args.num_iterations):
+ for i in range(amdshark_args.num_iterations):
out = frontend_model.forward(input)
end = time.time()
if device == "cuda":
@@ -176,14 +176,14 @@ class SharkBenchmarkRunner(SharkRunner):
device_peak_b = None
print(
- f"Torch benchmark:{shark_args.num_iterations/(end-begin)} iter/second, Total Iterations:{shark_args.num_iterations}"
+ f"Torch benchmark:{amdshark_args.num_iterations/(end-begin)} iter/second, Total Iterations:{amdshark_args.num_iterations}"
)
if device == "cuda":
# Set device to CPU so we don't run into segfaults exiting pytest subprocesses.
torch_device = torch.device("cpu")
return [
- f"{shark_args.num_iterations/(end-begin)}",
- f"{((end-begin)/shark_args.num_iterations)*1000}",
+ f"{amdshark_args.num_iterations/(end-begin)}",
+ f"{((end-begin)/amdshark_args.num_iterations)*1000}",
"", # host_peak_b (CPU usage) is not reported by PyTorch.
_bytes_to_mb_str(device_peak_b),
]
@@ -217,13 +217,13 @@ class SharkBenchmarkRunner(SharkRunner):
)[:2]
frontend_model = model
- for i in range(shark_args.num_warmup_iterations):
+ for i in range(amdshark_args.num_warmup_iterations):
frontend_model.forward(*input)
if tf_device == TF_GPU_DEVICE:
tf.config.experimental.reset_memory_stats(tf_device)
begin = time.time()
- for i in range(shark_args.num_iterations):
+ for i in range(amdshark_args.num_iterations):
out = frontend_model.forward(*input)
end = time.time()
if tf_device == TF_GPU_DEVICE:
@@ -235,11 +235,11 @@ class SharkBenchmarkRunner(SharkRunner):
device_peak_b = None
print(
- f"TF benchmark:{shark_args.num_iterations/(end-begin)} iter/second, Total Iterations:{shark_args.num_iterations}"
+ f"TF benchmark:{amdshark_args.num_iterations/(end-begin)} iter/second, Total Iterations:{amdshark_args.num_iterations}"
)
return [
- f"{shark_args.num_iterations/(end-begin)}",
- f"{((end-begin)/shark_args.num_iterations)*1000}",
+ f"{amdshark_args.num_iterations/(end-begin)}",
+ f"{((end-begin)/amdshark_args.num_iterations)*1000}",
"", # host_peak_b (CPU usage) is not reported by TensorFlow.
_bytes_to_mb_str(device_peak_b),
]
@@ -248,7 +248,7 @@ class SharkBenchmarkRunner(SharkRunner):
iter_per_second, host_peak_b, device_peak_b = run_benchmark_module(
self.benchmark_cl
)
- print(f"Shark-IREE-C benchmark:{iter_per_second} iter/second")
+ print(f"AMDShark-IREE-C benchmark:{iter_per_second} iter/second")
return [
f"{iter_per_second}",
f"{1000/iter_per_second}",
@@ -258,25 +258,25 @@ class SharkBenchmarkRunner(SharkRunner):
def benchmark_python(self, inputs):
input_list = [x for x in inputs]
- for i in range(shark_args.num_warmup_iterations):
+ for i in range(amdshark_args.num_warmup_iterations):
self.run("forward", input_list)
begin = time.time()
- for i in range(shark_args.num_iterations):
+ for i in range(amdshark_args.num_iterations):
out = self.run("forward", input_list)
end = time.time()
print(
- f"Shark-IREE Python benchmark:{shark_args.num_iterations/(end-begin)} iter/second, Total Iterations:{shark_args.num_iterations}"
+ f"AMDShark-IREE Python benchmark:{amdshark_args.num_iterations/(end-begin)} iter/second, Total Iterations:{amdshark_args.num_iterations}"
)
return [
- f"{shark_args.num_iterations/(end-begin)}",
- f"{((end-begin)/shark_args.num_iterations)*1000}",
+ f"{amdshark_args.num_iterations/(end-begin)}",
+ f"{((end-begin)/amdshark_args.num_iterations)*1000}",
]
def benchmark_onnx(self, modelname, inputs):
if self.device == "cuda":
print(
- "Currently GPU benchmarking on ONNX is not supported in SHARK."
+ "Currently GPU benchmarking on ONNX is not supported in AMDSHARK."
)
return ["N/A", "N/A"]
else:
@@ -325,7 +325,7 @@ for currently supported models. Exiting benchmark ONNX."
num_threads,
batch_sizes,
sequence_lengths,
- shark_args.num_iterations,
+ amdshark_args.num_iterations,
input_counts,
optimize_onnx,
validate_onnx,
@@ -340,7 +340,7 @@ for currently supported models. Exiting benchmark ONNX."
onnx_args,
)
print(
- f"ONNX ORT-benchmark:{result[0]['QPS']} iter/second, Total Iterations:{shark_args.num_iterations}"
+ f"ONNX ORT-benchmark:{result[0]['QPS']} iter/second, Total Iterations:{amdshark_args.num_iterations}"
)
return [
result[0]["QPS"],
@@ -408,13 +408,13 @@ for currently supported models. Exiting benchmark ONNX."
]
# "frontend" must be the first element.
if self.mode == "native":
- engines = ["shark_python", "shark_iree_c"]
+ engines = ["amdshark_python", "amdshark_iree_c"]
if self.mode == "baseline":
engines = ["frontend"]
if self.mode == "all":
- engines = ["frontend", "shark_python", "shark_iree_c"]
+ engines = ["frontend", "amdshark_python", "amdshark_iree_c"]
- if shark_args.onnx_bench == True:
+ if amdshark_args.onnx_bench == True:
engines.append("onnxruntime")
if not os.path.exists("bench_results.csv"):
@@ -428,7 +428,7 @@ for currently supported models. Exiting benchmark ONNX."
bench_info["model"] = modelname
bench_info["batch_size"] = str(import_args["batch_size"])
bench_info["dialect"] = self.mlir_dialect
- bench_info["iterations"] = shark_args.num_iterations
+ bench_info["iterations"] = amdshark_args.num_iterations
if dynamic == True:
bench_info["shape_type"] = "dynamic"
else:
@@ -462,8 +462,8 @@ for currently supported models. Exiting benchmark ONNX."
self.frontend_result = None
continue
- elif e == "shark_python":
- engine_result["engine"] = "shark_python"
+ elif e == "amdshark_python":
+ engine_result["engine"] = "amdshark_python"
(
engine_result["iter/sec"],
engine_result["ms/iter"],
@@ -475,8 +475,8 @@ for currently supported models. Exiting benchmark ONNX."
self.frontend_result, engine_result["ms/iter"]
)
- elif e == "shark_iree_c":
- engine_result["engine"] = "shark_iree_c"
+ elif e == "amdshark_iree_c":
+ engine_result["engine"] = "amdshark_iree_c"
(
engine_result["iter/sec"],
engine_result["ms/iter"],
diff --git a/shark/shark_compile.py b/amdshark/amdshark_compile.py
similarity index 87%
rename from shark/shark_compile.py
rename to amdshark/amdshark_compile.py
index 49b003de..5ea8b30f 100644
--- a/shark/shark_compile.py
+++ b/amdshark/amdshark_compile.py
@@ -1,7 +1,7 @@
import os
import tempfile
-from shark.shark_inference import SharkInference
-from shark.shark_importer import import_with_fx, save_mlir
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import import_with_fx, save_mlir
import torch
import torch_mlir
from torch_mlir.compiler_utils import run_pipeline_with_repro_report
@@ -40,37 +40,37 @@ brevitas_matmul_rhs_group_quant_library = [
def load_vmfb(extended_model_name, device, mlir_dialect, extra_args=[]):
vmfb_path = os.path.join(os.getcwd(), extended_model_name + ".vmfb")
- shark_module = None
+ amdshark_module = None
if os.path.isfile(vmfb_path):
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
None,
device=device,
mlir_dialect=mlir_dialect,
)
print(f"loading existing vmfb from: {vmfb_path}")
- shark_module.load_module(vmfb_path, extra_args=extra_args)
- return shark_module
+ amdshark_module.load_module(vmfb_path, extra_args=extra_args)
+ return amdshark_module
def compile_module(
- shark_module, extended_model_name, generate_vmfb, extra_args=[]
+ amdshark_module, extended_model_name, generate_vmfb, extra_args=[]
):
if generate_vmfb:
vmfb_path = os.path.join(os.getcwd(), extended_model_name + ".vmfb")
if os.path.isfile(vmfb_path):
print(f"loading existing vmfb from: {vmfb_path}")
- shark_module.load_module(vmfb_path, extra_args=extra_args)
+ amdshark_module.load_module(vmfb_path, extra_args=extra_args)
else:
print(
"No vmfb found. Compiling and saving to {}".format(vmfb_path)
)
- path = shark_module.save_module(
+ path = amdshark_module.save_module(
os.getcwd(), extended_model_name, extra_args
)
- shark_module.load_module(path, extra_args=extra_args)
+ amdshark_module.load_module(path, extra_args=extra_args)
else:
- shark_module.compile(extra_args)
- return shark_module
+ amdshark_module.compile(extra_args)
+ return amdshark_module
def compile_int_precision(
@@ -139,7 +139,7 @@ def compile_int_precision(
del mlir_module
print(f"Elided IR written for {extended_model_name}")
return bytecode_path
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=bytecode_path, device=device, mlir_dialect="tm_tensor"
)
extra_args = [
@@ -150,7 +150,7 @@ def compile_int_precision(
]
return (
compile_module(
- shark_module,
+ amdshark_module,
extended_model_name=extended_model_name,
generate_vmfb=generate_vmfb,
extra_args=extra_args,
@@ -159,7 +159,7 @@ def compile_int_precision(
)
-def shark_compile_through_fx(
+def amdshark_compile_through_fx(
model,
inputs,
extended_model_name,
@@ -174,22 +174,22 @@ def shark_compile_through_fx(
):
is_f16 = precision == "fp16"
if generate_or_load_vmfb:
- shark_module = load_vmfb(
+ amdshark_module = load_vmfb(
extended_model_name=extended_model_name,
device=device,
mlir_dialect=mlir_dialect,
extra_args=extra_args,
)
- if shark_module:
+ if amdshark_module:
return (
- shark_module,
+ amdshark_module,
None,
)
- from shark.parser import shark_args
+ from amdshark.parser import amdshark_args
if "cuda" in device:
- shark_args.enable_tf32 = True
+ amdshark_args.enable_tf32 = True
if precision in ["int4", "int8"]:
mlir_module = compile_int_precision(
@@ -225,14 +225,14 @@ def shark_compile_through_fx(
mlir_dialect=mlir_dialect,
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module,
device=device,
mlir_dialect=mlir_dialect,
)
return (
compile_module(
- shark_module,
+ amdshark_module,
extended_model_name,
generate_vmfb=generate_or_load_vmfb,
extra_args=extra_args,
diff --git a/shark/shark_downloader.py b/amdshark/amdshark_downloader.py
similarity index 84%
rename from shark/shark_downloader.py
rename to amdshark/amdshark_downloader.py
index b9baf325..69a50b12 100644
--- a/shark/shark_downloader.py
+++ b/amdshark/amdshark_downloader.py
@@ -1,8 +1,8 @@
# Lint as: python3
-"""SHARK Downloader"""
-# Requirements : Put shark_tank in SHARK directory
-# /SHARK
-# /gen_shark_tank
+"""AMDSHARK Downloader"""
+# Requirements : Put amdshark_tank in AMDSHARK directory
+# /AMDSHARK
+# /gen_amdshark_tank
# /tflite
# /albert_lite_base
# /...model_name...
@@ -17,7 +17,7 @@ import os
from tqdm.std import tqdm
import sys
from pathlib import Path
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
from google.cloud import storage
@@ -83,8 +83,8 @@ input_type_to_np_dtype = {
# Save the model in the home local so it needn't be fetched everytime in the CI.
home = str(Path.home())
-alt_path = os.path.join(os.path.dirname(__file__), "../gen_shark_tank/")
-custom_path = shark_args.local_tank_cache
+alt_path = os.path.join(os.path.dirname(__file__), "../gen_amdshark_tank/")
+custom_path = amdshark_args.local_tank_cache
if custom_path is not None:
if not os.path.exists(custom_path):
@@ -92,17 +92,17 @@ if custom_path is not None:
WORKDIR = custom_path
- print(f"Using {WORKDIR} as local shark_tank cache directory.")
+ print(f"Using {WORKDIR} as local amdshark_tank cache directory.")
elif os.path.exists(alt_path):
WORKDIR = alt_path
print(
- f"Using {WORKDIR} as shark_tank directory. Delete this directory if you aren't working from locally generated shark_tank."
+ f"Using {WORKDIR} as amdshark_tank directory. Delete this directory if you aren't working from locally generated amdshark_tank."
)
else:
- WORKDIR = os.path.join(home, ".local/shark_tank/")
+ WORKDIR = os.path.join(home, ".local/amdshark_tank/")
print(
- f"shark_tank local cache is located at {WORKDIR} . You may change this by setting the --local_tank_cache= flag"
+ f"amdshark_tank local cache is located at {WORKDIR} . You may change this by setting the --local_tank_cache= flag"
)
os.makedirs(WORKDIR, exist_ok=True)
@@ -150,8 +150,8 @@ def _internet_connected():
def get_git_revision_short_hash() -> str:
import subprocess
- if shark_args.shark_prefix is not None:
- prefix_kw = shark_args.shark_prefix
+ if amdshark_args.amdshark_prefix is not None:
+ prefix_kw = amdshark_args.amdshark_prefix
else:
import json
@@ -160,11 +160,11 @@ def get_git_revision_short_hash() -> str:
with open(src, "r") as f:
data = json.loads(f.read())
prefix_kw = data["version"]
- print(f"Checking for updates from gs://shark_tank/{prefix_kw}")
+ print(f"Checking for updates from gs://amdshark_tank/{prefix_kw}")
return prefix_kw
-def get_sharktank_prefix():
+def get_amdsharktank_prefix():
tank_prefix = ""
if not _internet_connected():
print(
@@ -174,7 +174,7 @@ def get_sharktank_prefix():
else:
desired_prefix = get_git_revision_short_hash()
storage_client_a = storage.Client.create_anonymous_client()
- base_bucket_name = "shark_tank"
+ base_bucket_name = "amdshark_tank"
base_bucket = storage_client_a.bucket(base_bucket_name)
dir_blobs = base_bucket.list_blobs(prefix=f"{desired_prefix}")
for blob in dir_blobs:
@@ -186,13 +186,13 @@ def get_sharktank_prefix():
continue
if tank_prefix == "":
print(
- f"shark_tank bucket not found matching ({desired_prefix}). Defaulting to nightly."
+ f"amdshark_tank bucket not found matching ({desired_prefix}). Defaulting to nightly."
)
tank_prefix = "nightly"
return tank_prefix
-# Downloads the torch model from gs://shark_tank dir.
+# Downloads the torch model from gs://amdshark_tank dir.
def download_model(
model_name,
dynamic=False,
@@ -204,7 +204,7 @@ def download_model(
model_name = model_name.replace("/", "_")
dyn_str = "_dynamic" if dynamic else ""
os.makedirs(WORKDIR, exist_ok=True)
- shark_args.shark_prefix = get_sharktank_prefix()
+ amdshark_args.amdshark_prefix = get_amdsharktank_prefix()
if import_args["batch_size"] and import_args["batch_size"] != 1:
model_dir_name = (
model_name
@@ -221,7 +221,7 @@ def download_model(
model_dir = os.path.join(WORKDIR, model_dir_name)
if not tank_url:
- tank_url = "gs://shark_tank/" + shark_args.shark_prefix
+ tank_url = "gs://amdshark_tank/" + amdshark_args.amdshark_prefix
full_gs_url = tank_url.rstrip("/") + "/" + model_dir_name
if not check_dir_exists(
@@ -232,7 +232,7 @@ def download_model(
)
download_public_file(full_gs_url, model_dir)
- elif shark_args.force_update_tank == True:
+ elif amdshark_args.force_update_tank == True:
print(
f"Force-updating artifacts for model {model_name} from: {full_gs_url}"
)
@@ -259,13 +259,13 @@ def download_model(
except FileNotFoundError:
print(f"Model artifact hash not found at {model_dir}.")
upstream_hash = None
- if local_hash != upstream_hash and shark_args.update_tank == True:
+ if local_hash != upstream_hash and amdshark_args.update_tank == True:
print(f"Updating artifacts for model {model_name}...")
download_public_file(full_gs_url, model_dir)
elif local_hash != upstream_hash:
print(
- "Hash does not match upstream in gs://shark_tank/. If you want to use locally generated artifacts, this is working as intended. Otherwise, run with --update_tank."
+ "Hash does not match upstream in gs://amdshark_tank/. If you want to use locally generated artifacts, this is working as intended. Otherwise, run with --update_tank."
)
else:
print(
@@ -280,12 +280,12 @@ def download_model(
f"Verifying that model artifacts were downloaded successfully to {mlir_filename}..."
)
if not os.path.exists(mlir_filename):
- from tank.generate_sharktank import gen_shark_files
+ from tank.generate_amdsharktank import gen_amdshark_files
print(
"The model data was not found. Trying to generate artifacts locally."
)
- gen_shark_files(model_name, frontend, WORKDIR, import_args)
+ gen_amdshark_files(model_name, frontend, WORKDIR, import_args)
assert os.path.exists(mlir_filename), f"MLIR not found at {mlir_filename}"
function_name = str(np.load(os.path.join(model_dir, "function_name.npy")))
diff --git a/shark/shark_eager/shark_eager.py b/amdshark/amdshark_eager/amdshark_eager.py
similarity index 80%
rename from shark/shark_eager/shark_eager.py
rename to amdshark/amdshark_eager/amdshark_eager.py
index bd751199..d1d32c38 100644
--- a/shark/shark_eager/shark_eager.py
+++ b/amdshark/amdshark_eager/amdshark_eager.py
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, Tuple
from collections import defaultdict
-from shark.shark_importer import import_with_fx, save_mlir
+from amdshark.amdshark_importer import import_with_fx, save_mlir
import torchvision.models as models
import copy
import io
@@ -13,7 +13,7 @@ from typing import Dict
import torch_mlir
-def shark_backend(fx_g: torch.fx.GraphModule, inputs, device: str = "cpu"):
+def amdshark_backend(fx_g: torch.fx.GraphModule, inputs, device: str = "cpu"):
mlir_module = torch_mlir.compile(
fx_g, inputs, output_type="linalg-on-tensors"
)
@@ -22,19 +22,19 @@ def shark_backend(fx_g: torch.fx.GraphModule, inputs, device: str = "cpu"):
bytecode = bytecode_stream.getvalue()
bytecode_path = save_mlir(
bytecode,
- model_name="shark_eager_module",
+ model_name="amdshark_eager_module",
frontend="torch",
mlir_dialect="tm_tensor",
)
- from shark.shark_inference import SharkInference
+ from amdshark.amdshark_inference import AMDSharkInference
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=bytecode_path,
device=device,
mlir_dialect="tm_tensor",
)
- shark_module.compile(extra_args=[])
- return shark_module
+ amdshark_module.compile(extra_args=[])
+ return amdshark_module
def _make_single_op_gm(node, captured_val, compiled_graph):
@@ -55,7 +55,7 @@ def _make_single_op_gm(node, captured_val, compiled_graph):
g.output(call)
g.lint()
single_node = torch.fx.GraphModule(torch.nn.Module(), g)
- compiled_module = shark_backend(single_node, inputs)
+ compiled_module = amdshark_backend(single_node, inputs)
compiled_graph[node.name] = {
"module": compiled_module,
"inputs": [i for i in env],
@@ -172,41 +172,41 @@ shape_prop = ShapeProp(fx_graph)
x = shape_prop.propagate(input[0])
-shark_graph = compiled_graph(fx_graph, x)
+amdshark_graph = compiled_graph(fx_graph, x)
-for key in shark_graph:
+for key in amdshark_graph:
if key.startswith("getitem"):
- input_val = shark_graph[key]["input"]
- pos = shark_graph[key]["pos"]
- if input_val not in shark_graph:
- shark_graph[key]["result"] = x[input_val][pos].detach()
+ input_val = amdshark_graph[key]["input"]
+ pos = amdshark_graph[key]["pos"]
+ if input_val not in amdshark_graph:
+ amdshark_graph[key]["result"] = x[input_val][pos].detach()
else:
- shark_graph[key]["result"] = shark_graph[input_val]["result"][
+ amdshark_graph[key]["result"] = amdshark_graph[input_val]["result"][
pos
].detach()
elif key.startswith("empty"):
- operator = shark_graph[key]["target"]
- args = shark_graph[key]["args"]
- kwargs = shark_graph[key]["kwargs"]
- shark_graph[key]["result"] = operator(*args, **kwargs).detach()
+ operator = amdshark_graph[key]["target"]
+ args = amdshark_graph[key]["args"]
+ kwargs = amdshark_graph[key]["kwargs"]
+ amdshark_graph[key]["result"] = operator(*args, **kwargs).detach()
else:
- input_val = shark_graph[key]["inputs"]
+ input_val = amdshark_graph[key]["inputs"]
input_tensors = []
for input in input_val:
- if input not in shark_graph:
+ if input not in amdshark_graph:
input_tensors.append(x[input].detach())
else:
- input_tensors.append(shark_graph[input]["result"])
+ input_tensors.append(amdshark_graph[input]["result"])
- val = shark_graph[key]["module"]("forward", input_tensors)
+ val = amdshark_graph[key]["module"]("forward", input_tensors)
if isinstance(val, (tuple, list)):
list_val = []
for v in val:
list_val.append(torch.from_numpy(v))
- shark_graph[key]["result"] = list_val
+ amdshark_graph[key]["result"] = list_val
else:
- shark_graph[key]["result"] = torch.from_numpy(val)
+ amdshark_graph[key]["result"] = torch.from_numpy(val)
-print(shark_graph)
+print(amdshark_graph)
diff --git a/shark/shark_generate_model_config.py b/amdshark/amdshark_generate_model_config.py
similarity index 98%
rename from shark/shark_generate_model_config.py
rename to amdshark/amdshark_generate_model_config.py
index 9847b116..90cbbbe7 100644
--- a/shark/shark_generate_model_config.py
+++ b/amdshark/amdshark_generate_model_config.py
@@ -4,7 +4,7 @@ import numpy as np
import torch_mlir
from iree.compiler import compile_file
-from shark.shark_importer import import_with_fx, get_f16_inputs, save_mlir
+from amdshark.amdshark_importer import import_with_fx, get_f16_inputs, save_mlir
class GenerateConfigFile:
diff --git a/shark/shark_importer.py b/amdshark/amdshark_importer.py
similarity index 98%
rename from shark/shark_importer.py
rename to amdshark/amdshark_importer.py
index e05b81fa..531f64a4 100644
--- a/shark/shark_importer.py
+++ b/amdshark/amdshark_importer.py
@@ -1,12 +1,12 @@
# Lint as: python3
-"""SHARK Importer"""
+"""AMDSHARK Importer"""
import sys
import tempfile
import os
import hashlib
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
def create_hash(file_name):
with open(file_name, "rb") as f:
@@ -28,9 +28,9 @@ supported_frontends = {
}
-class SharkImporter:
+class AMDSharkImporter:
"""
- SharkImporter converts frontend modules into a
+ AMDSharkImporter converts frontend modules into a
mlir_module. The supported frameworks are tensorflow,
pytorch, and tf-lite.
@@ -83,7 +83,7 @@ class SharkImporter:
# NOTE: The default function for torch is "forward" and tf-lite is "main".
def _torch_mlir(self, is_dynamic, tracing_required, mlir_type):
- from shark.torch_mlir_utils import get_torch_mlir_module
+ from amdshark.torch_mlir_utils import get_torch_mlir_module
return get_torch_mlir_module(
self.module,
@@ -121,7 +121,7 @@ class SharkImporter:
is_dynamic=False,
tracing_required=False,
func_name="forward",
- save_dir=cmd_opts.tmp_dir, #"./shark_tmp/",
+ save_dir=cmd_opts.tmp_dir, #"./amdshark_tmp/",
mlir_type="linalg",
):
if self.frontend in ["torch", "pytorch"]:
@@ -773,7 +773,7 @@ def import_with_fx(
return ts_graph
inputs = get_f16_inputs(inputs, is_f16, f16_input_mask)
- mlir_importer = SharkImporter(
+ mlir_importer = AMDSharkImporter(
ts_graph,
inputs,
frontend="torch",
@@ -807,7 +807,7 @@ def save_mlir(
model_name + "_" + frontend + "_" + mlir_dialect + ".mlir"
)
if dir == "":
- dir = cmd_opts.tmp_dir, #os.path.join(".", "shark_tmp")
+ dir = cmd_opts.tmp_dir, #os.path.join(".", "amdshark_tmp")
mlir_path = os.path.join(dir, model_name_mlir)
print(f"saving {model_name_mlir} to {dir}")
if not os.path.exists(dir):
diff --git a/shark/shark_inference.py b/amdshark/amdshark_inference.py
similarity index 85%
rename from shark/shark_inference.py
rename to amdshark/amdshark_inference.py
index 032137c0..8a71e099 100644
--- a/shark/shark_inference.py
+++ b/amdshark/amdshark_inference.py
@@ -9,15 +9,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-from shark.iree_utils.compile_utils import (
+from amdshark.iree_utils.compile_utils import (
export_iree_module_to_vmfb,
load_flatbuffer,
create_dispatch_dirs,
compile_benchmark_dirs,
)
import os
-from shark.shark_runner import SharkRunner
-from shark.parser import shark_args
+from amdshark.amdshark_runner import AMDSharkRunner
+from amdshark.parser import amdshark_args
import numpy as np
@@ -30,7 +30,7 @@ dtype_to_np_dtype = {
}
-class SharkInference:
+class AMDSharkInference:
"""
Runs prediction or inference on mlir_module.
@@ -47,7 +47,7 @@ class SharkInference:
The dialect in which the given mlir_module is in.
Refer to {https://mlir.llvm.org/docs/Dialects/}
is_benchmark: bool
- Whether this SharkInference module should be benchmark-enabled.
+ Whether this AMDSharkInference module should be benchmark-enabled.
mmap: bool
Whether to load/run vmfb using mmap. It's `True` by default.
@@ -79,27 +79,27 @@ class SharkInference:
if mlir_module is not None:
if mlir_module and not os.path.isfile(mlir_module):
print(
- "Warning: Initializing SharkInference with a mlir string/bytecode object will duplicate the model in RAM at compile time. To avoid this, initialize SharkInference with a path to a MLIR module on your hard disk instead."
+ "Warning: Initializing AMDSharkInference with a mlir string/bytecode object will duplicate the model in RAM at compile time. To avoid this, initialize AMDSharkInference with a path to a MLIR module on your hard disk instead."
)
self.compile_str = True
else:
self.compile_str = False
- self.device = shark_args.device if device == "none" else device
+ self.device = amdshark_args.device if device == "none" else device
self.mlir_dialect = mlir_dialect
self.is_benchmark = is_benchmark
self.device_idx = device_idx
self.dispatch_benchmarks = (
- shark_args.dispatch_benchmarks
+ amdshark_args.dispatch_benchmarks
if dispatch_benchmark is None
else dispatch_benchmark
)
self.dispatch_benchmarks_dir = (
- shark_args.dispatch_benchmarks_dir
+ amdshark_args.dispatch_benchmarks_dir
if dispatch_benchmark_dir == "temp_dispatch_benchmarks"
else dispatch_benchmark_dir
)
- self.shark_runner = None
+ self.amdshark_runner = None
self.mmap = mmap
self.rt_flags = rt_flags
@@ -120,9 +120,9 @@ class SharkInference:
)
if self.is_benchmark == True:
- from shark.shark_benchmark_runner import SharkBenchmarkRunner
+ from amdshark.amdshark_benchmark_runner import AMDSharkBenchmarkRunner
- self.shark_runner = SharkBenchmarkRunner(
+ self.amdshark_runner = AMDSharkBenchmarkRunner(
self.mlir_module,
self.device,
self.mlir_dialect,
@@ -130,7 +130,7 @@ class SharkInference:
)
else:
- self.shark_runner = SharkRunner(
+ self.amdshark_runner = AMDSharkRunner(
self.mlir_module,
self.device,
self.mlir_dialect,
@@ -150,19 +150,19 @@ class SharkInference:
# inputs are considered to be tuple of np.array.
def __call__(self, function_name: str, inputs: tuple, send_to_host=True):
- return self.shark_runner.run(
+ return self.amdshark_runner.run(
function_name, inputs, send_to_host, device=self.device
)
# forward function.
def forward(self, inputs: tuple, send_to_host=True):
- return self.shark_runner.run(
+ return self.amdshark_runner.run(
"forward", inputs, send_to_host, device=self.device
)
# Get all function names defined within the compiled module.
def get_functions_in_module(self):
- return self.shark_runner.get_functions_in_module()
+ return self.amdshark_runner.get_functions_in_module()
# Captures the static input information from the mlir_module.
# TODO(pashu123): Generate the input information for dynamic shapes.
@@ -223,7 +223,7 @@ class SharkInference:
# load and return the module.
def load_module(self, path, extra_args=[]):
- self.shark_runner = SharkRunner(
+ self.amdshark_runner = AMDSharkRunner(
device=self.device,
compile_vmfb=False,
extra_args=extra_args,
@@ -236,8 +236,8 @@ class SharkInference:
mmap=self.mmap,
rt_flags=self.rt_flags,
)
- self.shark_runner.iree_compilation_module = params["vmfb"]
- self.shark_runner.iree_config = params["config"]
- self.shark_runner.temp_file_to_unlink = params["temp_file_to_unlink"]
+ self.amdshark_runner.iree_compilation_module = params["vmfb"]
+ self.amdshark_runner.iree_config = params["config"]
+ self.amdshark_runner.temp_file_to_unlink = params["temp_file_to_unlink"]
del params
return
diff --git a/shark/shark_runner.py b/amdshark/amdshark_runner.py
similarity index 85%
rename from shark/shark_runner.py
rename to amdshark/amdshark_runner.py
index 9f24409b..bea8d5f5 100644
--- a/shark/shark_runner.py
+++ b/amdshark/amdshark_runner.py
@@ -12,19 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from shark.iree_utils.compile_utils import (
+from amdshark.iree_utils.compile_utils import (
get_iree_compiled_module,
get_results,
export_iree_module_to_vmfb,
load_flatbuffer,
)
-from shark.iree_utils._common import check_device_drivers, device_driver_info
-from shark.parser import shark_args
+from amdshark.iree_utils._common import check_device_drivers, device_driver_info
+from amdshark.parser import amdshark_args
import os
import sys
-# supported dialects by the shark-runtime.
+# supported dialects by the amdshark-runtime.
supported_dialects = {
"linalg",
"auto",
@@ -35,9 +35,9 @@ supported_dialects = {
}
-class SharkRunner:
+class AMDSharkRunner:
"""
- Base class for SharkInference and SharkTrainer
+ Base class for AMDSharkInference and AMDSharkTrainer
used to execute an mlir_module.
...
@@ -78,12 +78,12 @@ class SharkRunner:
if self.mlir_module is not None:
if not os.path.isfile(mlir_module):
print(
- "Warning: Initializing SharkRunner with a mlir string/bytecode object will duplicate the model in RAM at compile time. To avoid this, initialize SharkInference with a path to a MLIR module on your hard disk instead."
+ "Warning: Initializing AMDSharkRunner with a mlir string/bytecode object will duplicate the model in RAM at compile time. To avoid this, initialize AMDSharkInference with a path to a MLIR module on your hard disk instead."
)
self.compile_str = True
else:
self.compile_str = False
- self.device = shark_args.device if device == "none" else device
+ self.device = amdshark_args.device if device == "none" else device
self.mlir_dialect = mlir_dialect
self.extra_args = extra_args
self.device_idx = device_idx
diff --git a/shark/shark_trainer.py b/amdshark/amdshark_trainer.py
similarity index 86%
rename from shark/shark_trainer.py
rename to amdshark/amdshark_trainer.py
index 16bdd984..6e39035a 100644
--- a/shark/shark_trainer.py
+++ b/amdshark/amdshark_trainer.py
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from shark.parser import shark_args
-from shark.shark_runner import SharkRunner
-from shark.backward_makefx import MakeFxModule
-from shark.shark_importer import import_with_fx, save_mlir
+from amdshark.parser import amdshark_args
+from amdshark.amdshark_runner import AMDSharkRunner
+from amdshark.backward_makefx import MakeFxModule
+from amdshark.amdshark_importer import import_with_fx, save_mlir
import numpy as np
from tqdm import tqdm
import sys
@@ -26,8 +26,8 @@ def print_err(*a):
print(*a, file=sys.stderr)
-class SharkTrainer:
- """Training pytorch, tensorflow module on shark runtime."""
+class AMDSharkTrainer:
+ """Training pytorch, tensorflow module on amdshark runtime."""
def __init__(
self,
@@ -48,9 +48,9 @@ class SharkTrainer:
# By default it's the torch frontend.
self.frontend = "pytorch"
- self.device = device if device is not None else shark_args.device
+ self.device = device if device is not None else amdshark_args.device
- self.shark_runner = None
+ self.amdshark_runner = None
# Sets the frontend i.e `pytorch` or `tensorflow`.
def set_frontend(self, frontend: str):
@@ -86,18 +86,18 @@ class SharkTrainer:
)
mlir_module = save_mlir(
mlir_module,
- model_name="shark_model",
+ model_name="amdshark_model",
frontend="torch",
mlir_dialect=mlir_type,
)
- self.shark_runner = SharkRunner(
+ self.amdshark_runner = AMDSharkRunner(
mlir_module,
self.device,
"tm_tensor",
extra_args=extra_args,
)
elif self.frontend in ["tensorflow", "tf", "mhlo", "stablehlo"]:
- self.shark_runner = SharkRunner(
+ self.amdshark_runner = AMDSharkRunner(
self.model,
self.input,
self.dynamic,
@@ -123,7 +123,7 @@ class SharkTrainer:
params = [x.numpy() for x in params]
print(f"Training started for {num_iters} iterations:")
for i in tqdm(range(num_iters)):
- params = self.shark_runner.run(
+ params = self.amdshark_runner.run(
"forward", params + self.input, self.frontend
)
@@ -131,7 +131,7 @@ class SharkTrainer:
# Function to train tensorflow module.
# Output final loss.
- # TODO(raikonenfnu): Save updated weight/states in SHARK.
+ # TODO(raikonenfnu): Save updated weight/states in AMDSHARK.
def _train_tf(self, num_iters):
input_list = []
for x in self.input:
@@ -150,7 +150,7 @@ class SharkTrainer:
print(f"Training started for {num_iters} iterations:")
for i in tqdm(range(num_iters)):
- outputs = self.shark_runner.forward(input_list, self.frontend)
+ outputs = self.amdshark_runner.forward(input_list, self.frontend)
return outputs
def train(self, num_iters=1):
diff --git a/shark/backward_makefx.py b/amdshark/backward_makefx.py
similarity index 98%
rename from shark/backward_makefx.py
rename to amdshark/backward_makefx.py
index a6e70e65..a5aa032e 100644
--- a/shark/backward_makefx.py
+++ b/amdshark/backward_makefx.py
@@ -71,7 +71,7 @@ class MakeFxModule:
fx_g = self.change_fx_graph_return_to_tuple(fx_g)
ts_g = torch.jit.script(fx_g)
temp = tempfile.NamedTemporaryFile(
- suffix="_shark_ts", prefix="temp_ts_"
+ suffix="_amdshark_ts", prefix="temp_ts_"
)
ts_g.save(temp.name)
new_ts = torch.jit.load(temp.name)
diff --git a/apps/shark_studio/web/ui/__init__.py b/amdshark/dynamo_backend/__init__.py
similarity index 100%
rename from apps/shark_studio/web/ui/__init__.py
rename to amdshark/dynamo_backend/__init__.py
diff --git a/shark/dynamo_backend/utils.py b/amdshark/dynamo_backend/utils.py
similarity index 92%
rename from shark/dynamo_backend/utils.py
rename to amdshark/dynamo_backend/utils.py
index 90808d63..d5bf8d7b 100644
--- a/shark/dynamo_backend/utils.py
+++ b/amdshark/dynamo_backend/utils.py
@@ -3,7 +3,7 @@ from typing import List, Optional
import torch
from torch.fx.experimental.proxy_tensor import make_fx
from torch._functorch.compile_utils import strip_overloads
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
from torch._decomp import get_decompositions
from torch.func import functionalize
import io
@@ -93,13 +93,13 @@ def _unwrap_single_tuple_return(fx_g: torch.fx.GraphModule) -> bool:
return unwrapped_tuple
-class SharkBackend:
+class AMDSharkBackend:
def __init__(
self, fx_g: torch.fx.GraphModule, inputs: tuple, options: dict
):
self.fx_g = fx_g
self.inputs = inputs
- self.shark_module = None
+ self.amdshark_module = None
self.device: str = options.get("device", "cpu")
self.was_unwrapped: bool = False
self.none_indices: list = []
@@ -125,19 +125,19 @@ class SharkBackend:
bytecode_stream = io.BytesIO()
mlir_module.operation.write_bytecode(bytecode_stream)
bytecode = bytecode_stream.getvalue()
- from shark.shark_inference import SharkInference
+ from amdshark.amdshark_inference import AMDSharkInference
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=bytecode,
device=self.device,
mlir_dialect="tm_tensor",
)
- shark_module.compile(extra_args=[])
- self.shark_module = shark_module
+ amdshark_module.compile(extra_args=[])
+ self.amdshark_module = amdshark_module
def __call__(self, *inputs):
np_inputs = [x.contiguous().detach().cpu().numpy() for x in inputs]
- np_outs = self.shark_module("forward", np_inputs)
+ np_outs = self.amdshark_module("forward", np_inputs)
if self.was_unwrapped:
np_outs = [
np_outs,
diff --git a/shark/examples/shark_dynamo/basic_examples.py b/amdshark/examples/amdshark_dynamo/basic_examples.py
similarity index 63%
rename from shark/examples/shark_dynamo/basic_examples.py
rename to amdshark/examples/amdshark_dynamo/basic_examples.py
index 16b21fa5..2e1028ac 100644
--- a/shark/examples/shark_dynamo/basic_examples.py
+++ b/amdshark/examples/amdshark_dynamo/basic_examples.py
@@ -1,5 +1,5 @@
import torch
-import shark
+import amdshark
def foo(x, a):
@@ -9,8 +9,8 @@ def foo(x, a):
return x + 3
-shark_options = {"device": "cpu"}
-compiled = torch.compile(foo, backend="shark", options=shark_options)
+amdshark_options = {"device": "cpu"}
+compiled = torch.compile(foo, backend="amdshark", options=amdshark_options)
input = torch.ones(4)
diff --git a/shark/examples/shark_eager/dynamo_demo.ipynb b/amdshark/examples/amdshark_eager/dynamo_demo.ipynb
similarity index 99%
rename from shark/examples/shark_eager/dynamo_demo.ipynb
rename to amdshark/examples/amdshark_eager/dynamo_demo.ipynb
index 526ff95b..de622c02 100644
--- a/shark/examples/shark_eager/dynamo_demo.ipynb
+++ b/amdshark/examples/amdshark_eager/dynamo_demo.ipynb
@@ -22,7 +22,7 @@
"source": [
"# standard imports\n",
"import torch\n",
- "from shark.iree_utils import get_iree_compiled_module"
+ "from amdshark.iree_utils import get_iree_compiled_module"
]
},
{
diff --git a/shark/examples/shark_eager/dynamo_demo.py b/amdshark/examples/amdshark_eager/dynamo_demo.py
similarity index 97%
rename from shark/examples/shark_eager/dynamo_demo.py
rename to amdshark/examples/amdshark_eager/dynamo_demo.py
index a4cf9ca9..168ec8fa 100644
--- a/shark/examples/shark_eager/dynamo_demo.py
+++ b/amdshark/examples/amdshark_eager/dynamo_demo.py
@@ -1,7 +1,7 @@
import torch
from torch_mlir import compile, OutputType
-from shark.iree_utils import get_iree_compiled_module
+from amdshark.iree_utils import get_iree_compiled_module
try:
import torchdynamo
diff --git a/shark/examples/shark_eager/eager_mode.ipynb b/amdshark/examples/amdshark_eager/eager_mode.ipynb
similarity index 97%
rename from shark/examples/shark_eager/eager_mode.ipynb
rename to amdshark/examples/amdshark_eager/eager_mode.ipynb
index 7d162e92..da2260eb 100644
--- a/shark/examples/shark_eager/eager_mode.ipynb
+++ b/amdshark/examples/amdshark_eager/eager_mode.ipynb
@@ -32,7 +32,7 @@
"source": [
"# eager mode imports\n",
"from torch_mlir.eager_mode.torch_mlir_tensor import TorchMLIRTensor\n",
- "from shark.iree_eager_backend import EagerModeIREELinalgOnTensorsBackend"
+ "from amdshark.iree_eager_backend import EagerModeIREELinalgOnTensorsBackend"
],
"metadata": {
"collapsed": false,
@@ -440,7 +440,7 @@
{
"cell_type": "markdown",
"source": [
- "There is a convenience class `SharkEagerMode` that will handle both the installation of the backend and the wrapping of `torch.Tensor`s:"
+ "There is a convenience class `AMDSharkEagerMode` that will handle both the installation of the backend and the wrapping of `torch.Tensor`s:"
],
"metadata": {
"collapsed": false,
@@ -684,9 +684,9 @@
],
"source": [
"# eager mode RAII\n",
- "from shark.shark_runner import SharkEagerMode\n",
+ "from amdshark.amdshark_runner import AMDSharkEagerMode\n",
"\n",
- "shark_eager_mode = SharkEagerMode(\"cpu\")\n",
+ "amdshark_eager_mode = AMDSharkEagerMode(\"cpu\")\n",
"\n",
"t = torch.ones((10, 10))\n",
"u = torch.ones((10, 10))\n",
@@ -712,7 +712,7 @@
{
"cell_type": "markdown",
"source": [
- "The `SharkEagerMode` class is a hacky take on [RAII](https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization) that defines a \"deleter\" that runs when an instantiation (of `SharkEagerMode`) is garbage collected. Takeaway is that if you want to turn off `SharkEagerMode`, or switch backends, you need to `del` the instance:"
+ "The `AMDSharkEagerMode` class is a hacky take on [RAII](https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization) that defines a \"deleter\" that runs when an instantiation (of `AMDSharkEagerMode`) is garbage collected. Takeaway is that if you want to turn off `AMDSharkEagerMode`, or switch backends, you need to `del` the instance:"
],
"metadata": {
"collapsed": false,
@@ -757,8 +757,8 @@
}
],
"source": [
- "del shark_eager_mode\n",
- "shark_eager_mode = SharkEagerMode(\"cuda\")\n",
+ "del amdshark_eager_mode\n",
+ "amdshark_eager_mode = AMDSharkEagerMode(\"cuda\")\n",
"\n",
"t = torch.ones((10, 10))\n",
"u = torch.ones((10, 10))\n",
diff --git a/shark/examples/shark_eager/eager_mode.py b/amdshark/examples/amdshark_eager/eager_mode.py
similarity index 93%
rename from shark/examples/shark_eager/eager_mode.py
rename to amdshark/examples/amdshark_eager/eager_mode.py
index a440cc7e..92c0f173 100644
--- a/shark/examples/shark_eager/eager_mode.py
+++ b/amdshark/examples/amdshark_eager/eager_mode.py
@@ -17,8 +17,8 @@ from torch.utils.cpp_extension import load_inline, include_paths
from torch_mlir.eager_mode import torch_mlir_tensor
from torch_mlir.eager_mode.torch_mlir_tensor import TorchMLIRTensor
-from shark.iree_eager_backend import EagerModeIREELinalgOnTensorsBackend
-from shark.shark_runner import SharkEagerMode
+from amdshark.iree_eager_backend import EagerModeIREELinalgOnTensorsBackend
+from amdshark.amdshark_runner import AMDSharkEagerMode
def test_cpu():
@@ -85,7 +85,7 @@ def test_gpu():
def test_python_mode_ref_backend():
# hide this wherever you want?
- _ = SharkEagerMode("refbackend")
+ _ = AMDSharkEagerMode("refbackend")
t = torch.ones((10, 10), device="cpu")
u = torch.ones((10, 10), device="cpu")
@@ -103,7 +103,7 @@ def test_python_mode_ref_backend():
def test_python_mode_iree_cpu():
# hide this wherever you want?
- _ = SharkEagerMode("cpu")
+ _ = AMDSharkEagerMode("cpu")
t = torch.ones((10, 10), device="cpu")
u = torch.ones((10, 10), device="cpu")
@@ -121,7 +121,7 @@ def test_python_mode_iree_cpu():
def test_python_mode_iree_gpu():
- _ = SharkEagerMode("gpu")
+ _ = AMDSharkEagerMode("gpu")
t = torch.ones((10, 10), device="cpu")
u = torch.ones((10, 10), device="cpu")
diff --git a/shark/examples/shark_eager/squeezenet_lockstep.py b/amdshark/examples/amdshark_eager/squeezenet_lockstep.py
similarity index 94%
rename from shark/examples/shark_eager/squeezenet_lockstep.py
rename to amdshark/examples/amdshark_eager/squeezenet_lockstep.py
index f5fcf42d..e91bb40b 100644
--- a/shark/examples/shark_eager/squeezenet_lockstep.py
+++ b/amdshark/examples/amdshark_eager/squeezenet_lockstep.py
@@ -47,7 +47,7 @@ golden_probabilities = torch.nn.functional.softmax(
golden_confidences = golden_confidences.numpy()
-from shark.torch_mlir_lockstep_tensor import TorchMLIRLockstepTensor
+from amdshark.torch_mlir_lockstep_tensor import TorchMLIRLockstepTensor
input_detached_clone = input_batch.clone()
eager_input_batch = TorchMLIRLockstepTensor(input_detached_clone)
@@ -62,7 +62,7 @@ probabilities = torch.nn.functional.softmax(
torch.from_numpy(confidences), dim=0
).numpy()
-print("The obtained result via shark is: ", confidences)
+print("The obtained result via amdshark is: ", confidences)
print("The golden result is:", golden_confidences)
np.testing.assert_allclose(
diff --git a/shark/examples/shark_inference/CLIPModel_tf.py b/amdshark/examples/amdshark_inference/CLIPModel_tf.py
similarity index 88%
rename from shark/examples/shark_inference/CLIPModel_tf.py
rename to amdshark/examples/amdshark_inference/CLIPModel_tf.py
index 78d90949..ac8b90f0 100644
--- a/shark/examples/shark_inference/CLIPModel_tf.py
+++ b/amdshark/examples/amdshark_inference/CLIPModel_tf.py
@@ -3,7 +3,7 @@ import requests
from transformers import CLIPProcessor, TFCLIPModel
import tensorflow as tf
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
# Create a set of inputs
clip_vit_inputs = [
@@ -43,7 +43,7 @@ if __name__ == "__main__":
padding=True,
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
CLIPModule(),
(
inputs["input_ids"],
@@ -51,11 +51,11 @@ if __name__ == "__main__":
inputs["pixel_values"],
),
)
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
print(
- shark_module.forward(
+ amdshark_module.forward(
(
inputs["input_ids"],
inputs["attention_mask"],
diff --git a/shark/examples/shark_inference/ESRGAN/README.md b/amdshark/examples/amdshark_inference/ESRGAN/README.md
similarity index 100%
rename from shark/examples/shark_inference/ESRGAN/README.md
rename to amdshark/examples/amdshark_inference/ESRGAN/README.md
diff --git a/shark/examples/shark_inference/ESRGAN/esrgan.py b/amdshark/examples/amdshark_inference/ESRGAN/esrgan.py
similarity index 90%
rename from shark/examples/shark_inference/ESRGAN/esrgan.py
rename to amdshark/examples/amdshark_inference/ESRGAN/esrgan.py
index 426f4e93..cc7b25c1 100644
--- a/shark/examples/shark_inference/ESRGAN/esrgan.py
+++ b/amdshark/examples/amdshark_inference/ESRGAN/esrgan.py
@@ -7,7 +7,7 @@ import torch
from torch.fx.experimental.proxy_tensor import make_fx
from torch._decomp import get_decompositions
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
import torch_mlir
import tempfile
import functools
@@ -176,12 +176,12 @@ def compile_through_fx(model, inputs, mlir_loc=None):
mlir_model = str(module)
func_name = "forward"
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_model, device=args.device, mlir_dialect="linalg"
)
- shark_module.compile()
+ amdshark_module.compile()
- return shark_module
+ return amdshark_module
model_path = "models/RRDB_ESRGAN_x4.pth" # models/RRDB_ESRGAN_x4.pth OR models/RRDB_PSNR_x4.pth
@@ -213,22 +213,22 @@ if __name__ == "__main__":
img_LR = img_LR.to(device)
with torch.no_grad():
- shark_module = compile_through_fx(inference, img_LR)
- shark_output = shark_module.forward((img_LR,))
- shark_output = torch.from_numpy(shark_output)
- shark_output = (
- shark_output.data.squeeze().float().cpu().clamp_(0, 1).numpy()
+ amdshark_module = compile_through_fx(inference, img_LR)
+ amdshark_output = amdshark_module.forward((img_LR,))
+ amdshark_output = torch.from_numpy(amdshark_output)
+ amdshark_output = (
+ amdshark_output.data.squeeze().float().cpu().clamp_(0, 1).numpy()
)
esrgan_output = (
model(img_LR).data.squeeze().float().cpu().clamp_(0, 1).numpy()
)
- # SHARK OUTPUT
- shark_output = np.transpose(shark_output[[2, 1, 0], :, :], (1, 2, 0))
- shark_output = (shark_output * 255.0).round()
+ # AMDSHARK OUTPUT
+ amdshark_output = np.transpose(amdshark_output[[2, 1, 0], :, :], (1, 2, 0))
+ amdshark_output = (amdshark_output * 255.0).round()
cv2.imwrite(
- "OutputImages/{:s}_rlt_shark_output.png".format(base), shark_output
+ "OutputImages/{:s}_rlt_amdshark_output.png".format(base), amdshark_output
)
- print("Generated SHARK's output")
+ print("Generated AMDSHARK's output")
# ESRGAN OUTPUT
esrgan_output = np.transpose(esrgan_output[[2, 1, 0], :, :], (1, 2, 0))
esrgan_output = (esrgan_output * 255.0).round()
diff --git a/shark/examples/shark_inference/albert_maskfill_pt.py b/amdshark/examples/amdshark_inference/albert_maskfill_pt.py
similarity index 87%
rename from shark/examples/shark_inference/albert_maskfill_pt.py
rename to amdshark/examples/amdshark_inference/albert_maskfill_pt.py
index 2c5d11c3..731c7639 100644
--- a/shark/examples/shark_inference/albert_maskfill_pt.py
+++ b/amdshark/examples/amdshark_inference/albert_maskfill_pt.py
@@ -1,7 +1,7 @@
from transformers import AutoModelForMaskedLM, AutoTokenizer
import torch
-from shark.shark_inference import SharkInference
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import AMDSharkImporter
from iree.compiler import compile_str
from iree import runtime as ireert
import os
@@ -35,7 +35,7 @@ if __name__ == "__main__":
return_tensors="pt",
)
inputs = (encoded_inputs["input_ids"], encoded_inputs["attention_mask"])
- mlir_importer = SharkImporter(
+ mlir_importer = AMDSharkImporter(
AlbertModule(),
inputs,
frontend="torch",
@@ -43,9 +43,9 @@ if __name__ == "__main__":
minilm_mlir, func_name = mlir_importer.import_mlir(
is_dynamic=False, tracing_required=True
)
- shark_module = SharkInference(minilm_mlir)
- shark_module.compile()
- token_logits = torch.tensor(shark_module.forward(inputs))
+ amdshark_module = AMDSharkInference(minilm_mlir)
+ amdshark_module.compile()
+ token_logits = torch.tensor(amdshark_module.forward(inputs))
mask_id = torch.where(
encoded_inputs["input_ids"] == tokenizer.mask_token_id
)[1]
@@ -69,7 +69,7 @@ if __name__ == "__main__":
encoded_inputs["input_ids"],
encoded_inputs["attention_mask"],
)
- token_logits = torch.tensor(shark_module.forward(inputs))
+ token_logits = torch.tensor(amdshark_module.forward(inputs))
mask_id = torch.where(
encoded_inputs["input_ids"] == tokenizer.mask_token_id
)[1]
diff --git a/shark/examples/shark_inference/albert_maskfill_tf.py b/amdshark/examples/amdshark_inference/albert_maskfill_tf.py
similarity index 88%
rename from shark/examples/shark_inference/albert_maskfill_tf.py
rename to amdshark/examples/amdshark_inference/albert_maskfill_tf.py
index a7927ecd..43df48b7 100644
--- a/shark/examples/shark_inference/albert_maskfill_tf.py
+++ b/amdshark/examples/amdshark_inference/albert_maskfill_tf.py
@@ -3,8 +3,8 @@ import requests
from transformers import TFAutoModelForMaskedLM, AutoTokenizer
import tensorflow as tf
-from shark.shark_inference import SharkInference
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import AMDSharkImporter
from iree.compiler import tf as tfc
from iree.compiler import compile_str
from iree import runtime as ireert
@@ -46,7 +46,7 @@ if __name__ == "__main__":
return_tensors="tf",
)
inputs = (encoded_inputs["input_ids"], encoded_inputs["attention_mask"])
- mlir_importer = SharkImporter(
+ mlir_importer = AMDSharkImporter(
AlbertModule(),
inputs,
frontend="tf",
@@ -54,11 +54,11 @@ if __name__ == "__main__":
minilm_mlir, func_name = mlir_importer.import_mlir(
is_dynamic=False, tracing_required=False
)
- shark_module = SharkInference(minilm_mlir, mlir_dialect="mhlo")
- shark_module.compile()
+ amdshark_module = AMDSharkInference(minilm_mlir, mlir_dialect="mhlo")
+ amdshark_module.compile()
output_idx = 0
data_idx = 1
- token_logits = shark_module.forward(inputs)[output_idx][data_idx]
+ token_logits = amdshark_module.forward(inputs)[output_idx][data_idx]
mask_id = np.where(
tf.squeeze(encoded_inputs["input_ids"]) == tokenizer.mask_token_id
)
@@ -82,7 +82,7 @@ if __name__ == "__main__":
encoded_inputs["input_ids"],
encoded_inputs["attention_mask"],
)
- token_logits = shark_module.forward(inputs)[output_idx][data_idx]
+ token_logits = amdshark_module.forward(inputs)[output_idx][data_idx]
mask_id = np.where(
tf.squeeze(encoded_inputs["input_ids"])
== tokenizer.mask_token_id
diff --git a/amdshark/examples/amdshark_inference/bloom_tank.py b/amdshark/examples/amdshark_inference/bloom_tank.py
new file mode 100644
index 00000000..249ec453
--- /dev/null
+++ b/amdshark/examples/amdshark_inference/bloom_tank.py
@@ -0,0 +1,14 @@
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
+
+mlir_model, func_name, inputs, golden_out = download_model(
+ "bloom", frontend="torch"
+)
+
+amdshark_module = AMDSharkInference(
+ mlir_model, device="cpu", mlir_dialect="tm_tensor"
+)
+amdshark_module.compile()
+result = amdshark_module.forward(inputs)
+print("The obtained result via amdshark is: ", result)
+print("The golden result is:", golden_out)
diff --git a/shark/examples/shark_inference/gpt2_tf.py b/amdshark/examples/amdshark_inference/gpt2_tf.py
similarity index 79%
rename from shark/examples/shark_inference/gpt2_tf.py
rename to amdshark/examples/amdshark_inference/gpt2_tf.py
index 98b402fc..5ad11cfc 100644
--- a/shark/examples/shark_inference/gpt2_tf.py
+++ b/amdshark/examples/amdshark_inference/gpt2_tf.py
@@ -3,7 +3,7 @@ import requests
from transformers import GPT2Tokenizer, TFGPT2Model
import tensorflow as tf
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
# Create a set of inputs
gpt2_inputs = [
@@ -30,11 +30,11 @@ if __name__ == "__main__":
text = "I love the distilled version of models."
inputs = tokenizer(text, return_tensors="tf")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
GPT2Module(), (inputs["input_ids"], inputs["attention_mask"])
)
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
print(
- shark_module.forward((inputs["input_ids"], inputs["attention_mask"]))
+ amdshark_module.forward((inputs["input_ids"], inputs["attention_mask"]))
)
diff --git a/shark/examples/shark_inference/llama/README.md b/amdshark/examples/amdshark_inference/llama/README.md
similarity index 87%
rename from shark/examples/shark_inference/llama/README.md
rename to amdshark/examples/amdshark_inference/llama/README.md
index e6ca3489..b39c98ae 100644
--- a/shark/examples/shark_inference/llama/README.md
+++ b/amdshark/examples/amdshark_inference/llama/README.md
@@ -1,4 +1,4 @@
-# SHARK LLaMA
+# AMDSHARK LLaMA
## TORCH-MLIR Version
@@ -14,5 +14,5 @@ git clone https://github.com/nod-ai/llama.git
Then in this repository
```
pip install -e .
-python llama/shark_model.py
+python llama/amdshark_model.py
```
diff --git a/shark/examples/shark_inference/mega_test.py b/amdshark/examples/amdshark_inference/mega_test.py
similarity index 82%
rename from shark/examples/shark_inference/mega_test.py
rename to amdshark/examples/amdshark_inference/mega_test.py
index a4e6f6b4..16e6366e 100644
--- a/shark/examples/shark_inference/mega_test.py
+++ b/amdshark/examples/amdshark_inference/mega_test.py
@@ -1,7 +1,7 @@
import torch
import torch_mlir
-from shark.shark_inference import SharkInference
-from shark.shark_compile import shark_compile_through_fx
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_compile import amdshark_compile_through_fx
from MEGABYTE_pytorch import MEGABYTE
import os
@@ -38,10 +38,10 @@ inputs = [torch.randint(0, 16000, (1, 1024, 4))]
# CURRENTLY IT BAILS OUT HERE BECAUSE OF MISSING OP LOWERINGS :-
# 1. aten.alias
-shark_module, _ = shark_compile_through_fx(
+amdshark_module, _ = amdshark_compile_through_fx(
model=megaModel,
inputs=inputs,
- extended_model_name="mega_shark",
+ extended_model_name="mega_amdshark",
is_f16=False,
f16_input_mask=None,
save_dir=os.getcwd(),
@@ -59,8 +59,8 @@ def print_output_info(output, msg):
print("\n\t", output.shape)
-ans = shark_module("forward", inputs)
-print_output_info(torch.from_numpy(ans), "SHARK's output")
+ans = amdshark_module("forward", inputs)
+print_output_info(torch.from_numpy(ans), "AMDSHARK's output")
ans = megaModel.forward(*inputs)
print_output_info(ans, "ORIGINAL Model's output")
@@ -68,5 +68,5 @@ print_output_info(ans, "ORIGINAL Model's output")
# and sample from the logits accordingly
# or you can use the generate function
-# NEED TO LOOK AT THIS LATER IF REQUIRED IN SHARK.
+# NEED TO LOOK AT THIS LATER IF REQUIRED IN AMDSHARK.
# sampled = model.generate(temperature = 0.9, filter_thres = 0.9) # (1, 1024, 4)
diff --git a/amdshark/examples/amdshark_inference/mhlo_example.py b/amdshark/examples/amdshark_inference/mhlo_example.py
new file mode 100644
index 00000000..5b3da400
--- /dev/null
+++ b/amdshark/examples/amdshark_inference/mhlo_example.py
@@ -0,0 +1,31 @@
+from amdshark.amdshark_inference import AMDSharkInference
+import numpy as np
+
+mhlo_ir = r"""builtin.module {
+ func.func @forward(%arg0: tensor<1x4xf32>, %arg1: tensor<4x1xf32>) -> tensor<4x4xf32> {
+ %0 = chlo.broadcast_add %arg0, %arg1 : (tensor<1x4xf32>, tensor<4x1xf32>) -> tensor<4x4xf32>
+ %1 = "mhlo.abs"(%0) : (tensor<4x4xf32>) -> tensor<4x4xf32>
+ return %1 : tensor<4x4xf32>
+ }
+}"""
+
+arg0 = np.ones((1, 4)).astype(np.float32)
+arg1 = np.ones((4, 1)).astype(np.float32)
+
+print("Running amdshark on cpu backend")
+amdshark_module = AMDSharkInference(mhlo_ir, device="cpu", mlir_dialect="mhlo")
+
+# Generate the random inputs and feed into the graph.
+x = amdshark_module.generate_random_inputs()
+amdshark_module.compile()
+print(amdshark_module.forward(x))
+
+print("Running amdshark on cuda backend")
+amdshark_module = AMDSharkInference(mhlo_ir, device="cuda", mlir_dialect="mhlo")
+amdshark_module.compile()
+print(amdshark_module.forward(x))
+
+print("Running amdshark on vulkan backend")
+amdshark_module = AMDSharkInference(mhlo_ir, device="vulkan", mlir_dialect="mhlo")
+amdshark_module.compile()
+print(amdshark_module.forward(x))
diff --git a/shark/examples/shark_inference/minilm_benchmark.py b/amdshark/examples/amdshark_inference/minilm_benchmark.py
similarity index 82%
rename from shark/examples/shark_inference/minilm_benchmark.py
rename to amdshark/examples/amdshark_inference/minilm_benchmark.py
index 3263f84d..86968630 100644
--- a/shark/examples/shark_inference/minilm_benchmark.py
+++ b/amdshark/examples/amdshark_inference/minilm_benchmark.py
@@ -1,6 +1,6 @@
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
torch.manual_seed(0)
tokenizer = AutoTokenizer.from_pretrained("microsoft/MiniLM-L12-H384-uncased")
@@ -23,13 +23,13 @@ class MiniLMSequenceClassification(torch.nn.Module):
test_input = torch.randint(2, (1, 128))
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
MiniLMSequenceClassification(),
(test_input,),
jit_trace=True,
benchmark_mode=True,
)
-shark_module.compile()
-shark_module.forward((test_input,))
-shark_module.benchmark_all((test_input,))
+amdshark_module.compile()
+amdshark_module.forward((test_input,))
+amdshark_module.benchmark_all((test_input,))
diff --git a/shark/examples/shark_inference/minilm_benchmark_tf.py b/amdshark/examples/amdshark_inference/minilm_benchmark_tf.py
similarity index 89%
rename from shark/examples/shark_inference/minilm_benchmark_tf.py
rename to amdshark/examples/amdshark_inference/minilm_benchmark_tf.py
index 1c2858e8..960d7abd 100644
--- a/shark/examples/shark_inference/minilm_benchmark_tf.py
+++ b/amdshark/examples/amdshark_inference/minilm_benchmark_tf.py
@@ -1,6 +1,6 @@
import tensorflow as tf
from transformers import BertModel, BertTokenizer, TFBertModel
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
MAX_SEQUENCE_LENGTH = 512
BATCH_SIZE = 1
@@ -53,9 +53,9 @@ if __name__ == "__main__":
encoded_input["attention_mask"],
encoded_input["token_type_ids"],
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
BertModule(), test_input, benchmark_mode=True
)
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
- shark_module.benchmark_all(test_input)
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
+ amdshark_module.benchmark_all(test_input)
diff --git a/shark/examples/shark_inference/minilm_jax.py b/amdshark/examples/amdshark_inference/minilm_jax.py
similarity index 88%
rename from shark/examples/shark_inference/minilm_jax.py
rename to amdshark/examples/amdshark_inference/minilm_jax.py
index 6207c6f2..30c5ea2b 100644
--- a/shark/examples/shark_inference/minilm_jax.py
+++ b/amdshark/examples/amdshark_inference/minilm_jax.py
@@ -3,7 +3,7 @@ import torch
import jax
from typing import Union, Dict, List, Any
import numpy as np
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
import io
NumpyTree = Union[np.ndarray, Dict[str, np.ndarray], List[np.ndarray]]
@@ -60,11 +60,11 @@ jax_model = get_jax_model()
mlir = export_jax_to_mlir(jax_model, sample_input)
# Compile and load module.
-shark_inference = SharkInference(mlir_module=mlir, mlir_dialect="mhlo")
-shark_inference.compile()
+amdshark_inference = AMDSharkInference(mlir_module=mlir, mlir_dialect="mhlo")
+amdshark_inference.compile()
# Run main function.
-result = shark_inference("main", jax.tree_util.tree_flatten(sample_input)[0])
+result = amdshark_inference("main", jax.tree_util.tree_flatten(sample_input)[0])
# Run JAX model.
reference_result = jax.tree_util.tree_flatten(jax_model(**sample_input))[0]
diff --git a/shark/examples/shark_inference/minilm_jax_requirements.txt b/amdshark/examples/amdshark_inference/minilm_jax_requirements.txt
similarity index 72%
rename from shark/examples/shark_inference/minilm_jax_requirements.txt
rename to amdshark/examples/amdshark_inference/minilm_jax_requirements.txt
index 1f92025a..9d979e25 100644
--- a/shark/examples/shark_inference/minilm_jax_requirements.txt
+++ b/amdshark/examples/amdshark_inference/minilm_jax_requirements.txt
@@ -1,6 +1,6 @@
flax
jax[cpu]
-nodai-SHARK
+nodai-AMDSHARK
orbax
transformers
torch
diff --git a/amdshark/examples/amdshark_inference/minilm_jit.py b/amdshark/examples/amdshark_inference/minilm_jit.py
new file mode 100644
index 00000000..9225f5fe
--- /dev/null
+++ b/amdshark/examples/amdshark_inference/minilm_jit.py
@@ -0,0 +1,23 @@
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
+
+
+mlir_model, func_name, inputs, golden_out = download_model(
+ "microsoft/MiniLM-L12-H384-uncased",
+ frontend="torch",
+)
+
+
+amdshark_module = AMDSharkInference(mlir_model, device="cpu", mlir_dialect="linalg")
+amdshark_module.compile()
+result = amdshark_module.forward(inputs)
+print("The obtained result via amdshark is: ", result)
+print("The golden result is:", golden_out)
+
+
+# Let's generate random inputs, currently supported
+# for static models.
+rand_inputs = amdshark_module.generate_random_inputs()
+rand_results = amdshark_module.forward(rand_inputs)
+
+print("Running amdshark_module with random_inputs is: ", rand_results)
diff --git a/shark/examples/shark_inference/minilm_tf.py b/amdshark/examples/amdshark_inference/minilm_tf.py
similarity index 90%
rename from shark/examples/shark_inference/minilm_tf.py
rename to amdshark/examples/amdshark_inference/minilm_tf.py
index 3ac0d7bf..61b8eecb 100644
--- a/shark/examples/shark_inference/minilm_tf.py
+++ b/amdshark/examples/amdshark_inference/minilm_tf.py
@@ -1,6 +1,6 @@
import tensorflow as tf
from transformers import BertModel, BertTokenizer, TFBertModel
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
MAX_SEQUENCE_LENGTH = 512
BATCH_SIZE = 1
@@ -48,7 +48,7 @@ if __name__ == "__main__":
tf.convert_to_tensor(encoded_input[key]), 0
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
BertModule(),
(
encoded_input["input_ids"],
@@ -56,11 +56,11 @@ if __name__ == "__main__":
encoded_input["token_type_ids"],
),
)
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
print(
- shark_module.forward(
+ amdshark_module.forward(
(
encoded_input["input_ids"],
encoded_input["attention_mask"],
diff --git a/shark/examples/shark_inference/minilm_tf_gpu_config.json b/amdshark/examples/amdshark_inference/minilm_tf_gpu_config.json
similarity index 100%
rename from shark/examples/shark_inference/minilm_tf_gpu_config.json
rename to amdshark/examples/amdshark_inference/minilm_tf_gpu_config.json
diff --git a/shark/examples/shark_inference/resnest.py b/amdshark/examples/amdshark_inference/resnest.py
similarity index 69%
rename from shark/examples/shark_inference/resnest.py
rename to amdshark/examples/amdshark_inference/resnest.py
index cfb81f3f..b021cac2 100644
--- a/shark/examples/shark_inference/resnest.py
+++ b/amdshark/examples/amdshark_inference/resnest.py
@@ -1,7 +1,7 @@
import torch
import torchvision.models as models
-from shark.shark_inference import SharkInference
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import AMDSharkImporter
torch.hub.list("zhanghang1989/ResNeSt", force_reload=True)
@@ -21,7 +21,7 @@ class ResnestModule(torch.nn.Module):
input = torch.randn(1, 3, 224, 224)
-mlir_importer = SharkImporter(
+mlir_importer = AMDSharkImporter(
ResnestModule(),
(input,),
frontend="torch",
@@ -33,7 +33,7 @@ mlir_importer = SharkImporter(
print(golden_out)
-shark_module = SharkInference(vision_mlir, mlir_dialect="linalg")
-shark_module.compile()
-result = shark_module.forward((input,))
+amdshark_module = AMDSharkInference(vision_mlir, mlir_dialect="linalg")
+amdshark_module.compile()
+result = amdshark_module.forward((input,))
print("Obtained result", result)
diff --git a/shark/examples/shark_inference/resnet50_fp16.py b/amdshark/examples/amdshark_inference/resnet50_fp16.py
similarity index 79%
rename from shark/examples/shark_inference/resnet50_fp16.py
rename to amdshark/examples/amdshark_inference/resnet50_fp16.py
index 4fe6aa40..b3a956e5 100644
--- a/shark/examples/shark_inference/resnet50_fp16.py
+++ b/amdshark/examples/amdshark_inference/resnet50_fp16.py
@@ -1,5 +1,5 @@
-from shark.shark_inference import SharkInference
-from shark.parser import shark_args
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.parser import amdshark_args
import torch
import numpy as np
@@ -49,21 +49,21 @@ module = torch_mlir.compile(
mlir_model = module
func_name = "forward"
-shark_module = SharkInference(mlir_model, device="cuda", mlir_dialect="linalg")
-shark_module.compile()
+amdshark_module = AMDSharkInference(mlir_model, device="cuda", mlir_dialect="linalg")
+amdshark_module.compile()
-def shark_result(x):
+def amdshark_result(x):
x_ny = x.cpu().detach().numpy()
inputs = (x_ny,)
- result = shark_module.forward(inputs)
+ result = amdshark_module.forward(inputs)
return torch.from_numpy(result)
-observed_out = shark_result(test_input_fp16)
+observed_out = amdshark_result(test_input_fp16)
print("Golden result:", actual_out_fp16)
-print("SHARK result:", observed_out)
+print("AMDSHARK result:", observed_out)
actual_out_fp16 = actual_out_fp16.to(device=torch.device("cpu"))
diff --git a/shark/examples/shark_inference/resnet50_script.py b/amdshark/examples/amdshark_inference/resnet50_script.py
similarity index 85%
rename from shark/examples/shark_inference/resnet50_script.py
rename to amdshark/examples/amdshark_inference/resnet50_script.py
index e597d429..514daf29 100644
--- a/shark/examples/shark_inference/resnet50_script.py
+++ b/amdshark/examples/amdshark_inference/resnet50_script.py
@@ -4,8 +4,8 @@ import torch
import torchvision.models as models
from torchvision import transforms
import sys
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
################################## Preprocessing inputs and model ############
@@ -70,13 +70,13 @@ mlir_model, func_name, inputs, golden_out = download_model(
"resnet50", frontend="torch"
)
-shark_module = SharkInference(mlir_model, mlir_dialect="linalg")
-shark_module.compile()
-path = shark_module.save_module()
-shark_module.load_module(path)
-result = shark_module("forward", (img.detach().numpy(),))
+amdshark_module = AMDSharkInference(mlir_model, mlir_dialect="linalg")
+amdshark_module.compile()
+path = amdshark_module.save_module()
+amdshark_module.load_module(path)
+result = amdshark_module("forward", (img.detach().numpy(),))
-print("The top 3 results obtained via shark_runner is:")
+print("The top 3 results obtained via amdshark_runner is:")
print(top3_possibilities(torch.from_numpy(result)))
print()
diff --git a/shark/examples/shark_inference/sharded_bloom.py b/amdshark/examples/amdshark_inference/sharded_bloom.py
similarity index 98%
rename from shark/examples/shark_inference/sharded_bloom.py
rename to amdshark/examples/amdshark_inference/sharded_bloom.py
index 3e8df14f..50c1b8ee 100644
--- a/shark/examples/shark_inference/sharded_bloom.py
+++ b/amdshark/examples/amdshark_inference/sharded_bloom.py
@@ -34,8 +34,8 @@ import subprocess
from torch.fx.experimental.proxy_tensor import make_fx
from torch._decomp import get_decompositions
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_public_file
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_public_file
from transformers import (
BloomTokenizerFast,
BloomForSequenceClassification,
@@ -77,13 +77,13 @@ class ShardedBloom:
module = f_.read()
f_.close()
module = bytes(module, "utf-8")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
module,
device=device,
mlir_dialect="tm_tensor",
device_idx=device_idx,
)
- shark_module.save_module(
+ amdshark_module.save_module(
module_name=f"{self.src_folder}/{layer_name}",
extra_args=[
"--iree-vm-bytecode-module-output-format=flatbuffer-binary",
@@ -92,14 +92,14 @@ class ShardedBloom:
],
)
else:
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
"",
device=device,
mlir_dialect="tm_tensor",
device_idx=device_idx,
)
- return shark_module
+ return amdshark_module
def init_layers(self, device, replace=False, device_idx=[0]):
if device_idx is not None:
@@ -311,7 +311,7 @@ def _prepare_attn_mask(
def download_model(destination_folder, model_name):
download_public_file(
- f"gs://shark_tank/sharded_bloom/{model_name}/", destination_folder
+ f"gs://amdshark_tank/sharded_bloom/{model_name}/", destination_folder
)
diff --git a/shark/examples/shark_inference/sharded_bloom_large_models.py b/amdshark/examples/amdshark_inference/sharded_bloom_large_models.py
similarity index 91%
rename from shark/examples/shark_inference/sharded_bloom_large_models.py
rename to amdshark/examples/amdshark_inference/sharded_bloom_large_models.py
index 1635ac13..d0bdef14 100644
--- a/shark/examples/shark_inference/sharded_bloom_large_models.py
+++ b/amdshark/examples/amdshark_inference/sharded_bloom_large_models.py
@@ -2,7 +2,7 @@ import sys
import os
from transformers import AutoTokenizer, AutoModelForCausalLM, BloomConfig
import re
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
import torch
import torch.nn as nn
from collections import OrderedDict
@@ -142,7 +142,7 @@ if __name__ == "__main__":
mlir_str = bytes(mlir_str, "utf-8")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_str,
device="cpu",
mlir_dialect="tm_tensor",
@@ -150,7 +150,7 @@ if __name__ == "__main__":
)
if will_compile:
- shark_module.save_module(
+ amdshark_module.save_module(
module_name=f"{working_dir}/word_embeddings",
extra_args=[
"--iree-vm-bytecode-module-output-format=flatbuffer-binary",
@@ -159,8 +159,8 @@ if __name__ == "__main__":
],
)
- shark_module.load_module(f"{working_dir}/word_embeddings.vmfb")
- input_embeds = shark_module(
+ amdshark_module.load_module(f"{working_dir}/word_embeddings.vmfb")
+ input_embeds = amdshark_module(
inputs=(input_ids,), function_name="forward"
)
input_embeds = torch.tensor(input_embeds).float()
@@ -175,7 +175,7 @@ if __name__ == "__main__":
mlir_str = f.read()
f.close()
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_str,
device="cpu",
mlir_dialect="tm_tensor",
@@ -183,7 +183,7 @@ if __name__ == "__main__":
)
if will_compile:
- shark_module.save_module(
+ amdshark_module.save_module(
module_name=f"{working_dir}/word_embeddings_layernorm",
extra_args=[
"--iree-vm-bytecode-module-output-format=flatbuffer-binary",
@@ -192,10 +192,10 @@ if __name__ == "__main__":
],
)
- shark_module.load_module(
+ amdshark_module.load_module(
f"{working_dir}/word_embeddings_layernorm.vmfb"
)
- hidden_states = shark_module(
+ hidden_states = amdshark_module(
inputs=(input_embeds,), function_name="forward"
)
hidden_states = torch.tensor(hidden_states).float()
@@ -243,7 +243,7 @@ if __name__ == "__main__":
mlir_str = bytes(mlir_str, "utf-8")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_str,
device=device,
mlir_dialect="tm_tensor",
@@ -251,7 +251,7 @@ if __name__ == "__main__":
)
if will_compile:
- shark_module.save_module(
+ amdshark_module.save_module(
module_name=f"{working_dir}/bloom_block_{layer_name}",
extra_args=[
"--iree-vm-bytecode-module-output-format=flatbuffer-binary",
@@ -260,11 +260,11 @@ if __name__ == "__main__":
],
)
- shark_module.load_module(
+ amdshark_module.load_module(
f"{working_dir}/bloom_block_{layer_name}.vmfb"
)
- output = shark_module(
+ output = amdshark_module(
inputs=(
hidden_states.detach().numpy(),
alibi.detach().numpy(),
@@ -290,7 +290,7 @@ if __name__ == "__main__":
mlir_str = bytes(mlir_str, "utf-8")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_str,
device="cpu",
mlir_dialect="tm_tensor",
@@ -298,7 +298,7 @@ if __name__ == "__main__":
)
if will_compile:
- shark_module.save_module(
+ amdshark_module.save_module(
module_name=f"{working_dir}/ln_f",
extra_args=[
"--iree-vm-bytecode-module-output-format=flatbuffer-binary",
@@ -307,11 +307,11 @@ if __name__ == "__main__":
],
)
- shark_module.load_module(f"{working_dir}/ln_f.vmfb")
+ amdshark_module.load_module(f"{working_dir}/ln_f.vmfb")
hidden_states = torch.load(f"{working_dir}/hidden_states_{n_layer}.pt")
- hidden_states = shark_module(
+ hidden_states = amdshark_module(
inputs=(hidden_states,), function_name="forward"
)
@@ -347,7 +347,7 @@ if __name__ == "__main__":
logits = lm_head(torch.tensor(hidden_states).float())
else:
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_str,
device="cpu",
mlir_dialect="tm_tensor",
@@ -355,7 +355,7 @@ if __name__ == "__main__":
)
if will_compile:
- shark_module.save_module(
+ amdshark_module.save_module(
module_name=f"{working_dir}/lm_head",
extra_args=[
"--iree-vm-bytecode-module-output-format=flatbuffer-binary",
@@ -364,9 +364,9 @@ if __name__ == "__main__":
],
)
- shark_module.load_module(f"{working_dir}/lm_head.vmfb")
+ amdshark_module.load_module(f"{working_dir}/lm_head.vmfb")
- logits = shark_module(
+ logits = amdshark_module(
inputs=(hidden_states,), function_name="forward"
)
diff --git a/shark/examples/shark_inference/simple_dlrm.py b/amdshark/examples/amdshark_inference/simple_dlrm.py
similarity index 98%
rename from shark/examples/shark_inference/simple_dlrm.py
rename to amdshark/examples/amdshark_inference/simple_dlrm.py
index fd1056a4..8b9574ce 100644
--- a/shark/examples/shark_inference/simple_dlrm.py
+++ b/amdshark/examples/amdshark_inference/simple_dlrm.py
@@ -52,8 +52,8 @@ import sys
import numpy as np
import torch
import torch.nn as nn
-from shark.shark_inference import SharkInference
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import AMDSharkImporter
torch.manual_seed(0)
@@ -349,7 +349,7 @@ input_dlrm = (dense_inp, vs0, *vsi)
golden_output = dlrm_model(dense_inp, vs0, *vsi)
-mlir_importer = SharkImporter(
+mlir_importer = AMDSharkImporter(
dlrm_model,
input_dlrm,
frontend="torch",
@@ -359,11 +359,11 @@ mlir_importer = SharkImporter(
tracing_required=True
)
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
dlrm_mlir, device="vulkan", mlir_dialect="linalg"
)
-shark_module.compile()
-result = shark_module.forward(input_dlrm)
+amdshark_module.compile()
+result = amdshark_module.forward(input_dlrm)
np.testing.assert_allclose(
golden_output.detach().numpy(), result, rtol=1e-02, atol=1e-03
)
diff --git a/shark/examples/shark_inference/sparse_arch.py b/amdshark/examples/amdshark_inference/sparse_arch.py
similarity index 93%
rename from shark/examples/shark_inference/sparse_arch.py
rename to amdshark/examples/amdshark_inference/sparse_arch.py
index 6cf6cddf..ed87aae7 100644
--- a/shark/examples/shark_inference/sparse_arch.py
+++ b/amdshark/examples/amdshark_inference/sparse_arch.py
@@ -15,8 +15,8 @@ from torchrec.models.dlrm import (
SparseArch,
OverArch,
)
-from shark.shark_inference import SharkInference
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import AMDSharkImporter
import numpy as np
torch.manual_seed(0)
@@ -70,7 +70,7 @@ def to_list(key_jagged, combined_keys):
return combined_list
-class SparseArchShark(nn.Module):
+class SparseArchAMDShark(nn.Module):
def create_emb(self, embedding_dim, num_embeddings_list):
embedding_list = nn.ModuleList()
for i in range(0, num_embeddings_list.size):
@@ -91,7 +91,7 @@ class SparseArchShark(nn.Module):
total_features,
num_embeddings_list,
):
- super(SparseArchShark, self).__init__()
+ super(SparseArchAMDShark, self).__init__()
self.embedding_dim = embedding_dim
self.num_features = total_features
self.embedding_list = self.create_emb(
@@ -150,7 +150,7 @@ def test_sparse_arch() -> None:
),
offsets=offsets,
)
- sparse_archi = SparseArchShark(D, 3, np.array([10, 10]))
+ sparse_archi = SparseArchAMDShark(D, 3, np.array([10, 10]))
sparse_archi.embedding_list[0].weight = w1
sparse_archi.embedding_list[1].weight = w2
inputs = to_list(features, {"f1": 0, "f3": 0, "f2": 1})
@@ -169,7 +169,7 @@ def test_sparse_arch() -> None:
test_sparse_arch()
-class DLRMShark(nn.Module):
+class DLRMAMDShark(nn.Module):
def __init__(
self,
embedding_dim,
@@ -181,7 +181,7 @@ class DLRMShark(nn.Module):
) -> None:
super().__init__()
- self.sparse_arch: SparseArchShark = SparseArchShark(
+ self.sparse_arch: SparseArchAMDShark = SparseArchAMDShark(
embedding_dim, total_features, num_embeddings_list
)
num_sparse_features: int = total_features
@@ -250,7 +250,7 @@ def test_dlrm() -> None:
dense_arch_layer_sizes=[20, D],
over_arch_layer_sizes=[5, 1],
)
- sparse_nn_nod = DLRMShark(
+ sparse_nn_nod = DLRMAMDShark(
embedding_dim=8,
total_features=3,
num_embeddings_list=np.array([100, 100]),
@@ -283,7 +283,7 @@ def test_dlrm() -> None:
# print(logits_nod)
# Import the module and print.
- mlir_importer = SharkImporter(
+ mlir_importer = AMDSharkImporter(
sparse_nn_nod,
(dense_features, *x),
frontend="torch",
@@ -293,11 +293,11 @@ def test_dlrm() -> None:
tracing_required=True
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
dlrm_mlir, device="cpu", mlir_dialect="linalg"
)
- shark_module.compile()
- result = shark_module.forward(inputs)
+ amdshark_module.compile()
+ result = amdshark_module.forward(inputs)
np.testing.assert_allclose(golden_out, result, rtol=1e-02, atol=1e-03)
torch.allclose(
diff --git a/shark/examples/shark_inference/t5_tf.py b/amdshark/examples/amdshark_inference/t5_tf.py
similarity index 77%
rename from shark/examples/shark_inference/t5_tf.py
rename to amdshark/examples/amdshark_inference/t5_tf.py
index e72004a8..1df186a0 100644
--- a/shark/examples/shark_inference/t5_tf.py
+++ b/amdshark/examples/amdshark_inference/t5_tf.py
@@ -3,7 +3,7 @@ import requests
from transformers import T5Tokenizer, TFT5Model
import tensorflow as tf
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
# Create a set of inputs
t5_inputs = [
@@ -29,7 +29,7 @@ if __name__ == "__main__":
text = "I love the distilled version of models."
inputs = tokenizer(text, return_tensors="tf").input_ids
- shark_module = SharkInference(T5Module(), (inputs, inputs))
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
- print(shark_module.forward((inputs, inputs)))
+ amdshark_module = AMDSharkInference(T5Module(), (inputs, inputs))
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
+ print(amdshark_module.forward((inputs, inputs)))
diff --git a/shark/examples/shark_inference/torch_vision_models_script.py b/amdshark/examples/amdshark_inference/torch_vision_models_script.py
similarity index 87%
rename from shark/examples/shark_inference/torch_vision_models_script.py
rename to amdshark/examples/amdshark_inference/torch_vision_models_script.py
index ae66883b..1945e243 100644
--- a/shark/examples/shark_inference/torch_vision_models_script.py
+++ b/amdshark/examples/amdshark_inference/torch_vision_models_script.py
@@ -1,6 +1,6 @@
import torch
import torchvision.models as models
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
class VisionModule(torch.nn.Module):
@@ -35,9 +35,9 @@ vision_models_list = [
]
for i, vision_model in enumerate(vision_models_list):
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
VisionModule(vision_model),
(input,),
)
- shark_module.compile()
- shark_module.forward((input,))
+ amdshark_module.compile()
+ amdshark_module.forward((input,))
diff --git a/shark/examples/shark_inference/unet_script.py b/amdshark/examples/amdshark_inference/unet_script.py
similarity index 71%
rename from shark/examples/shark_inference/unet_script.py
rename to amdshark/examples/amdshark_inference/unet_script.py
index 01b5eebe..d6929f00 100644
--- a/shark/examples/shark_inference/unet_script.py
+++ b/amdshark/examples/amdshark_inference/unet_script.py
@@ -1,7 +1,7 @@
import torch
import numpy as np
-from shark.shark_inference import SharkInference
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import AMDSharkImporter
class UnetModule(torch.nn.Module):
@@ -23,7 +23,7 @@ class UnetModule(torch.nn.Module):
input = torch.randn(1, 3, 224, 224)
-mlir_importer = SharkImporter(
+mlir_importer = AMDSharkImporter(
UnetModule(),
(input,),
frontend="torch",
@@ -33,7 +33,7 @@ mlir_importer = SharkImporter(
tracing_required=False
)
-shark_module = SharkInference(vision_mlir, mlir_dialect="linalg")
-shark_module.compile()
-result = shark_module.forward((input,))
+amdshark_module = AMDSharkInference(vision_mlir, mlir_dialect="linalg")
+amdshark_module.compile()
+result = amdshark_module.forward((input,))
np.testing.assert_allclose(golden_out, result, rtol=1e-02, atol=1e-03)
diff --git a/shark/examples/shark_inference/upscaler/main.py b/amdshark/examples/amdshark_inference/upscaler/main.py
similarity index 77%
rename from shark/examples/shark_inference/upscaler/main.py
rename to amdshark/examples/amdshark_inference/upscaler/main.py
index e5ad11ac..160d5f88 100644
--- a/shark/examples/shark_inference/upscaler/main.py
+++ b/amdshark/examples/amdshark_inference/upscaler/main.py
@@ -1,13 +1,13 @@
import requests
from PIL import Image
from io import BytesIO
-from pipeline_shark_stable_diffusion_upscale import (
- SharkStableDiffusionUpscalePipeline,
+from pipeline_amdshark_stable_diffusion_upscale import (
+ AMDSharkStableDiffusionUpscalePipeline,
)
import torch
model_id = "stabilityai/stable-diffusion-x4-upscaler"
-pipeline = SharkStableDiffusionUpscalePipeline(model_id)
+pipeline = AMDSharkStableDiffusionUpscalePipeline(model_id)
# let's download an image
url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-upscale/low_res_cat.png"
diff --git a/shark/examples/shark_inference/upscaler/model_wrappers.py b/amdshark/examples/amdshark_inference/upscaler/model_wrappers.py
similarity index 92%
rename from shark/examples/shark_inference/upscaler/model_wrappers.py
rename to amdshark/examples/amdshark_inference/upscaler/model_wrappers.py
index 1de747c4..a4169625 100644
--- a/shark/examples/shark_inference/upscaler/model_wrappers.py
+++ b/amdshark/examples/amdshark_inference/upscaler/model_wrappers.py
@@ -32,13 +32,13 @@ def get_clip_mlir(model_name="clip_text", extra_args=[]):
return self.text_encoder(input)[0]
clip_model = CLIPText()
- shark_clip = compile_through_fx(
+ amdshark_clip = compile_through_fx(
clip_model,
model_input["clip"],
model_name=model_name,
extra_args=extra_args,
)
- return shark_clip
+ return amdshark_clip
def get_vae_mlir(model_name="vae", extra_args=[]):
@@ -55,13 +55,13 @@ def get_vae_mlir(model_name="vae", extra_args=[]):
return x
vae = VaeModel()
- shark_vae = compile_through_fx(
+ amdshark_vae = compile_through_fx(
vae,
model_input["vae"],
model_name=model_name,
extra_args=extra_args,
)
- return shark_vae
+ return amdshark_vae
def get_unet_mlir(model_name="unet", extra_args=[]):
@@ -87,7 +87,7 @@ def get_unet_mlir(model_name="unet", extra_args=[]):
unet = UnetModel()
f16_input_mask = (True, True, True, False)
- shark_unet = compile_through_fx(
+ amdshark_unet = compile_through_fx(
unet,
model_input["unet"],
model_name=model_name,
@@ -95,4 +95,4 @@ def get_unet_mlir(model_name="unet", extra_args=[]):
f16_input_mask=f16_input_mask,
extra_args=extra_args,
)
- return shark_unet
+ return amdshark_unet
diff --git a/shark/examples/shark_inference/upscaler/opt_params.py b/amdshark/examples/amdshark_inference/upscaler/opt_params.py
similarity index 80%
rename from shark/examples/shark_inference/upscaler/opt_params.py
rename to amdshark/examples/amdshark_inference/upscaler/opt_params.py
index d293e89e..2b762ad6 100644
--- a/shark/examples/shark_inference/upscaler/opt_params.py
+++ b/amdshark/examples/amdshark_inference/upscaler/opt_params.py
@@ -5,7 +5,7 @@ from model_wrappers import (
get_clip_mlir,
)
from upscaler_args import args
-from utils import get_shark_model
+from utils import get_amdshark_model
BATCH_SIZE = len(args.prompts)
if BATCH_SIZE != 1:
@@ -24,25 +24,25 @@ clip_flag = [
"--iree-preprocessing-pass-pipeline=builtin.module(func.func(iree-preprocessing-pad-linalg-ops{pad-size=16}))"
]
-bucket = "gs://shark_tank/stable_diffusion/"
+bucket = "gs://amdshark_tank/stable_diffusion/"
def get_unet():
model_name = "upscaler_unet"
if args.import_mlir:
return get_unet_mlir(model_name, unet_flag)
- return get_shark_model(bucket, model_name, unet_flag)
+ return get_amdshark_model(bucket, model_name, unet_flag)
def get_vae():
model_name = "upscaler_vae"
if args.import_mlir:
return get_vae_mlir(model_name, vae_flag)
- return get_shark_model(bucket, model_name, vae_flag)
+ return get_amdshark_model(bucket, model_name, vae_flag)
def get_clip():
model_name = "upscaler_clip"
if args.import_mlir:
return get_clip_mlir(model_name, clip_flag)
- return get_shark_model(bucket, model_name, clip_flag)
+ return get_amdshark_model(bucket, model_name, clip_flag)
diff --git a/shark/examples/shark_inference/upscaler/pipeline_shark_stable_diffusion_upscale.py b/amdshark/examples/amdshark_inference/upscaler/pipeline_amdshark_stable_diffusion_upscale.py
similarity index 98%
rename from shark/examples/shark_inference/upscaler/pipeline_shark_stable_diffusion_upscale.py
rename to amdshark/examples/amdshark_inference/upscaler/pipeline_amdshark_stable_diffusion_upscale.py
index d1aeb538..22825ba3 100644
--- a/shark/examples/shark_inference/upscaler/pipeline_shark_stable_diffusion_upscale.py
+++ b/amdshark/examples/amdshark_inference/upscaler/pipeline_amdshark_stable_diffusion_upscale.py
@@ -46,13 +46,13 @@ def preprocess(image):
return image
-def shark_run_wrapper(model, *args):
+def amdshark_run_wrapper(model, *args):
np_inputs = tuple([x.detach().numpy() for x in args])
outputs = model("forward", np_inputs)
return torch.from_numpy(outputs)
-class SharkStableDiffusionUpscalePipeline:
+class AMDSharkStableDiffusionUpscalePipeline:
def __init__(
self,
model_id,
@@ -131,7 +131,7 @@ class SharkStableDiffusionUpscalePipeline:
# else:
# attention_mask = None
- text_embeddings = shark_run_wrapper(
+ text_embeddings = amdshark_run_wrapper(
self.text_encoder, text_input_ids.to(device)
)
@@ -180,7 +180,7 @@ class SharkStableDiffusionUpscalePipeline:
# else:
# attention_mask = None
- uncond_embeddings = shark_run_wrapper(
+ uncond_embeddings = amdshark_run_wrapper(
self.text_encoder,
uncond_input.input_ids.to(device),
)
@@ -227,7 +227,7 @@ class SharkStableDiffusionUpscalePipeline:
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.decode_latents with 0.18215->0.08333
def decode_latents(self, latents):
latents = 1 / 0.08333 * latents
- image = shark_run_wrapper(self.vae, latents)
+ image = amdshark_run_wrapper(self.vae, latents)
image = (image / 2 + 0.5).clamp(0, 1)
# we always cast to float32 as this does not cause significant overhead and is compatible with bfloa16
image = image.cpu().permute(0, 2, 3, 1).float().numpy()
@@ -445,7 +445,7 @@ class SharkStableDiffusionUpscalePipeline:
timestep = torch.tensor([t]).to(torch.float32)
# predict the noise residual
- noise_pred = shark_run_wrapper(
+ noise_pred = amdshark_run_wrapper(
self.unet,
latent_model_input.half(),
timestep,
diff --git a/shark/examples/shark_inference/upscaler/upscaler_args.py b/amdshark/examples/amdshark_inference/upscaler/upscaler_args.py
similarity index 95%
rename from shark/examples/shark_inference/upscaler/upscaler_args.py
rename to amdshark/examples/amdshark_inference/upscaler/upscaler_args.py
index f91c0306..49db12ed 100644
--- a/shark/examples/shark_inference/upscaler/upscaler_args.py
+++ b/amdshark/examples/amdshark_inference/upscaler/upscaler_args.py
@@ -59,7 +59,7 @@ p.add_argument(
"--import_mlir",
default=False,
action=argparse.BooleanOptionalAction,
- help="imports the model from torch module to shark_module otherwise downloads the model from shark_tank.",
+ help="imports the model from torch module to amdshark_module otherwise downloads the model from amdshark_tank.",
)
p.add_argument(
diff --git a/shark/examples/shark_inference/upscaler/utils.py b/amdshark/examples/amdshark_inference/upscaler/utils.py
similarity index 84%
rename from shark/examples/shark_inference/upscaler/utils.py
rename to amdshark/examples/amdshark_inference/upscaler/utils.py
index 4531d4e8..8275492b 100644
--- a/shark/examples/shark_inference/upscaler/utils.py
+++ b/amdshark/examples/amdshark_inference/upscaler/utils.py
@@ -1,16 +1,16 @@
import os
import torch
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
from upscaler_args import args
-from shark.shark_importer import import_with_fx
-from shark.iree_utils.vulkan_utils import (
+from amdshark.amdshark_importer import import_with_fx
+from amdshark.iree_utils.vulkan_utils import (
set_iree_vulkan_runtime_flags,
get_vulkan_target_triple,
get_iree_vulkan_runtime_flags,
)
-def _compile_module(shark_module, model_name, extra_args=[]):
+def _compile_module(amdshark_module, model_name, extra_args=[]):
if args.load_vmfb or args.save_vmfb:
device = (
args.device
@@ -21,7 +21,7 @@ def _compile_module(shark_module, model_name, extra_args=[]):
vmfb_path = os.path.join(os.getcwd(), extended_name + ".vmfb")
if args.load_vmfb and os.path.isfile(vmfb_path) and not args.save_vmfb:
print(f"loading existing vmfb from: {vmfb_path}")
- shark_module.load_module(vmfb_path, extra_args=extra_args)
+ amdshark_module.load_module(vmfb_path, extra_args=extra_args)
else:
if args.save_vmfb:
print("Saving to {}".format(vmfb_path))
@@ -31,48 +31,48 @@ def _compile_module(shark_module, model_name, extra_args=[]):
vmfb_path
)
)
- path = shark_module.save_module(
+ path = amdshark_module.save_module(
os.getcwd(), extended_name, extra_args
)
- shark_module.load_module(path, extra_args=extra_args)
+ amdshark_module.load_module(path, extra_args=extra_args)
else:
- shark_module.compile(extra_args)
- return shark_module
+ amdshark_module.compile(extra_args)
+ return amdshark_module
-# Downloads the model from shark_tank and returns the shark_module.
-def get_shark_model(tank_url, model_name, extra_args=[]):
- from shark.shark_downloader import download_model
- from shark.parser import shark_args
+# Downloads the model from amdshark_tank and returns the amdshark_module.
+def get_amdshark_model(tank_url, model_name, extra_args=[]):
+ from amdshark.amdshark_downloader import download_model
+ from amdshark.parser import amdshark_args
- # Set local shark_tank cache directory.
- # shark_args.local_tank_cache = args.local_tank_cache
+ # Set local amdshark_tank cache directory.
+ # amdshark_args.local_tank_cache = args.local_tank_cache
mlir_model, func_name, inputs, golden_out = download_model(
model_name,
tank_url=tank_url,
frontend="torch",
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_model, device=args.device, mlir_dialect="linalg"
)
- return _compile_module(shark_module, model_name, extra_args)
+ return _compile_module(amdshark_module, model_name, extra_args)
-# Converts the torch-module into a shark_module.
+# Converts the torch-module into a amdshark_module.
def compile_through_fx(
model, inputs, model_name, is_f16=False, f16_input_mask=None, extra_args=[]
):
mlir_module, func_name = import_with_fx(
model, inputs, is_f16, f16_input_mask
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module,
device=args.device,
mlir_dialect="linalg",
)
- return _compile_module(shark_module, model_name, extra_args)
+ return _compile_module(amdshark_module, model_name, extra_args)
def set_iree_runtime_flags():
@@ -112,7 +112,7 @@ def get_device_mapping(driver, key_combination=3):
Returns:
dict: map to possible device names user can input mapped to desired combination of name/path.
"""
- from shark.iree_utils._common import iree_device_map
+ from amdshark.iree_utils._common import iree_device_map
driver = iree_device_map(driver)
device_list = get_all_devices(driver)
@@ -205,7 +205,7 @@ def set_init_device_flags():
# Utility to get list of devices available.
def get_available_devices():
def get_devices_by_name(driver_name):
- from shark.iree_utils._common import iree_device_map
+ from amdshark.iree_utils._common import iree_device_map
device_list = []
try:
diff --git a/amdshark/examples/amdshark_inference/v_diffusion.py b/amdshark/examples/amdshark_inference/v_diffusion.py
new file mode 100644
index 00000000..164176b4
--- /dev/null
+++ b/amdshark/examples/amdshark_inference/v_diffusion.py
@@ -0,0 +1,15 @@
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
+
+
+mlir_model, func_name, inputs, golden_out = download_model(
+ "v_diffusion", frontend="torch"
+)
+
+amdshark_module = AMDSharkInference(
+ mlir_model, device="vulkan", mlir_dialect="linalg"
+)
+amdshark_module.compile()
+result = amdshark_module.forward(inputs)
+print("The obtained result via amdshark is: ", result)
+print("The golden result is:", golden_out)
diff --git a/shark/examples/shark_training/bert_training.py b/amdshark/examples/amdshark_training/bert_training.py
similarity index 88%
rename from shark/examples/shark_training/bert_training.py
rename to amdshark/examples/amdshark_training/bert_training.py
index b0cf43a2..0e17bdab 100644
--- a/shark/examples/shark_training/bert_training.py
+++ b/amdshark/examples/amdshark_training/bert_training.py
@@ -1,7 +1,7 @@
import torch
from torch.nn.utils import stateless
from transformers import AutoTokenizer, AutoModelForSequenceClassification
-from shark.shark_trainer import SharkTrainer
+from amdshark.amdshark_trainer import AMDSharkTrainer
class MiniLMSequenceClassification(torch.nn.Module):
@@ -42,7 +42,7 @@ def forward(params, buffers, args):
return params, buffers
-shark_module = SharkTrainer(mod, inp)
-shark_module.compile(forward)
-shark_module.train(num_iters=2)
+amdshark_module = AMDSharkTrainer(mod, inp)
+amdshark_module.compile(forward)
+amdshark_module.train(num_iters=2)
print("training done")
diff --git a/shark/examples/shark_training/bert_training_load_tf.py b/amdshark/examples/amdshark_training/bert_training_load_tf.py
similarity index 82%
rename from shark/examples/shark_training/bert_training_load_tf.py
rename to amdshark/examples/amdshark_training/bert_training_load_tf.py
index ae214c4d..08a5ebc3 100644
--- a/shark/examples/shark_training/bert_training_load_tf.py
+++ b/amdshark/examples/amdshark_training/bert_training_load_tf.py
@@ -3,8 +3,8 @@ import os
import time
import tensorflow as tf
-from shark.shark_trainer import SharkTrainer
-from shark.parser import parser
+from amdshark.amdshark_trainer import AMDSharkTrainer
+from amdshark.parser import parser
from urllib import request
parser.add_argument(
@@ -28,7 +28,7 @@ if __name__ == "__main__":
np.random.randint(5, size=(BATCH_SIZE, SEQUENCE_LENGTH)),
np.random.randint(5, size=(BATCH_SIZE, SEQUENCE_LENGTH)),
]
- file_link = "https://storage.googleapis.com/shark_tank/users/stanley/bert_tf_training.mlir"
+ file_link = "https://storage.googleapis.com/amdshark_tank/users/stanley/bert_tf_training.mlir"
response = request.urlretrieve(file_link, load_args.download_mlir_path)
sample_input_tensors = [
tf.convert_to_tensor(val, dtype=tf.int32)
@@ -41,7 +41,7 @@ if __name__ == "__main__":
)
with open(load_args.download_mlir_path, "rb") as input_file:
bert_mlir = input_file.read()
- shark_module = SharkTrainer(
+ amdshark_module = AMDSharkTrainer(
bert_mlir,
(
sample_input_tensors,
@@ -50,10 +50,10 @@ if __name__ == "__main__":
),
),
)
- shark_module.set_frontend("mhlo")
- shark_module.compile()
+ amdshark_module.set_frontend("mhlo")
+ amdshark_module.compile()
start = time.time()
- print(shark_module.train(num_iter))
+ print(amdshark_module.train(num_iter))
end = time.time()
total_time = end - start
print("time: " + str(total_time))
diff --git a/shark/examples/shark_training/bert_training_tf.py b/amdshark/examples/amdshark_training/bert_training_tf.py
similarity index 93%
rename from shark/examples/shark_training/bert_training_tf.py
rename to amdshark/examples/amdshark_training/bert_training_tf.py
index 8db49c61..fcbde000 100644
--- a/shark/examples/shark_training/bert_training_tf.py
+++ b/amdshark/examples/amdshark_training/bert_training_tf.py
@@ -8,7 +8,7 @@ from official.nlp.modeling import layers
from official.nlp.modeling import networks
from official.nlp.modeling.models import bert_classifier
-from shark.shark_trainer import SharkTrainer
+from amdshark.amdshark_trainer import AMDSharkTrainer
tf.random.set_seed(0)
@@ -79,7 +79,7 @@ if __name__ == "__main__":
for val in predict_sample_input
]
num_iter = 10
- shark_module = SharkTrainer(
+ amdshark_module = AMDSharkTrainer(
BertModule(),
(
sample_input_tensors,
@@ -88,10 +88,10 @@ if __name__ == "__main__":
),
),
)
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
start = time.time()
- print(shark_module.train(num_iter))
+ print(amdshark_module.train(num_iter))
end = time.time()
total_time = end - start
print("time: " + str(total_time))
diff --git a/shark/examples/shark_training/neural_net_training.py b/amdshark/examples/amdshark_training/neural_net_training.py
similarity index 84%
rename from shark/examples/shark_training/neural_net_training.py
rename to amdshark/examples/amdshark_training/neural_net_training.py
index a28397e0..e3c61d92 100644
--- a/shark/examples/shark_training/neural_net_training.py
+++ b/amdshark/examples/amdshark_training/neural_net_training.py
@@ -1,6 +1,6 @@
import torch
from torch.nn.utils import _stateless
-from shark.shark_trainer import SharkTrainer
+from amdshark.amdshark_trainer import AMDSharkTrainer
class Foo(torch.nn.Module):
@@ -37,8 +37,8 @@ def forward(params, buffers, args):
# fx_graph = forward(dict(mod.named_parameters()), dict(mod.named_buffers()), inp)
-shark_module = SharkTrainer(mod, inp)
+amdshark_module = AMDSharkTrainer(mod, inp)
# Pass the training function in case of torch
-shark_module.compile(training_fn=forward)
+amdshark_module.compile(training_fn=forward)
-shark_module.train(num_iters=10)
+amdshark_module.train(num_iters=10)
diff --git a/shark/examples/shark_training/stable-diffusion-img2img/README.md b/amdshark/examples/amdshark_training/stable-diffusion-img2img/README.md
similarity index 95%
rename from shark/examples/shark_training/stable-diffusion-img2img/README.md
rename to amdshark/examples/amdshark_training/stable-diffusion-img2img/README.md
index 8ac562db..887bfacc 100644
--- a/shark/examples/shark_training/stable-diffusion-img2img/README.md
+++ b/amdshark/examples/amdshark_training/stable-diffusion-img2img/README.md
@@ -5,10 +5,10 @@
Installation (Linux)
-### Activate shark.venv Virtual Environment
+### Activate amdshark.venv Virtual Environment
```shell
-source shark.venv/bin/activate
+source amdshark.venv/bin/activate
# Some older pip installs may not be able to handle the recent PyTorch deps
python -m pip install --upgrade pip
diff --git a/shark/examples/shark_training/stable-diffusion-img2img/setup.sh b/amdshark/examples/amdshark_training/stable-diffusion-img2img/setup.sh
similarity index 100%
rename from shark/examples/shark_training/stable-diffusion-img2img/setup.sh
rename to amdshark/examples/amdshark_training/stable-diffusion-img2img/setup.sh
diff --git a/shark/examples/shark_training/stable-diffusion-img2img/stable_diffusion_img2img.py b/amdshark/examples/amdshark_training/stable-diffusion-img2img/stable_diffusion_img2img.py
similarity index 100%
rename from shark/examples/shark_training/stable-diffusion-img2img/stable_diffusion_img2img.py
rename to amdshark/examples/amdshark_training/stable-diffusion-img2img/stable_diffusion_img2img.py
diff --git a/shark/examples/shark_training/stable_diffusion/README.md b/amdshark/examples/amdshark_training/stable_diffusion/README.md
similarity index 90%
rename from shark/examples/shark_training/stable_diffusion/README.md
rename to amdshark/examples/amdshark_training/stable_diffusion/README.md
index a1ba77c0..d182c7a4 100644
--- a/shark/examples/shark_training/stable_diffusion/README.md
+++ b/amdshark/examples/amdshark_training/stable_diffusion/README.md
@@ -2,10 +2,10 @@
## Installation (Linux)
-### Activate shark.venv Virtual Environment
+### Activate amdshark.venv Virtual Environment
```shell
-source shark.venv/bin/activate
+source amdshark.venv/bin/activate
# Some older pip installs may not be able to handle the recent PyTorch deps
python -m pip install --upgrade pip
@@ -23,7 +23,7 @@ pip install accelerate transformers ftfy
Please cherry-pick this branch of torch-mlir: https://github.com/vivekkhandelwal1/torch-mlir/tree/sd-ops
and build it locally. You can find the instructions for using locally build Torch-MLIR,
-here: https://github.com/nod-ai/SHARK-Studio#how-to-use-your-locally-built-iree--torch-mlir-with-shark
+here: https://github.com/nod-ai/AMDSHARK-Studio#how-to-use-your-locally-built-iree--torch-mlir-with-amdshark
## Run the Stable diffusion fine tuning
diff --git a/shark/examples/shark_training/stable_diffusion/stable_diffusion_fine_tuning.py b/amdshark/examples/amdshark_training/stable_diffusion/stable_diffusion_fine_tuning.py
similarity index 98%
rename from shark/examples/shark_training/stable_diffusion/stable_diffusion_fine_tuning.py
rename to amdshark/examples/amdshark_training/stable_diffusion/stable_diffusion_fine_tuning.py
index e16a25dd..ba462e5d 100644
--- a/shark/examples/shark_training/stable_diffusion/stable_diffusion_fine_tuning.py
+++ b/amdshark/examples/amdshark_training/stable_diffusion/stable_diffusion_fine_tuning.py
@@ -24,7 +24,7 @@ from torch_mlir.dynamo import make_simple_dynamo_backend
import torch._dynamo as dynamo
from torch.fx.experimental.proxy_tensor import make_fx
from torch_mlir_e2e_test.linalg_on_tensors_backends import refbackend
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
torch._dynamo.config.verbose = True
@@ -476,8 +476,8 @@ class UnetModel(torch.nn.Module):
return self.unet.forward(x, y, z, return_dict=False)[0]
-shark_vae = VaeModel()
-shark_unet = UnetModel()
+amdshark_vae = VaeModel()
+amdshark_unet = UnetModel()
####### Creating our training data ########
@@ -638,14 +638,14 @@ def refbackend_torchdynamo_backend(
mlir_module.operation.write_bytecode(bytecode_stream)
bytecode = bytecode_stream.getvalue()
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=bytecode, device=args.device, mlir_dialect="tm_tensor"
)
- shark_module.compile()
+ amdshark_module.compile()
def compiled_callable(*inputs):
inputs = [x.numpy() for x in inputs]
- result = shark_module("forward", inputs)
+ result = amdshark_module("forward", inputs)
if was_unwrapped:
result = [
result,
@@ -709,7 +709,7 @@ optimizer = torch.optim.AdamW(
# Training function
def train_func(batch_pixel_values, batch_input_ids):
# Convert images to latent space
- latents = shark_vae(batch_pixel_values).sample().detach()
+ latents = amdshark_vae(batch_pixel_values).sample().detach()
latents = latents * 0.18215
# Sample noise that we'll add to the latents
@@ -731,7 +731,7 @@ def train_func(batch_pixel_values, batch_input_ids):
encoder_hidden_states = text_encoder(batch_input_ids)[0]
# Predict the noise residual
- noise_pred = shark_unet(
+ noise_pred = amdshark_unet(
noisy_latents,
timesteps,
encoder_hidden_states,
diff --git a/shark/iree_eager_backend.py b/amdshark/iree_eager_backend.py
similarity index 98%
rename from shark/iree_eager_backend.py
rename to amdshark/iree_eager_backend.py
index 6be9cbf2..77dfa447 100644
--- a/shark/iree_eager_backend.py
+++ b/amdshark/iree_eager_backend.py
@@ -31,7 +31,7 @@ from torch_mlir_e2e_test.eager_backends.refbackend import (
NUMPY_TO_TORCH_DTYPE_DICT,
)
-from shark.iree_utils.compile_utils import (
+from amdshark.iree_utils.compile_utils import (
get_iree_compiled_module,
IREE_DEVICE_MAP,
)
diff --git a/apps/shark_studio/web/utils/__init__.py b/amdshark/iree_utils/__init__.py
similarity index 100%
rename from apps/shark_studio/web/utils/__init__.py
rename to amdshark/iree_utils/__init__.py
diff --git a/shark/iree_utils/_common.py b/amdshark/iree_utils/_common.py
similarity index 98%
rename from shark/iree_utils/_common.py
rename to amdshark/iree_utils/_common.py
index 8eccf242..8b8089b5 100644
--- a/shark/iree_utils/_common.py
+++ b/amdshark/iree_utils/_common.py
@@ -157,7 +157,7 @@ def device_driver_info(device):
f"Required drivers for {device} not found. {device_driver_err_map[device]['debug']} "
f"Please install the required drivers{device_driver_err_map[device]['solution']} "
f"For further assistance please reach out to the community on discord [https://discord.com/invite/RUqY2h2s9u]"
- f" and/or file a bug at https://github.com/nod-ai/SHARK-Studio/issues"
+ f" and/or file a bug at https://github.com/nod-ai/AMDSHARK-Studio/issues"
)
return err_msg
else:
diff --git a/shark/iree_utils/benchmark_utils.py b/amdshark/iree_utils/benchmark_utils.py
similarity index 96%
rename from shark/iree_utils/benchmark_utils.py
rename to amdshark/iree_utils/benchmark_utils.py
index f32380e8..d368fe1f 100644
--- a/shark/iree_utils/benchmark_utils.py
+++ b/amdshark/iree_utils/benchmark_utils.py
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from shark.iree_utils._common import run_cmd, iree_device_map
-from shark.iree_utils.cpu_utils import get_cpu_count
+from amdshark.iree_utils._common import run_cmd, iree_device_map
+from amdshark.iree_utils.cpu_utils import get_cpu_count
import numpy as np
import os
import re
@@ -132,7 +132,7 @@ def run_benchmark_module(benchmark_cl):
benchmark_path = benchmark_cl[0]
assert os.path.exists(
benchmark_path
- ), "Cannot find iree_benchmark_module, Please contact SHARK maintainer on discord."
+ ), "Cannot find iree_benchmark_module, Please contact AMDSHARK maintainer on discord."
bench_stdout, bench_stderr = run_cmd(" ".join(benchmark_cl))
try:
regex_split = re.compile("(\d+[.]*\d*)( *)([a-zA-Z]+)")
diff --git a/shark/iree_utils/compile_utils.py b/amdshark/iree_utils/compile_utils.py
similarity index 94%
rename from shark/iree_utils/compile_utils.py
rename to amdshark/iree_utils/compile_utils.py
index f93c8fef..8d7b4899 100644
--- a/shark/iree_utils/compile_utils.py
+++ b/amdshark/iree_utils/compile_utils.py
@@ -20,7 +20,7 @@ from pathlib import Path
import iree.runtime as ireert
import iree.compiler as ireec
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
from .trace import DetailLogger
from ._common import iree_device_map, iree_target_map
@@ -34,7 +34,7 @@ def get_iree_device_args(device, extra_args=[]):
device, device_num = clean_device_info(device)
if "cpu" in device:
- from shark.iree_utils.cpu_utils import get_iree_cpu_args
+ from amdshark.iree_utils.cpu_utils import get_iree_cpu_args
u_kernel_flag = ["--iree-llvmcpu-enable-ukernels"]
stack_size_flag = ["--iree-llvmcpu-stack-allocation-limit=256000"]
@@ -45,25 +45,25 @@ def get_iree_device_args(device, extra_args=[]):
+ stack_size_flag
)
if device == "cuda":
- from shark.iree_utils.gpu_utils import get_iree_gpu_args
+ from amdshark.iree_utils.gpu_utils import get_iree_gpu_args
return get_iree_gpu_args()
if device == "vulkan":
- from shark.iree_utils.vulkan_utils import get_iree_vulkan_args
+ from amdshark.iree_utils.vulkan_utils import get_iree_vulkan_args
return get_iree_vulkan_args(
device_num=device_num, extra_args=extra_args
)
if device == "metal":
- from shark.iree_utils.metal_utils import get_iree_metal_args
+ from amdshark.iree_utils.metal_utils import get_iree_metal_args
return get_iree_metal_args(extra_args=extra_args)
if device == "rocm":
- from shark.iree_utils.gpu_utils import get_iree_rocm_args
+ from amdshark.iree_utils.gpu_utils import get_iree_rocm_args
return get_iree_rocm_args(device_num=device_num, extra_args=extra_args)
if device == "hip":
- from shark.iree_utils.gpu_utils import get_iree_rocm_args
+ from amdshark.iree_utils.gpu_utils import get_iree_rocm_args
return get_iree_rocm_args(device_num=device_num, extra_args=extra_args, hip_driver=True)
return []
@@ -137,19 +137,19 @@ def get_iree_common_args(debug=False):
# Args that are suitable only for certain models or groups of models.
-# shark_args are passed down from pytests to control which models compile with these flags,
-# but they can also be set in shark/parser.py
+# amdshark_args are passed down from pytests to control which models compile with these flags,
+# but they can also be set in amdshark/parser.py
def get_model_specific_args():
ms_args = []
- if shark_args.enable_conv_transform == True:
+ if amdshark_args.enable_conv_transform == True:
ms_args += [
"--iree-preprocessing-pass-pipeline=builtin.module(func.func(iree-flow-convert-conv-nchw-to-nhwc))"
]
- if shark_args.enable_img2col_transform == True:
+ if amdshark_args.enable_img2col_transform == True:
ms_args += [
"--iree-preprocessing-pass-pipeline=builtin.module(func.func(iree-preprocessing-convert-conv2d-to-img2col))"
]
- if shark_args.use_winograd == True:
+ if amdshark_args.use_winograd == True:
ms_args += [
"--iree-preprocessing-pass-pipeline=builtin.module(func.func(iree-linalg-ext-convert-conv2d-to-winograd))"
]
@@ -262,7 +262,7 @@ def compile_benchmark_dirs(bench_dir, device, dispatch_benchmarks):
benchmark_file.write(f"DISPATCH: {d_}\n")
benchmark_file.write(str(iter_per_second) + "\n")
benchmark_file.write(
- "SHARK BENCHMARK RESULT: "
+ "AMDSHARK BENCHMARK RESULT: "
+ str(1 / (iter_per_second * 0.001))
+ "\n"
)
@@ -323,7 +323,7 @@ def compile_module_to_flatbuffer(
args += get_iree_common_args(debug=debug)
args += get_model_specific_args()
args += extra_args
- args += shark_args.additional_compile_args
+ args += amdshark_args.additional_compile_args
if frontend in ["tensorflow", "tf"]:
input_type = "auto"
@@ -382,7 +382,7 @@ def get_iree_module(
]
haldevice = haldriver.create_device(
hal_device_id,
- allocators=shark_args.device_allocator,
+ allocators=amdshark_args.device_allocator,
)
config = ireert.Config(device=haldevice)
config.id = hal_device_id
@@ -433,7 +433,7 @@ def load_vmfb_using_mmap(
]
haldevice = haldriver.create_device(
hal_device_id,
- allocators=shark_args.device_allocator,
+ allocators=amdshark_args.device_allocator,
)
dl.log(f"ireert.create_device()")
config = ireert.Config(device=haldevice)
@@ -452,9 +452,9 @@ def load_vmfb_using_mmap(
# Now load vmfb.
# Two scenarios we have here :-
# 1. We either have the vmfb already saved and therefore pass the path of it.
- # (This would arise if we're invoking `load_module` from a SharkInference obj)
+ # (This would arise if we're invoking `load_module` from a AMDSharkInference obj)
# OR 2. We are compiling on the fly, therefore we have the flatbuffer blob to play with.
- # (This would arise if we're invoking `compile` from a SharkInference obj)
+ # (This would arise if we're invoking `compile` from a AMDSharkInference obj)
temp_file_to_unlink = None
if isinstance(flatbuffer_blob_or_path, Path):
flatbuffer_blob_or_path = flatbuffer_blob_or_path.__str__()
@@ -486,7 +486,7 @@ def load_vmfb_using_mmap(
)
ctx = ireert.SystemContext(config=config, vm_modules=vm_modules)
dl.log(f"ireert.SystemContext created")
- for flag in shark_args.additional_runtime_args:
+ for flag in amdshark_args.additional_runtime_args:
ireert.flags.parse_flags(flag)
dl.log(f"module initialized")
mmaped_vmfb = getattr(ctx.modules, mmaped_vmfb.name)
@@ -650,7 +650,7 @@ def get_results(
haldriver = ireert.get_driver("rocm")
haldevice = haldriver.create_device(
config.id,
- allocators=shark_args.device_allocator,
+ allocators=amdshark_args.device_allocator,
)
for input_array in input:
dl.log(f"Load to device: {input_array.shape}")
@@ -688,7 +688,7 @@ def get_results(
def get_iree_runtime_config(device):
device = iree_device_map(device)
haldriver = ireert.get_driver(device)
- if "metal" in device and shark_args.device_allocator == "caching":
+ if "metal" in device and amdshark_args.device_allocator == "caching":
print(
"[WARNING] metal devices can not have a `caching` allocator."
"\nUsing default allocator `None`"
@@ -696,7 +696,7 @@ def get_iree_runtime_config(device):
haldevice = haldriver.create_device_by_uri(
device,
# metal devices have a failure with caching allocators atm. blcking this util it gets fixed upstream.
- allocators=shark_args.device_allocator
+ allocators=amdshark_args.device_allocator
if "metal" not in device
else None,
)
diff --git a/shark/iree_utils/cpu_utils.py b/amdshark/iree_utils/cpu_utils.py
similarity index 88%
rename from shark/iree_utils/cpu_utils.py
rename to amdshark/iree_utils/cpu_utils.py
index 8aca1170..108d597c 100644
--- a/shark/iree_utils/cpu_utils.py
+++ b/amdshark/iree_utils/cpu_utils.py
@@ -17,7 +17,7 @@
import functools
import subprocess
import platform
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
def get_cpu_count():
@@ -44,7 +44,7 @@ def get_iree_cpu_args():
elif os_name == "Windows":
target_triple = "x86_64-pc-windows-msvc"
else:
- error_message = f"OS Type f{os_name} not supported and triple can't be determined, open issue to dSHARK team please :)"
+ error_message = f"OS Type f{os_name} not supported and triple can't be determined, open issue to dAMDSHARK team please :)"
raise Exception(error_message)
print(f"Target triple found:{target_triple}")
return [
@@ -59,7 +59,7 @@ def get_iree_cpu_rt_args():
default = default if default <= 8 else default - 2
cpu_count = (
default
- if shark_args.task_topology_max_group_count is None
- else shark_args.task_topology_max_group_count
+ if amdshark_args.task_topology_max_group_count is None
+ else amdshark_args.task_topology_max_group_count
)
return [f"--task_topology_max_group_count={cpu_count}"]
diff --git a/shark/iree_utils/gpu_utils.py b/amdshark/iree_utils/gpu_utils.py
similarity index 98%
rename from shark/iree_utils/gpu_utils.py
rename to amdshark/iree_utils/gpu_utils.py
index db6ef14e..7276499d 100644
--- a/shark/iree_utils/gpu_utils.py
+++ b/amdshark/iree_utils/gpu_utils.py
@@ -19,8 +19,8 @@ import iree.runtime as ireert
import ctypes
import sys
from subprocess import CalledProcessError
-from shark.parser import shark_args
-from shark.iree_utils._common import run_cmd
+from amdshark.parser import amdshark_args
+from amdshark.iree_utils._common import run_cmd
# TODO: refactor to rocm and cuda utils
@@ -35,7 +35,7 @@ def get_iree_gpu_args():
if (
sm_arch
in ["sm_70", "sm_72", "sm_75", "sm_80", "sm_84", "sm_86", "sm_89"]
- ) and (shark_args.enable_tf32 == True):
+ ) and (amdshark_args.enable_tf32 == True):
return [
f"--iree-hal-cuda-llvm-target-arch={sm_arch}",
]
diff --git a/shark/iree_utils/metal_utils.py b/amdshark/iree_utils/metal_utils.py
similarity index 93%
rename from shark/iree_utils/metal_utils.py
rename to amdshark/iree_utils/metal_utils.py
index 21dfee84..9efe400f 100644
--- a/shark/iree_utils/metal_utils.py
+++ b/amdshark/iree_utils/metal_utils.py
@@ -16,10 +16,10 @@
import functools
-from shark.iree_utils._common import run_cmd
+from amdshark.iree_utils._common import run_cmd
import iree.runtime as ireert
from sys import platform
-from shark.iree_utils.vulkan_target_env_utils import get_vulkan_target_env_flag
+from amdshark.iree_utils.vulkan_target_env_utils import get_vulkan_target_env_flag
@functools.cache
@@ -81,7 +81,7 @@ def get_metal_triple_flag(device_name="", device_num=0, extra_args=[]):
return f"-iree-metal-target-platform={triple}"
print(
"""Optimized kernel for your target device is not added yet.
- Contact SHARK Admin on discord[https://discord.com/invite/RUqY2h2s9u]
+ Contact AMDSHARK Admin on discord[https://discord.com/invite/RUqY2h2s9u]
or pull up an issue."""
)
print(f"Target : {metal_device}")
diff --git a/shark/iree_utils/trace.py b/amdshark/iree_utils/trace.py
similarity index 97%
rename from shark/iree_utils/trace.py
rename to amdshark/iree_utils/trace.py
index ea51243b..c11eb54a 100644
--- a/shark/iree_utils/trace.py
+++ b/amdshark/iree_utils/trace.py
@@ -20,7 +20,7 @@ import time
def _enable_detail_trace() -> bool:
- return os.getenv("SHARK_DETAIL_TRACE", "0") == "1"
+ return os.getenv("AMDSHARK_DETAIL_TRACE", "0") == "1"
class DetailLogger:
diff --git a/shark/iree_utils/vulkan_target_env_utils.py b/amdshark/iree_utils/vulkan_target_env_utils.py
similarity index 100%
rename from shark/iree_utils/vulkan_target_env_utils.py
rename to amdshark/iree_utils/vulkan_target_env_utils.py
diff --git a/shark/iree_utils/vulkan_utils.py b/amdshark/iree_utils/vulkan_utils.py
similarity index 93%
rename from shark/iree_utils/vulkan_utils.py
rename to amdshark/iree_utils/vulkan_utils.py
index 96ad3360..27b9c4c7 100644
--- a/shark/iree_utils/vulkan_utils.py
+++ b/amdshark/iree_utils/vulkan_utils.py
@@ -16,11 +16,11 @@
import functools
from os import linesep
-from shark.iree_utils._common import run_cmd
+from amdshark.iree_utils._common import run_cmd
import iree.runtime as ireert
from sys import platform
-from shark.iree_utils.vulkan_target_env_utils import get_vulkan_target_env_flag
-from shark.parser import shark_args
+from amdshark.iree_utils.vulkan_target_env_utils import get_vulkan_target_env_flag
+from amdshark.parser import amdshark_args
@functools.cache
@@ -174,7 +174,7 @@ def get_vulkan_triple_flag(device_name="", device_num=0, extra_args=[]):
return f"--iree-vulkan-target-triple={triple}"
print(
"""Optimized kernel for your target device is not added yet.
- Contact SHARK Admin on discord[https://discord.com/invite/RUqY2h2s9u]
+ Contact AMDSHARK Admin on discord[https://discord.com/invite/RUqY2h2s9u]
or pull up an issue."""
)
print(f"Target : {vulkan_device}")
@@ -208,9 +208,9 @@ def get_iree_vulkan_args(device_num=0, extra_args=[]):
@functools.cache
def get_iree_vulkan_runtime_flags():
vulkan_runtime_flags = [
- f"--vulkan_validation_layers={'true' if shark_args.vulkan_debug_utils else 'false'}",
- f"--vulkan_debug_verbosity={'4' if shark_args.vulkan_debug_utils else '0'}"
- f"--vulkan-robust-buffer-access={'true' if shark_args.vulkan_debug_utils else 'false'}",
+ f"--vulkan_validation_layers={'true' if amdshark_args.vulkan_debug_utils else 'false'}",
+ f"--vulkan_debug_verbosity={'4' if amdshark_args.vulkan_debug_utils else '0'}"
+ f"--vulkan-robust-buffer-access={'true' if amdshark_args.vulkan_debug_utils else 'false'}",
]
return vulkan_runtime_flags
diff --git a/shark/model_annotation.py b/amdshark/model_annotation.py
similarity index 99%
rename from shark/model_annotation.py
rename to amdshark/model_annotation.py
index 4126a3ad..31456236 100644
--- a/shark/model_annotation.py
+++ b/amdshark/model_annotation.py
@@ -18,7 +18,7 @@ This function takes the model mlir file and the tuned config file as input,
and output a new mlir file with lowering configs annotated on certain ops.
There are two ways to utilize the function:
1. Call model_annotation function within another python script
-from shark.model_annotation import model_annotation
+from amdshark.model_annotation import model_annotation
with create_context() as ctx:
module = model_annotation(ctx, input_contents=..., config_path=..., search_op=...)
2. Run model_annotation.py directly
diff --git a/shark/parser.py b/amdshark/parser.py
similarity index 86%
rename from shark/parser.py
rename to amdshark/parser.py
index 008c42f0..03a05439 100644
--- a/shark/parser.py
+++ b/amdshark/parser.py
@@ -29,13 +29,13 @@ class SplitStrToListAction(argparse.Action):
setattr(namespace, self.dest, shlex.split(" "))
-parser = argparse.ArgumentParser(description="SHARK runner.")
+parser = argparse.ArgumentParser(description="AMDSHARK runner.")
parser.add_argument(
"--device",
type=str,
default="cpu",
- help="Device on which shark_runner runs. options are cpu, cuda, and vulkan",
+ help="Device on which amdshark_runner runs. options are cpu, cuda, and vulkan",
)
parser.add_argument(
"--additional_compile_args",
@@ -82,26 +82,26 @@ parser.add_argument(
help="When enabled, pytest bench results will include ONNX benchmark results.",
)
parser.add_argument(
- "--shark_prefix",
+ "--amdshark_prefix",
default=None,
- help="gs://shark_tank//model_directories",
+ help="gs://amdshark_tank//model_directories",
)
parser.add_argument(
"--update_tank",
default=True,
action="store_true",
- help="When enabled, SHARK downloader will update local shark_tank if local hash is different from latest upstream hash.",
+ help="When enabled, AMDSHARK downloader will update local amdshark_tank if local hash is different from latest upstream hash.",
)
parser.add_argument(
"--force_update_tank",
default=False,
action="store_true",
- help="When enabled, SHARK downloader will force an update of local shark_tank artifacts for each request.",
+ help="When enabled, AMDSHARK downloader will force an update of local amdshark_tank artifacts for each request.",
)
parser.add_argument(
"--local_tank_cache",
default=None,
- help="Specify where to save downloaded shark_tank artifacts. If this is not set, the default is ~/.local/shark_tank/.",
+ help="Specify where to save downloaded amdshark_tank artifacts. If this is not set, the default is ~/.local/amdshark_tank/.",
)
parser.add_argument(
@@ -167,4 +167,4 @@ parser.add_argument(
help="Flag for disabling vulkan validation layers when benchmarking.",
)
-shark_args, unknown = parser.parse_known_args()
+amdshark_args, unknown = parser.parse_known_args()
diff --git a/shark/stress_test.py b/amdshark/stress_test.py
similarity index 89%
rename from shark/stress_test.py
rename to amdshark/stress_test.py
index 44dc9c42..0f5fb93f 100644
--- a/shark/stress_test.py
+++ b/amdshark/stress_test.py
@@ -13,25 +13,25 @@
# limitations under the License.
from iree.runtime import query_available_drivers, get_driver
-from shark.shark_downloader import download_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_model
+from amdshark.amdshark_inference import AMDSharkInference
from typing import List, Optional, Tuple
import numpy as np
import argparse
-from shark.iree_utils._common import _IREE_DEVICE_MAP
+from amdshark.iree_utils._common import _IREE_DEVICE_MAP
import multiprocessing
-from shark.shark_runner import supported_dialects
+from amdshark.amdshark_runner import supported_dialects
import logging
from concurrent.futures import ProcessPoolExecutor
from concurrent.futures.thread import ThreadPoolExecutor
import time
import numpy as np
-IREE_TO_SHARK_DRIVER_MAP = {v: k for k, v in _IREE_DEVICE_MAP.items()}
+IREE_TO_AMDSHARK_DRIVER_MAP = {v: k for k, v in _IREE_DEVICE_MAP.items()}
def stress_test_compiled_model(
- shark_module_path: str,
+ amdshark_module_path: str,
function_name: str,
device: str,
inputs: List[np.ndarray],
@@ -50,14 +50,14 @@ def stress_test_compiled_model(
# We are using execution in a sperate thread in order to be able
# to wait with a timeout on the inference operation.
module_executor = ThreadPoolExecutor(1)
- shark_module = module_executor.submit(
- SharkInference,
+ amdshark_module = module_executor.submit(
+ AMDSharkInference,
mlir_module=bytes(),
function_name=function_name,
device=device,
).result()
module_executor.submit(
- shark_module.load_module, shark_module_path
+ amdshark_module.load_module, amdshark_module_path
).result()
input_batches = [np.repeat(arr, batch_size, axis=0) for arr in inputs]
golden_output_batches = np.repeat(golden_out, batch_size, axis=0)
@@ -67,7 +67,7 @@ def stress_test_compiled_model(
first_iteration_output = None
for i in range(max_iterations):
output = module_executor.submit(
- shark_module.forward, input_batches
+ amdshark_module.forward, input_batches
).result(inference_timeout_seconds)
if first_iteration_output is None:
np.testing.assert_array_almost_equal_nulp(
@@ -100,9 +100,9 @@ def query_devices(device_types: Optional[List[str]] = None) -> List[str]:
devices = []
if device_types is None:
device_types = [
- IREE_TO_SHARK_DRIVER_MAP[name]
+ IREE_TO_AMDSHARK_DRIVER_MAP[name]
for name in query_available_drivers()
- if name in IREE_TO_SHARK_DRIVER_MAP
+ if name in IREE_TO_AMDSHARK_DRIVER_MAP
]
for device_type in device_types:
driver = get_driver(_IREE_DEVICE_MAP[device_type])
@@ -121,19 +121,19 @@ def query_devices(device_types: Optional[List[str]] = None) -> List[str]:
def compile_stress_test_module(
device_types: List[str], mlir_model: str, func_name: str, mlir_dialect: str
) -> List[str]:
- shark_module_paths = []
+ amdshark_module_paths = []
for device_type in device_types:
logging.info(
f"Compiling stress test model for device type {device_type}."
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_model,
func_name,
mlir_dialect=mlir_dialect,
device=device_type,
)
- shark_module_paths.append(shark_module.save_module())
- return shark_module_paths
+ amdshark_module_paths.append(amdshark_module.save_module())
+ return amdshark_module_paths
def stress_test(
@@ -169,21 +169,21 @@ def stress_test(
# This needs to run in a subprocess because when compiling for CUDA,
# some stuff get intialized and cuInit will fail in a forked process
# later. It should be just compiling, but alas.
- shark_module_paths_set = executor.submit(
+ amdshark_module_paths_set = executor.submit(
compile_stress_test_module,
device_types_set,
mlir_model,
func_name,
mlir_dialect,
).result()
- device_type_shark_module_path_map = {
+ device_type_amdshark_module_path_map = {
device_type: module_path
for device_type, module_path in zip(
- device_types_set, shark_module_paths_set
+ device_types_set, amdshark_module_paths_set
)
}
- device_name_shark_module_path_map = {
- device_name: device_type_shark_module_path_map[
+ device_name_amdshark_module_path_map = {
+ device_name: device_type_amdshark_module_path_map[
get_device_type(device_name)
]
for device_name in device_names
@@ -193,7 +193,7 @@ def stress_test(
# in IREE and a subsequent call to `iree.runtime.SystemContext.add_vm_module`
# in a forked process will hang.
with multiprocessing.Pool(
- len(device_name_shark_module_path_map) * oversubscription_factor
+ len(device_name_amdshark_module_path_map) * oversubscription_factor
) as process_pool:
process_pool.starmap(
stress_test_compiled_model,
@@ -212,7 +212,7 @@ def stress_test(
stress_test_index,
)
for stress_test_index, (device_name, module_path) in enumerate(
- list(device_name_shark_module_path_map.items())
+ list(device_name_amdshark_module_path_map.items())
* oversubscription_factor
)
],
diff --git a/shark/tests/test_shark_importer.py b/amdshark/tests/test_amdshark_importer.py
similarity index 84%
rename from shark/tests/test_shark_importer.py
rename to amdshark/tests/test_amdshark_importer.py
index 801a7b45..fa42f092 100644
--- a/shark/tests/test_shark_importer.py
+++ b/amdshark/tests/test_amdshark_importer.py
@@ -1,10 +1,10 @@
# RUN: %PYTHON %s
import numpy as np
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_importer import AMDSharkImporter
import pytest
-from shark.parser import shark_args
-from shark.shark_inference import SharkInference
-from shark.tflite_utils import TFLitePreprocessor
+from amdshark.parser import amdshark_args
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.tflite_utils import TFLitePreprocessor
import sys
# model_path = "https://tfhub.dev/tensorflow/lite-model/albert_lite_base/squadv1/1?lite-format=tflite"
@@ -66,32 +66,32 @@ class AlbertTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
tflite_preprocessor = TFLitePreprocessor(model_name="albert_lite_base")
raw_model_file_path = tflite_preprocessor.get_raw_model_file()
inputs = tflite_preprocessor.get_inputs()
tflite_interpreter = tflite_preprocessor.get_interpreter()
- my_shark_importer = SharkImporter(
+ my_amdshark_importer = AMDSharkImporter(
module=tflite_interpreter,
inputs=inputs,
frontend="tflite",
raw_model_file=raw_model_file_path,
)
- mlir_model, func_name = my_shark_importer.import_mlir()
+ mlir_model, func_name = my_amdshark_importer.import_mlir()
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
## post process results for compare
input_details, output_details = tflite_preprocessor.get_model_details()
mlir_results = list(mlir_results)
@@ -105,14 +105,14 @@ class AlbertTfliteModuleTester:
input_details, output_details = tflite_preprocessor.get_model_details()
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
## post process results for compare
tflite_results = tflite_preprocessor.get_golden_output()
compare_results(mlir_results, tflite_results, output_details)
diff --git a/shark/tests/test_stress_test.py b/amdshark/tests/test_stress_test.py
similarity index 92%
rename from shark/tests/test_stress_test.py
rename to amdshark/tests/test_stress_test.py
index 1474da12..4fb2c1f3 100644
--- a/shark/tests/test_stress_test.py
+++ b/amdshark/tests/test_stress_test.py
@@ -22,7 +22,7 @@ def test_stress_test():
subprocess.check_call(
[
sys.executable,
- importlib.util.find_spec("shark.stress_test").origin,
+ importlib.util.find_spec("amdshark.stress_test").origin,
"--model=squeezenet1_0",
"--devices",
"cpu",
diff --git a/shark/tests/test_txt2img_ui.py b/amdshark/tests/test_txt2img_ui.py
similarity index 100%
rename from shark/tests/test_txt2img_ui.py
rename to amdshark/tests/test_txt2img_ui.py
diff --git a/shark/tflite_utils.py b/amdshark/tflite_utils.py
similarity index 99%
rename from shark/tflite_utils.py
rename to amdshark/tflite_utils.py
index b6755aa5..b08716dd 100644
--- a/shark/tflite_utils.py
+++ b/amdshark/tflite_utils.py
@@ -96,7 +96,7 @@ class TFLitePreprocessor:
print("Setting up for TMP_WORK_DIR")
self.workdir = os.path.join(
- os.path.dirname(__file__), "./../gen_shark_tank"
+ os.path.dirname(__file__), "./../gen_amdshark_tank"
)
os.makedirs(self.workdir, exist_ok=True)
print(f"TMP_WORK_DIR = {self.workdir}")
diff --git a/shark/torch_mlir_lockstep_tensor.py b/amdshark/torch_mlir_lockstep_tensor.py
similarity index 99%
rename from shark/torch_mlir_lockstep_tensor.py
rename to amdshark/torch_mlir_lockstep_tensor.py
index bfcaafed..44fdf789 100644
--- a/shark/torch_mlir_lockstep_tensor.py
+++ b/amdshark/torch_mlir_lockstep_tensor.py
@@ -28,7 +28,7 @@ from torch_mlir.eager_mode.torch_mlir_tensor import (
no_dispatch,
)
from torch_mlir.eager_mode import torch_mlir_tensor
-from shark.iree_eager_backend import EagerModeIREELinalgOnTensorsBackend
+from amdshark.iree_eager_backend import EagerModeIREELinalgOnTensorsBackend
backend = EagerModeIREELinalgOnTensorsBackend("cpu")
diff --git a/shark/torch_mlir_utils.py b/amdshark/torch_mlir_utils.py
similarity index 98%
rename from shark/torch_mlir_utils.py
rename to amdshark/torch_mlir_utils.py
index 85593d54..ee6af6dc 100644
--- a/shark/torch_mlir_utils.py
+++ b/amdshark/torch_mlir_utils.py
@@ -16,7 +16,7 @@ from torch_mlir.ir import StringAttr
import torch_mlir
from torch_mlir_e2e_test.linalg_on_tensors_backends import refbackend
import tempfile
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import io
mlir_type_mapping_dict = {
diff --git a/apps/shark_studio/shark_studio.spec b/apps/amdshark_studio/amdshark_studio.spec
similarity index 89%
rename from apps/shark_studio/shark_studio.spec
rename to apps/amdshark_studio/amdshark_studio.spec
index 1c87c953..49c0b7fd 100644
--- a/apps/shark_studio/shark_studio.spec
+++ b/apps/amdshark_studio/amdshark_studio.spec
@@ -1,5 +1,5 @@
# -*- mode: python ; coding: utf-8 -*-
-from apps.shark_studio.studio_imports import pathex, datas, hiddenimports
+from apps.amdshark_studio.studio_imports import pathex, datas, hiddenimports
binaries = []
@@ -32,7 +32,7 @@ exe = EXE(
a.zipfiles,
a.datas,
[],
- name='nodai_shark_studio',
+ name='nodai_amdshark_studio',
debug=False,
bootloader_ignore_signals=False,
strip=False,
diff --git a/apps/shark_studio/api/controlnet.py b/apps/amdshark_studio/api/controlnet.py
similarity index 98%
rename from apps/shark_studio/api/controlnet.py
rename to apps/amdshark_studio/api/controlnet.py
index 2c8a8b56..cfc0fb7a 100644
--- a/apps/shark_studio/api/controlnet.py
+++ b/apps/amdshark_studio/api/controlnet.py
@@ -2,7 +2,7 @@
import os
import PIL
import numpy as np
-from apps.shark_studio.web.utils.file_utils import (
+from apps.amdshark_studio.web.utils.file_utils import (
get_generated_imgs_path,
)
from datetime import datetime
diff --git a/apps/shark_studio/api/initializers.py b/apps/amdshark_studio/api/initializers.py
similarity index 85%
rename from apps/shark_studio/api/initializers.py
rename to apps/amdshark_studio/api/initializers.py
index a8119a7d..6197f2ac 100644
--- a/apps/shark_studio/api/initializers.py
+++ b/apps/amdshark_studio/api/initializers.py
@@ -6,13 +6,13 @@ import warnings
import json
from threading import Thread
-from apps.shark_studio.modules.timer import startup_timer
+from apps.amdshark_studio.modules.timer import startup_timer
-from apps.shark_studio.web.utils.tmp_configs import (
+from apps.amdshark_studio.web.utils.tmp_configs import (
config_tmp,
clear_tmp_mlir,
clear_tmp_imgs,
- shark_tmp,
+ amdshark_tmp,
)
@@ -30,12 +30,12 @@ def imports():
startup_timer.record("import gradio")
- import apps.shark_studio.web.utils.globals as global_obj
+ import apps.amdshark_studio.web.utils.globals as global_obj
global_obj._init()
startup_timer.record("initialize globals")
- from apps.shark_studio.modules import (
+ from apps.amdshark_studio.modules import (
img_processing,
) # noqa: F401
@@ -44,7 +44,7 @@ def imports():
def initialize():
configure_sigint_handler()
- # Setup to use shark_tmp for gradio's temporary image files and clear any
+ # Setup to use amdshark_tmp for gradio's temporary image files and clear any
# existing temporary images there if they exist. Then we can import gradio.
# It has to be in this order or gradio ignores what we've set up.
@@ -52,7 +52,7 @@ def initialize():
# clear_tmp_mlir()
clear_tmp_imgs()
- from apps.shark_studio.web.utils.file_utils import (
+ from apps.amdshark_studio.web.utils.file_utils import (
create_model_folders,
)
@@ -83,7 +83,7 @@ def dumpstacks():
code.append(f"""File: "{filename}", line {lineno}, in {name}""")
if line:
code.append(" " + line.strip())
- with open(os.path.join(shark_tmp, "stack_dump.log"), "w") as f:
+ with open(os.path.join(amdshark_tmp, "stack_dump.log"), "w") as f:
f.write("\n".join(code))
@@ -100,7 +100,7 @@ def setup_middleware(app):
def configure_cors_middleware(app):
from starlette.middleware.cors import CORSMiddleware
- from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+ from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
cors_options = {
"allow_methods": ["*"],
diff --git a/apps/shark_studio/api/llm.py b/apps/amdshark_studio/api/llm.py
similarity index 98%
rename from apps/shark_studio/api/llm.py
rename to apps/amdshark_studio/api/llm.py
index f6d33adc..ff5dd770 100644
--- a/apps/shark_studio/api/llm.py
+++ b/apps/amdshark_studio/api/llm.py
@@ -2,13 +2,13 @@ from turbine_models.custom_models import stateless_llama
from turbine_models.model_runner import vmfbRunner
from turbine_models.gen_external_params.gen_external_params import gen_external_params
import time
-from shark.iree_utils.compile_utils import compile_module_to_flatbuffer
-from apps.shark_studio.web.utils.file_utils import (
+from amdshark.iree_utils.compile_utils import compile_module_to_flatbuffer
+from apps.amdshark_studio.web.utils.file_utils import (
get_resource_path,
get_checkpoints_path,
)
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
-from apps.shark_studio.api.utils import parse_device
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.api.utils import parse_device
from urllib.request import urlopen
import iree.runtime as ireert
from itertools import chain
@@ -366,7 +366,7 @@ def get_mfma_spec_path(target_chip, save_dir):
def llm_chat_api(InputData: dict):
from datetime import datetime as dt
- import apps.shark_studio.web.utils.globals as global_obj
+ import apps.amdshark_studio.web.utils.globals as global_obj
print(f"Input keys : {InputData.keys()}")
diff --git a/apps/shark_studio/api/sd.py b/apps/amdshark_studio/api/sd.py
similarity index 93%
rename from apps/shark_studio/api/sd.py
rename to apps/amdshark_studio/api/sd.py
index 1b535b66..280a52ed 100644
--- a/apps/shark_studio/api/sd.py
+++ b/apps/amdshark_studio/api/sd.py
@@ -12,26 +12,26 @@ from tqdm.auto import tqdm
from pathlib import Path
from random import randint
-from turbine_models.custom_models.sd_inference.sd_pipeline import SharkSDPipeline
+from turbine_models.custom_models.sd_inference.sd_pipeline import AMDSharkSDPipeline
from turbine_models.custom_models.sdxl_inference.sdxl_compiled_pipeline import (
- SharkSDXLPipeline,
+ AMDSharkSDXLPipeline,
)
-from apps.shark_studio.api.controlnet import control_adapter_map
-from apps.shark_studio.api.utils import parse_device
-from apps.shark_studio.web.utils.state import status_label
-from apps.shark_studio.web.utils.file_utils import (
+from apps.amdshark_studio.api.controlnet import control_adapter_map
+from apps.amdshark_studio.api.utils import parse_device
+from apps.amdshark_studio.web.utils.state import status_label
+from apps.amdshark_studio.web.utils.file_utils import (
safe_name,
get_resource_path,
get_checkpoints_path,
)
-from apps.shark_studio.modules.img_processing import (
+from apps.amdshark_studio.modules.img_processing import (
save_output_img,
)
-from apps.shark_studio.modules.ckpt_processing import (
+from apps.amdshark_studio.modules.ckpt_processing import (
preprocessCKPT,
save_irpa,
)
@@ -114,10 +114,10 @@ class StableDiffusion:
self.turbine_pipe = custom_module.StudioPipeline
self.model_map = custom_module.MODEL_MAP
elif self.is_sdxl:
- self.turbine_pipe = SharkSDXLPipeline
+ self.turbine_pipe = AMDSharkSDXLPipeline
self.model_map = EMPTY_SDXL_MAP
else:
- self.turbine_pipe = SharkSDPipeline
+ self.turbine_pipe = AMDSharkSDPipeline
self.model_map = EMPTY_SD_MAP
max_length = 64
target_backend, self.rt_device, triple = parse_device(device, target_triple)
@@ -273,7 +273,7 @@ class StableDiffusion:
return img
-def shark_sd_fn_dict_input(
+def amdshark_sd_fn_dict_input(
sd_kwargs: dict,
):
print("\n[LOG] Submitting Request...")
@@ -312,11 +312,11 @@ def shark_sd_fn_dict_input(
)
return None, ""
- generated_imgs = yield from shark_sd_fn(**sd_kwargs)
+ generated_imgs = yield from amdshark_sd_fn(**sd_kwargs)
return generated_imgs
-def shark_sd_fn(
+def amdshark_sd_fn(
prompt,
negative_prompt,
sd_init_image: list,
@@ -346,8 +346,8 @@ def shark_sd_fn(
sd_init_image = [sd_init_image]
is_img2img = True if sd_init_image[0] is not None else False
- from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
- import apps.shark_studio.web.utils.globals as global_obj
+ from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
+ import apps.amdshark_studio.web.utils.globals as global_obj
adapters = {}
is_controlled = False
@@ -466,7 +466,7 @@ def shark_sd_fn(
def unload_sd():
print("Unloading models.")
- import apps.shark_studio.web.utils.globals as global_obj
+ import apps.amdshark_studio.web.utils.globals as global_obj
global_obj.clear_cache()
gc.collect()
@@ -489,8 +489,8 @@ def safe_name(name):
if __name__ == "__main__":
- from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
- import apps.shark_studio.web.utils.globals as global_obj
+ from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
+ import apps.amdshark_studio.web.utils.globals as global_obj
global_obj._init()
@@ -501,5 +501,5 @@ if __name__ == "__main__":
for arg in vars(cmd_opts):
if arg in sd_kwargs:
sd_kwargs[arg] = getattr(cmd_opts, arg)
- for i in shark_sd_fn_dict_input(sd_kwargs):
+ for i in amdshark_sd_fn_dict_input(sd_kwargs):
print(i)
diff --git a/apps/shark_studio/api/utils.py b/apps/amdshark_studio/api/utils.py
similarity index 95%
rename from apps/shark_studio/api/utils.py
rename to apps/amdshark_studio/api/utils.py
index e61e99b7..58446d88 100644
--- a/apps/shark_studio/api/utils.py
+++ b/apps/amdshark_studio/api/utils.py
@@ -8,11 +8,11 @@ from random import (
)
from pathlib import Path
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
from cpuinfo import get_cpu_info
# TODO: migrate these utils to studio
-from shark.iree_utils.vulkan_utils import (
+from amdshark.iree_utils.vulkan_utils import (
set_iree_vulkan_runtime_flags,
get_vulkan_target_triple,
get_iree_vulkan_runtime_flags,
@@ -21,7 +21,7 @@ from shark.iree_utils.vulkan_utils import (
def get_available_devices():
def get_devices_by_name(driver_name):
- from shark.iree_utils._common import iree_device_map
+ from amdshark.iree_utils._common import iree_device_map
device_list = []
try:
@@ -59,7 +59,7 @@ def get_available_devices():
cpu_device = get_devices_by_name("cpu-task")
available_devices.extend(cpu_device)
- from shark.iree_utils.vulkan_utils import (
+ from amdshark.iree_utils.vulkan_utils import (
get_all_vulkan_devices,
)
@@ -116,7 +116,7 @@ def set_init_device_flags():
elif "metal" in cmd_opts.device:
device_name, cmd_opts.device = map_device_to_name_path(cmd_opts.device)
if not cmd_opts.iree_metal_target_platform:
- from shark.iree_utils.metal_utils import get_metal_target_triple
+ from amdshark.iree_utils.metal_utils import get_metal_target_triple
triple = get_metal_target_triple(device_name)
if triple is not None:
@@ -146,7 +146,7 @@ def set_iree_runtime_flags():
def parse_device(device_str, target_override=""):
- from shark.iree_utils.compile_utils import (
+ from amdshark.iree_utils.compile_utils import (
clean_device_info,
get_iree_target_triple,
iree_target_map,
@@ -192,7 +192,7 @@ def get_rocm_target_chip(device_str):
if key in device_str:
return rocm_chip_map[key]
raise AssertionError(
- f"Device {device_str} not recognized. Please file an issue at https://github.com/nod-ai/SHARK-Studio/issues."
+ f"Device {device_str} not recognized. Please file an issue at https://github.com/nod-ai/AMDSHARK-Studio/issues."
)
@@ -225,7 +225,7 @@ def get_device_mapping(driver, key_combination=3):
dict: map to possible device names user can input mapped to desired
combination of name/path.
"""
- from shark.iree_utils._common import iree_device_map
+ from amdshark.iree_utils._common import iree_device_map
driver = iree_device_map(driver)
device_list = get_all_devices(driver)
@@ -256,7 +256,7 @@ def get_opt_flags(model, precision="fp16"):
f"-iree-vulkan-target-triple={cmd_opts.iree_vulkan_target_triple}"
)
if "rocm" in cmd_opts.device:
- from shark.iree_utils.gpu_utils import get_iree_rocm_args
+ from amdshark.iree_utils.gpu_utils import get_iree_rocm_args
rocm_args = get_iree_rocm_args()
iree_flags.extend(rocm_args)
@@ -301,7 +301,7 @@ def map_device_to_name_path(device, key_combination=3):
return device_mapping
def get_devices_by_name(driver_name):
- from shark.iree_utils._common import iree_device_map
+ from amdshark.iree_utils._common import iree_device_map
device_list = []
try:
@@ -332,7 +332,7 @@ def map_device_to_name_path(device, key_combination=3):
set_iree_runtime_flags()
available_devices = []
- from shark.iree_utils.vulkan_utils import (
+ from amdshark.iree_utils.vulkan_utils import (
get_all_vulkan_devices,
)
diff --git a/apps/shark_studio/modules/ckpt_processing.py b/apps/amdshark_studio/modules/ckpt_processing.py
similarity index 98%
rename from apps/shark_studio/modules/ckpt_processing.py
rename to apps/amdshark_studio/modules/ckpt_processing.py
index e398cbca..700563ee 100644
--- a/apps/shark_studio/modules/ckpt_processing.py
+++ b/apps/amdshark_studio/modules/ckpt_processing.py
@@ -12,7 +12,7 @@ from pathlib import Path
from tqdm import tqdm
from omegaconf import OmegaConf
from diffusers import StableDiffusionPipeline
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
from diffusers.pipelines.stable_diffusion.convert_from_ckpt import (
download_from_original_stable_diffusion_ckpt,
create_vae_diffusers_config,
diff --git a/apps/shark_studio/modules/embeddings.py b/apps/amdshark_studio/modules/embeddings.py
similarity index 99%
rename from apps/shark_studio/modules/embeddings.py
rename to apps/amdshark_studio/modules/embeddings.py
index 95d228d7..1f6a4d8f 100644
--- a/apps/shark_studio/modules/embeddings.py
+++ b/apps/amdshark_studio/modules/embeddings.py
@@ -5,7 +5,7 @@ import json
import safetensors
from dataclasses import dataclass
from safetensors.torch import load_file
-from apps.shark_studio.web.utils.file_utils import (
+from apps.amdshark_studio.web.utils.file_utils import (
get_checkpoint_pathfile,
get_path_stem,
)
diff --git a/apps/shark_studio/modules/img_processing.py b/apps/amdshark_studio/modules/img_processing.py
similarity index 98%
rename from apps/shark_studio/modules/img_processing.py
rename to apps/amdshark_studio/modules/img_processing.py
index 401c042a..72052793 100644
--- a/apps/shark_studio/modules/img_processing.py
+++ b/apps/amdshark_studio/modules/img_processing.py
@@ -25,11 +25,11 @@ resampler_list = resamplers.keys()
# save output images and the inputs corresponding to it.
def save_output_img(output_img, img_seed, extra_info=None):
- from apps.shark_studio.web.utils.file_utils import (
+ from apps.amdshark_studio.web.utils.file_utils import (
get_generated_imgs_path,
get_generated_imgs_todays_subdir,
)
- from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+ from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
if extra_info is None:
extra_info = {}
diff --git a/apps/shark_studio/modules/logger.py b/apps/amdshark_studio/modules/logger.py
similarity index 86%
rename from apps/shark_studio/modules/logger.py
rename to apps/amdshark_studio/modules/logger.py
index bff6c933..143bfccc 100644
--- a/apps/shark_studio/modules/logger.py
+++ b/apps/amdshark_studio/modules/logger.py
@@ -30,8 +30,8 @@ def logger_test(x):
def read_sd_logs():
sys.stdout.flush()
- with open("shark_tmp/sd.log", "r") as f:
+ with open("amdshark_tmp/sd.log", "r") as f:
return f.read()
-sys.stdout = Logger("shark_tmp/sd.log", filter="[LOG]")
+sys.stdout = Logger("amdshark_tmp/sd.log", filter="[LOG]")
diff --git a/apps/shark_studio/modules/pipeline.py b/apps/amdshark_studio/modules/pipeline.py
similarity index 97%
rename from apps/shark_studio/modules/pipeline.py
rename to apps/amdshark_studio/modules/pipeline.py
index 2daedc33..a9b7066b 100644
--- a/apps/shark_studio/modules/pipeline.py
+++ b/apps/amdshark_studio/modules/pipeline.py
@@ -1,14 +1,14 @@
-from shark.iree_utils.compile_utils import (
+from amdshark.iree_utils.compile_utils import (
get_iree_compiled_module,
load_vmfb_using_mmap,
clean_device_info,
get_iree_target_triple,
)
-from apps.shark_studio.web.utils.file_utils import (
+from apps.amdshark_studio.web.utils.file_utils import (
get_checkpoints_path,
get_resource_path,
)
-from apps.shark_studio.modules.shared_cmd_opts import (
+from apps.amdshark_studio.modules.shared_cmd_opts import (
cmd_opts,
)
from iree import runtime as ireert
@@ -17,7 +17,7 @@ import gc
import os
-class SharkPipelineBase:
+class AMDSharkPipelineBase:
# This class is a lightweight base for managing an
# inference API class. It should provide methods for:
# - compiling a set (model map) of torch IR modules
diff --git a/apps/shark_studio/modules/prompt_encoding.py b/apps/amdshark_studio/modules/prompt_encoding.py
similarity index 99%
rename from apps/shark_studio/modules/prompt_encoding.py
rename to apps/amdshark_studio/modules/prompt_encoding.py
index 3dc61aba..2afb81a4 100644
--- a/apps/shark_studio/modules/prompt_encoding.py
+++ b/apps/amdshark_studio/modules/prompt_encoding.py
@@ -224,7 +224,7 @@ def get_unweighted_text_embeddings(
text_embedding = text_embedding[:, 1:-1]
text_embeddings.append(text_embedding)
- # SHARK: Convert the result to tensor
+ # AMDSHARK: Convert the result to tensor
# text_embeddings = torch.concat(text_embeddings, axis=1)
text_embeddings_np = np.concatenate(np.array(text_embeddings))
text_embeddings = torch.from_numpy(text_embeddings_np)
diff --git a/apps/shark_studio/modules/schedulers.py b/apps/amdshark_studio/modules/schedulers.py
similarity index 98%
rename from apps/shark_studio/modules/schedulers.py
rename to apps/amdshark_studio/modules/schedulers.py
index 731e5707..9f6f73d5 100644
--- a/apps/shark_studio/modules/schedulers.py
+++ b/apps/amdshark_studio/modules/schedulers.py
@@ -1,4 +1,4 @@
-# from shark_turbine.turbine_models.schedulers import export_scheduler_model
+# from amdshark_turbine.turbine_models.schedulers import export_scheduler_model
from diffusers import (
LCMScheduler,
LMSDiscreteScheduler,
diff --git a/apps/shark_studio/modules/seed.py b/apps/amdshark_studio/modules/seed.py
similarity index 100%
rename from apps/shark_studio/modules/seed.py
rename to apps/amdshark_studio/modules/seed.py
diff --git a/apps/shark_studio/modules/shared_cmd_opts.py b/apps/amdshark_studio/modules/shared_cmd_opts.py
similarity index 97%
rename from apps/shark_studio/modules/shared_cmd_opts.py
rename to apps/amdshark_studio/modules/shared_cmd_opts.py
index d7f5f002..bf14fed2 100644
--- a/apps/shark_studio/modules/shared_cmd_opts.py
+++ b/apps/amdshark_studio/modules/shared_cmd_opts.py
@@ -2,7 +2,7 @@ import argparse
import os
from pathlib import Path
-from apps.shark_studio.modules.img_processing import resampler_list
+from apps.amdshark_studio.modules.img_processing import resampler_list
def path_expand(s):
@@ -299,8 +299,8 @@ p.add_argument(
"--import_mlir",
default=True,
action=argparse.BooleanOptionalAction,
- help="Imports the model from torch module to shark_module otherwise "
- "downloads the model from shark_tank.",
+ help="Imports the model from torch module to amdshark_module otherwise "
+ "downloads the model from amdshark_tank.",
)
p.add_argument(
@@ -487,8 +487,8 @@ p.add_argument(
p.add_argument(
"--local_tank_cache",
default="",
- help="Specify where to save downloaded shark_tank artifacts. "
- "If this is not set, the default is ~/.local/shark_tank/.",
+ help="Specify where to save downloaded amdshark_tank artifacts. "
+ "If this is not set, the default is ~/.local/amdshark_tank/.",
)
p.add_argument(
@@ -562,7 +562,7 @@ p.add_argument(
default=False,
action=argparse.BooleanOptionalAction,
help="If import_mlir is True, saves mlir via the debug option "
- "in shark importer. Does nothing if import_mlir is false (the default).",
+ "in amdshark importer. Does nothing if import_mlir is false (the default).",
)
p.add_argument(
@@ -615,7 +615,7 @@ p.add_argument(
p.add_argument(
"--tmp_dir",
type=str,
- default=os.path.join(os.getcwd(), "shark_tmp"),
+ default=os.path.join(os.getcwd(), "amdshark_tmp"),
help="Path to tmp directory",
)
diff --git a/apps/shark_studio/modules/timer.py b/apps/amdshark_studio/modules/timer.py
similarity index 100%
rename from apps/shark_studio/modules/timer.py
rename to apps/amdshark_studio/modules/timer.py
diff --git a/apps/shark_studio/studio_imports.py b/apps/amdshark_studio/studio_imports.py
similarity index 95%
rename from apps/shark_studio/studio_imports.py
rename to apps/amdshark_studio/studio_imports.py
index 3f7aa319..1b789370 100644
--- a/apps/shark_studio/studio_imports.py
+++ b/apps/amdshark_studio/studio_imports.py
@@ -38,7 +38,7 @@ datas += collect_data_files("transformers")
datas += collect_data_files("gradio")
datas += collect_data_files("gradio_client")
datas += collect_data_files("iree", include_py_files=True)
-datas += collect_data_files("shark", include_py_files=True)
+datas += collect_data_files("amdshark", include_py_files=True)
datas += collect_data_files("tqdm")
datas += collect_data_files("tkinter")
datas += collect_data_files("sentencepiece")
@@ -54,7 +54,7 @@ datas += [
# hidden imports for pyinstaller
-hiddenimports = ["shark", "apps"]
+hiddenimports = ["amdshark", "apps"]
hiddenimports += [x for x in collect_submodules("gradio") if "tests" not in x]
hiddenimports += [x for x in collect_submodules("diffusers") if "tests" not in x]
blacklist = ["tests", "convert"]
diff --git a/apps/shark_studio/tests/api_test.py b/apps/amdshark_studio/tests/api_test.py
similarity index 77%
rename from apps/shark_studio/tests/api_test.py
rename to apps/amdshark_studio/tests/api_test.py
index 49f44825..58789fb0 100644
--- a/apps/shark_studio/tests/api_test.py
+++ b/apps/amdshark_studio/tests/api_test.py
@@ -8,14 +8,14 @@ import logging
import unittest
import json
import gc
-from apps.shark_studio.api.llm import LanguageModel, llm_chat_api
-from apps.shark_studio.api.sd import shark_sd_fn_dict_input, view_json_file
-from apps.shark_studio.web.utils.file_utils import get_resource_path
+from apps.amdshark_studio.api.llm import LanguageModel, llm_chat_api
+from apps.amdshark_studio.api.sd import amdshark_sd_fn_dict_input, view_json_file
+from apps.amdshark_studio.web.utils.file_utils import get_resource_path
# class SDAPITest(unittest.TestCase):
# def testSDSimple(self):
-# from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
-# import apps.shark_studio.web.utils.globals as global_obj
+# from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
+# import apps.amdshark_studio.web.utils.globals as global_obj
# global_obj._init()
@@ -24,7 +24,7 @@ from apps.shark_studio.web.utils.file_utils import get_resource_path
# for arg in vars(cmd_opts):
# if arg in sd_kwargs:
# sd_kwargs[arg] = getattr(cmd_opts, arg)
-# for i in shark_sd_fn_dict_input(sd_kwargs):
+# for i in amdshark_sd_fn_dict_input(sd_kwargs):
# print(i)
diff --git a/apps/shark_studio/tests/export_unet.py b/apps/amdshark_studio/tests/export_unet.py
similarity index 100%
rename from apps/shark_studio/tests/export_unet.py
rename to apps/amdshark_studio/tests/export_unet.py
diff --git a/apps/shark_studio/tests/jupiter.png b/apps/amdshark_studio/tests/jupiter.png
similarity index 100%
rename from apps/shark_studio/tests/jupiter.png
rename to apps/amdshark_studio/tests/jupiter.png
diff --git a/apps/shark_studio/tests/rest_api_test.py b/apps/amdshark_studio/tests/rest_api_test.py
similarity index 88%
rename from apps/shark_studio/tests/rest_api_test.py
rename to apps/amdshark_studio/tests/rest_api_test.py
index 741fa523..803a1e12 100644
--- a/apps/shark_studio/tests/rest_api_test.py
+++ b/apps/amdshark_studio/tests/rest_api_test.py
@@ -38,8 +38,8 @@ def llm_chat_test(verbose=False):
if __name__ == "__main__":
- # "Exercises the chatbot REST API of Shark. Make sure "
- # "Shark is running in API mode on 127.0.0.1:8080 before running"
+ # "Exercises the chatbot REST API of AMDShark. Make sure "
+ # "AMDShark is running in API mode on 127.0.0.1:8080 before running"
# "this script."
llm_chat_test(verbose=True)
diff --git a/apps/shark_studio/web/api/compat.py b/apps/amdshark_studio/web/api/compat.py
similarity index 97%
rename from apps/shark_studio/web/api/compat.py
rename to apps/amdshark_studio/web/api/compat.py
index b5e81f2e..76cbf6b9 100644
--- a/apps/shark_studio/web/api/compat.py
+++ b/apps/amdshark_studio/web/api/compat.py
@@ -18,10 +18,10 @@ from fastapi.exceptions import HTTPException
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
-# from sdapi_v1 import shark_sd_api
-from apps.shark_studio.api.llm import llm_chat_api
+# from sdapi_v1 import amdshark_sd_api
+from apps.amdshark_studio.api.llm import llm_chat_api
def decode_base64_to_image(encoding):
@@ -183,8 +183,8 @@ class ApiCompat:
self.app = app
self.queue_lock = queue_lock
api_middleware(self.app)
- # self.add_api_route("/sdapi/v1/txt2img", shark_sd_api, methods=["POST"])
- # self.add_api_route("/sdapi/v1/img2img", shark_sd_api, methods=["POST"])
+ # self.add_api_route("/sdapi/v1/txt2img", amdshark_sd_api, methods=["POST"])
+ # self.add_api_route("/sdapi/v1/img2img", amdshark_sd_api, methods=["POST"])
# self.add_api_route("/sdapi/v1/upscaler", self.upscaler_api, methods=["POST"])
# self.add_api_route("/sdapi/v1/extra-single-image", self.extras_single_image_api, methods=["POST"], response_model=models.ExtrasSingleImageResponse)
# self.add_api_route("/sdapi/v1/extra-batch-images", self.extras_batch_images_api, methods=["POST"], response_model=models.ExtrasBatchImagesResponse)
diff --git a/apps/shark_studio/web/api/sd.py b/apps/amdshark_studio/web/api/sd.py
similarity index 100%
rename from apps/shark_studio/web/api/sd.py
rename to apps/amdshark_studio/web/api/sd.py
diff --git a/apps/shark_studio/web/index.py b/apps/amdshark_studio/web/index.py
similarity index 89%
rename from apps/shark_studio/web/index.py
rename to apps/amdshark_studio/web/index.py
index 756ecad0..4c200fe4 100644
--- a/apps/shark_studio/web/index.py
+++ b/apps/amdshark_studio/web/index.py
@@ -7,10 +7,10 @@ import os
import time
import sys
import logging
-import apps.shark_studio.api.initializers as initialize
+import apps.amdshark_studio.api.initializers as initialize
-from apps.shark_studio.modules import timer
+from apps.amdshark_studio.modules import timer
startup_timer = timer.startup_timer
startup_timer.record("launcher")
@@ -24,7 +24,7 @@ if sys.platform == "darwin":
def create_api(app):
- from apps.shark_studio.web.api.compat import ApiCompat, FIFOLock
+ from apps.amdshark_studio.web.api.compat import ApiCompat, FIFOLock
queue_lock = FIFOLock()
api = ApiCompat(app, queue_lock)
@@ -33,7 +33,7 @@ def create_api(app):
def api_only():
from fastapi import FastAPI
- from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+ from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
initialize.initialize()
@@ -64,7 +64,7 @@ def launch_webui(address):
width = int(window.winfo_screenwidth() * 0.81)
height = int(window.winfo_screenheight() * 0.91)
webview.create_window(
- "SHARK AI Studio",
+ "AMDSHARK AI Studio",
url=address,
width=width,
height=height,
@@ -74,8 +74,8 @@ def launch_webui(address):
def webui():
- from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
- from apps.shark_studio.web.ui.utils import (
+ from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
+ from apps.amdshark_studio.web.ui.utils import (
amdicon_loc,
amdlogo_loc,
)
@@ -91,10 +91,10 @@ def webui():
freeze_support()
# if args.api or "api" in args.ui.split(","):
- # from apps.shark_studio.api.llm import (
+ # from apps.amdshark_studio.api.llm import (
# chat,
# )
- # from apps.shark_studio.web.api import sdapi
+ # from apps.amdshark_studio.web.api import sdapi
#
# from fastapi import FastAPI, APIRouter
# from fastapi.middleware.cors import CORSMiddleware
@@ -144,7 +144,7 @@ def webui():
dark_theme = resource_path("ui/css/sd_dark_theme.css")
gradio_workarounds = resource_path("ui/js/sd_gradio_workarounds.js")
- # from apps.shark_studio.web.ui import load_ui_from_script
+ # from apps.amdshark_studio.web.ui import load_ui_from_script
def register_button_click(button, selectedid, inputs, outputs):
button.click(
@@ -170,7 +170,7 @@ def webui():
css=dark_theme,
js=gradio_workarounds,
analytics_enabled=False,
- title="Shark Studio 2.0 Beta",
+ title="AMDShark Studio 2.0 Beta",
) as studio_web:
amd_logo = Image.open(amdlogo_loc)
gr.Image(
@@ -214,7 +214,7 @@ def webui():
if __name__ == "__main__":
- from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+ from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
if cmd_opts.webui == False:
api_only()
diff --git a/shark/dynamo_backend/__init__.py b/apps/amdshark_studio/web/ui/__init__.py
similarity index 100%
rename from shark/dynamo_backend/__init__.py
rename to apps/amdshark_studio/web/ui/__init__.py
diff --git a/apps/shark_studio/web/ui/chat.py b/apps/amdshark_studio/web/ui/chat.py
similarity index 96%
rename from apps/shark_studio/web/ui/chat.py
rename to apps/amdshark_studio/web/ui/chat.py
index cad9f4cb..1179bf3f 100644
--- a/apps/shark_studio/web/ui/chat.py
+++ b/apps/amdshark_studio/web/ui/chat.py
@@ -5,12 +5,12 @@ from pathlib import Path
from datetime import datetime as dt
import json
import sys
-from apps.shark_studio.api.llm import (
+from apps.amdshark_studio.api.llm import (
llm_model_map,
LanguageModel,
)
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
-import apps.shark_studio.web.utils.globals as global_obj
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
+import apps.amdshark_studio.web.utils.globals as global_obj
B_SYS, E_SYS = "", ""
@@ -129,7 +129,7 @@ with gr.Blocks(title="Chat") as chat_element:
tokens_time = gr.Textbox(label="Tokens generated per second")
with gr.Column():
download_vmfb = gr.Checkbox(
- label="Download vmfb from Shark tank if available",
+ label="Download vmfb from AMDShark tank if available",
value=False,
interactive=True,
visible=False,
diff --git a/apps/shark_studio/web/ui/common_events.py b/apps/amdshark_studio/web/ui/common_events.py
similarity index 95%
rename from apps/shark_studio/web/ui/common_events.py
rename to apps/amdshark_studio/web/ui/common_events.py
index 7dda8ba2..bd7055d2 100644
--- a/apps/shark_studio/web/ui/common_events.py
+++ b/apps/amdshark_studio/web/ui/common_events.py
@@ -1,8 +1,8 @@
-from apps.shark_studio.web.ui.utils import (
+from apps.amdshark_studio.web.ui.utils import (
HSLHue,
hsl_color,
)
-from apps.shark_studio.modules.embeddings import get_lora_metadata
+from apps.amdshark_studio.modules.embeddings import get_lora_metadata
# Answers HTML to show the most frequent tags used when a LoRA was trained,
diff --git a/apps/shark_studio/web/ui/css/sd_dark_theme.css b/apps/amdshark_studio/web/ui/css/sd_dark_theme.css
similarity index 99%
rename from apps/shark_studio/web/ui/css/sd_dark_theme.css
rename to apps/amdshark_studio/web/ui/css/sd_dark_theme.css
index 89c5bb57..2a2cbc9a 100644
--- a/apps/shark_studio/web/ui/css/sd_dark_theme.css
+++ b/apps/amdshark_studio/web/ui/css/sd_dark_theme.css
@@ -100,7 +100,7 @@ Procedure to upgrade the dark theme:
--input-border-width: 1px;
}
-/* SHARK theme */
+/* AMDSHARK theme */
body {
background-color: var(--background-fill-primary);
}
diff --git a/apps/shark_studio/web/ui/js/sd_gradio_workarounds.js b/apps/amdshark_studio/web/ui/js/sd_gradio_workarounds.js
similarity index 100%
rename from apps/shark_studio/web/ui/js/sd_gradio_workarounds.js
rename to apps/amdshark_studio/web/ui/js/sd_gradio_workarounds.js
diff --git a/apps/shark_studio/web/ui/logos/amd-icon.jpg b/apps/amdshark_studio/web/ui/logos/amd-icon.jpg
similarity index 100%
rename from apps/shark_studio/web/ui/logos/amd-icon.jpg
rename to apps/amdshark_studio/web/ui/logos/amd-icon.jpg
diff --git a/apps/shark_studio/web/ui/logos/amd-logo.jpg b/apps/amdshark_studio/web/ui/logos/amd-logo.jpg
similarity index 100%
rename from apps/shark_studio/web/ui/logos/amd-logo.jpg
rename to apps/amdshark_studio/web/ui/logos/amd-logo.jpg
diff --git a/apps/shark_studio/web/ui/outputgallery.py b/apps/amdshark_studio/web/ui/outputgallery.py
similarity index 98%
rename from apps/shark_studio/web/ui/outputgallery.py
rename to apps/amdshark_studio/web/ui/outputgallery.py
index 0ed467d3..561bd4d6 100644
--- a/apps/shark_studio/web/ui/outputgallery.py
+++ b/apps/amdshark_studio/web/ui/outputgallery.py
@@ -5,13 +5,13 @@ import subprocess
import sys
from PIL import Image
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
-from apps.shark_studio.web.utils.file_utils import (
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.web.utils.file_utils import (
get_generated_imgs_path,
get_generated_imgs_todays_subdir,
)
-from apps.shark_studio.web.ui.utils import amdlogo_loc
-from apps.shark_studio.web.utils.metadata import displayable_metadata
+from apps.amdshark_studio.web.ui.utils import amdlogo_loc
+from apps.amdshark_studio.web.utils.metadata import displayable_metadata
# -- Functions for file, directory and image info querying
diff --git a/apps/shark_studio/web/ui/sd.py b/apps/amdshark_studio/web/ui/sd.py
similarity index 97%
rename from apps/shark_studio/web/ui/sd.py
rename to apps/amdshark_studio/web/ui/sd.py
index c658dab0..353cc82a 100644
--- a/apps/shark_studio/web/ui/sd.py
+++ b/apps/amdshark_studio/web/ui/sd.py
@@ -9,40 +9,40 @@ from datetime import datetime as dt
from gradio.components.image_editor import (
EditorValue,
)
-from apps.shark_studio.web.utils.file_utils import (
+from apps.amdshark_studio.web.utils.file_utils import (
get_generated_imgs_path,
get_checkpoints_path,
get_checkpoints,
get_configs_path,
write_default_sd_configs,
)
-from apps.shark_studio.api.sd import (
- shark_sd_fn_dict_input,
+from apps.amdshark_studio.api.sd import (
+ amdshark_sd_fn_dict_input,
cancel_sd,
unload_sd,
)
-from apps.shark_studio.api.controlnet import (
+from apps.amdshark_studio.api.controlnet import (
cnet_preview,
)
-from apps.shark_studio.modules.schedulers import (
+from apps.amdshark_studio.modules.schedulers import (
scheduler_model_map,
)
-from apps.shark_studio.modules.img_processing import (
+from apps.amdshark_studio.modules.img_processing import (
resampler_list,
resize_stencil,
)
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
-from apps.shark_studio.web.ui.utils import (
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.web.ui.utils import (
amdlogo_loc,
none_to_str_none,
str_none_to_none,
)
-from apps.shark_studio.web.utils.state import (
+from apps.amdshark_studio.web.utils.state import (
status_label,
)
-from apps.shark_studio.web.ui.common_events import lora_changed
-from apps.shark_studio.modules import logger
-import apps.shark_studio.web.utils.globals as global_obj
+from apps.amdshark_studio.web.ui.common_events import lora_changed
+from apps.amdshark_studio.modules import logger
+import apps.amdshark_studio.web.utils.globals as global_obj
sd_default_models = [
"runwayml/stable-diffusion-v1-5",
@@ -758,7 +758,7 @@ with gr.Blocks(title="Stable Diffusion") as sd_element:
)
gen_kwargs = dict(
- fn=shark_sd_fn_dict_input,
+ fn=amdshark_sd_fn_dict_input,
inputs=[sd_json],
outputs=[
sd_gallery,
diff --git a/apps/shark_studio/web/ui/utils.py b/apps/amdshark_studio/web/ui/utils.py
similarity index 100%
rename from apps/shark_studio/web/ui/utils.py
rename to apps/amdshark_studio/web/ui/utils.py
diff --git a/apps/shark_studio/web/utils.py b/apps/amdshark_studio/web/utils.py
similarity index 100%
rename from apps/shark_studio/web/utils.py
rename to apps/amdshark_studio/web/utils.py
diff --git a/shark/iree_utils/__init__.py b/apps/amdshark_studio/web/utils/__init__.py
similarity index 100%
rename from shark/iree_utils/__init__.py
rename to apps/amdshark_studio/web/utils/__init__.py
diff --git a/apps/shark_studio/web/utils/default_configs.py b/apps/amdshark_studio/web/utils/default_configs.py
similarity index 100%
rename from apps/shark_studio/web/utils/default_configs.py
rename to apps/amdshark_studio/web/utils/default_configs.py
diff --git a/apps/shark_studio/web/utils/file_utils.py b/apps/amdshark_studio/web/utils/file_utils.py
similarity index 94%
rename from apps/shark_studio/web/utils/file_utils.py
rename to apps/amdshark_studio/web/utils/file_utils.py
index 84ba6a6c..bedd1f37 100644
--- a/apps/shark_studio/web/utils/file_utils.py
+++ b/apps/amdshark_studio/web/utils/file_utils.py
@@ -4,14 +4,14 @@ import glob
from datetime import datetime as dt
from pathlib import Path
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
checkpoints_filetypes = (
"*.ckpt",
"*.safetensors",
)
-from apps.shark_studio.web.utils.default_configs import default_sd_configs
+from apps.amdshark_studio.web.utils.default_configs import default_sd_configs
def write_default_sd_configs(path):
diff --git a/apps/shark_studio/web/utils/globals.py b/apps/amdshark_studio/web/utils/globals.py
similarity index 100%
rename from apps/shark_studio/web/utils/globals.py
rename to apps/amdshark_studio/web/utils/globals.py
diff --git a/apps/shark_studio/web/utils/metadata/__init__.py b/apps/amdshark_studio/web/utils/metadata/__init__.py
similarity index 100%
rename from apps/shark_studio/web/utils/metadata/__init__.py
rename to apps/amdshark_studio/web/utils/metadata/__init__.py
diff --git a/apps/shark_studio/web/utils/metadata/csv_metadata.py b/apps/amdshark_studio/web/utils/metadata/csv_metadata.py
similarity index 100%
rename from apps/shark_studio/web/utils/metadata/csv_metadata.py
rename to apps/amdshark_studio/web/utils/metadata/csv_metadata.py
diff --git a/apps/shark_studio/web/utils/metadata/display.py b/apps/amdshark_studio/web/utils/metadata/display.py
similarity index 100%
rename from apps/shark_studio/web/utils/metadata/display.py
rename to apps/amdshark_studio/web/utils/metadata/display.py
diff --git a/apps/shark_studio/web/utils/metadata/exif_metadata.py b/apps/amdshark_studio/web/utils/metadata/exif_metadata.py
similarity index 100%
rename from apps/shark_studio/web/utils/metadata/exif_metadata.py
rename to apps/amdshark_studio/web/utils/metadata/exif_metadata.py
diff --git a/apps/shark_studio/web/utils/metadata/format.py b/apps/amdshark_studio/web/utils/metadata/format.py
similarity index 98%
rename from apps/shark_studio/web/utils/metadata/format.py
rename to apps/amdshark_studio/web/utils/metadata/format.py
index 308d9f8e..8d4c0d3b 100644
--- a/apps/shark_studio/web/utils/metadata/format.py
+++ b/apps/amdshark_studio/web/utils/metadata/format.py
@@ -1,4 +1,4 @@
-# As SHARK has evolved more columns have been added to images_details.csv. However, since
+# As AMDSHARK has evolved more columns have been added to images_details.csv. However, since
# no version of the CSV has any headers (yet) we don't actually have anything within the
# file that tells us which parameter each column is for. So this is a list of known patterns
# indexed by length which is what we're going to have to use to guess which columns are the
diff --git a/apps/shark_studio/web/utils/metadata/png_metadata.py b/apps/amdshark_studio/web/utils/metadata/png_metadata.py
similarity index 97%
rename from apps/shark_studio/web/utils/metadata/png_metadata.py
rename to apps/amdshark_studio/web/utils/metadata/png_metadata.py
index d1cadc1e..fd64ccb5 100644
--- a/apps/shark_studio/web/utils/metadata/png_metadata.py
+++ b/apps/amdshark_studio/web/utils/metadata/png_metadata.py
@@ -1,11 +1,11 @@
import re
from pathlib import Path
-from apps.shark_studio.web.utils.file_utils import (
+from apps.amdshark_studio.web.utils.file_utils import (
get_checkpoint_pathfile,
)
-from apps.shark_studio.api.sd import EMPTY_SD_MAP as sd_model_map
+from apps.amdshark_studio.api.sd import EMPTY_SD_MAP as sd_model_map
-from apps.shark_studio.modules.schedulers import (
+from apps.amdshark_studio.modules.schedulers import (
scheduler_model_map,
)
diff --git a/apps/shark_studio/web/utils/state.py b/apps/amdshark_studio/web/utils/state.py
similarity index 95%
rename from apps/shark_studio/web/utils/state.py
rename to apps/amdshark_studio/web/utils/state.py
index 133c8fd8..c2405767 100644
--- a/apps/shark_studio/web/utils/state.py
+++ b/apps/amdshark_studio/web/utils/state.py
@@ -1,4 +1,4 @@
-import apps.shark_studio.web.utils.globals as global_obj
+import apps.amdshark_studio.web.utils.globals as global_obj
import gc
diff --git a/apps/shark_studio/web/utils/tmp_configs.py b/apps/amdshark_studio/web/utils/tmp_configs.py
similarity index 66%
rename from apps/shark_studio/web/utils/tmp_configs.py
rename to apps/amdshark_studio/web/utils/tmp_configs.py
index ebbc4ae6..a7e75469 100644
--- a/apps/shark_studio/web/utils/tmp_configs.py
+++ b/apps/amdshark_studio/web/utils/tmp_configs.py
@@ -2,9 +2,9 @@ import os
import shutil
from time import time
-from apps.shark_studio.modules.shared_cmd_opts import cmd_opts
+from apps.amdshark_studio.modules.shared_cmd_opts import cmd_opts
-shark_tmp = cmd_opts.tmp_dir # os.path.join(os.getcwd(), "shark_tmp/")
+amdshark_tmp = cmd_opts.tmp_dir # os.path.join(os.getcwd(), "amdshark_tmp/")
def clear_tmp_mlir():
@@ -12,20 +12,20 @@ def clear_tmp_mlir():
print("Clearing .mlir temporary files from a prior run. This may take some time...")
mlir_files = [
filename
- for filename in os.listdir(shark_tmp)
- if os.path.isfile(os.path.join(shark_tmp, filename))
+ for filename in os.listdir(amdshark_tmp)
+ if os.path.isfile(os.path.join(amdshark_tmp, filename))
and filename.endswith(".mlir")
]
for filename in mlir_files:
- os.remove(os.path.join(shark_tmp, filename))
+ os.remove(os.path.join(amdshark_tmp, filename))
print(f"Clearing .mlir temporary files took {time() - cleanup_start:.4f} seconds.")
def clear_tmp_imgs():
- # tell gradio to use a directory under shark_tmp for its temporary
+ # tell gradio to use a directory under amdshark_tmp for its temporary
# image files unless somewhere else has been set
if "GRADIO_TEMP_DIR" not in os.environ:
- os.environ["GRADIO_TEMP_DIR"] = os.path.join(shark_tmp, "gradio")
+ os.environ["GRADIO_TEMP_DIR"] = os.path.join(amdshark_tmp, "gradio")
print(
f"gradio temporary image cache located at {os.environ['GRADIO_TEMP_DIR']}. "
@@ -43,22 +43,22 @@ def clear_tmp_imgs():
f"Clearing gradio UI temporary image files took {time() - cleanup_start:.4f} seconds."
)
- # older SHARK versions had to workaround gradio bugs and stored things differently
+ # older AMDSHARK versions had to workaround gradio bugs and stored things differently
else:
image_files = [
filename
- for filename in os.listdir(shark_tmp)
- if os.path.isfile(os.path.join(shark_tmp, filename))
+ for filename in os.listdir(amdshark_tmp)
+ if os.path.isfile(os.path.join(amdshark_tmp, filename))
and filename.startswith("tmp")
and filename.endswith(".png")
]
if len(image_files) > 0:
print(
- "Clearing temporary image files of a prior run of a previous SHARK version. This may take some time..."
+ "Clearing temporary image files of a prior run of a previous AMDSHARK version. This may take some time..."
)
cleanup_start = time()
for filename in image_files:
- os.remove(shark_tmp + filename)
+ os.remove(amdshark_tmp + filename)
print(
f"Clearing temporary image files took {time() - cleanup_start:.4f} seconds."
)
@@ -67,9 +67,9 @@ def clear_tmp_imgs():
def config_tmp():
- # create shark_tmp if it does not exist
- if not os.path.exists(shark_tmp):
- os.mkdir(shark_tmp)
+ # create amdshark_tmp if it does not exist
+ if not os.path.exists(amdshark_tmp):
+ os.mkdir(amdshark_tmp)
clear_tmp_mlir()
clear_tmp_imgs()
diff --git a/benchmarks/hf_model_benchmark.py b/benchmarks/hf_model_benchmark.py
index e8526286..784fa7fb 100644
--- a/benchmarks/hf_model_benchmark.py
+++ b/benchmarks/hf_model_benchmark.py
@@ -1,6 +1,6 @@
import torch
-from shark.parser import parser
-from benchmarks.hf_transformer import SharkHFBenchmarkRunner
+from amdshark.parser import parser
+from benchmarks.hf_transformer import AMDSharkHFBenchmarkRunner
parser.add_argument(
"--model_name",
@@ -13,10 +13,10 @@ load_args, unknown = parser.parse_known_args()
if __name__ == "__main__":
model_name = load_args.model_name
test_input = torch.randint(2, (1, 128))
- shark_module = SharkHFBenchmarkRunner(
+ amdshark_module = AMDSharkHFBenchmarkRunner(
model_name, (test_input,), jit_trace=True
)
- shark_module.benchmark_c()
- shark_module.benchmark_python((test_input,))
- shark_module.benchmark_torch(test_input)
- shark_module.benchmark_onnx(test_input)
+ amdshark_module.benchmark_c()
+ amdshark_module.benchmark_python((test_input,))
+ amdshark_module.benchmark_torch(test_input)
+ amdshark_module.benchmark_onnx(test_input)
diff --git a/benchmarks/hf_transformer.py b/benchmarks/hf_transformer.py
index 5f4ae9d9..57144d78 100644
--- a/benchmarks/hf_transformer.py
+++ b/benchmarks/hf_transformer.py
@@ -1,6 +1,6 @@
import torch
-from shark.shark_benchmark_runner import SharkBenchmarkRunner
-from shark.parser import shark_args
+from amdshark.amdshark_benchmark_runner import AMDSharkBenchmarkRunner
+from amdshark.parser import amdshark_args
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from onnxruntime.transformers.benchmark import (
run_pytorch,
@@ -42,8 +42,8 @@ class HuggingFaceLanguage(torch.nn.Module):
return self.model.forward(tokens)[0]
-class SharkHFBenchmarkRunner(SharkBenchmarkRunner):
- # SharkRunner derived class with Benchmarking capabilities.
+class AMDSharkHFBenchmarkRunner(AMDSharkBenchmarkRunner):
+ # AMDSharkRunner derived class with Benchmarking capabilities.
def __init__(
self,
model_name: str,
@@ -54,14 +54,14 @@ class SharkHFBenchmarkRunner(SharkBenchmarkRunner):
from_aot: bool = False,
frontend: str = "torch",
):
- self.device = device if device is not None else shark_args.device
+ self.device = device if device is not None else amdshark_args.device
if self.device == "gpu":
raise ValueError(
"Currently GPU Benchmarking is not supported due to OOM from ORT."
)
self.model_name = model_name
model = HuggingFaceLanguage(model_name)
- SharkBenchmarkRunner.__init__(
+ AMDSharkBenchmarkRunner.__init__(
self,
model,
input,
@@ -90,13 +90,13 @@ class SharkHFBenchmarkRunner(SharkBenchmarkRunner):
num_threads,
batch_sizes,
sequence_lengths,
- shark_args.num_iterations,
+ amdshark_args.num_iterations,
False,
cache_dir,
verbose,
)
print(
- f"ONNX Pytorch-benchmark:{result[0]['QPS']} iter/second, Total Iterations:{shark_args.num_iterations}"
+ f"ONNX Pytorch-benchmark:{result[0]['QPS']} iter/second, Total Iterations:{amdshark_args.num_iterations}"
)
# TODO: Currently non-functional due to TF runtime error. There might be some issue with, initializing TF.
@@ -118,12 +118,12 @@ class SharkHFBenchmarkRunner(SharkBenchmarkRunner):
num_threads,
batch_sizes,
sequence_lengths,
- shark_args.num_iterations,
+ amdshark_args.num_iterations,
cache_dir,
verbose,
)
print(
- f"ONNX TF-benchmark:{result[0]['QPS']} iter/second, Total Iterations:{shark_args.num_iterations}"
+ f"ONNX TF-benchmark:{result[0]['QPS']} iter/second, Total Iterations:{amdshark_args.num_iterations}"
)
def benchmark_onnx(self, inputs):
@@ -162,7 +162,7 @@ for currently supported models. Exiting benchmark ONNX."
num_threads,
batch_sizes,
sequence_lengths,
- shark_args.num_iterations,
+ amdshark_args.num_iterations,
input_counts,
optimize_onnx,
validate_onnx,
@@ -177,5 +177,5 @@ for currently supported models. Exiting benchmark ONNX."
onnx_args,
)
print(
- f"ONNX ORT-benchmark:{result[0]['QPS']} iter/second, Total Iterations:{shark_args.num_iterations}"
+ f"ONNX ORT-benchmark:{result[0]['QPS']} iter/second, Total Iterations:{amdshark_args.num_iterations}"
)
diff --git a/benchmarks/tests/test_benchmark.py b/benchmarks/tests/test_benchmark.py
index eac22f68..d92c21e6 100644
--- a/benchmarks/tests/test_benchmark.py
+++ b/benchmarks/tests/test_benchmark.py
@@ -1,5 +1,5 @@
-from shark.shark_inference import SharkInference
-from shark.iree_utils._common import check_device_drivers
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.iree_utils._common import check_device_drivers
import torch
import tensorflow as tf
@@ -164,7 +164,7 @@ def test_bench_minilm_torch(dynamic, device):
model, test_input, act_out = get_hf_model(
"microsoft/MiniLM-L12-H384-uncased"
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
model,
(test_input,),
device=device,
@@ -174,8 +174,8 @@ def test_bench_minilm_torch(dynamic, device):
)
try:
# If becnhmarking succesful, assert success/True.
- shark_module.compile()
- shark_module.benchmark_all((test_input,))
+ amdshark_module.compile()
+ amdshark_module.benchmark_all((test_input,))
assert True
except Exception as e:
# If anything happen during benchmarking, assert False/failure.
@@ -189,7 +189,7 @@ def test_bench_minilm_torch(dynamic, device):
@pytest_benchmark_param
def test_bench_distilbert(dynamic, device):
model, test_input, act_out = get_TFhf_model("distilbert-base-uncased")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
model,
test_input,
device=device,
@@ -199,9 +199,9 @@ def test_bench_distilbert(dynamic, device):
)
try:
# If becnhmarking succesful, assert success/True.
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
- shark_module.benchmark_all(test_input)
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
+ amdshark_module.benchmark_all(test_input)
assert True
except Exception as e:
# If anything happen during benchmarking, assert False/failure.
@@ -212,7 +212,7 @@ def test_bench_distilbert(dynamic, device):
@pytest_benchmark_param
def test_bench_xlm_roberta(dynamic, device):
model, test_input, act_out = get_TFhf_model("xlm-roberta-base")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
model,
test_input,
device=device,
@@ -222,9 +222,9 @@ def test_bench_xlm_roberta(dynamic, device):
)
try:
# If becnhmarking succesful, assert success/True.
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
- shark_module.benchmark_all(test_input)
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
+ amdshark_module.benchmark_all(test_input)
assert True
except Exception as e:
# If anything happen during benchmarking, assert False/failure.
diff --git a/benchmarks/tests/test_hf_benchmark.py b/benchmarks/tests/test_hf_benchmark.py
index cfbd6d38..5b55c401 100644
--- a/benchmarks/tests/test_hf_benchmark.py
+++ b/benchmarks/tests/test_hf_benchmark.py
@@ -1,5 +1,5 @@
import torch
-from benchmarks.hf_transformer import SharkHFBenchmarkRunner
+from benchmarks.hf_transformer import AMDSharkHFBenchmarkRunner
import importlib
import pytest
@@ -27,17 +27,17 @@ def test_HFbench_minilm_torch(dynamic, device):
model_name = "bert-base-uncased"
test_input = torch.randint(2, (1, 128))
try:
- shark_module = SharkHFBenchmarkRunner(
+ amdshark_module = AMDSharkHFBenchmarkRunner(
model_name,
(test_input,),
jit_trace=True,
dynamic=dynamic,
device=device,
)
- shark_module.benchmark_c()
- shark_module.benchmark_python((test_input,))
- shark_module.benchmark_torch(test_input)
- shark_module.benchmark_onnx(test_input)
+ amdshark_module.benchmark_c()
+ amdshark_module.benchmark_python((test_input,))
+ amdshark_module.benchmark_torch(test_input)
+ amdshark_module.benchmark_onnx(test_input)
# If becnhmarking succesful, assert success/True.
assert True
except Exception as e:
diff --git a/build_tools/docker/Dockerfile-ubuntu-22.04 b/build_tools/docker/Dockerfile-ubuntu-22.04
index ba1f451a..22ff8875 100644
--- a/build_tools/docker/Dockerfile-ubuntu-22.04
+++ b/build_tools/docker/Dockerfile-ubuntu-22.04
@@ -39,7 +39,7 @@ FROM base-${TARGETARCH}
ARG TARGETARCH
-LABEL maintainer "SHARK"
+LABEL maintainer "AMDSHARK"
# Register the ROCM package repository, and install rocm-dev package
ARG ROCM_VERSION=5.6
diff --git a/build_tools/docker/README.md b/build_tools/docker/README.md
index 36d4c9a5..7e50c13d 100644
--- a/build_tools/docker/README.md
+++ b/build_tools/docker/README.md
@@ -15,7 +15,7 @@ Install Nvidia [Container and register it](https://docs.nvidia.com/datacenter/cl
Build docker with :
```
-docker build . -f Dockerfile-ubuntu-22.04 -t shark/dev-22.04:5.6 --build-arg=ROCM_VERSION=5.6 --build-arg=AMDGPU_VERSION=5.6 --build-arg=APT_PREF="Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" --build-arg=IMAGE_NAME=nvidia/cuda --build-arg=TARGETARCH=amd64
+docker build . -f Dockerfile-ubuntu-22.04 -t amdshark/dev-22.04:5.6 --build-arg=ROCM_VERSION=5.6 --build-arg=AMDGPU_VERSION=5.6 --build-arg=APT_PREF="Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" --build-arg=IMAGE_NAME=nvidia/cuda --build-arg=TARGETARCH=amd64
```
Run with:
@@ -23,19 +23,19 @@ Run with:
*CPU*
```
-docker run -it docker.io/shark/dev-22.04:5.6
+docker run -it docker.io/amdshark/dev-22.04:5.6
```
*Nvidia GPU*
```
-docker run --rm -it --gpus all docker.io/shark/dev-22.04:5.6
+docker run --rm -it --gpus all docker.io/amdshark/dev-22.04:5.6
```
*AMD GPUs*
```
-docker run --device /dev/kfd --device /dev/dri docker.io/shark/dev-22.04:5.6
+docker run --device /dev/kfd --device /dev/dri docker.io/amdshark/dev-22.04:5.6
```
More AMD instructions are [here](https://docs.amd.com/en/latest/deploy/docker.html)
diff --git a/build_tools/image_comparison.py b/build_tools/image_comparison.py
index 6179717f..006ea737 100644
--- a/build_tools/image_comparison.py
+++ b/build_tools/image_comparison.py
@@ -13,7 +13,7 @@ parser.add_argument("-n", "--newfile")
parser.add_argument(
"-g",
"--golden_url",
- default="https://storage.googleapis.com/shark_tank/testdata/cyberpunk_fores_42_0_230119_021148.png",
+ default="https://storage.googleapis.com/amdshark_tank/testdata/cyberpunk_fores_42_0_230119_021148.png",
)
@@ -36,7 +36,7 @@ def compare_images(new_filename, golden_filename, upload=False):
"gsutil",
"cp",
new_filename,
- "gs://shark_tank/testdata/builder/",
+ "gs://amdshark_tank/testdata/builder/",
]
)
raise AssertionError("new and golden not close")
diff --git a/build_tools/populate_sharktank_ci.sh b/build_tools/populate_amdsharktank_ci.sh
similarity index 57%
rename from build_tools/populate_sharktank_ci.sh
rename to build_tools/populate_amdsharktank_ci.sh
index dd2aee65..c7429f10 100644
--- a/build_tools/populate_sharktank_ci.sh
+++ b/build_tools/populate_amdsharktank_ci.sh
@@ -1,6 +1,6 @@
#!/bin/bash
IMPORTER=1 BENCHMARK=1 NO_BREVITAS=1 ./setup_venv.sh
-source $GITHUB_WORKSPACE/shark.venv/bin/activate
+source $GITHUB_WORKSPACE/amdshark.venv/bin/activate
python build_tools/stable_diffusion_testing.py --gen
-python tank/generate_sharktank.py
+python tank/generate_amdsharktank.py
diff --git a/build_tools/stable_diffusion_testing.py b/build_tools/stable_diffusion_testing.py
index 8eeb1a73..8bdc4e1c 100644
--- a/build_tools/stable_diffusion_testing.py
+++ b/build_tools/stable_diffusion_testing.py
@@ -5,7 +5,7 @@ from apps.stable_diffusion.src.utils.resources import (
get_json_file,
)
from datetime import datetime as dt
-from shark.shark_downloader import download_public_file
+from amdshark.amdshark_downloader import download_public_file
from image_comparison import compare_images
import argparse
from glob import glob
@@ -178,7 +178,7 @@ def test_loop(
print("Successfully generated image")
os.makedirs("./test_images/golden/" + model_name, exist_ok=True)
download_public_file(
- "gs://shark_tank/testdata/golden/" + model_name,
+ "gs://amdshark_tank/testdata/golden/" + model_name,
"./test_images/golden/" + model_name,
)
test_file_path = os.path.join(
@@ -239,7 +239,7 @@ def test_loop(
def prepare_artifacts():
- gen_path = os.path.join(os.getcwd(), "gen_shark_tank")
+ gen_path = os.path.join(os.getcwd(), "gen_amdshark_tank")
if not os.path.isdir(gen_path):
os.mkdir(gen_path)
for dirname in os.listdir(os.getcwd()):
diff --git a/conftest.py b/conftest.py
index f11bdf0f..e22b7247 100644
--- a/conftest.py
+++ b/conftest.py
@@ -1,5 +1,5 @@
def pytest_addoption(parser):
- # Attaches SHARK command-line arguments to the pytest machinery.
+ # Attaches AMDSHARK command-line arguments to the pytest machinery.
parser.addoption(
"--benchmark",
action="store",
@@ -24,7 +24,7 @@ def pytest_addoption(parser):
"--save_repro",
action="store_true",
default="False",
- help="Pass option to save reproduction artifacts to SHARK/shark_tmp/test_case/",
+ help="Pass option to save reproduction artifacts to AMDSHARK/amdshark_tmp/test_case/",
)
parser.addoption(
"--save_fails",
@@ -42,13 +42,13 @@ def pytest_addoption(parser):
"--update_tank",
action="store_true",
default="False",
- help="Update local shark tank with latest artifacts if model artifact hash mismatched.",
+ help="Update local amdshark tank with latest artifacts if model artifact hash mismatched.",
)
parser.addoption(
"--force_update_tank",
action="store_true",
default="False",
- help="Force-update local shark tank with artifacts from specified shark_tank URL (defaults to nightly).",
+ help="Force-update local amdshark tank with artifacts from specified amdshark_tank URL (defaults to nightly).",
)
parser.addoption(
"--ci_sha",
@@ -60,19 +60,19 @@ def pytest_addoption(parser):
"--local_tank_cache",
action="store",
default=None,
- help="Specify the directory in which all downloaded shark_tank artifacts will be cached.",
+ help="Specify the directory in which all downloaded amdshark_tank artifacts will be cached.",
)
parser.addoption(
"--tank_url",
type=str,
- default="gs://shark_tank/nightly",
- help="URL to bucket from which to download SHARK tank artifacts. Default is gs://shark_tank/latest",
+ default="gs://amdshark_tank/nightly",
+ help="URL to bucket from which to download AMDSHARK tank artifacts. Default is gs://amdshark_tank/latest",
)
parser.addoption(
"--tank_prefix",
type=str,
default=None,
- help="Prefix to gs://shark_tank/ model directories from which to download SHARK tank artifacts. Default is nightly.",
+ help="Prefix to gs://amdshark_tank/ model directories from which to download AMDSHARK tank artifacts. Default is nightly.",
)
parser.addoption(
"--benchmark_dispatches",
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 080ca9a1..1042874a 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -28,7 +28,7 @@ include(FetchContent)
FetchContent_Declare(
iree
GIT_REPOSITORY https://github.com/nod-ai/srt.git
- GIT_TAG shark
+ GIT_TAG amdshark
GIT_SUBMODULES_RECURSE OFF
GIT_SHALLOW OFF
GIT_PROGRESS ON
diff --git a/cpp/README.md b/cpp/README.md
index c503ecee..e50f8024 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -1,7 +1,7 @@
-# SHARK C/C++ Samples
+# AMDSHARK C/C++ Samples
These C/C++ samples can be built using CMake. The samples depend on the main
-SHARK-Runtime project's C/C++ sources, including both the runtime and the compiler.
+AMDSHARK-Runtime project's C/C++ sources, including both the runtime and the compiler.
Individual samples may require additional dependencies. Watch CMake's output
for information about which you are missing for individual samples.
@@ -9,10 +9,10 @@ for information about which you are missing for individual samples.
On Windows we recommend using https://github.com/microsoft/vcpkg to download packages for
your system. The general setup flow looks like
-*Install and activate SHARK*
+*Install and activate AMDSHARK*
```bash
-source shark.venv/bin/activate #follow main repo instructions to setup your venv
+source amdshark.venv/bin/activate #follow main repo instructions to setup your venv
```
*Install Dependencies*
@@ -39,7 +39,7 @@ cmake --build build/
*Prepare the model*
```bash
-wget https://storage.googleapis.com/shark_tank/latest/resnet50_tf/resnet50_tf.mlir
+wget https://storage.googleapis.com/amdshark_tank/latest/resnet50_tf/resnet50_tf.mlir
iree-compile --iree-input-type=auto --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=vulkan --iree-llvmcpu-embedded-linker-path=`python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'`/iree/compiler/tools/../_mlir_libs/iree-lld --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false --mlir-pass-pipeline-crash-reproducer=ist/core-reproducer.mlir --iree-llvmcpu-target-cpu-features=host -iree-vulkan-target-triple=rdna2-unknown-linux resnet50_tf.mlir -o resnet50_tf.vmfb
```
*Prepare the input*
@@ -64,19 +64,19 @@ A tool for benchmarking other models is built and can be invoked with a command
```
see `./build/vulkan_gui/iree-vulkan-gui --help` for an explanation on the function input. For example, stable diffusion unet can be tested with the following commands:
```bash
-wget https://storage.googleapis.com/shark_tank/quinn/stable_diff_tf/stable_diff_tf.mlir
+wget https://storage.googleapis.com/amdshark_tank/quinn/stable_diff_tf/stable_diff_tf.mlir
iree-compile --iree-input-type=auto --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=vulkan --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false --iree-llvmcpu-target-cpu-features=host -iree-vulkan-target-triple=rdna2-unknown-linux stable_diff_tf.mlir -o stable_diff_tf.vmfb
./build/vulkan_gui/iree-vulkan-gui --module-file=stable_diff_tf.vmfb --function_input=2x4x64x64xf32 --function_input=1xf32 --function_input=2x77x768xf32
```
VAE and Autoencoder are also available
```bash
# VAE
-wget https://storage.googleapis.com/shark_tank/quinn/stable_diff_tf/vae_tf/vae.mlir
+wget https://storage.googleapis.com/amdshark_tank/quinn/stable_diff_tf/vae_tf/vae.mlir
iree-compile --iree-input-type=auto --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=vulkan --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false --iree-llvmcpu-target-cpu-features=host -iree-vulkan-target-triple=rdna2-unknown-linux vae.mlir -o vae.vmfb
./build/vulkan_gui/iree-vulkan-gui --module-file=stable_diff_tf.vmfb --function_input=1x4x64x64xf32
# CLIP Autoencoder
-wget https://storage.googleapis.com/shark_tank/quinn/stable_diff_tf/clip_tf/clip_autoencoder.mlir
+wget https://storage.googleapis.com/amdshark_tank/quinn/stable_diff_tf/clip_tf/clip_autoencoder.mlir
iree-compile --iree-input-type=auto --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=vulkan --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false --iree-llvmcpu-target-cpu-features=host -iree-vulkan-target-triple=rdna2-unknown-linux clip_autoencoder.mlir -o clip_autoencoder.vmfb
./build/vulkan_gui/iree-vulkan-gui --module-file=stable_diff_tf.vmfb --function_input=1x77xi32 --function_input=1x77xi32
```
diff --git a/cpp/save_img.py b/cpp/save_img.py
index 3d6d856c..1dfe9397 100644
--- a/cpp/save_img.py
+++ b/cpp/save_img.py
@@ -1,6 +1,6 @@
import numpy as np
import tensorflow as tf
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
def load_and_preprocess_image(fname: str):
diff --git a/dataset/README.md b/dataset/README.md
index c0e7c6ac..609fe2f9 100644
--- a/dataset/README.md
+++ b/dataset/README.md
@@ -1,12 +1,12 @@
# Dataset annotation tool
-SHARK annotator for adding or modifying prompts of dataset images
+AMDSHARK annotator for adding or modifying prompts of dataset images
## Set up
-Activate SHARK Python virtual environment and install additional packages
+Activate AMDSHARK Python virtual environment and install additional packages
```shell
-source ../shark.venv/bin/activate
+source ../amdshark.venv/bin/activate
pip install -r requirements.txt
```
diff --git a/dataset/annotation_tool.py b/dataset/annotation_tool.py
index ae98cd37..bec5b1dc 100644
--- a/dataset/annotation_tool.py
+++ b/dataset/annotation_tool.py
@@ -8,12 +8,12 @@ from PIL import Image
from utils import get_datasets
-shark_root = Path(__file__).parent.parent
-demo_css = shark_root.joinpath("web/demo.css").resolve()
-nodlogo_loc = shark_root.joinpath("web/models/stable_diffusion/logos/amd-logo.jpg")
+amdshark_root = Path(__file__).parent.parent
+demo_css = amdshark_root.joinpath("web/demo.css").resolve()
+nodlogo_loc = amdshark_root.joinpath("web/models/stable_diffusion/logos/amd-logo.jpg")
-with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
+with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as amdshark_web:
with gr.Row(elem_id="ui_title"):
nod_logo = Image.open(nodlogo_loc)
with gr.Column(scale=1, elem_id="demo_title_outer"):
@@ -62,7 +62,7 @@ with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
return gr.Dropdown.update(value=None, choices=[])
# create the dataset dir if doesn't exist and download prompt file
- dataset_path = str(shark_root) + "/dataset/" + dataset
+ dataset_path = str(amdshark_root) + "/dataset/" + dataset
if not os.path.exists(dataset_path):
os.mkdir(dataset_path)
@@ -89,7 +89,7 @@ with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
img_gs_path = args.gs_url + "/" + dataset + "/" + image_name
img_sub_path = "/".join(image_name.split("/")[:-1])
img_dst_path = (
- str(shark_root) + "/dataset/" + dataset + "/" + img_sub_path + "/"
+ str(amdshark_root) + "/dataset/" + dataset + "/" + img_sub_path + "/"
)
if not os.path.exists(img_dst_path):
os.mkdir(img_dst_path)
@@ -126,7 +126,7 @@ with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
idx = prompt_data[image_name].index(prompts)
prompt_data[image_name][idx] = prompt
- prompt_path = str(shark_root) + "/dataset/" + dataset + "/metadata.jsonl"
+ prompt_path = str(amdshark_root) + "/dataset/" + dataset + "/metadata.jsonl"
# write prompt jsonlines file
with open(prompt_path, "w") as f:
for key, value in prompt_data.items():
@@ -153,7 +153,7 @@ with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
return
prompt_data[image_name].remove(prompts)
- prompt_path = str(shark_root) + "/dataset/" + dataset + "/metadata.jsonl"
+ prompt_path = str(amdshark_root) + "/dataset/" + dataset + "/metadata.jsonl"
# write prompt jsonlines file
with open(prompt_path, "w") as f:
for key, value in prompt_data.items():
@@ -178,7 +178,7 @@ with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
return
# remove local image
- img_path = str(shark_root) + "/dataset/" + dataset + "/" + image_name
+ img_path = str(amdshark_root) + "/dataset/" + dataset + "/" + image_name
os.system(f'rm "{img_path}"')
# get the index for the back image
idx = images[dataset].index(image_name)
@@ -196,7 +196,7 @@ with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
return
# remove local image
- img_path = str(shark_root) + "/dataset/" + dataset + "/" + image_name
+ img_path = str(amdshark_root) + "/dataset/" + dataset + "/" + image_name
os.system(f'rm "{img_path}"')
# get the index for the next image
idx = images[dataset].index(image_name)
@@ -214,7 +214,7 @@ with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
return
# upload prompt and remove local data
- dataset_path = str(shark_root) + "/dataset/" + dataset
+ dataset_path = str(amdshark_root) + "/dataset/" + dataset
dataset_gs_path = args.gs_url + "/" + dataset + "/"
os.system(f'gsutil cp "{dataset_path}/metadata.jsonl" "{dataset_gs_path}"')
os.system(f'rm -rf "{dataset_path}"')
@@ -225,7 +225,7 @@ with gr.Blocks(title="Dataset Annotation Tool", css=demo_css) as shark_web:
if __name__ == "__main__":
- shark_web.launch(
+ amdshark_web.launch(
share=args.share,
inbrowser=True,
server_name="0.0.0.0",
diff --git a/dataset/requirements.txt b/dataset/requirements.txt
index 8378f0e4..de8ae6f7 100644
--- a/dataset/requirements.txt
+++ b/dataset/requirements.txt
@@ -1,3 +1,3 @@
-# SHARK Annotator
+# AMDSHARK Annotator
gradio==4.19.2
jsonlines
diff --git a/docs/shark_iree_profiling.md b/docs/amdshark_iree_profiling.md
similarity index 86%
rename from docs/shark_iree_profiling.md
rename to docs/amdshark_iree_profiling.md
index bf317712..fec041a3 100644
--- a/docs/shark_iree_profiling.md
+++ b/docs/amdshark_iree_profiling.md
@@ -1,23 +1,23 @@
# Overview
-This document is intended to provide a starting point for profiling with SHARK/IREE. At it's core
-[SHARK](https://github.com/nod-ai/SHARK-Studio/tree/main/tank) is a python API that links the MLIR lowerings from various
+This document is intended to provide a starting point for profiling with AMDSHARK/IREE. At it's core
+[AMDSHARK](https://github.com/nod-ai/AMDSHARK-Studio/tree/main/tank) is a python API that links the MLIR lowerings from various
frameworks + frontends (e.g. PyTorch -> Torch-MLIR) with the compiler + runtime offered by IREE. More information
-on model coverage and framework support can be found [here](https://github.com/nod-ai/SHARK-Studio/tree/main/tank). The intended
-use case for SHARK is for compilation and deployment of performant state of the art AI models.
+on model coverage and framework support can be found [here](https://github.com/nod-ai/AMDSHARK-Studio/tree/main/tank). The intended
+use case for AMDSHARK is for compilation and deployment of performant state of the art AI models.

-## Benchmarking with SHARK
+## Benchmarking with AMDSHARK
TODO: Expand this section.
-SHARK offers native benchmarking support, although because it is model focused, fine grain profiling is
-hidden when compared against the common "model benchmarking suite" use case SHARK is good at.
+AMDSHARK offers native benchmarking support, although because it is model focused, fine grain profiling is
+hidden when compared against the common "model benchmarking suite" use case AMDSHARK is good at.
-### SharkBenchmarkRunner
+### AMDSharkBenchmarkRunner
-SharkBenchmarkRunner is a class designed for benchmarking models against other runtimes.
+AMDSharkBenchmarkRunner is a class designed for benchmarking models against other runtimes.
TODO: List supported runtimes for comparison + example on how to benchmark with it.
## Directly profiling IREE
@@ -30,11 +30,11 @@ focus on the bridging the gap between the two.
- https://github.com/iree-org/iree/blob/main/docs/developers/developing_iree/profiling_vulkan_gpu.md
- https://github.com/iree-org/iree/blob/main/docs/developers/developing_iree/profiling_cpu_events.md
-Internally, SHARK builds a pair of IREE commands to compile + run a model. At a high level the flow starts with the
+Internally, AMDSHARK builds a pair of IREE commands to compile + run a model. At a high level the flow starts with the
model represented with a high level dialect (commonly Linalg) and is compiled to a flatbuffer (.vmfb) that
the runtime is capable of ingesting. At this point (with potentially a few runtime flags) the compiled model is then run
through the IREE runtime. This is all facilitated with the IREE python bindings, which offers a convenient method
-to capture the compile command SHARK comes up with. This is done by setting the environment variable
+to capture the compile command AMDSHARK comes up with. This is done by setting the environment variable
`IREE_SAVE_TEMPS` to point to a directory of choice, e.g. for stable diffusion
```
# Linux
@@ -63,7 +63,7 @@ Where `${NUM}` is the dispatch number that you want to benchmark/profile in isol
### Enabling Tracy for Vulkan profiling
-To begin profiling with Tracy, a build of IREE runtime with tracing enabled is needed. SHARK-Runtime (SRT) builds an
+To begin profiling with Tracy, a build of IREE runtime with tracing enabled is needed. AMDSHARK-Runtime (SRT) builds an
instrumented version alongside the normal version nightly (.whls typically found [here](https://github.com/nod-ai/SRT/releases)), however this is only available for Linux. For Windows, tracing can be enabled by enabling a CMake flag.
```
$env:IREE_ENABLE_RUNTIME_TRACING="ON"
@@ -92,7 +92,7 @@ The trace can then be viewed with
iree-tracy-profiler /path/to/trace.tracy
```
Capturing a runtime trace will work with any IREE tooling that uses the runtime. For example, `iree-benchmark-module`
-can be used for benchmarking an individual module. Importantly this means that any SHARK script can be profiled with tracy.
+can be used for benchmarking an individual module. Importantly this means that any AMDSHARK script can be profiled with tracy.
NOTE: Not all backends have the same tracy support. This writeup is focused on CPU/Vulkan backends but there is recently added support for tracing on CUDA (requires the `--cuda_tracing` flag).
diff --git a/docs/shark_sd_blender.md b/docs/amdshark_sd_blender.md
similarity index 80%
rename from docs/shark_sd_blender.md
rename to docs/amdshark_sd_blender.md
index 98859893..871c9dc2 100644
--- a/docs/shark_sd_blender.md
+++ b/docs/amdshark_sd_blender.md
@@ -1,21 +1,21 @@
# Overview
-This document is intended to provide a starting point for using SHARK stable diffusion with Blender.
+This document is intended to provide a starting point for using AMDSHARK stable diffusion with Blender.
We currently make use of the [AI-Render Plugin](https://github.com/benrugg/AI-Render) to integrate with Blender.
-## Setup SHARK and prerequisites:
+## Setup AMDSHARK and prerequisites:
- * Download the latest SHARK SD webui .exe from [here](https://github.com/nod-ai/SHARK-Studio/releases) or follow instructions on the [README](https://github.com/nod-ai/SHARK-Studio#readme)
- * Once you have the .exe where you would like SHARK to install, run the .exe from terminal/PowerShell with the `--api` flag:
+ * Download the latest AMDSHARK SD webui .exe from [here](https://github.com/nod-ai/AMDSHARK-Studio/releases) or follow instructions on the [README](https://github.com/nod-ai/AMDSHARK-Studio#readme)
+ * Once you have the .exe where you would like AMDSHARK to install, run the .exe from terminal/PowerShell with the `--api` flag:
```
## Run the .exe in API mode:
-.\shark_sd__.exe --api
+.\amdshark_sd__.exe --api
## For example:
-.\shark_sd_20230411_671.exe --api --server_port=8082
+.\amdshark_sd_20230411_671.exe --api --server_port=8082
-## From a the base directory of a source clone of SHARK:
+## From a the base directory of a source clone of AMDSHARK:
./setup_venv.ps1
python apps\stable_diffusion\web\index.py --api
@@ -38,7 +38,7 @@ Your AI-Render preferences should be configured as shown; the highlighted part s
The [AI-Render README](https://github.com/benrugg/AI-Render/blob/main/README.md) has more details on installation and usage, as well as video tutorials.
-## Using AI-Render + SHARK in your Blender project
+## Using AI-Render + AMDSHARK in your Blender project
- In the Render Properties tab, in the AI-Render dropdown, enable AI-Render.
@@ -48,7 +48,7 @@ The [AI-Render README](https://github.com/benrugg/AI-Render/blob/main/README.md)

-- From here, you can enter a prompt and configure img2img Stable Diffusion parameters, and AI-Render will run SHARK SD img2img on the rendered scene.
+- From here, you can enter a prompt and configure img2img Stable Diffusion parameters, and AI-Render will run AMDSHARK SD img2img on the rendered scene.
- AI-Render has useful presets for aesthetic styles, so you should be able to keep your subject prompt simple and focus on creating a decent Blender scene to start from.

diff --git a/docs/shark_sd_koboldcpp.md b/docs/amdshark_sd_koboldcpp.md
similarity index 52%
rename from docs/shark_sd_koboldcpp.md
rename to docs/amdshark_sd_koboldcpp.md
index 4337128e..8f6e28fe 100644
--- a/docs/shark_sd_koboldcpp.md
+++ b/docs/amdshark_sd_koboldcpp.md
@@ -1,6 +1,6 @@
# Overview
-In [1.47.2](https://github.com/LostRuins/koboldcpp/releases/tag/v1.47.2) [Koboldcpp](https://github.com/LostRuins/koboldcpp) added AUTOMATIC1111 integration for image generation. Since SHARK implements a small subset of the A1111 REST api, you can also use SHARK for this. This document gives a starting point for how to get this working.
+In [1.47.2](https://github.com/LostRuins/koboldcpp/releases/tag/v1.47.2) [Koboldcpp](https://github.com/LostRuins/koboldcpp) added AUTOMATIC1111 integration for image generation. Since AMDSHARK implements a small subset of the A1111 REST api, you can also use AMDSHARK for this. This document gives a starting point for how to get this working.
## In Action
@@ -8,52 +8,52 @@ In [1.47.2](https://github.com/LostRuins/koboldcpp/releases/tag/v1.47.2) [Kobold
## Memory considerations
-Since both Koboldcpp and SHARK will use VRAM on your graphic card(s) running both at the same time using the same card will impose extra limitations on the model size you can fully offload to the video card in Koboldcpp. For me, on a RX 7900 XTX on Windows with 24 GiB of VRAM, the limit was about a 13 Billion parameter model with Q5_K_M quantisation.
+Since both Koboldcpp and AMDSHARK will use VRAM on your graphic card(s) running both at the same time using the same card will impose extra limitations on the model size you can fully offload to the video card in Koboldcpp. For me, on a RX 7900 XTX on Windows with 24 GiB of VRAM, the limit was about a 13 Billion parameter model with Q5_K_M quantisation.
## Performance Considerations
-When using SHARK for image generation, especially with Koboldcpp, you need to be aware that it is currently designed to pay a large upfront cost in time compiling and tuning the model you select, to get an optimal individual image generation time. You need to be the judge as to whether this trade-off is going to be worth it for your OS and hardware combination.
+When using AMDSHARK for image generation, especially with Koboldcpp, you need to be aware that it is currently designed to pay a large upfront cost in time compiling and tuning the model you select, to get an optimal individual image generation time. You need to be the judge as to whether this trade-off is going to be worth it for your OS and hardware combination.
-It means that the first time you run a particular Stable Diffusion model for a particular combination of image size, LoRA, and VAE, SHARK will spend *many minutes* - even on a beefy machaine with very fast graphics card with lots of memory - building that model combination just so it can save it to disk. It may even have to go away and download the model if it doesn't already have it locally. Once it has done its build of a model combination for your hardware once, it shouldn't need to do it again until you upgrade to a newer SHARK version, install different drivers or change your graphics hardware. It will just upload the files it generated the first time to your graphics card and proceed from there.
+It means that the first time you run a particular Stable Diffusion model for a particular combination of image size, LoRA, and VAE, AMDSHARK will spend *many minutes* - even on a beefy machaine with very fast graphics card with lots of memory - building that model combination just so it can save it to disk. It may even have to go away and download the model if it doesn't already have it locally. Once it has done its build of a model combination for your hardware once, it shouldn't need to do it again until you upgrade to a newer AMDSHARK version, install different drivers or change your graphics hardware. It will just upload the files it generated the first time to your graphics card and proceed from there.
-This does mean however, that on a brand new fresh install of SHARK that has not generated any images on a model you haven't selected before, the first image Koboldcpp requests may look like it is *never* going finish and that the whole process has broken. Be forewarned, make yourself a cup of coffee, and expect a lot of messages about compilation and tuning from SHARK in the terminal you ran it from.
+This does mean however, that on a brand new fresh install of AMDSHARK that has not generated any images on a model you haven't selected before, the first image Koboldcpp requests may look like it is *never* going finish and that the whole process has broken. Be forewarned, make yourself a cup of coffee, and expect a lot of messages about compilation and tuning from AMDSHARK in the terminal you ran it from.
-## Setup SHARK and prerequisites:
+## Setup AMDSHARK and prerequisites:
- * Make sure you have suitable drivers for your graphics card installed. See the prerequisties section of the [README](https://github.com/nod-ai/SHARK-Studio#readme).
- * Download the latest SHARK studio .exe from [here](https://github.com/nod-ai/SHARK-Studio/releases) or follow the instructions in the [README](https://github.com/nod-ai/SHARK-Studio#readme) for an advanced, Linux or Mac install.
- * Run SHARK from terminal/PowerShell with the `--api` flag. Since koboldcpp also expects both CORS support and the image generator to be running on port `7860` rather than SHARK default of `8080`, also include both the `--api_accept_origin` flag with a suitable origin (use `="*"` to enable all origins) and `--server_port=7860` on the command line. (See the if you want to run SHARK on a different port)
+ * Make sure you have suitable drivers for your graphics card installed. See the prerequisties section of the [README](https://github.com/nod-ai/AMDSHARK-Studio#readme).
+ * Download the latest AMDSHARK studio .exe from [here](https://github.com/nod-ai/AMDSHARK-Studio/releases) or follow the instructions in the [README](https://github.com/nod-ai/AMDSHARK-Studio#readme) for an advanced, Linux or Mac install.
+ * Run AMDSHARK from terminal/PowerShell with the `--api` flag. Since koboldcpp also expects both CORS support and the image generator to be running on port `7860` rather than AMDSHARK default of `8080`, also include both the `--api_accept_origin` flag with a suitable origin (use `="*"` to enable all origins) and `--server_port=7860` on the command line. (See the if you want to run AMDSHARK on a different port)
```powershell
## Run the .exe in API mode, with CORS support, on the A1111 endpoint port:
-.\node_ai_shark_studio__.exe --api --api_accept_origin="*" --server_port=7860
+.\node_ai_amdshark_studio__.exe --api --api_accept_origin="*" --server_port=7860
-## Run trom the base directory of a source clone of SHARK on Windows:
+## Run trom the base directory of a source clone of AMDSHARK on Windows:
.\setup_venv.ps1
python .\apps\stable_diffusion\web\index.py --api --api_accept_origin="*" --server_port=7860
-## Run a the base directory of a source clone of SHARK on Linux:
+## Run a the base directory of a source clone of AMDSHARK on Linux:
./setup_venv.sh
-source shark.venv/bin/activate
+source amdshark.venv/bin/activate
python ./apps/stable_diffusion/web/index.py --api --api_accept_origin="*" --server_port=7860
## An example giving improved performance on AMD cards using vulkan, that runs on the same port as A1111
-.\node_ai_shark_studio_20320901_2525.exe --api --api_accept_origin="*" --device_allocator="caching" --server_port=7860
+.\node_ai_amdshark_studio_20320901_2525.exe --api --api_accept_origin="*" --device_allocator="caching" --server_port=7860
-## Since the api respects most applicable SHARK command line arguments for options not specified,
+## Since the api respects most applicable AMDSHARK command line arguments for options not specified,
## or currently unimplemented by API, there might be some you want to set, as listed in `--help`
-.\node_ai_shark_studio_20320901_2525.exe --help
+.\node_ai_amdshark_studio_20320901_2525.exe --help
## For instance, the example above, but with a a custom VAE specified
-.\node_ai_shark_studio_20320901_2525.exe --api --api_accept_origin="*" --device_allocator="caching" --server_port=7860 --custom_vae="clearvae_v23.safetensors"
+.\node_ai_amdshark_studio_20320901_2525.exe --api --api_accept_origin="*" --device_allocator="caching" --server_port=7860 --custom_vae="clearvae_v23.safetensors"
## An example with multiple specific CORS origins
python apps/stable_diffusion/web/index.py --api --api_accept_origin="koboldcpp.example.com:7001" --api_accept_origin="koboldcpp.example.com:7002" --server_port=7860
```
-SHARK should start in server mode, and you should see something like this:
+AMDSHARK should start in server mode, and you should see something like this:
-
+
* Note: When running in api mode with `--api`, the .exe will not function as a webUI. Thus, the address or port shown in the terminal output will only be useful for API requests.
@@ -68,9 +68,9 @@ SHARK should start in server mode, and you should see something like this:

- *if you get an error here, see the next section [below](#connecting-to-shark-on-a-different-address-or-port)*
+ *if you get an error here, see the next section [below](#connecting-to-amdshark-on-a-different-address-or-port)*
-* A list of Stable Diffusion models available to your SHARK instance should now be listed in the box below *generate images*. The default value will usually be set to `stabilityai/stable-diffusion-2-1-base`. Choose the model you want to use for image generation from the list (but see [performance considerations](#performance-considerations)).
+* A list of Stable Diffusion models available to your AMDSHARK instance should now be listed in the box below *generate images*. The default value will usually be set to `stabilityai/stable-diffusion-2-1-base`. Choose the model you want to use for image generation from the list (but see [performance considerations](#performance-considerations)).
* You should now be ready to generate images, either by clicking the 'Add Img' button above the text entry box:

@@ -85,18 +85,18 @@ SHARK should start in server mode, and you should see something like this:

- This will bring up a dialog box where you can enter a short text that will sent as a prefix to the Prompt sent to SHARK:
+ This will bring up a dialog box where you can enter a short text that will sent as a prefix to the Prompt sent to AMDSHARK:

-## Connecting to SHARK on a different address or port
+## Connecting to AMDSHARK on a different address or port
-If you didn't set the port to `--server_port=7860` when starting SHARK, or you are running it on different machine on your network than you are running Koboldcpp, or to where you are running the koboldcpp's kdlite client frontend, then you very likely got the following error:
+If you didn't set the port to `--server_port=7860` when starting AMDSHARK, or you are running it on different machine on your network than you are running Koboldcpp, or to where you are running the koboldcpp's kdlite client frontend, then you very likely got the following error:

-As long as SHARK is running correctly, this means you need to set the url and port to the correct values in Koboldcpp. For instance. to set the port that Koboldcpp looks for an image generator to SHARK's default port of 8080:
+As long as AMDSHARK is running correctly, this means you need to set the url and port to the correct values in Koboldcpp. For instance. to set the port that Koboldcpp looks for an image generator to AMDSHARK's default port of 8080:
* Select the cog icon the Generate Images section of Advanced settings:
@@ -106,7 +106,7 @@ As long as SHARK is running correctly, this means you need to set the url and po

-* Similarly, when running SHARK on a different machine you will need to change host part of the endpoint url to the hostname or ip address where SHARK is running, similarly:
+* Similarly, when running AMDSHARK on a different machine you will need to change host part of the endpoint url to the hostname or ip address where AMDSHARK is running, similarly:

@@ -125,16 +125,16 @@ And the same image when clicked on:

-## Where to find the images in SHARK
+## Where to find the images in AMDSHARK
Even though Koboldcpp requests images at a size of 512x512, it resizes then to 256x256, converts them to `.jpeg`, and only shows them at 200x200 in the main text window. It does this so it can save them compactly embedded in your story as a `data://` uri.
-However the images at the original size are saved by SHARK in its `output_dir` which is usually a folder named for the current date. inside `generated_imgs` folder in the SHARK installation directory.
+However the images at the original size are saved by AMDSHARK in its `output_dir` which is usually a folder named for the current date. inside `generated_imgs` folder in the AMDSHARK installation directory.
-You can browse these, either using the Output Gallery tab from within the SHARK web ui:
+You can browse these, either using the Output Gallery tab from within the AMDSHARK web ui:
- 
+ 
...or by browsing to the `output_dir` in your operating system's file manager:
- 
+ 
diff --git a/process_skipfiles.py b/process_skipfiles.py
index 9086ce59..c2c8569d 100644
--- a/process_skipfiles.py
+++ b/process_skipfiles.py
@@ -1,6 +1,6 @@
# This script will toggle the comment/uncommenting aspect for dealing
# with __file__ AttributeError arising in case of a few modules in
-# `torch/_dynamo/skipfiles.py` (within shark.venv)
+# `torch/_dynamo/skipfiles.py` (within amdshark.venv)
from distutils.sysconfig import get_python_lib
import fileinput
diff --git a/pyproject.toml b/pyproject.toml
index 876df2f8..b626ec45 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,12 +17,12 @@ exclude = '''
/(
| apps/stable_diffusion
| apps/language_models
- | shark
+ | amdshark
| benchmarks
| tank
| build
| generated_imgs
- | shark.venv
+ | amdshark.venv
)/
| setup.py
)
diff --git a/pytest.ini b/pytest.ini
index 38572487..0cf3e291 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,3 +1,3 @@
[pytest]
addopts = --verbose -s -p no:warnings
-norecursedirs = inference tank/tflite examples benchmarks shark apps/shark_studio
+norecursedirs = inference tank/tflite examples benchmarks amdshark apps/amdshark_studio
diff --git a/requirements.txt b/requirements.txt
index b654c151..4aad4e09 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -8,14 +8,14 @@ wheel
torch==2.3.0
iree-turbine @ git+https://github.com/iree-org/iree-turbine.git@main
-turbine-models @ git+https://github.com/nod-ai/SHARK-ModelDev.git@main#subdirectory=models
-diffusers @ git+https://github.com/nod-ai/diffusers@0.29.0.dev0-shark
+turbine-models @ git+https://github.com/nod-ai/AMDSHARK-ModelDev.git@main#subdirectory=models
+diffusers @ git+https://github.com/nod-ai/diffusers@0.29.0.dev0-amdshark
brevitas @ git+https://github.com/Xilinx/brevitas.git@6695e8df7f6a2c7715b9ed69c4b78157376bb60b
-# SHARK Runner
+# AMDSHARK Runner
tqdm
-# SHARK Downloader
+# AMDSHARK Downloader
google-cloud-storage
# Testing
diff --git a/rest_api_tests/api_test.py b/rest_api_tests/api_test.py
index f3c0b0e1..08e73b67 100644
--- a/rest_api_tests/api_test.py
+++ b/rest_api_tests/api_test.py
@@ -321,8 +321,8 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(
description=(
- "Exercises the Stable Diffusion REST API of Shark. Make sure "
- "Shark is running in API mode on 127.0.0.1:8080 before running"
+ "Exercises the Stable Diffusion REST API of AMDShark. Make sure "
+ "AMDShark is running in API mode on 127.0.0.1:8080 before running"
"this script."
),
)
diff --git a/setup.py b/setup.py
index 223d091b..1e040067 100644
--- a/setup.py
+++ b/setup.py
@@ -7,21 +7,21 @@ import glob
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
-PACKAGE_VERSION = os.environ.get("SHARK_PACKAGE_VERSION") or "2.0.0"
+PACKAGE_VERSION = os.environ.get("AMDSHARK_PACKAGE_VERSION") or "2.0.0"
backend_deps = []
setup(
- name="nodai-SHARK",
+ name="nodai-AMDSHARK",
version=f"{PACKAGE_VERSION}",
- description="SHARK provides a High Performance Machine Learning Framework",
+ description="AMDSHARK provides a High Performance Machine Learning Framework",
author="nod.ai",
author_email="stdin@nod.ai",
url="https://nod.ai",
long_description=long_description,
long_description_content_type="text/markdown",
project_urls={
- "Code": "https://github.com/nod-ai/SHARK",
- "Bug Tracker": "https://github.com/nod-ai/SHARK-Studio/issues",
+ "Code": "https://github.com/nod-ai/AMDSHARK",
+ "Bug Tracker": "https://github.com/nod-ai/AMDSHARK-Studio/issues",
},
classifiers=[
"Programming Language :: Python :: 3",
diff --git a/setup_venv.ps1 b/setup_venv.ps1
index d13abf87..45b0b43b 100644
--- a/setup_venv.ps1
+++ b/setup_venv.ps1
@@ -1,9 +1,9 @@
<#
.SYNOPSIS
- A script to update and install the SHARK runtime and its dependencies.
+ A script to update and install the AMDSHARK runtime and its dependencies.
.DESCRIPTION
- This script updates and installs the SHARK runtime and its dependencies.
+ This script updates and installs the AMDSHARK runtime and its dependencies.
It checks the Python version installed and installs any required build
dependencies into a Python virtual environment.
If that environment does not exist, it creates it.
@@ -40,11 +40,11 @@ if ($arguments -eq "--force"){
Deactivate
}
- if (Test-Path .\shark.venv\) {
+ if (Test-Path .\amdshark.venv\) {
Write-Host "removing and recreating venv..."
- Remove-Item .\shark.venv -Force -Recurse
- if (Test-Path .\shark.venv\) {
- Write-Host 'could not remove .\shark-venv - please try running ".\setup_venv.ps1 --force" again!'
+ Remove-Item .\amdshark.venv -Force -Recurse
+ if (Test-Path .\amdshark.venv\) {
+ Write-Host 'could not remove .\amdshark-venv - please try running ".\setup_venv.ps1 --force" again!'
exit 1
}
}
@@ -83,13 +83,13 @@ if (!($PyVer -like "*3.11*") -and !($p -like "*3.11*")) # if 3.11 is not in any
Write-Host "Installing Build Dependencies"
# make sure we really use 3.11 from list, even if it's not the default.
-if ($NULL -ne $PyVer) {py -3.11 -m venv .\shark.venv\}
-else {python -m venv .\shark.venv\}
-.\shark.venv\Scripts\activate
+if ($NULL -ne $PyVer) {py -3.11 -m venv .\amdshark.venv\}
+else {python -m venv .\amdshark.venv\}
+.\amdshark.venv\Scripts\activate
python -m pip install --upgrade pip
pip install wheel
pip install --pre -r requirements.txt
pip install --force-reinstall https://github.com/nod-ai/SRT/releases/download/candidate-20240528.279/iree_compiler-20240528.279-cp311-cp311-win_amd64.whl https://github.com/nod-ai/SRT/releases/download/candidate-20240528.279/iree_runtime-20240528.279-cp311-cp311-win_amd64.whl
pip install -e .
-Write-Host "Source your venv with ./shark.venv/Scripts/activate"
+Write-Host "Source your venv with ./amdshark.venv/Scripts/activate"
diff --git a/setup_venv.sh b/setup_venv.sh
index 11fe79fd..d8bc0650 100755
--- a/setup_venv.sh
+++ b/setup_venv.sh
@@ -1,15 +1,15 @@
#!/bin/bash
# Sets up a venv suitable for running samples.
# e.g:
-# ./setup_venv.sh #setup a default $PYTHON3 shark.venv
+# ./setup_venv.sh #setup a default $PYTHON3 amdshark.venv
# Environment variables used by the script.
# PYTHON=$PYTHON3.10 ./setup_venv.sh #pass a version of $PYTHON to use
-# VENV_DIR=myshark.venv #create a venv called myshark.venv
+# VENV_DIR=myamdshark.venv #create a venv called myamdshark.venv
# SKIP_VENV=1 #Don't create and activate a Python venv. Use the current environment.
-# USE_IREE=1 #use stock IREE instead of Nod.ai's SHARK build
+# USE_IREE=1 #use stock IREE instead of Nod.ai's AMDSHARK build
# IMPORTER=1 #Install importer deps
# BENCHMARK=1 #Install benchmark deps
-# NO_BACKEND=1 #Don't install iree or shark backend
+# NO_BACKEND=1 #Don't install iree or amdshark backend
# if you run the script from a conda env it will install in your conda env
TD="$(cd $(dirname $0) && pwd)"
@@ -35,7 +35,7 @@ fi
if [[ "$SKIP_VENV" != "1" ]]; then
if [[ -z "${CONDA_PREFIX}" ]]; then
# Not a conda env. So create a new VENV dir
- VENV_DIR=${VENV_DIR:-shark.venv}
+ VENV_DIR=${VENV_DIR:-amdshark.venv}
echo "Using pip venv.. Setting up venv dir: $VENV_DIR"
$PYTHON -m venv "$VENV_DIR" || die "Could not create venv."
source "$VENV_DIR/bin/activate" || die "Could not activate venv"
diff --git a/shark/__init__.py b/shark/__init__.py
deleted file mode 100644
index 9f45abfb..00000000
--- a/shark/__init__.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import importlib
-import logging
-
-from torch._dynamo import register_backend
-
-log = logging.getLogger(__name__)
-
-
-@register_backend
-def shark(model, inputs, *, options):
- try:
- from shark.dynamo_backend.utils import SharkBackend
- except ImportError:
- log.exception(
- "Unable to import SHARK - High Performance Machine Learning Distribution"
- "Please install the right version of SHARK that matches the PyTorch version being used. "
- "Refer to https://github.com/nod-ai/SHARK-Studio/ for details."
- )
- raise
- return SharkBackend(model, inputs, options)
-
-
-def has_shark():
- try:
- importlib.import_module("shark")
- return True
- except ImportError:
- return False
diff --git a/shark/examples/shark_inference/bloom_tank.py b/shark/examples/shark_inference/bloom_tank.py
deleted file mode 100644
index 25f67f6c..00000000
--- a/shark/examples/shark_inference/bloom_tank.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
-
-mlir_model, func_name, inputs, golden_out = download_model(
- "bloom", frontend="torch"
-)
-
-shark_module = SharkInference(
- mlir_model, device="cpu", mlir_dialect="tm_tensor"
-)
-shark_module.compile()
-result = shark_module.forward(inputs)
-print("The obtained result via shark is: ", result)
-print("The golden result is:", golden_out)
diff --git a/shark/examples/shark_inference/mhlo_example.py b/shark/examples/shark_inference/mhlo_example.py
deleted file mode 100644
index b2714032..00000000
--- a/shark/examples/shark_inference/mhlo_example.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from shark.shark_inference import SharkInference
-import numpy as np
-
-mhlo_ir = r"""builtin.module {
- func.func @forward(%arg0: tensor<1x4xf32>, %arg1: tensor<4x1xf32>) -> tensor<4x4xf32> {
- %0 = chlo.broadcast_add %arg0, %arg1 : (tensor<1x4xf32>, tensor<4x1xf32>) -> tensor<4x4xf32>
- %1 = "mhlo.abs"(%0) : (tensor<4x4xf32>) -> tensor<4x4xf32>
- return %1 : tensor<4x4xf32>
- }
-}"""
-
-arg0 = np.ones((1, 4)).astype(np.float32)
-arg1 = np.ones((4, 1)).astype(np.float32)
-
-print("Running shark on cpu backend")
-shark_module = SharkInference(mhlo_ir, device="cpu", mlir_dialect="mhlo")
-
-# Generate the random inputs and feed into the graph.
-x = shark_module.generate_random_inputs()
-shark_module.compile()
-print(shark_module.forward(x))
-
-print("Running shark on cuda backend")
-shark_module = SharkInference(mhlo_ir, device="cuda", mlir_dialect="mhlo")
-shark_module.compile()
-print(shark_module.forward(x))
-
-print("Running shark on vulkan backend")
-shark_module = SharkInference(mhlo_ir, device="vulkan", mlir_dialect="mhlo")
-shark_module.compile()
-print(shark_module.forward(x))
diff --git a/shark/examples/shark_inference/minilm_jit.py b/shark/examples/shark_inference/minilm_jit.py
deleted file mode 100644
index df9aa98b..00000000
--- a/shark/examples/shark_inference/minilm_jit.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
-
-
-mlir_model, func_name, inputs, golden_out = download_model(
- "microsoft/MiniLM-L12-H384-uncased",
- frontend="torch",
-)
-
-
-shark_module = SharkInference(mlir_model, device="cpu", mlir_dialect="linalg")
-shark_module.compile()
-result = shark_module.forward(inputs)
-print("The obtained result via shark is: ", result)
-print("The golden result is:", golden_out)
-
-
-# Let's generate random inputs, currently supported
-# for static models.
-rand_inputs = shark_module.generate_random_inputs()
-rand_results = shark_module.forward(rand_inputs)
-
-print("Running shark_module with random_inputs is: ", rand_results)
diff --git a/shark/examples/shark_inference/v_diffusion.py b/shark/examples/shark_inference/v_diffusion.py
deleted file mode 100644
index e74c8afc..00000000
--- a/shark/examples/shark_inference/v_diffusion.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
-
-
-mlir_model, func_name, inputs, golden_out = download_model(
- "v_diffusion", frontend="torch"
-)
-
-shark_module = SharkInference(
- mlir_model, device="vulkan", mlir_dialect="linalg"
-)
-shark_module.compile()
-result = shark_module.forward(inputs)
-print("The obtained result via shark is: ", result)
-print("The golden result is:", golden_out)
diff --git a/tank/README.md b/tank/README.md
index fa38694d..8cb66d95 100644
--- a/tank/README.md
+++ b/tank/README.md
@@ -2,7 +2,7 @@
### PyTorch HuggingFace Models
-| PyTorch Language Models | Torch-MLIR lowerable | SHARK-CPU | SHARK-CUDA | SHARK-METAL |
+| PyTorch Language Models | Torch-MLIR lowerable | AMDSHARK-CPU | AMDSHARK-CUDA | AMDSHARK-METAL |
|---------------------|----------------------|----------|----------|-------------|
| BERT | :green_heart: (JIT) | :green_heart: | :green_heart: | :green_heart: |
| Albert | :green_heart: (JIT) | :green_heart: | :green_heart: | :green_heart: |
@@ -17,7 +17,7 @@
### Torchvision Models
-| TORCHVISION Models | Torch-MLIR lowerable | SHARK-CPU | SHARK-CUDA | SHARK-METAL |
+| TORCHVISION Models | Torch-MLIR lowerable | AMDSHARK-CPU | AMDSHARK-CUDA | AMDSHARK-METAL |
|--------------------|----------------------|----------|----------|-------------|
| AlexNet | :green_heart: (Script) | :green_heart: | :green_heart: | :green_heart: |
| MobileNetV2 | :green_heart: (Script) | :green_heart: | :green_heart: | :green_heart: |
@@ -40,7 +40,7 @@ For more information refer to [MODEL TRACKING SHEET](https://docs.google.com/spr
### Tensorflow Models (Inference)
-| Hugging Face Models | tf-mhlo lowerable | SHARK-CPU | SHARK-CUDA | SHARK-METAL |
+| Hugging Face Models | tf-mhlo lowerable | AMDSHARK-CPU | AMDSHARK-CUDA | AMDSHARK-METAL |
|---------------------|----------------------|----------|----------|-------------|
| BERT | :green_heart: | :green_heart: | :green_heart: | :green_heart: |
| MiniLM | :green_heart: | :green_heart: | :green_heart: | :green_heart: |
@@ -63,14 +63,14 @@ For more information refer to [MODEL TRACKING SHEET](https://docs.google.com/spr
### PyTorch Training Models
-| Models | Torch-MLIR lowerable | SHARK-CPU | SHARK-CUDA | SHARK-METAL |
+| Models | Torch-MLIR lowerable | AMDSHARK-CPU | AMDSHARK-CUDA | AMDSHARK-METAL |
|---------------------|----------------------|----------|----------|-------------|
| BERT | :green_heart: | :green_heart: | | |
| FullyConnected | :green_heart: | :green_heart: | | |
### JAX Models
-| Models | JAX-MHLO lowerable | SHARK-CPU | SHARK-CUDA | SHARK-METAL |
+| Models | JAX-MHLO lowerable | AMDSHARK-CPU | AMDSHARK-CUDA | AMDSHARK-METAL |
|---------------------|----------------------|----------|----------|-------------|
| DALL-E | :broken_heart: | :broken_heart: | | |
| FullyConnected | :green_heart: | :green_heart: | | |
@@ -80,7 +80,7 @@ For more information refer to [MODEL TRACKING SHEET](https://docs.google.com/spr
### TFLite Models
-| Models | TOSA/LinAlg | SHARK-CPU | SHARK-CUDA | SHARK-METAL |
+| Models | TOSA/LinAlg | AMDSHARK-CPU | AMDSHARK-CUDA | AMDSHARK-METAL |
|---------------------|----------------------|----------|----------|-------------|
| BERT | :broken_heart: | :broken_heart: | | |
| FullyConnected | :green_heart: | :green_heart: | | |
@@ -142,7 +142,7 @@ For more information refer to [MODEL TRACKING SHEET](https://docs.google.com/spr
### Run all model tests on CPU/GPU/VULKAN/Metal
-For a list of models included in our pytest model suite, see https://github.com/nod-ai/SHARK-Studio/blob/main/tank/all_models.csv
+For a list of models included in our pytest model suite, see https://github.com/nod-ai/AMDSHARK-Studio/blob/main/tank/all_models.csv
```shell
pytest tank/test_models.py
@@ -170,7 +170,7 @@ pytest tank/test_models.py -k "resnet and tf and vulkan"
# Exclude a test case:
pytest tank/test_models.py -k "not ..."
-### Run benchmarks on SHARK tank pytests and generate bench_results.csv with results.
+### Run benchmarks on AMDSHARK tank pytests and generate bench_results.csv with results.
(the following requires source installation with `IMPORTER=1 ./setup_venv.sh`)
@@ -206,11 +206,11 @@ cd transformer-benchmarks
```
-To run the fine tuning example, from the root SHARK directory, run:
+To run the fine tuning example, from the root AMDSHARK directory, run:
```shell
IMPORTER=1 ./setup_venv.sh
-source shark.venv/bin/activate
+source amdshark.venv/bin/activate
pip install jupyter tf-models-nightly tf-datasets
jupyter-notebook
```
diff --git a/tank/all_models.csv b/tank/all_models.csv
index fcf3f2cc..4efcc5b3 100644
--- a/tank/all_models.csv
+++ b/tank/all_models.csv
@@ -1,19 +1,19 @@
bert-base-uncased,linalg,torch,1e-2,1e-3,default,None,False,False,False,"",""
bert-large-uncased,linalg,torch,1e-2,1e-3,default,None,False,False,False,"",""
facebook/deit-small-distilled-patch16-224,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,False,False,False,"Fails during iree-compile.",""
-google/vit-base-patch16-224,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,True,True,True,"https://github.com/nod-ai/SHARK/issues/311",""
-microsoft/beit-base-patch16-224-pt22k-ft22k,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,False,False,False,"https://github.com/nod-ai/SHARK/issues/390","macos"
+google/vit-base-patch16-224,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,True,True,True,"https://github.com/nod-ai/AMDSHARK/issues/311",""
+microsoft/beit-base-patch16-224-pt22k-ft22k,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,False,False,False,"https://github.com/nod-ai/AMDSHARK/issues/390","macos"
microsoft/MiniLM-L12-H384-uncased,linalg,torch,1e-2,1e-3,default,None,False,False,False,"",""
-google/mobilebert-uncased,linalg,torch,1e-2,1e-3,default,None,False,False,False,"https://github.com/nod-ai/SHARK/issues/344","macos"
-mobilenet_v3_small,linalg,torch,1e-1,1e-2,default,nhcw-nhwc,False,False,False,"https://github.com/nod-ai/SHARK/issues/388, https://github.com/nod-ai/SHARK/issues/1487","macos"
-nvidia/mit-b0,linalg,torch,1e-2,1e-3,default,None,True,True,True,"https://github.com/nod-ai/SHARK/issues/343,https://github.com/nod-ai/SHARK/issues/1487","macos"
+google/mobilebert-uncased,linalg,torch,1e-2,1e-3,default,None,False,False,False,"https://github.com/nod-ai/AMDSHARK/issues/344","macos"
+mobilenet_v3_small,linalg,torch,1e-1,1e-2,default,nhcw-nhwc,False,False,False,"https://github.com/nod-ai/AMDSHARK/issues/388, https://github.com/nod-ai/AMDSHARK/issues/1487","macos"
+nvidia/mit-b0,linalg,torch,1e-2,1e-3,default,None,True,True,True,"https://github.com/nod-ai/AMDSHARK/issues/343,https://github.com/nod-ai/AMDSHARK/issues/1487","macos"
resnet101,linalg,torch,1e-2,1e-3,default,nhcw-nhwc/img2col,True,True,True,"","macos"
resnet18,linalg,torch,1e-2,1e-3,default,None,True,True,True,"","macos"
resnet50,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,False,False,False,"","macos"
squeezenet1_0,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,False,False,False,"","macos"
wide_resnet50_2,linalg,torch,1e-2,1e-3,default,nhcw-nhwc/img2col,True,True,True,"","macos"
mnasnet1_0,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,False,False,False,"","macos"
-efficientnet_b0,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,True,True,True,"https://github.com/nod-ai/SHARK/issues/1487","macos"
-efficientnet_b7,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,True,True,True,"https://github.com/nod-ai/SHARK/issues/1487","macos"
+efficientnet_b0,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,True,True,True,"https://github.com/nod-ai/AMDSHARK/issues/1487","macos"
+efficientnet_b7,linalg,torch,1e-2,1e-3,default,nhcw-nhwc,True,True,True,"https://github.com/nod-ai/AMDSHARK/issues/1487","macos"
t5-base,linalg,torch,1e-2,1e-3,default,None,True,True,True,"","macos"
t5-large,linalg,torch,1e-2,1e-3,default,None,True,True,True,"","macos"
diff --git a/tank/examples/MiniLM_tf/seq_classification.py b/tank/examples/MiniLM_tf/seq_classification.py
index aedc3a6d..43f5f8ed 100755
--- a/tank/examples/MiniLM_tf/seq_classification.py
+++ b/tank/examples/MiniLM_tf/seq_classification.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
from transformers import TFAutoModelForSequenceClassification, AutoTokenizer
import tensorflow as tf
-from shark.shark_inference import SharkInference
-from shark.parser import shark_args
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.parser import amdshark_args
import argparse
seq_parser = argparse.ArgumentParser(
- description="Shark Sequence Classification."
+ description="AMDShark Sequence Classification."
)
seq_parser.add_argument(
"--hf_model_name",
@@ -61,13 +61,13 @@ class SeqClassification(tf.Module):
if __name__ == "__main__":
inputs = preprocess_input()
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
SeqClassification(seq_args.hf_model_name),
(inputs["input_ids"], inputs["attention_mask"]),
)
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
- print(f"Model has been successfully compiled on {shark_args.device}")
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
+ print(f"Model has been successfully compiled on {amdshark_args.device}")
while True:
input_text = input(
@@ -77,7 +77,7 @@ if __name__ == "__main__":
break
inputs = preprocess_input(input_text)
print(
- shark_module.forward(
+ amdshark_module.forward(
(inputs["input_ids"], inputs["attention_mask"])
)
)
diff --git a/tank/examples/bert-base-uncased_tosa_torch/bert_base_uncased_tosa.py b/tank/examples/bert-base-uncased_tosa_torch/bert_base_uncased_tosa.py
index 12dbb33c..c4a0275c 100644
--- a/tank/examples/bert-base-uncased_tosa_torch/bert_base_uncased_tosa.py
+++ b/tank/examples/bert-base-uncased_tosa_torch/bert_base_uncased_tosa.py
@@ -1,17 +1,17 @@
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
mlir_model, func_name, inputs, golden_out = download_model(
"bert-base-uncased_tosa",
frontend="torch",
)
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
mlir_model, func_name, device="cpu", mlir_dialect="tosa"
)
-shark_module.compile()
-result = shark_module.forward(inputs)
-print("The obtained result via shark is: ", result)
+amdshark_module.compile()
+result = amdshark_module.forward(inputs)
+print("The obtained result via amdshark is: ", result)
print("The golden result is:", golden_out)
import numpy as np
diff --git a/tank/examples/bert_tf/seq_classification.py b/tank/examples/bert_tf/seq_classification.py
index aedc3a6d..43f5f8ed 100755
--- a/tank/examples/bert_tf/seq_classification.py
+++ b/tank/examples/bert_tf/seq_classification.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
from transformers import TFAutoModelForSequenceClassification, AutoTokenizer
import tensorflow as tf
-from shark.shark_inference import SharkInference
-from shark.parser import shark_args
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.parser import amdshark_args
import argparse
seq_parser = argparse.ArgumentParser(
- description="Shark Sequence Classification."
+ description="AMDShark Sequence Classification."
)
seq_parser.add_argument(
"--hf_model_name",
@@ -61,13 +61,13 @@ class SeqClassification(tf.Module):
if __name__ == "__main__":
inputs = preprocess_input()
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
SeqClassification(seq_args.hf_model_name),
(inputs["input_ids"], inputs["attention_mask"]),
)
- shark_module.set_frontend("tensorflow")
- shark_module.compile()
- print(f"Model has been successfully compiled on {shark_args.device}")
+ amdshark_module.set_frontend("tensorflow")
+ amdshark_module.compile()
+ print(f"Model has been successfully compiled on {amdshark_args.device}")
while True:
input_text = input(
@@ -77,7 +77,7 @@ if __name__ == "__main__":
break
inputs = preprocess_input(input_text)
print(
- shark_module.forward(
+ amdshark_module.forward(
(inputs["input_ids"], inputs["attention_mask"])
)
)
diff --git a/tank/examples/bloom/README.md b/tank/examples/bloom/README.md
index 807f334b..fbeb4762 100644
--- a/tank/examples/bloom/README.md
+++ b/tank/examples/bloom/README.md
@@ -5,10 +5,10 @@
Installation (Linux)
-### Activate shark.venv Virtual Environment
+### Activate amdshark.venv Virtual Environment
```shell
-source shark.venv/bin/activate
+source amdshark.venv/bin/activate
# Some older pip installs may not be able to handle the recent PyTorch deps
python -m pip install --upgrade pip
diff --git a/tank/examples/bloom/bloom_model.py b/tank/examples/bloom/bloom_model.py
index b57dd60a..4e236754 100644
--- a/tank/examples/bloom/bloom_model.py
+++ b/tank/examples/bloom/bloom_model.py
@@ -9,7 +9,7 @@ from transformers import BloomTokenizerFast, BloomForSequenceClassification
from torch.fx.experimental.proxy_tensor import make_fx
from torch._decomp import get_decompositions
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
p = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter
@@ -103,20 +103,20 @@ module = torch_mlir.compile(
mlir_model = module
func_name = "forward"
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
mlir_model, func_name, device=args.device, mlir_dialect="tm_tensor"
)
-shark_module.compile()
+amdshark_module.compile()
-def shark_result(x):
+def amdshark_result(x):
x_ny = x.detach().numpy()
inputs = (x_ny,)
- result = shark_module.forward(inputs)
+ result = amdshark_module.forward(inputs)
return torch.from_numpy(result)
-observed_out = shark_result(test_input)
+observed_out = amdshark_result(test_input)
print("Golden result:", actual_out)
-print("SHARK result:", observed_out)
+print("AMDSHARK result:", observed_out)
diff --git a/tank/examples/deberta-base_tf/deberta-base_tf_test.py b/tank/examples/deberta-base_tf/deberta-base_tf_test.py
index 016bfb34..fc8829b1 100644
--- a/tank/examples/deberta-base_tf/deberta-base_tf_test.py
+++ b/tank/examples/deberta-base_tf/deberta-base_tf_test.py
@@ -1,7 +1,7 @@
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
-from shark.parser import shark_args
-from tank.test_utils import get_valid_test_params, shark_test_name_func
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
+from amdshark.parser import amdshark_args
+from tank.test_utils import get_valid_test_params, amdshark_test_name_func
from parameterized import parameterized
import iree.compiler as ireec
@@ -24,11 +24,11 @@ class DebertaBaseModuleTester:
"microsoft/deberta-base", frontend="tf"
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
model, func_name, device=device, mlir_dialect="mhlo"
)
- shark_module.compile()
- result = shark_module.forward(inputs)
+ amdshark_module.compile()
+ result = amdshark_module.forward(inputs)
np.testing.assert_allclose(golden_out, result, rtol=1e-02, atol=1e-03)
@@ -41,7 +41,7 @@ class DebertaBaseModuleTest(unittest.TestCase):
param_list = get_valid_test_params()
- @parameterized.expand(param_list, name_func=shark_test_name_func)
+ @parameterized.expand(param_list, name_func=amdshark_test_name_func)
def test_module(self, dynamic, device):
self.module_tester.create_and_check_module(dynamic, device)
diff --git a/tank/examples/gpt2-64/gpt2-64_tflite_test.py b/tank/examples/gpt2-64/gpt2-64_tflite_test.py
index bf0237b8..9cafdb5d 100644
--- a/tank/examples/gpt2-64/gpt2-64_tflite_test.py
+++ b/tank/examples/gpt2-64/gpt2-64_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://s3.amazonaws.com/models.huggingface.co/bert/gpt2-64.tflite"
@@ -54,23 +54,23 @@ class GptTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_model(
model_name="gpt2-64", backend="tflite"
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -82,14 +82,14 @@ class GptTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/examples/opt/README.md b/tank/examples/opt/README.md
index 323e3616..dd3911de 100644
--- a/tank/examples/opt/README.md
+++ b/tank/examples/opt/README.md
@@ -1,18 +1,18 @@
-# Run OPT for sentence completion through SHARK
+# Run OPT for sentence completion through AMDSHARK
-From base SHARK directory, follow instructions to set up a virtual environment with SHARK. (`./setup_venv.sh` or `./setup_venv.ps1`)
-Then, you may run opt_causallm.py to get a very simple sentence completion application running through SHARK
+From base AMDSHARK directory, follow instructions to set up a virtual environment with AMDSHARK. (`./setup_venv.sh` or `./setup_venv.ps1`)
+Then, you may run opt_causallm.py to get a very simple sentence completion application running through AMDSHARK
```
python opt_causallm.py
```
-# Run OPT performance comparison on SHARK vs. PyTorch
+# Run OPT performance comparison on AMDSHARK vs. PyTorch
```
python opt_perf_comparison.py --max-seq-len=512 --model-name=facebook/opt-1.3b \
- --platform=shark
+ --platform=amdshark
```
-Any OPT model from huggingface should work with this script, and you can choose between `--platform=shark` or `--platform=huggingface` to generate benchmarks of OPT inference on SHARK / PyTorch.
+Any OPT model from huggingface should work with this script, and you can choose between `--platform=amdshark` or `--platform=huggingface` to generate benchmarks of OPT inference on AMDSHARK / PyTorch.
# Run a small suite of OPT models through the benchmark script
diff --git a/tank/examples/opt/shark_hf_base_opt.py b/tank/examples/opt/amdshark_hf_base_opt.py
similarity index 74%
rename from tank/examples/opt/shark_hf_base_opt.py
rename to tank/examples/opt/amdshark_hf_base_opt.py
index ef41b8d3..d81c23f7 100644
--- a/tank/examples/opt/shark_hf_base_opt.py
+++ b/tank/examples/opt/amdshark_hf_base_opt.py
@@ -1,9 +1,9 @@
import os
import torch
from transformers import AutoTokenizer, OPTForCausalLM
-from shark.shark_inference import SharkInference
-from shark.shark_importer import import_with_fx, save_mlir
-from shark_opt_wrapper import OPTForCausalLMModel
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import import_with_fx, save_mlir
+from amdshark_opt_wrapper import OPTForCausalLMModel
model_name = "facebook/opt-1.3b"
base_model = OPTForCausalLM.from_pretrained(model_name)
@@ -32,15 +32,15 @@ mlir_module = save_mlir(
frontend="torch",
mlir_dialect="linalg",
)
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
mlir_module,
device="cpu-sync",
mlir_dialect="tm_tensor",
)
-shark_module.compile()
+amdshark_module.compile()
# Generated logits.
-logits = shark_module("forward", inputs=inputs)
-print("SHARK module returns logits:")
+logits = amdshark_module("forward", inputs=inputs)
+print("AMDSHARK module returns logits:")
print(logits[0])
hf_logits = base_model.forward(inputs[0], inputs[1], return_dict=False)[0]
diff --git a/tank/examples/opt/shark_opt_wrapper.py b/tank/examples/opt/amdshark_opt_wrapper.py
similarity index 100%
rename from tank/examples/opt/shark_opt_wrapper.py
rename to tank/examples/opt/amdshark_opt_wrapper.py
diff --git a/tank/examples/opt/shark_opt_wrapper_train.py b/tank/examples/opt/amdshark_opt_wrapper_train.py
similarity index 100%
rename from tank/examples/opt/shark_opt_wrapper_train.py
rename to tank/examples/opt/amdshark_opt_wrapper_train.py
diff --git a/tank/examples/opt/opt_causallm.py b/tank/examples/opt/opt_causallm.py
index c84fa5a9..fb057be8 100644
--- a/tank/examples/opt/opt_causallm.py
+++ b/tank/examples/opt/opt_causallm.py
@@ -2,9 +2,9 @@ import argparse
import os
import torch
import numpy as np
-from shark_opt_wrapper import OPTForCausalLMModel
-from shark.shark_inference import SharkInference
-from shark.shark_importer import import_with_fx
+from amdshark_opt_wrapper import OPTForCausalLMModel
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import import_with_fx
from transformers import AutoTokenizer, OPTForCausalLM
from typing import Iterable
@@ -48,7 +48,7 @@ def create_module(model_name, tokenizer, device, args):
print(f"Saved mlir at {mlir_path}")
del model_mlir
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_path,
device=device,
mlir_dialect="tm_tensor",
@@ -56,7 +56,7 @@ def create_module(model_name, tokenizer, device, args):
)
vmfb_name = f"{opt_fs_name}_causallm_{args.max_seq_len}_torch_cpu"
- shark_module.save_module(module_name=vmfb_name, debug=False)
+ amdshark_module.save_module(module_name=vmfb_name, debug=False)
vmfb_path = vmfb_name + ".vmfb"
return vmfb_path
@@ -69,7 +69,7 @@ def shouldStop(tokens):
return False
-def generate_new_token(shark_module, tokenizer, new_text, max_seq_len: int):
+def generate_new_token(amdshark_module, tokenizer, new_text, max_seq_len: int):
model_inputs = tokenizer(
new_text,
padding="max_length",
@@ -82,7 +82,7 @@ def generate_new_token(shark_module, tokenizer, new_text, max_seq_len: int):
model_inputs["attention_mask"],
)
sum_attentionmask = torch.sum(model_inputs.attention_mask)
- output = shark_module("forward", inputs)
+ output = amdshark_module("forward", inputs)
output = torch.FloatTensor(output[0])
next_toks = torch.topk(output, 1)
stop_generation = False
@@ -140,7 +140,7 @@ def parse_args():
def generate_tokens(
- opt_shark_module: "SharkInference",
+ opt_amdshark_module: "AMDSharkInference",
tokenizer,
input_text: str,
max_output_len: int,
@@ -151,7 +151,7 @@ def generate_tokens(
try:
for _ in range(max_output_len):
generated_token_op = generate_new_token(
- opt_shark_module, tokenizer, new_text, max_output_len
+ opt_amdshark_module, tokenizer, new_text, max_output_len
)
detok = generated_token_op["detok"]
if generated_token_op["stop_generation"]:
@@ -182,16 +182,16 @@ if __name__ == "__main__":
rt_flags = [f"--executable_plugin={args.plugin_path}"]
else:
rt_flags = []
- opt_shark_module = SharkInference(
+ opt_amdshark_module = AMDSharkInference(
mlir_module=None, device="cpu-task", rt_flags=rt_flags
)
if os.path.isfile(vmfb_path):
- opt_shark_module.load_module(vmfb_path)
+ opt_amdshark_module.load_module(vmfb_path)
else:
vmfb_path = create_module(args.model_name, tokenizer, "cpu-task", args)
- opt_shark_module.load_module(vmfb_path)
+ opt_amdshark_module.load_module(vmfb_path)
while True:
input_text = input("Give me a sentence to complete:")
generate_tokens(
- opt_shark_module, tokenizer, input_text, args.max_seq_len
+ opt_amdshark_module, tokenizer, input_text, args.max_seq_len
)
diff --git a/tank/examples/opt/opt_causallm_samples.py b/tank/examples/opt/opt_causallm_samples.py
index e6525798..db63537b 100644
--- a/tank/examples/opt/opt_causallm_samples.py
+++ b/tank/examples/opt/opt_causallm_samples.py
@@ -4,7 +4,7 @@ import os
import opt_causallm
import opt_util
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
from transformers import AutoTokenizer, OPTForCausalLM
@@ -51,21 +51,21 @@ if __name__ == "__main__":
rt_flags = [f"--executable_plugin={args.plugin_path}"]
else:
rt_flags = []
- opt_shark_module = SharkInference(
+ opt_amdshark_module = AMDSharkInference(
mlir_module=None, device="cpu-task", rt_flags=rt_flags
)
if os.path.isfile(vmfb_path):
- opt_shark_module.load_module(vmfb_path)
+ opt_amdshark_module.load_module(vmfb_path)
else:
vmfb_path = opt_causallm.create_module(
args.model_name, tokenizer, "cpu-task", args
)
- opt_shark_module.load_module(vmfb_path)
+ opt_amdshark_module.load_module(vmfb_path)
for prompt in opt_util.PROMPTS:
print("\n\nprompt: {}".format(prompt))
response = opt_causallm.generate_tokens(
- opt_shark_module,
+ opt_amdshark_module,
tokenizer,
prompt,
args.max_seq_len,
diff --git a/tank/examples/opt/opt_causallm_torch_test.py b/tank/examples/opt/opt_causallm_torch_test.py
index 17cc1a93..bd21ec60 100644
--- a/tank/examples/opt/opt_causallm_torch_test.py
+++ b/tank/examples/opt/opt_causallm_torch_test.py
@@ -3,10 +3,10 @@ import os
import pytest
import torch
import numpy as np
-from shark_opt_wrapper import OPTForCausalLMModel
-from shark.iree_utils._common import check_device_drivers, device_driver_info
-from shark.shark_inference import SharkInference
-from shark.shark_importer import import_with_fx, save_mlir
+from amdshark_opt_wrapper import OPTForCausalLMModel
+from amdshark.iree_utils._common import check_device_drivers, device_driver_info
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import import_with_fx, save_mlir
from transformers import AutoTokenizer, OPTForCausalLM
OPT_MODEL = "facebook/opt-1.3b"
@@ -59,17 +59,17 @@ class OPTModuleTester:
print(f"Saved mlir at {mlir_path}")
del mlir_module
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_path,
device=device,
mlir_dialect="tm_tensor",
is_benchmark=self.benchmark,
)
- shark_module.compile()
- results = shark_module("forward", inputs)
+ amdshark_module.compile()
+ results = amdshark_module("forward", inputs)
print(
- "SHARK logits have shape: ",
+ "AMDSHARK logits have shape: ",
str(results[0].shape) + " : " + str(results[0]),
)
print(
@@ -79,11 +79,11 @@ class OPTModuleTester:
+ str(act_out[0])
)
# exp_out = tokenizer.decode(act_out[0][0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
- # shark_out = tokenizer.decode(results[0][0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
+ # amdshark_out = tokenizer.decode(results[0][0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
np.testing.assert_allclose(act_out[0].detach(), results[0])
if self.benchmark:
- shark_module.shark_runner.benchmark_all_csv(
+ amdshark_module.amdshark_runner.benchmark_all_csv(
inputs,
"opt",
dynamic,
diff --git a/tank/examples/opt/opt_perf_comparison.py b/tank/examples/opt/opt_perf_comparison.py
index 21a1ee97..d5d07374 100644
--- a/tank/examples/opt/opt_perf_comparison.py
+++ b/tank/examples/opt/opt_perf_comparison.py
@@ -1,14 +1,14 @@
"""
-Script for comparing OPT model performance between SHARK and Huggingface
+Script for comparing OPT model performance between AMDSHARK and Huggingface
PyTorch.
Usage Example:
python opt_perf_comparison.py --max-seq-len=32 --model-name=facebook/opt-125m \
- --platform=shark
+ --platform=amdshark
python opt_perf_comparison.py --max-seq-len=512 --model-name=facebook/opt-1.3b \
- --platform=shark
+ --platform=amdshark
See parse_args() below for command line argument usage.
"""
@@ -23,15 +23,15 @@ import numpy as np
from typing import Tuple
from opt_util import PROMPTS
-from shark.shark_inference import SharkInference
-from shark.shark_importer import import_with_fx
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_importer import import_with_fx
from transformers import AutoTokenizer, OPTForCausalLM
-from shark_opt_wrapper import OPTForCausalLMModel
-from shark.parser import shark_args
+from amdshark_opt_wrapper import OPTForCausalLMModel
+from amdshark.parser import amdshark_args
import iree.compiler as ireec
DEVICE = "cpu"
-PLATFORM_SHARK = "shark"
+PLATFORM_AMDSHARK = "amdshark"
PLATFORM_HUGGINGFACE = "huggingface"
# Dict keys for reports.
@@ -98,17 +98,17 @@ def create_vmfb_module(
tokenizer,
device: str,
max_seq_len: int,
- recompile_shark: bool,
+ recompile_amdshark: bool,
):
opt_fs_name = get_opt_fs_name(model_name)
mlir_path = f"./{opt_fs_name}_causallm_{max_seq_len}_torch.mlir"
# If MLIR has already been loaded and recompilation is not requested, use
# the loaded MLIR file.
has_mlir = os.path.isfile(mlir_path)
- # The purpose of recompile_shark is to measure compilation time; the
+ # The purpose of recompile_amdshark is to measure compilation time; the
# compilation time can be correctly measured only when MLIR has already been
# loaded.
- assert not recompile_shark or has_mlir
+ assert not recompile_amdshark or has_mlir
if not has_mlir:
import_mlir_module(
model_name,
@@ -116,7 +116,7 @@ def create_vmfb_module(
device,
max_seq_len,
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_path,
device=device,
mlir_dialect="tm_tensor",
@@ -125,38 +125,38 @@ def create_vmfb_module(
)
vmfb_name = f"{opt_fs_name}_causallm_{max_seq_len}_torch_{DEVICE}"
- shark_module.save_module(module_name=vmfb_name)
+ amdshark_module.save_module(module_name=vmfb_name)
vmfb_path = vmfb_name + ".vmfb"
return vmfb_path
-def load_shark_model(
+def load_amdshark_model(
model_name: str,
token_model_name: str,
max_seq_len: int,
- recompile_shark: bool,
+ recompile_amdshark: bool,
plugin_path: str = [],
) -> ModelWrapper:
opt_fs_name = get_opt_fs_name(model_name)
vmfb_name = f"{opt_fs_name}_causallm_{max_seq_len}_torch_{DEVICE}.vmfb"
tokenizer = AutoTokenizer.from_pretrained(token_model_name, use_fast=False)
- if recompile_shark or not os.path.isfile(vmfb_name):
+ if recompile_amdshark or not os.path.isfile(vmfb_name):
print(f"vmfb not found. compiling and saving to {vmfb_name}")
create_vmfb_module(
- model_name, tokenizer, DEVICE, max_seq_len, recompile_shark
+ model_name, tokenizer, DEVICE, max_seq_len, recompile_amdshark
)
if plugin_path is not None:
rt_flags = [f"--executable_plugin={plugin_path}"]
else:
rt_flags = []
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=None, device="cpu-task", rt_flags=rt_flags
)
- shark_module.load_module(vmfb_name)
- return ModelWrapper(model=shark_module, tokenizer=tokenizer)
+ amdshark_module.load_module(vmfb_name)
+ return ModelWrapper(model=amdshark_module, tokenizer=tokenizer)
-def run_shark_model(model_wrapper: ModelWrapper, tokens):
+def run_amdshark_model(model_wrapper: ModelWrapper, tokens):
# Generate logits output of OPT model.
return model_wrapper.model("forward", tokens)
@@ -231,21 +231,21 @@ def collect_huggingface_logits(
}
-def collect_shark_logits(
+def collect_amdshark_logits(
model_name: str,
token_model_name: str,
max_seq_len: int,
- recompile_shark: bool,
+ recompile_amdshark: bool,
to_save_json: bool,
plugin_path: str,
) -> Tuple[float, float]:
# Load
t0 = time.time()
- model_wrapper = load_shark_model(
- model_name, token_model_name, max_seq_len, recompile_shark, plugin_path
+ model_wrapper = load_amdshark_model(
+ model_name, token_model_name, max_seq_len, recompile_amdshark, plugin_path
)
load_time = time.time() - t0
- print("--- Took {} seconds to load Shark.".format(load_time))
+ print("--- Took {} seconds to load AMDShark.".format(load_time))
load_memory_info = get_memory_info()
results = []
@@ -268,18 +268,18 @@ def collect_shark_logits(
t0 = time.time()
for idx, tokens in enumerate(tokenized_prompts):
print("prompt: {}".format(PROMPTS[idx]))
- logits = run_shark_model(model_wrapper, tokens)
+ logits = run_amdshark_model(model_wrapper, tokens)
lst = [e.tolist() for e in logits]
if to_save_json:
results.append([PROMPTS[idx], lst])
run_time = time.time() - t0
- print("--- Took {} seconds to run Shark.".format(run_time))
+ print("--- Took {} seconds to run AMDShark.".format(run_time))
if to_save_json:
- save_json(results, "/tmp/shark.json")
- platform_postfix = "-compile" if recompile_shark else "-precompiled"
+ save_json(results, "/tmp/amdshark.json")
+ platform_postfix = "-compile" if recompile_amdshark else "-precompiled"
run_memory_info = get_memory_info()
return {
- REPORT_PLATFORM: PLATFORM_SHARK + platform_postfix,
+ REPORT_PLATFORM: PLATFORM_AMDSHARK + platform_postfix,
REPORT_MODEL_NAME: model_name,
REPORT_MAX_SEQ_LEN: max_seq_len,
REPORT_LOAD_TIME: load_time,
@@ -333,17 +333,17 @@ def parse_args():
default="facebook/opt-1.3b",
)
parser.add_argument(
- "--recompile-shark",
+ "--recompile-amdshark",
help="If set, recompiles MLIR",
action=argparse.BooleanOptionalAction,
default=False,
)
parser.add_argument(
"--platform",
- help="Either shark or huggingface",
+ help="Either amdshark or huggingface",
type=str,
- choices=[PLATFORM_SHARK, PLATFORM_HUGGINGFACE],
- default=PLATFORM_SHARK,
+ choices=[PLATFORM_AMDSHARK, PLATFORM_HUGGINGFACE],
+ default=PLATFORM_AMDSHARK,
)
parser.add_argument(
"--plugin-path",
@@ -371,16 +371,16 @@ if __name__ == "__main__":
)
else:
args.token_model_name = args.model_name
- if args.platform == PLATFORM_SHARK:
- shark_report = collect_shark_logits(
+ if args.platform == PLATFORM_AMDSHARK:
+ amdshark_report = collect_amdshark_logits(
args.model_name,
args.token_model_name,
args.max_seq_len,
- args.recompile_shark,
+ args.recompile_amdshark,
args.save_json,
args.plugin_path,
)
- print("# Summary: {}".format(json.dumps(shark_report)))
+ print("# Summary: {}".format(json.dumps(amdshark_report)))
else:
huggingface_report = collect_huggingface_logits(
args.model_name,
diff --git a/tank/examples/opt/opt_torch_test.py b/tank/examples/opt/opt_torch_test.py
index a56055af..3eaf953b 100644
--- a/tank/examples/opt/opt_torch_test.py
+++ b/tank/examples/opt/opt_torch_test.py
@@ -2,9 +2,9 @@ import unittest
import pytest
import torch_mlir
-from shark_hf_opt import OPTModel
-from shark.iree_utils._common import check_device_drivers, device_driver_info
-from shark.shark_inference import SharkInference
+from amdshark_hf_opt import OPTModel
+from amdshark.iree_utils._common import check_device_drivers, device_driver_info
+from amdshark.amdshark_inference import AMDSharkInference
from tank.model_utils import compare_tensors
from transformers import AutoTokenizer
@@ -45,7 +45,7 @@ class OPTModuleTester:
func_name = "forward"
act_out = opt_model(input_ids, attention_mask).detach()
- # mlir_importer = SharkImporter(
+ # mlir_importer = AMDSharkImporter(
# model,
# (input,),
# frontend="torch",
@@ -54,18 +54,18 @@ class OPTModuleTester:
# is_dynamic=dynamic, tracing_required=True
# )
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
model_mlir,
device=device,
mlir_dialect="tm_tensor",
is_benchmark=self.benchmark,
)
- shark_module.compile()
- results = shark_module("forward", (input_ids, attention_mask))
+ amdshark_module.compile()
+ results = amdshark_module("forward", (input_ids, attention_mask))
assert compare_tensors(act_out, results)
if self.benchmark:
- shark_module.shark_runner.benchmark_all_csv(
+ amdshark_module.amdshark_runner.benchmark_all_csv(
(input_ids, attention_mask),
"opt",
dynamic,
diff --git a/tank/examples/rembert_tf/rembert_tf_test.py b/tank/examples/rembert_tf/rembert_tf_test.py
index 1f401c96..d073d9b8 100644
--- a/tank/examples/rembert_tf/rembert_tf_test.py
+++ b/tank/examples/rembert_tf/rembert_tf_test.py
@@ -1,6 +1,6 @@
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
-from tank.test_utils import get_valid_test_params, shark_test_name_func
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
+from tank.test_utils import get_valid_test_params, amdshark_test_name_func
from parameterized import parameterized
import iree.compiler as ireec
@@ -21,11 +21,11 @@ class RemBertModuleTester:
"google/rembert", frontend="tf"
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
model, func_name, device=device, mlir_dialect="mhlo"
)
- shark_module.compile()
- result = shark_module.forward(inputs)
+ amdshark_module.compile()
+ result = amdshark_module.forward(inputs)
np.testing.assert_allclose(golden_out, result, rtol=1e-02, atol=1e-03)
@@ -38,7 +38,7 @@ class RemBertModuleTest(unittest.TestCase):
param_list = get_valid_test_params()
- @parameterized.expand(param_list, name_func=shark_test_name_func)
+ @parameterized.expand(param_list, name_func=amdshark_test_name_func)
def test_module(self, dynamic, device):
self.module_tester.create_and_check_module(dynamic, device)
diff --git a/tank/examples/tapas-base_tf/tapas-base_tf_test.py b/tank/examples/tapas-base_tf/tapas-base_tf_test.py
index 20df6490..e23c4fb6 100644
--- a/tank/examples/tapas-base_tf/tapas-base_tf_test.py
+++ b/tank/examples/tapas-base_tf/tapas-base_tf_test.py
@@ -1,6 +1,6 @@
-from shark.iree_utils._common import check_device_drivers, device_driver_info
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
+from amdshark.iree_utils._common import check_device_drivers, device_driver_info
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
import iree.compiler as ireec
import unittest
@@ -21,11 +21,11 @@ class TapasBaseModuleTester:
frontend="tf",
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
model, func_name, device=device, mlir_dialect="mhlo"
)
- shark_module.compile()
- result = shark_module.forward(inputs)
+ amdshark_module.compile()
+ result = amdshark_module.forward(inputs)
np.testing.assert_allclose(golden_out, result, rtol=1e-02, atol=1e-03)
diff --git a/tank/examples/v_diffusion_pytorch/README.md b/tank/examples/v_diffusion_pytorch/README.md
index 8b73e0fe..bcd9c441 100644
--- a/tank/examples/v_diffusion_pytorch/README.md
+++ b/tank/examples/v_diffusion_pytorch/README.md
@@ -5,10 +5,10 @@
Installation (Linux)
-### Activate shark.venv Virtual Environment
+### Activate amdshark.venv Virtual Environment
```shell
-source shark.venv/bin/activate
+source amdshark.venv/bin/activate
# Some older pip installs may not be able to handle the recent PyTorch deps
python -m pip install --upgrade pip
diff --git a/tank/examples/v_diffusion_pytorch/cfg_sample.py b/tank/examples/v_diffusion_pytorch/cfg_sample.py
index 5a66199a..f6833873 100755
--- a/tank/examples/v_diffusion_pytorch/cfg_sample.py
+++ b/tank/examples/v_diffusion_pytorch/cfg_sample.py
@@ -14,7 +14,7 @@ from torchvision import transforms
from torchvision.transforms import functional as TF
from tqdm import trange
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
import sys
@@ -70,7 +70,7 @@ p.add_argument("--device", type=str, help="the device to use")
p.add_argument(
"--runtime_device",
type=str,
- help="the device to use with SHARK",
+ help="the device to use with AMDSHARK",
default="cpu",
)
p.add_argument(
@@ -240,17 +240,17 @@ module = torch_mlir.compile(
mlir_model = module
func_name = "forward"
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
mlir_model, func_name, device=args.runtime_device, mlir_dialect="linalg"
)
-shark_module.compile()
+amdshark_module.compile()
def compiled_cfg_model_fn(x, t):
x_ny = x.detach().numpy()
t_ny = t.detach().numpy()
inputs = (x_ny, t_ny)
- result = shark_module.forward(inputs)
+ result = amdshark_module.forward(inputs)
return torch.from_numpy(result)
diff --git a/tank/examples/v_diffusion_pytorch/cfg_sample_eager.py b/tank/examples/v_diffusion_pytorch/cfg_sample_eager.py
index 513121a6..c901e2dd 100755
--- a/tank/examples/v_diffusion_pytorch/cfg_sample_eager.py
+++ b/tank/examples/v_diffusion_pytorch/cfg_sample_eager.py
@@ -14,8 +14,8 @@ from torchvision import transforms
from torchvision.transforms import functional as TF
from tqdm import trange
-from shark.shark_inference import SharkInference
-from shark.torch_mlir_lockstep_tensor import TorchMLIRLockstepTensor
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.torch_mlir_lockstep_tensor import TorchMLIRLockstepTensor
import sys
@@ -235,10 +235,10 @@ ts_g = torch.jit.script(fx_g)
# mlir_model = module
# func_name = "forward"
#
-# shark_module = SharkInference(
+# amdshark_module = AMDSharkInference(
# mlir_model, func_name, device="cuda", mlir_dialect="linalg"
# )
-# shark_module.compile()
+# amdshark_module.compile()
def compiled_cfg_model_fn(x, t):
diff --git a/tank/examples/v_diffusion_pytorch/cfg_sample_from_mlir.py b/tank/examples/v_diffusion_pytorch/cfg_sample_from_mlir.py
index 769aa20d..f61d1788 100755
--- a/tank/examples/v_diffusion_pytorch/cfg_sample_from_mlir.py
+++ b/tank/examples/v_diffusion_pytorch/cfg_sample_from_mlir.py
@@ -14,8 +14,8 @@ from torchvision import transforms
from torchvision.transforms import functional as TF
from tqdm import trange
-from shark.shark_inference import SharkInference
-from shark.shark_downloader import download_model
+from amdshark.amdshark_inference import AMDSharkInference
+from amdshark.amdshark_downloader import download_model
import numpy as np
import sys
@@ -72,7 +72,7 @@ p.add_argument("--device", type=str, help="the device to use")
p.add_argument(
"--runtime_device",
type=str,
- help="the device to use with SHARK",
+ help="the device to use with AMDSHARK",
default="cpu",
)
p.add_argument(
@@ -195,17 +195,17 @@ mlir_model, func_name, inputs, golden_out = download_model(
"v_diffusion", frontend="torch"
)
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
mlir_model, func_name, device=args.runtime_device, mlir_dialect="linalg"
)
-shark_module.compile()
+amdshark_module.compile()
def compiled_cfg_model_fn(x, t):
x_ny = x.detach().numpy()
t_ny = t.detach().numpy()
inputs = (x_ny, t_ny)
- result = shark_module.forward(inputs)
+ result = amdshark_module.forward(inputs)
return torch.from_numpy(result)
diff --git a/tank/examples/v_diffusion_pytorch/cfg_sample_preprocess.py b/tank/examples/v_diffusion_pytorch/cfg_sample_preprocess.py
index de1dfb7f..02360f92 100755
--- a/tank/examples/v_diffusion_pytorch/cfg_sample_preprocess.py
+++ b/tank/examples/v_diffusion_pytorch/cfg_sample_preprocess.py
@@ -15,7 +15,7 @@ from torchvision.transforms import functional as TF
from tqdm import trange
import numpy as np
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
import sys
@@ -72,7 +72,7 @@ p.add_argument("--device", type=str, help="the device to use")
p.add_argument(
"--runtime_device",
type=str,
- help="the device to use with SHARK",
+ help="the device to use with AMDSHARK",
default="intel-gpu",
)
p.add_argument(
@@ -265,10 +265,10 @@ module = torch_mlir.compile(
mlir_model = module
func_name = "forward"
-shark_module = SharkInference(
+amdshark_module = AMDSharkInference(
mlir_model, func_name, device=args.runtime_device, mlir_dialect="linalg"
)
-shark_module.compile()
+amdshark_module.compile()
def compiled_cfg_model_fn(x, t):
@@ -295,7 +295,7 @@ def compiled_cfg_model_fn(x, t):
timestep_embed_ny = timestep_embed.detach().numpy()
selfcond_ny = selfcond.detach().numpy()
inputs = (x_ny, timestep_embed_ny, selfcond_ny)
- result = shark_module.forward(inputs)
+ result = amdshark_module.forward(inputs)
vs = torch.from_numpy(result).view([n_conds, n, *x.shape[1:]])
v = vs.mul(weights[:, None, None, None, None]).sum(0)
diff --git a/tank/generate_sharktank.py b/tank/generate_amdsharktank.py
similarity index 89%
rename from tank/generate_sharktank.py
rename to tank/generate_amdsharktank.py
index c0bca61a..22ae2175 100644
--- a/tank/generate_sharktank.py
+++ b/tank/generate_amdsharktank.py
@@ -1,9 +1,9 @@
# Lint as: python3
-"""SHARK Tank"""
-# python generate_sharktank.py, you have to give a csv tile with [model_name, model_download_url]
-# will generate local shark tank folder like this:
-# /SHARK
-# /gen_shark_tank
+"""AMDSHARK Tank"""
+# python generate_amdsharktank.py, you have to give a csv tile with [model_name, model_download_url]
+# will generate local amdshark tank folder like this:
+# /AMDSHARK
+# /gen_amdshark_tank
# /albert_lite_base
# /...model_name...
#
@@ -11,7 +11,7 @@
import os
import csv
import argparse
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_importer import AMDSharkImporter
import subprocess as sp
import hashlib
import numpy as np
@@ -36,7 +36,7 @@ def save_torch_model(torch_model_list, local_tank_cache, import_args):
get_hf_img_cls_model,
get_fp16_model,
)
- from shark.shark_importer import import_with_fx, save_mlir
+ from amdshark.amdshark_importer import import_with_fx, save_mlir
with open(torch_model_list) as csvfile:
torch_reader = csv.reader(csvfile, delimiter=",")
@@ -107,7 +107,7 @@ def save_torch_model(torch_model_list, local_tank_cache, import_args):
tracing_required=True,
)
else:
- mlir_importer = SharkImporter(
+ mlir_importer = AMDSharkImporter(
model,
(input,),
frontend="torch",
@@ -146,8 +146,8 @@ class NoImportException(Exception):
pass
-def gen_shark_files(modelname, frontend, tank_dir, importer_args):
- # If a model's artifacts are requested by shark_downloader but they don't exist in the cloud, we call this function to generate the artifacts on-the-fly.
+def gen_amdshark_files(modelname, frontend, tank_dir, importer_args):
+ # If a model's artifacts are requested by amdshark_downloader but they don't exist in the cloud, we call this function to generate the artifacts on-the-fly.
# TODO: Add TFlite support.
import tempfile
@@ -191,7 +191,7 @@ if __name__ == "__main__":
# type=lambda x: is_valid_file(x),
# default="./tank/torch_model_list.csv",
# help="""Contains the file with torch_model name and args.
- # Please see: https://github.com/nod-ai/SHARK-Studio/blob/main/tank/torch_model_list.csv""",
+ # Please see: https://github.com/nod-ai/AMDSHARK-Studio/blob/main/tank/torch_model_list.csv""",
# )
# parser.add_argument(
# "--ci_tank_dir",
@@ -206,7 +206,7 @@ if __name__ == "__main__":
}
print(import_args)
home = str(Path.home())
- WORKDIR = os.path.join(os.path.dirname(__file__), "..", "gen_shark_tank")
+ WORKDIR = os.path.join(os.path.dirname(__file__), "..", "gen_amdshark_tank")
torch_model_csv = os.path.join(
os.path.dirname(__file__), "torch_model_list.csv"
)
diff --git a/tank/model_utils.py b/tank/model_utils.py
index db3dd49f..891fb527 100644
--- a/tank/model_utils.py
+++ b/tank/model_utils.py
@@ -1,4 +1,4 @@
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_inference import AMDSharkInference
import torch
import numpy as np
diff --git a/tank/test_models.py b/tank/test_models.py
index 188243bc..648b40c9 100644
--- a/tank/test_models.py
+++ b/tank/test_models.py
@@ -1,10 +1,10 @@
-from shark.iree_utils._common import (
+from amdshark.iree_utils._common import (
check_device_drivers,
device_driver_info,
get_supported_device_list,
)
-from shark.iree_utils.vulkan_utils import get_vulkan_triple_flag
-from shark.parser import shark_args
+from amdshark.iree_utils.vulkan_utils import get_vulkan_triple_flag
+from amdshark.parser import amdshark_args
from parameterized import parameterized
import iree.compiler as ireec
import pytest
@@ -101,7 +101,7 @@ def is_valid_case(test_params):
return True
-def shark_test_name_func(testcase_func, param_num, param):
+def amdshark_test_name_func(testcase_func, param_num, param):
"""
Generate function name string which shows dynamic/static and device name.
this will be ingested by 'parameterized' package to rename the pytest.
@@ -129,7 +129,7 @@ def shark_test_name_func(testcase_func, param_num, param):
)
-class SharkModuleTester:
+class AMDSharkModuleTester:
def __init__(self, config):
"""config should be a dict containing minimally:
dialect: (str) name of input dialect
@@ -140,43 +140,43 @@ class SharkModuleTester:
self.config = config
def create_and_check_module(self, dynamic, device):
- shark_args.update_tank = self.update_tank
- shark_args.force_update_tank = self.force_update_tank
- shark_args.shark_prefix = self.shark_tank_prefix
- shark_args.local_tank_cache = self.local_tank_cache
- shark_args.dispatch_benchmarks = self.benchmark_dispatches
- shark_args.enable_tf32 = self.tf32
+ amdshark_args.update_tank = self.update_tank
+ amdshark_args.force_update_tank = self.force_update_tank
+ amdshark_args.amdshark_prefix = self.amdshark_tank_prefix
+ amdshark_args.local_tank_cache = self.local_tank_cache
+ amdshark_args.dispatch_benchmarks = self.benchmark_dispatches
+ amdshark_args.enable_tf32 = self.tf32
if self.benchmark_dispatches is not None:
_m = self.config["model_name"].split("/")
_m.extend([self.config["framework"], str(dynamic), device])
_m = "_".join(_m)
- shark_args.dispatch_benchmarks_dir = os.path.join(
+ amdshark_args.dispatch_benchmarks_dir = os.path.join(
self.dispatch_benchmarks_dir,
_m,
)
if not os.path.exists(self.dispatch_benchmarks_dir):
os.mkdir(self.dispatch_benchmarks_dir)
- if not os.path.exists(shark_args.dispatch_benchmarks_dir):
- os.mkdir(shark_args.dispatch_benchmarks_dir)
+ if not os.path.exists(amdshark_args.dispatch_benchmarks_dir):
+ os.mkdir(amdshark_args.dispatch_benchmarks_dir)
if "nhcw-nhwc" in self.config["flags"] and not os.path.isfile(
".use-iree"
):
- shark_args.enable_conv_transform = True
+ amdshark_args.enable_conv_transform = True
else:
- shark_args.enable_conv_transform = False
+ amdshark_args.enable_conv_transform = False
if "img2col" in self.config["flags"]:
- shark_args.enable_img2col_transform = True
+ amdshark_args.enable_img2col_transform = True
if "winograd" in self.config["flags"]:
- shark_args.use_winograd = True
+ amdshark_args.use_winograd = True
import_config = {
"batch_size": self.batch_size,
}
- from shark.shark_downloader import download_model
- from shark.shark_inference import SharkInference
- from tank.generate_sharktank import NoImportException
+ from amdshark.amdshark_downloader import download_model
+ from amdshark.amdshark_inference import AMDSharkInference
+ from tank.generate_amdsharktank import NoImportException
dl_gen_attempts = 2
for i in range(dl_gen_attempts):
@@ -199,7 +199,7 @@ class SharkModuleTester:
)
break
is_bench = True if self.benchmark is not None else False
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
model,
device=device,
mlir_dialect=self.config["dialect"],
@@ -207,7 +207,7 @@ class SharkModuleTester:
)
try:
- shark_module.compile()
+ amdshark_module.compile()
except:
if any([self.ci, self.save_repro, self.save_fails]) == True:
self.save_reproducers()
@@ -215,7 +215,7 @@ class SharkModuleTester:
self.upload_repro()
raise
- result = shark_module(func_name, inputs)
+ result = amdshark_module(func_name, inputs)
golden_out, result = self.postprocess_outputs(golden_out, result)
if self.tf32 == True:
print(
@@ -237,7 +237,7 @@ class SharkModuleTester:
self.upload_repro()
if self.benchmark is not None:
self.benchmark_module(
- shark_module, inputs, dynamic, device, mode=self.benchmark
+ amdshark_module, inputs, dynamic, device, mode=self.benchmark
)
print(msg)
pytest.xfail(
@@ -245,21 +245,21 @@ class SharkModuleTester:
)
if self.benchmark is not None:
self.benchmark_module(
- shark_module, inputs, dynamic, device, mode=self.benchmark
+ amdshark_module, inputs, dynamic, device, mode=self.benchmark
)
if self.save_repro == True:
self.save_reproducers()
def benchmark_module(
- self, shark_module, inputs, dynamic, device, mode="native"
+ self, amdshark_module, inputs, dynamic, device, mode="native"
):
model_config = {
"batch_size": self.batch_size,
}
- shark_args.onnx_bench = self.onnx_bench
- shark_module.shark_runner.benchmark_all_csv(
+ amdshark_args.onnx_bench = self.onnx_bench
+ amdshark_module.amdshark_runner.benchmark_all_csv(
(inputs),
self.config["model_name"],
dynamic,
@@ -286,9 +286,9 @@ class SharkModuleTester:
repro_path = os.path.join("reproducers", self.tmp_prefix, "*")
- bashCommand = f"gsutil cp -r {repro_path} gs://shark-public/builder/repro_artifacts/{self.ci_sha}/{self.tmp_prefix}/"
+ bashCommand = f"gsutil cp -r {repro_path} gs://amdshark-public/builder/repro_artifacts/{self.ci_sha}/{self.tmp_prefix}/"
print(
- f"Uploading reproducer {repro_path} to gs://shark-public/builder/repro_artifacts/{self.ci_sha}/{self.tmp_prefix}/"
+ f"Uploading reproducer {repro_path} to gs://amdshark-public/builder/repro_artifacts/{self.ci_sha}/{self.tmp_prefix}/"
)
process = subprocess.run(bashCommand.split())
@@ -309,16 +309,16 @@ class SharkModuleTester:
return expected, logits
-class SharkModuleTest(unittest.TestCase):
+class AMDSharkModuleTest(unittest.TestCase):
@pytest.fixture(autouse=True)
def configure(self, pytestconfig):
self.pytestconfig = pytestconfig
param_list = get_valid_test_params()
- @parameterized.expand(param_list, name_func=shark_test_name_func)
+ @parameterized.expand(param_list, name_func=amdshark_test_name_func)
def test_module(self, dynamic, device, config):
- self.module_tester = SharkModuleTester(config)
+ self.module_tester = AMDSharkModuleTester(config)
self.module_tester.batch_size = self.pytestconfig.getoption(
"batchsize"
)
@@ -344,7 +344,7 @@ class SharkModuleTest(unittest.TestCase):
self.module_tester.force_update_tank = self.pytestconfig.getoption(
"force_update_tank"
)
- self.module_tester.shark_tank_prefix = self.pytestconfig.getoption(
+ self.module_tester.amdshark_tank_prefix = self.pytestconfig.getoption(
"tank_prefix"
)
self.module_tester.benchmark_dispatches = self.pytestconfig.getoption(
@@ -396,7 +396,7 @@ class SharkModuleTest(unittest.TestCase):
and device == "rocm"
):
pytest.xfail(
- reason="iree-compile buffer limit issue: https://github.com/nod-ai/SHARK-Studio/issues/475"
+ reason="iree-compile buffer limit issue: https://github.com/nod-ai/AMDSHARK-Studio/issues/475"
)
if (
config["model_name"]
@@ -407,7 +407,7 @@ class SharkModuleTest(unittest.TestCase):
and device == "rocm"
):
pytest.xfail(
- reason="Numerics issues: https://github.com/nod-ai/SHARK-Studio/issues/476"
+ reason="Numerics issues: https://github.com/nod-ai/AMDSHARK-Studio/issues/476"
)
if config["framework"] == "tf" and self.module_tester.batch_size != 1:
pytest.xfail(
diff --git a/tank/tflite/albert.py b/tank/tflite/albert.py
index ef3dd476..273fcfb6 100755
--- a/tank/tflite/albert.py
+++ b/tank/tflite/albert.py
@@ -1,6 +1,6 @@
# RUN: %PYTHON %s
import numpy as np
-from shark.shark_importer import SharkImporter
+from amdshark.amdshark_importer import AMDSharkImporter
import pytest
model_path = "https://tfhub.dev/tensorflow/lite-model/albert_lite_base/squadv1/1?lite-format=tflite"
@@ -34,7 +34,7 @@ def generate_inputs(input_details):
if __name__ == "__main__":
- my_shark_importer = SharkImporter(
+ my_amdshark_importer = AMDSharkImporter(
model_path=model_path,
model_type="tflite",
model_source_hub="tfhub",
@@ -43,11 +43,11 @@ if __name__ == "__main__":
jit_trace=True,
)
# Case1: Use default inputs
- my_shark_importer.compile()
- shark_results = my_shark_importer.forward()
+ my_amdshark_importer.compile()
+ amdshark_results = my_amdshark_importer.forward()
# Case2: Use manually set inputs
- input_details, output_details = my_shark_importer.get_model_details()
+ input_details, output_details = my_amdshark_importer.get_model_details()
inputs = generate_inputs(input_details) # device_inputs
- my_shark_importer.compile(inputs)
- shark_results = my_shark_importer.forward(inputs)
- # print(shark_results)
+ my_amdshark_importer.compile(inputs)
+ amdshark_results = my_amdshark_importer.forward(inputs)
+ # print(amdshark_results)
diff --git a/tank/tflite/albert_lite_base/albert_lite_base_tflite_sharkimporter.txt b/tank/tflite/albert_lite_base/albert_lite_base_tflite_amdsharkimporter.txt
similarity index 84%
rename from tank/tflite/albert_lite_base/albert_lite_base_tflite_sharkimporter.txt
rename to tank/tflite/albert_lite_base/albert_lite_base_tflite_amdsharkimporter.txt
index ca8c2ca7..70227539 100644
--- a/tank/tflite/albert_lite_base/albert_lite_base_tflite_sharkimporter.txt
+++ b/tank/tflite/albert_lite_base/albert_lite_base_tflite_amdsharkimporter.txt
@@ -1,10 +1,10 @@
# import numpy as np
-# from shark.shark_importer import SharkImporter
-# from shark.shark_inference import SharkInference
+# from amdshark.amdshark_importer import AMDSharkImporter
+# from amdshark.amdshark_inference import AMDSharkInference
# import pytest
# import unittest
-# from shark.parser import shark_args
-# from shark.tflite_utils import TFLitePreprocessor
+# from amdshark.parser import amdshark_args
+# from amdshark.tflite_utils import TFLitePreprocessor
#
#
# # model_path = "https://tfhub.dev/tensorflow/lite-model/albert_lite_base/squadv1/1?lite-format=tflite"
@@ -75,35 +75,35 @@
# self.save_vmfb = save_vmfb
#
# def create_and_check_module(self):
-# shark_args.save_mlir = self.save_mlir
-# shark_args.save_vmfb = self.save_vmfb
+# amdshark_args.save_mlir = self.save_mlir
+# amdshark_args.save_vmfb = self.save_vmfb
#
-# # Preprocess to get SharkImporter input args
+# # Preprocess to get AMDSharkImporter input args
# tflite_preprocessor = TFLitePreprocessor(model_name="albert_lite_base")
# raw_model_file_path = tflite_preprocessor.get_raw_model_file()
# inputs = tflite_preprocessor.get_inputs()
# tflite_interpreter = tflite_preprocessor.get_interpreter()
#
-# # Use SharkImporter to get SharkInference input args
-# my_shark_importer = SharkImporter(
+# # Use AMDSharkImporter to get AMDSharkInference input args
+# my_amdshark_importer = AMDSharkImporter(
# module=tflite_interpreter,
# inputs=inputs,
# frontend="tflite",
# raw_model_file=raw_model_file_path,
# )
-# mlir_model, func_name = my_shark_importer.import_mlir()
+# mlir_model, func_name = my_amdshark_importer.import_mlir()
#
-# # Use SharkInference to get inference result
-# shark_module = SharkInference(
+# # Use AMDSharkInference to get inference result
+# amdshark_module = AMDSharkInference(
# mlir_module=mlir_model,
# function_name=func_name,
# device=self.device,
# mlir_dialect="tflite",
# )
#
-# # Case1: Use shark_importer default generate inputs
-# shark_module.compile()
-# mlir_results = shark_module.forward(inputs)
+# # Case1: Use amdshark_importer default generate inputs
+# amdshark_module.compile()
+# mlir_results = amdshark_module.forward(inputs)
# ## post process results for compare
# # input_details, output_details = tflite_preprocessor.get_model_details()
# # mlir_results = list(mlir_results)
@@ -133,14 +133,14 @@
# ]
# inputs = generate_inputs(input_details) # new inputs
#
-# shark_module = SharkInference(
+# amdshark_module = AMDSharkInference(
# mlir_module=mlir_model,
# function_name=func_name,
# device=self.device,
# mlir_dialect="tflite",
# )
-# shark_module.compile()
-# mlir_results = shark_module.forward(inputs)
+# amdshark_module.compile()
+# mlir_results = amdshark_module.forward(inputs)
# ## post process results for compare
# tflite_results = tflite_preprocessor.get_golden_output()
# compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/albert_lite_base/albert_lite_base_tflite_test.py b/tank/tflite/albert_lite_base/albert_lite_base_tflite_test.py
index 0c3d1f4f..514e479a 100644
--- a/tank/tflite/albert_lite_base/albert_lite_base_tflite_test.py
+++ b/tank/tflite/albert_lite_base/albert_lite_base_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/tensorflow/lite-model/albert_lite_base/squadv1/1?lite-format=tflite"
@@ -75,8 +75,8 @@ class AlbertTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
(
mlir_model,
@@ -85,15 +85,15 @@ class AlbertTfliteModuleTester:
tflite_results,
) = download_tflite_model(model_name="albert_lite_base")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
- # print(shark_results)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
+ # print(amdshark_results)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/arbitrary-image-stylization-v1-256/arbitrary-image-stylization-v1-256_tflite_test.py b/tank/tflite/arbitrary-image-stylization-v1-256/arbitrary-image-stylization-v1-256_tflite_test.py
index ddc41c46..a90849c9 100644
--- a/tank/tflite/arbitrary-image-stylization-v1-256/arbitrary-image-stylization-v1-256_tflite_test.py
+++ b/tank/tflite/arbitrary-image-stylization-v1-256/arbitrary-image-stylization-v1-256_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/google/lite-model/magenta/arbitrary-image-stylization-v1-256/int8/prediction/1?lite-format=tflite"
@@ -41,8 +41,8 @@ class ArbitraryImageStylizationV1TfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
(
mlir_model,
@@ -52,16 +52,16 @@ class ArbitraryImageStylizationV1TfliteModuleTester:
) = download_tflite_model(
model_name="arbitrary-image-stylization-v1-256"
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
- # print(shark_results)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
+ # print(amdshark_results)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/birds_V1/birds_V1_tflite_test.py b/tank/tflite/birds_V1/birds_V1_tflite_test.py
index 78392325..55f23590 100644
--- a/tank/tflite/birds_V1/birds_V1_tflite_test.py
+++ b/tank/tflite/birds_V1/birds_V1_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
import urllib.request
@@ -60,8 +60,8 @@ class BirdsV1TfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
(
mlir_model,
@@ -69,16 +69,16 @@ class BirdsV1TfliteModuleTester:
inputs,
tflite_results,
) = download_tflite_model(model_name="birds_V1")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -89,14 +89,14 @@ class BirdsV1TfliteModuleTester:
}
]
inputs = generate_inputs(input_details) # device_inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/cartoongan/cartoongan_tflite_test.py b/tank/tflite/cartoongan/cartoongan_tflite_test.py
index a33cc0f3..65b1f2d0 100644
--- a/tank/tflite/cartoongan/cartoongan_tflite_test.py
+++ b/tank/tflite/cartoongan/cartoongan_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/sayakpaul/lite-model/cartoongan/dr/1?lite-format=tflite"
@@ -41,8 +41,8 @@ class CartoonganTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
(
mlir_model,
@@ -50,16 +50,16 @@ class CartoonganTfliteModuleTester:
inputs,
tflite_results,
) = download_tflite_model(model_name="cartoongan")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/deeplabv3/deeplabv3_tflite_test.py b/tank/tflite/deeplabv3/deeplabv3_tflite_test.py
index 9f98894a..64fa5a8e 100644
--- a/tank/tflite/deeplabv3/deeplabv3_tflite_test.py
+++ b/tank/tflite/deeplabv3/deeplabv3_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/google/lite-model/aiy/vision/classifier/birds_V1/3?lite-format=tflite"
@@ -41,10 +41,10 @@ class DeepLabV3TfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # preprocess to get SharkImporter input args
+ # preprocess to get AMDSharkImporter input args
(
mlir_model,
function_name,
@@ -52,16 +52,16 @@ class DeepLabV3TfliteModuleTester:
tflite_results,
) = download_tflite_model(model_name="deeplabv3")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/densenet/densenet_tflite_test.py b/tank/tflite/densenet/densenet_tflite_test.py
index c50d66e5..6d22fb9f 100644
--- a/tank/tflite/densenet/densenet_tflite_test.py
+++ b/tank/tflite/densenet/densenet_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/tensorflow/lite-model/densenet/1/metadata/1?lite-format=tflite"
@@ -41,10 +41,10 @@ class DensenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
(
mlir_model,
function_name,
@@ -52,16 +52,16 @@ class DensenetTfliteModuleTester:
tflite_results,
) = download_tflite_model(model_name="densenet")
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/efficientnet_224_fp32/efficientnet_224_fp32_tflite_test.py b/tank/tflite/efficientnet_224_fp32/efficientnet_224_fp32_tflite_test.py
index 84a4a33e..0756a6fd 100644
--- a/tank/tflite/efficientnet_224_fp32/efficientnet_224_fp32_tflite_test.py
+++ b/tank/tflite/efficientnet_224_fp32/efficientnet_224_fp32_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -55,25 +55,25 @@ class Efficientnet_224_fp32TfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="efficientnet_224_fp32"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -85,14 +85,14 @@ class Efficientnet_224_fp32TfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/efficientnet_lite0_fp32_2/efficientnet_lite0_fp32_2_tflite_test.py b/tank/tflite/efficientnet_lite0_fp32_2/efficientnet_lite0_fp32_2_tflite_test.py
index 6bf8b08e..f5ed0863 100644
--- a/tank/tflite/efficientnet_lite0_fp32_2/efficientnet_lite0_fp32_2_tflite_test.py
+++ b/tank/tflite/efficientnet_lite0_fp32_2/efficientnet_lite0_fp32_2_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -55,24 +55,24 @@ class Efficientnet_lite0_fp32_2TfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="efficientnet_lite0_fp32_2"
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -84,14 +84,14 @@ class Efficientnet_lite0_fp32_2TfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/efficientnet_lite0_int8_2/efficientnet_lite0_int8_2_tflite_test.py b/tank/tflite/efficientnet_lite0_int8_2/efficientnet_lite0_int8_2_tflite_test.py
index a478e4ff..62601bc1 100644
--- a/tank/tflite/efficientnet_lite0_int8_2/efficientnet_lite0_int8_2_tflite_test.py
+++ b/tank/tflite/efficientnet_lite0_int8_2/efficientnet_lite0_int8_2_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -53,24 +53,24 @@ class Efficientnet_lite0_int8_2TfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="efficientnet_lite0_int8_2"
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -82,14 +82,14 @@ class Efficientnet_lite0_int8_2TfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name="main",
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/inception_v4_299_fp32/inception_v4_299_fp32_tflite_test.py b/tank/tflite/inception_v4_299_fp32/inception_v4_299_fp32_tflite_test.py
index 0ed34232..a94e126c 100644
--- a/tank/tflite/inception_v4_299_fp32/inception_v4_299_fp32_tflite_test.py
+++ b/tank/tflite/inception_v4_299_fp32/inception_v4_299_fp32_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -55,24 +55,24 @@ class Inception_v4_299_fp32TfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="inception_v4_299_fp32"
)
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -84,14 +84,14 @@ class Inception_v4_299_fp32TfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/inception_v4_299_uint8/inception_v4_299_uint8_tflite_test.py b/tank/tflite/inception_v4_299_uint8/inception_v4_299_uint8_tflite_test.py
index 73ce5375..558f211a 100644
--- a/tank/tflite/inception_v4_299_uint8/inception_v4_299_uint8_tflite_test.py
+++ b/tank/tflite/inception_v4_299_uint8/inception_v4_299_uint8_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -52,25 +52,25 @@ class Inception_v4_299_uint8TfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="inception_v4_299_uint8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -82,14 +82,14 @@ class Inception_v4_299_uint8TfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/midas/midas_tflite_test.py b/tank/tflite/midas/midas_tflite_test.py
index 043408b6..4d0bfd62 100644
--- a/tank/tflite/midas/midas_tflite_test.py
+++ b/tank/tflite/midas/midas_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/intel/lite-model/midas/v2_1_small/1/lite/1?lite-format=tflite"
@@ -41,25 +41,25 @@ class MidasTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="midas"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/mnasnet_1.0_224/mnasnet_tflite_test.py b/tank/tflite/mnasnet_1.0_224/mnasnet_tflite_test.py
index b885cd56..556b3033 100644
--- a/tank/tflite/mnasnet_1.0_224/mnasnet_tflite_test.py
+++ b/tank/tflite/mnasnet_1.0_224/mnasnet_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/tensorflow/lite-model/mnasnet_1.0_224/1/metadata/1?lite-format=tflite"
@@ -41,25 +41,25 @@ class MnasnetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mnasnet_1.0_224"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/mobilebert-baseline-tf2-float/mobilebert-baseline-tf2-float_tflite_test.py b/tank/tflite/mobilebert-baseline-tf2-float/mobilebert-baseline-tf2-float_tflite_test.py
index 38fc8128..2e11f072 100644
--- a/tank/tflite/mobilebert-baseline-tf2-float/mobilebert-baseline-tf2-float_tflite_test.py
+++ b/tank/tflite/mobilebert-baseline-tf2-float/mobilebert-baseline-tf2-float_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
from tank.tflite import squad_data
@@ -59,25 +59,25 @@ class MobilebertTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilebert-baseline-tf2-float"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -97,14 +97,14 @@ class MobilebertTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilebert-baseline-tf2-quant/mobilebert-baseline-tf2-quant_tflite_test.py b/tank/tflite/mobilebert-baseline-tf2-quant/mobilebert-baseline-tf2-quant_tflite_test.py
index 6e3d6670..7cf0927a 100644
--- a/tank/tflite/mobilebert-baseline-tf2-quant/mobilebert-baseline-tf2-quant_tflite_test.py
+++ b/tank/tflite/mobilebert-baseline-tf2-quant/mobilebert-baseline-tf2-quant_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
from tank.tflite import squad_data
@@ -59,25 +59,25 @@ class MobilebertTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilebert-baseline-tf2-quant"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -97,14 +97,14 @@ class MobilebertTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilebert-edgetpu-s-float/mobilebert-edgetpu-s-float_tflite_test.py b/tank/tflite/mobilebert-edgetpu-s-float/mobilebert-edgetpu-s-float_tflite_test.py
index f954d1f0..a0914403 100644
--- a/tank/tflite/mobilebert-edgetpu-s-float/mobilebert-edgetpu-s-float_tflite_test.py
+++ b/tank/tflite/mobilebert-edgetpu-s-float/mobilebert-edgetpu-s-float_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://storage.googleapis.com/iree-model-artifacts/mobilebert-edgetpu-s-float.tflite"
@@ -66,25 +66,25 @@ class MobilebertTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilebert-edgetpu-s-float"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -104,14 +104,14 @@ class MobilebertTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilebert-edgetpu-s-quant/mobilebert-edgetpu-s-quant_tflite_test.py b/tank/tflite/mobilebert-edgetpu-s-quant/mobilebert-edgetpu-s-quant_tflite_test.py
index 2c1ea619..0ff3ef78 100644
--- a/tank/tflite/mobilebert-edgetpu-s-quant/mobilebert-edgetpu-s-quant_tflite_test.py
+++ b/tank/tflite/mobilebert-edgetpu-s-quant/mobilebert-edgetpu-s-quant_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://storage.googleapis.com/iree-model-artifacts/mobilebert-edgetpu-s-quant.tflite"
@@ -66,25 +66,25 @@ class MobilebertTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilebert-edgetpu-s-quant"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/mobilebert/mobilebert_tflite_test.py b/tank/tflite/mobilebert/mobilebert_tflite_test.py
index c4143dff..50d69317 100644
--- a/tank/tflite/mobilebert/mobilebert_tflite_test.py
+++ b/tank/tflite/mobilebert/mobilebert_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
from tank.tflite import squad_data
# model_path = "https://tfhub.dev/tensorflow/lite-model/mobilebert/1/metadata/1?lite-format=tflite"
@@ -58,25 +58,25 @@ class MobilebertTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilebert"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -96,14 +96,14 @@ class MobilebertTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilenet_v1_224_1.0_float/mobilenet_v1_float_tflite_test.py b/tank/tflite/mobilenet_v1_224_1.0_float/mobilenet_v1_float_tflite_test.py
index f6b3ae85..ae2c2978 100644
--- a/tank/tflite/mobilenet_v1_224_1.0_float/mobilenet_v1_float_tflite_test.py
+++ b/tank/tflite/mobilenet_v1_224_1.0_float/mobilenet_v1_float_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -54,25 +54,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v1_224_1.0_float"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -84,14 +84,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilenet_v1_224_1.0_uint8/mobilenet_v1_uint8_tflite_test.py b/tank/tflite/mobilenet_v1_224_1.0_uint8/mobilenet_v1_uint8_tflite_test.py
index bf8da463..0dfd7308 100644
--- a/tank/tflite/mobilenet_v1_224_1.0_uint8/mobilenet_v1_uint8_tflite_test.py
+++ b/tank/tflite/mobilenet_v1_224_1.0_uint8/mobilenet_v1_uint8_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -52,25 +52,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v1_224_1.0_uint8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -82,14 +82,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilenet_v2_1.00_224_int8/mobilenet_v2_int8_tflite_test.py b/tank/tflite/mobilenet_v2_1.00_224_int8/mobilenet_v2_int8_tflite_test.py
index 20d4099d..9ba6198b 100644
--- a/tank/tflite/mobilenet_v2_1.00_224_int8/mobilenet_v2_int8_tflite_test.py
+++ b/tank/tflite/mobilenet_v2_1.00_224_int8/mobilenet_v2_int8_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -54,25 +54,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v2_1.00_224_int8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -84,14 +84,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilenet_v2_1.0_224/mobilenet_v2_tflite_test.py b/tank/tflite/mobilenet_v2_1.0_224/mobilenet_v2_tflite_test.py
index 562e8829..84a5f929 100644
--- a/tank/tflite/mobilenet_v2_1.0_224/mobilenet_v2_tflite_test.py
+++ b/tank/tflite/mobilenet_v2_1.0_224/mobilenet_v2_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -55,25 +55,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v2_1.0_224"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -85,14 +85,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilenet_v2_224_1.0_uint8/mobilenet_v2_uint8_tflite_test.py b/tank/tflite/mobilenet_v2_224_1.0_uint8/mobilenet_v2_uint8_tflite_test.py
index 3768d7aa..e741e2e6 100644
--- a/tank/tflite/mobilenet_v2_224_1.0_uint8/mobilenet_v2_uint8_tflite_test.py
+++ b/tank/tflite/mobilenet_v2_224_1.0_uint8/mobilenet_v2_uint8_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -52,25 +52,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v2_224_1.0_uint8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -82,14 +82,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilenet_v3-large_224_1.0_float/mobilenet_v3_float_tflite_test.py b/tank/tflite/mobilenet_v3-large_224_1.0_float/mobilenet_v3_float_tflite_test.py
index 490a4a66..10e6f1eb 100644
--- a/tank/tflite/mobilenet_v3-large_224_1.0_float/mobilenet_v3_float_tflite_test.py
+++ b/tank/tflite/mobilenet_v3-large_224_1.0_float/mobilenet_v3_float_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -55,25 +55,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v3-large_224_1.0_float"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -85,14 +85,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilenet_v3-large_224_1.0_uint8/mobilenet_v3_tflite_test.py b/tank/tflite/mobilenet_v3-large_224_1.0_uint8/mobilenet_v3_tflite_test.py
index 9e40e95b..1cfcc1d8 100644
--- a/tank/tflite/mobilenet_v3-large_224_1.0_uint8/mobilenet_v3_tflite_test.py
+++ b/tank/tflite/mobilenet_v3-large_224_1.0_uint8/mobilenet_v3_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -52,25 +52,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v3-large_224_1.0_uint8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -82,14 +82,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/mobilenet_v3.5multiavg_1.00_224_int8/mobilenet_v35_int8_tflite_test.py b/tank/tflite/mobilenet_v3.5multiavg_1.00_224_int8/mobilenet_v35_int8_tflite_test.py
index 7e01f7c8..836b85ed 100644
--- a/tank/tflite/mobilenet_v3.5multiavg_1.00_224_int8/mobilenet_v35_int8_tflite_test.py
+++ b/tank/tflite/mobilenet_v3.5multiavg_1.00_224_int8/mobilenet_v35_int8_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import imagenet_data
@@ -55,25 +55,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v3.5multiavg_1.00_224_int8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
## post process results for compare
compare_results(mlir_results, tflite_results)
@@ -86,14 +86,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/multi_person_mobilenet_v1_075_float/multi_person_mobilenet_tflite_test.py b/tank/tflite/multi_person_mobilenet_v1_075_float/multi_person_mobilenet_tflite_test.py
index 38b8db41..c4ee65d8 100644
--- a/tank/tflite/multi_person_mobilenet_v1_075_float/multi_person_mobilenet_tflite_test.py
+++ b/tank/tflite/multi_person_mobilenet_v1_075_float/multi_person_mobilenet_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://storage.googleapis.com/download.tensorflow.org/models/tflite/gpu/multi_person_mobilenet_v1_075_float.tflite"
@@ -41,25 +41,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="mobilenet_v2_1.0_224"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/nasnet/nasnet_tflite_test.py b/tank/tflite/nasnet/nasnet_tflite_test.py
index 415b3f31..b77611db 100644
--- a/tank/tflite/nasnet/nasnet_tflite_test.py
+++ b/tank/tflite/nasnet/nasnet_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/tensorflow/lite-model/nasnet/large/1/default/1?lite-format=tflite"
@@ -41,25 +41,25 @@ class NasnetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="nasnet"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/resnet_50_224_int8/resnet_50_224_int8_tflite_test.py b/tank/tflite/resnet_50_224_int8/resnet_50_224_int8_tflite_test.py
index ef7c42b5..05f57890 100644
--- a/tank/tflite/resnet_50_224_int8/resnet_50_224_int8_tflite_test.py
+++ b/tank/tflite/resnet_50_224_int8/resnet_50_224_int8_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://storage.googleapis.com/tf_model_garden/vision/resnet50_imagenet/resnet_50_224_int8.tflite"
@@ -41,25 +41,25 @@ class ResnetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="resnet_50_224_int8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/squeezenet/squeezenet_tflite_test.py b/tank/tflite/squeezenet/squeezenet_tflite_test.py
index bbccb397..f6660b5c 100644
--- a/tank/tflite/squeezenet/squeezenet_tflite_test.py
+++ b/tank/tflite/squeezenet/squeezenet_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
# model_path = "https://tfhub.dev/tensorflow/lite-model/squeezenet/1/default/1?lite-format=tflite"
@@ -41,25 +41,25 @@ class SequeezeNetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="squeezenet"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
diff --git a/tank/tflite/ssd_mobilenet_v1_320_1.0_float/ssd_mobilenet_v1_float_tflite_test.py b/tank/tflite/ssd_mobilenet_v1_320_1.0_float/ssd_mobilenet_v1_float_tflite_test.py
index cc72f3c2..94908a95 100644
--- a/tank/tflite/ssd_mobilenet_v1_320_1.0_float/ssd_mobilenet_v1_float_tflite_test.py
+++ b/tank/tflite/ssd_mobilenet_v1_320_1.0_float/ssd_mobilenet_v1_float_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import coco_data
@@ -52,25 +52,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="ssd_mobilenet_v1_320_1.0_float"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -82,14 +82,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/ssd_mobilenet_v1_320_1.0_uint8/ssd_mobilenet_v1_uint8_tflite_test.py b/tank/tflite/ssd_mobilenet_v1_320_1.0_uint8/ssd_mobilenet_v1_uint8_tflite_test.py
index 658d9382..98af4c54 100644
--- a/tank/tflite/ssd_mobilenet_v1_320_1.0_uint8/ssd_mobilenet_v1_uint8_tflite_test.py
+++ b/tank/tflite/ssd_mobilenet_v1_320_1.0_uint8/ssd_mobilenet_v1_uint8_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import coco_data
@@ -49,25 +49,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="ssd_mobilenet_v1_320_1.0_uint8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -79,14 +79,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/ssd_mobilenet_v2_face_quant/ssd_mobilenet_v2_face_quant_tflite_test.py b/tank/tflite/ssd_mobilenet_v2_face_quant/ssd_mobilenet_v2_face_quant_tflite_test.py
index 21f668d6..c6f21360 100644
--- a/tank/tflite/ssd_mobilenet_v2_face_quant/ssd_mobilenet_v2_face_quant_tflite_test.py
+++ b/tank/tflite/ssd_mobilenet_v2_face_quant/ssd_mobilenet_v2_face_quant_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
import urllib.request
@@ -61,25 +61,25 @@ class MobilenetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="ssd_mobilenet_v2_face_quant"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -91,14 +91,14 @@ class MobilenetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/ssd_spaghettinet_edgetpu_large/ssd_spaghettinet_edgetpu_large_tflite_test.py b/tank/tflite/ssd_spaghettinet_edgetpu_large/ssd_spaghettinet_edgetpu_large_tflite_test.py
index 8169e035..22a121a6 100644
--- a/tank/tflite/ssd_spaghettinet_edgetpu_large/ssd_spaghettinet_edgetpu_large_tflite_test.py
+++ b/tank/tflite/ssd_spaghettinet_edgetpu_large/ssd_spaghettinet_edgetpu_large_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import coco_data
@@ -52,24 +52,24 @@ class SpaghettinetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="ssd_spaghettinet_edgetpu_large"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
## post process results for compare
compare_results(mlir_results, tflite_results)
@@ -82,14 +82,14 @@ class SpaghettinetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)
diff --git a/tank/tflite/ssd_spaghettinet_edgetpu_large_uint8/ssd_spaghettinet_edgetpu_large_uint8_tflite_test.py b/tank/tflite/ssd_spaghettinet_edgetpu_large_uint8/ssd_spaghettinet_edgetpu_large_uint8_tflite_test.py
index 988d8282..3c6b5519 100644
--- a/tank/tflite/ssd_spaghettinet_edgetpu_large_uint8/ssd_spaghettinet_edgetpu_large_uint8_tflite_test.py
+++ b/tank/tflite/ssd_spaghettinet_edgetpu_large_uint8/ssd_spaghettinet_edgetpu_large_uint8_tflite_test.py
@@ -1,9 +1,9 @@
import numpy as np
-from shark.shark_downloader import download_tflite_model
-from shark.shark_inference import SharkInference
+from amdshark.amdshark_downloader import download_tflite_model
+from amdshark.amdshark_inference import AMDSharkInference
import pytest
import unittest
-from shark.parser import shark_args
+from amdshark.parser import amdshark_args
import os
import sys
from tank.tflite import coco_data
@@ -49,25 +49,25 @@ class SpaghettinetTfliteModuleTester:
self.save_vmfb = save_vmfb
def create_and_check_module(self):
- shark_args.save_mlir = self.save_mlir
- shark_args.save_vmfb = self.save_vmfb
+ amdshark_args.save_mlir = self.save_mlir
+ amdshark_args.save_vmfb = self.save_vmfb
- # Preprocess to get SharkImporter input args
+ # Preprocess to get AMDSharkImporter input args
mlir_model, func_name, inputs, tflite_results = download_tflite_model(
model_name="ssd_spaghettinet_edgetpu_large_uint8"
)
- # Use SharkInference to get inference result
- shark_module = SharkInference(
+ # Use AMDSharkInference to get inference result
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- # Case1: Use shark_importer default generate inputs
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ # Case1: Use amdshark_importer default generate inputs
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# Case2: Use manually set inputs
@@ -79,14 +79,14 @@ class SpaghettinetTfliteModuleTester:
]
inputs = generate_inputs(input_details) # new inputs
- shark_module = SharkInference(
+ amdshark_module = AMDSharkInference(
mlir_module=mlir_model,
function_name=func_name,
device=self.device,
mlir_dialect="tflite",
)
- shark_module.compile()
- mlir_results = shark_module.forward(inputs)
+ amdshark_module.compile()
+ mlir_results = amdshark_module.forward(inputs)
compare_results(mlir_results, tflite_results)
# print(mlir_results)