diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..8f8b3171d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,407 @@ +# Contributing to Intel® AI Reference Models + +## Adding new sample + +> [!NOTE] +> At the moment repository is being updated to a new repo structure to simplify +> development and content layout. This section describes how to add new samples +> in the new repo structure. + +To add a new sample: + +1. Create home directory for the new sample with sample scripts and documentation +1. Add baremetal tests +1. (optional) Add docker(s) for your sample +1. (optional) Add tests for dockers +1. Update project documentation with the new sample description + +Project documentation update must include an update of top level +[README](./README.md) with the new sample name, supported precisions and a link +to the new sample README.md. + +### Sample home directory + +Scripts and documentation of each sample must be placed in the separate sample +home directory. Home directory must be named as follows: +``` +mkdir -p models_v2///// +``` +| | Values | +| ------------ | --------------------------------------------- | +| `framework` | `pytorch` or `tensorflow` | +| `model-name` | Actual model name, for example `efficientnet` | +| `mode` | `inference` or `training` | +| `platform` | `cpu` or `gpu` | + +Sample home directory must contain the following files: + +| File | | Purpose | +| ------------------ | ---------- | ---------------------------------------------------------------------- | +| `README.md` | Required | Readme describing the sample, original model source, and how to use it | +| `setup.sh` | Required | Shell script to setup runtime environment on baremetal | +| `run_model.sh` | Required | Shell script to run the sample | +| `tests.yaml` | Required | YAML file with test cases for CI/CD (see details below) | +| `*.*` | Optional | Other files and scripts used by the sample | + +If few samples share common utilities they can be placed at `models_v2/common`. +Note that common folder may contain framework specific utilities if needed. Do +not create common folder on framework folder level (i.e. do NOT create +`models_v2//common`). Utilties placed on `models_v2/common` must +be useful across multiple samples and have solid API to avoid breaking multiple +samples with modifications. + +If sample generates output files, one of the output files should be named +`results.yaml` and have the following format: +``` +results: +- key: + value: + unit: +``` + +Common results keys: + +| Key | Value | Unit | +| ---------- | ----- | --------------------------- | +| accuracy | float | percents | +| latency | float | seconds, milliseconds, etc. | +| throughput | float | images/s, records/s, etc. | + +If environment variables are used in the sample scripts their names must be +consistent across all samples available in the repository. The following table +lists such environemnt variables. + +| Environment variable | Values | Purpose | +| -------------------- | ----------------- | ----------------------------------------- | +| `BATCH_SIZE` | | Batch size | +| `DATASET_DIR` | | Path to data set | +| `MULTI_TILE` | `False` or `True` | Sets whether GPU is single or multi tile | +| `OUTPUT_DIR` | | Path to output logs | +| `PLATFORM` | | Platform on which sample runs | +| `PRECISION` | `bf16`, `fp16`, `fp32`, `int8` | Model precision | +| `NUM_ITERATIONS` | | Number of iterations to perform in a test | + +### Baremetal tests + +Test cases to run should be specified in `tests.yaml` file stored in the sample +home directory (see above). This YAML file must have the following format: +``` +: + cmd: ; command; + env: + : +``` + +`cmd` key sets commands to execute during test run. Tests must be executed by +[test-runner.py script](https://github.com/intel/ai-containers/tree/main/test-runner). +Before executing tests download and configure test runner as follows: +``` +git clone https://github.com/intel/ai-containers.git +python -m pip install -r ai-containers/test-runner/requirements.txt +``` + +Run tests by passing `tests.yaml` to the test runner: +``` +pyton test_runner.py -f /path/to/tests.yaml -l /path/to/logs +``` + +The following environment variables must be set before running the test runner +and can be used in `cmd` commands: + +| Environment variable | Value | +| ----------------------------- | ------------------------------------------------------------------------------- | +| `GITHUB_WORKSPACE` | Path to the cloned copy of this repository | +| `FRAMEWORK_VERSION` | Framework (pytorch or tesorflow) version to install (ex.: `2.14.0`) | +| `FRAMEWORK_EXTENSION_VERSION` | Version of Intel framework extension (IPEX or ITEX) to install (ex.: `2.14.0.1` | +| `IS_LKG_DROP` | `true` or `false`: whether test runs under LKG environment | +| `AIKIT_VERSION` | Version of AI kit (valid only of `IS_LKG_DROP` is `true`) | + +If test specific files or scripts are needed (which is typically the case), +they must be placed at the following locations: + +* Place framework specific scripts at `tests/cicd//` folder where + `framework` is `pytorch`, `tensorflow`, `IPEX-XPU` or `ITEX-XPU`. The + following scripts are required: + + | Script | | Purpose | + | ---------- | ---------- | ---------------------------- | + | `setup.sh` | Required | Script to install framework | + +* Place test specific scripts at `tests/cicd//-` + folder where `model` is model name being tested and `mode` is + `inference` or `training`. The following scripts are required: + + | Script | | Purpose | + | ------------- | ----------| --------------------------- | + | `run_test.sh` | Required | Script to execute test case | + +Test related scripts (`setup.sh` and `run_tests.sh` in particular) should exit +with `0` to indicate passing result. + +### Containers home directory + +Optionally sample might provide containers for easy setup. Container +Dockerfile(s) must be placed at the following directories: + +| Folder | Purpose | +| ------ | ------- | +| `docker/flex-gpu/--/` | Containers for [Intel® Data Center GPU Flex Series](https://ark.intel.com/content/www/us/en/ark/products/series/230021/intel-data-center-gpu-flex-series.html) | +| `docker/max-gpu/--/` | Containers for [Intel® Data Center GPU Max Series](https://ark.intel.com/content/www/us/en/ark/products/series/232874/intel-data-center-gpu-max-series.html) | +| `docker/pyt-cpu/-/` | Containers for pytorch running on CPU | +| `docker/tf-cpu/-/` | Containers for Tensorflow running on CPU | + + +Each container folder must contain the following files: + +| File | | Purpose | +| ------------------ | ---------- | ------------------------------------------------------------ | +| `*Dockerfile` | Required | Dockerfile to build the sample | +| `README.md` | Optional | Readme with container build and run instructions | +| `tests.yaml` | Required | YAML file with test cases for CI/CD (see details below) | + +The Dockerfile should be buildable with `docker build` via command line. The +Dockerfile may include optional and/or required command line arguments for custom +container builds. In this case a README must describe the container build arguments +that were used. + +New container must be added to the `docker-compose.yml` file located +in the parent folder: + +* [docker/flex-gpu/docker-compose.yml](./docker/flex-gpu/docker-compose.yml) +* [docker/max-gpu/docker-compose.yml](./docker/max-gpu/docker-compose.yml) +* [docker/pyt-cpu/docker-compose.yml](./docker/pyt-cpu/docker-compose.yml) +* [docker/tf-cpu/docker-compose.yml](./docker/tf-cpu/docker-compose.yml) + +Note that CI/CD is using `docker compose build` to build containers. + +### Container tests + +Test cases for containers should be specified in `tests.yaml` file stored in +the containers home directory (see above). This YAML file must have the +following format: +``` +: + img: + cmd: ; command; + ipc: host + device: /dev/dri + env: + : + volumes: + - src: + dst: +``` + +`cmd` key sets commands to execute during test run. Tests must be executed by +[test-runner.py script](https://github.com/intel/ai-containers/tree/main/test-runner). +Before executing tests download and configure test runner as follows: +``` +git clone https://github.com/intel/ai-containers.git +python -m pip install -r ai-containers/test-runner/requirements.txt +``` + +Run tests by passing `tests.yaml` to the test runner: +``` +pyton test_runner.py -f /path/to/tests.yaml -l /path/to/logs +``` + +The following environment variables must be set before running the test runner +and can be used in `cmd` commands: + +| Environment variable | Value | +| ----------------------------- | ------------------------------------------------------------------------------- | +| `REGISTRY` | Docker registry to fetch docker images from | +| `GITHUB_RUN_NUMBER` | A unique number for each run of a particular workflow | + +## OLD: Adding scripts for a new TensorFlow model + +This section covers contribution guidelines for the old repo structure. Please, +refer to this section only if you update not yet migrated content. + +### Code updates + +In order to add a new model to the zoo, there are a few things that are +required: + +1. Setup the directory structure to allow the + [launch script](/docs/general/tensorflow/LaunchBenchmark.md) to find + your model. This involves creating folders for: + `/benchmarks/////`. + Note that you will need to add `__init__.py` files in each new + directory that you add, in order for python to find the code. + + ![Directory Structure](benchmarks_directory_structure.png) + +2. Next, in the leaf folder that was created in the previous step, you + will need to create `config.json` and `model_init.py` files: + + ![Add model init](add_model_init_and_config.png) + + The `config.json` file contains the best known KMP environment variable + settings to get optimal performance for the model. Below default settings are recommended for most of + the models in Model Zoo. + + ``` + { + "optimization_parameters": { + "KMP_AFFINITY": "granularity=fine,verbose,compact,1,0", + "KMP_BLOCKTIME": 1, + "KMP_SETTINGS": 1 + } + } + ``` + + The `model_init.py` file is used to initialize the best known configuration for the + model, and then start executing inference or training. When the + [launch script](/docs/general/tensorflow/LaunchBenchmark.md) is run, + it will look for the appropriate `model_init.py` file to use + according to the model name, framework, mode, and precision that are + specified by the user. + + The contents of the `model_init.py` file will vary by framework. For + TensorFlow models, we typically use the + [base model init class](/benchmarks/common/base_model_init.py) that + includes functions for doing common tasks such as setting up the best + known environment variables (like `KMP_BLOCKTIME`, `KMP_SETTINGS`, + `KMP_AFFINITY` by loading **config.json** and `OMP_NUM_THREADS`), num intra threads, and num + inter threads. The `model_init.py` file also sets up the string that + will ultimately be used to run inference or model training, which + normally includes the use of `numactl` and sending all of the + appropriate arguments to the model's script. Also, if your model + requires any non-standard arguments (arguments that are not part of + the [launch script flags](/docs/general/tensorflow/LaunchBenchmark.md#launch_benchmarkpy-flags)), + the `model_init.py` file is where you would define and parse those + args. + +3. [start.sh](/benchmarks/common/tensorflow/start.sh) is a shell script + that is called by the `launch_benchmarks.py` script in the docker + container. This script installs dependencies that are required by + the model, sets up the `PYTHONPATH` environment variable, and then + calls the [run_tf_benchmark.py](/benchmarks/common/tensorflow/run_tf_benchmark.py) + script with the appropriate args. That run script will end up calling + the `model_init.py` file that you have defined in the previous step. + + To add support for a new model in the `start.sh` script, you will + need to add a function with the same name as your model. Note that + this function name should match the `` folder from the + first step where you setup the directories for your model. In this + function, add commands to install any third-party dependencies within + an `if [ ${NOINSTALL} != "True" ]; then` conditional block. The + purpose of the `--noinstall` flag or `NOINSTALL` env var is to be able + to skip the installs for quicker iteration when running on bare metal + or debugging. If your model requires the `PYTHONPATH` environment variable + to be setup to find model code or dependencies, that should be done in the + model's function. Next, setup the command that will be run. The + standard launch script args are already added to the `CMD` variable, + so your model function will only need to add on more args if you have + model-specific args defined in your `model_init.py`. Lastly, call the + `run_model` function with the `PYTHONPATH` and the `CMD` string. + + Below is a sample template of a `start.sh` model function that + installs dependencies from `requirements.txt` file, sets up the + `PYHTONPATH` to find model source files, adds on a custom steps flag + to the run command, and then runs the model: + ```bash + function () { + if [ ${PRECISION} == "fp32" ]; then + if [ ${NOINSTALL} != "True" ]; then + pip install -r ${MOUNT_EXTERNAL_MODELS_SOURCE}/requirements.txt + fi + + export PYTHONPATH=${PYTHONPATH}:${MOUNT_EXTERNAL_MODELS_SOURCE} + CMD="${CMD} $(add_steps_args)" + PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model + else + echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}" + exit 1 + fi + } + ``` + +Optional step: +* If there is CPU-optimized model code that has not been upstreamed to + the original repository, then it can be added to the + [models](/models) directory in the zoo repo. As with the first step + in the previous section, the directory structure should be setup like: + `/models/////`. + + ![Models Directory Structure](models_directory_structure.png) + + If there are model files that can be shared by multiple modes or + precisions, they can be placed the higher-level directory. For + example, if a file could be shared by both `FP32` and `Int8` + precisions, then it could be placed in the directory at: + `/models////` (omitting the + `` directory). Note that if this is being done, you need to + ensure that the license that is associated with the original model + repository is compatible with the license of the model zoo. + +### Debugging + +There are a couple of options for debugging and quicker iteration when +developing new scripts: +* Use the `--debug` flag in the launch_benchmark.py script, which will + give you a shell into the docker container. See the + [debugging section](/docs/general/tensorflow/LaunchBenchmark.md#debugging) + of the launch script documentation for more information on using this + flag. +* Run the launch script on bare metal (without a docker container). The + launch script documentation also has a + [section](/docs/general/tensorflow/LaunchBenchmark.md#alpha-feature-running-on-bare-metal) + with instructions on how to do this. Note that when running without + docker, you are responsible for installing all dependencies on your + system before running the launch script. If you are using this option + during development, be sure to also test _with_ a docker container to + ensure that the `start.sh` script dependency installation is working + properly for your model. + +### Documentation updates + +1. Create a `README.md` file in the + `/benchmarks///` directory: + + ![Add README file](add_readme.png) + + This README file should describe all of the steps necessary to run + the model, including downloading and preprocessing the dataset, + downloading the pretrained model, cloning repositories, and running + the model script with the appropriate arguments. Most models + have best known settings for batch and online inference performance + testing as well as testing accuracy. The README file should specify + how to set these configs using the `launch_benchmark.py` script. + +2. Update the table in the [main `benchmarks` README](/benchmarks/README.md) + with a link to the model that you are adding. Note that the models + in this table are ordered alphabetically by use case, framework, and + model name. The model name should link to the original paper for the + model. The instructions column should link to the README + file that you created in the previous step. + +### Testing + +1. After you've completed the above steps, run the model according to + instructions in the README file for the new model. Ensure that the + performance and accuracy metrics are on par with what you would + expect. + +2. Add unit tests to cover the new model. + * For TensorFlow models, there is a + [parameterized test](/tests/unit/common/tensorflow/test_run_tf_benchmarks.py#L80) + that checks the flow running from `run_tf_benchmarks.py` to the + inference command that is executed by the `model_init.py` file. The + test ensures that the inference command has all of the expected + arguments. + + To add a new parameterized instance of the test for your + new model, add a new JSON file `tf__args.json` to the [tf_models_args](/tests/unit/common/tensorflow/tf_model_args) + directory. Each file has a list of dictionaries, a dictionary has three + items: (1) `_comment` a comment describes the command, + (2) `input` the `run_tf_benchmarks.py` command with the appropriate + flags to run the model (3) `output` the expected inference or training + command that should get run by the `model_init.py` file. + * If any launch script or base class files were changed, then + additional unit tests should be added. + * Unit tests and style checks are run when you post a GitHub PR, and + the tests must be passing before the PR is merged. + * For information on how to run the unit tests and style checks + locally, see the [tests documentation](/tests/README.md). diff --git a/Contribute.md b/Contribute.md deleted file mode 100644 index 9d3a74850..000000000 --- a/Contribute.md +++ /dev/null @@ -1,191 +0,0 @@ -# Contributing to the Model Zoo for Intel® Architecture - -## Adding scripts for a new TensorFlow model - -### Code updates - -In order to add a new model to the zoo, there are a few things that are -required: - -1. Setup the directory structure to allow the - [launch script](/docs/general/tensorflow/LaunchBenchmark.md) to find - your model. This involves creating folders for: - `/benchmarks/////`. - Note that you will need to add `__init__.py` files in each new - directory that you add, in order for python to find the code. - - ![Directory Structure](benchmarks_directory_structure.png) - -2. Next, in the leaf folder that was created in the previous step, you - will need to create `config.json` and `model_init.py` files: - - ![Add model init](add_model_init_and_config.png) - - The `config.json` file contains the best known KMP environment variable - settings to get optimal performance for the model. Below default settings are recommended for most of - the models in Model Zoo. - - ``` - { - "optimization_parameters": { - "KMP_AFFINITY": "granularity=fine,verbose,compact,1,0", - "KMP_BLOCKTIME": 1, - "KMP_SETTINGS": 1 - } - } - ``` - - The `model_init.py` file is used to initialize the best known configuration for the - model, and then start executing inference or training. When the - [launch script](/docs/general/tensorflow/LaunchBenchmark.md) is run, - it will look for the appropriate `model_init.py` file to use - according to the model name, framework, mode, and precision that are - specified by the user. - - The contents of the `model_init.py` file will vary by framework. For - TensorFlow models, we typically use the - [base model init class](/benchmarks/common/base_model_init.py) that - includes functions for doing common tasks such as setting up the best - known environment variables (like `KMP_BLOCKTIME`, `KMP_SETTINGS`, - `KMP_AFFINITY` by loading **config.json** and `OMP_NUM_THREADS`), num intra threads, and num - inter threads. The `model_init.py` file also sets up the string that - will ultimately be used to run inference or model training, which - normally includes the use of `numactl` and sending all of the - appropriate arguments to the model's script. Also, if your model - requires any non-standard arguments (arguments that are not part of - the [launch script flags](/docs/general/tensorflow/LaunchBenchmark.md#launch_benchmarkpy-flags)), - the `model_init.py` file is where you would define and parse those - args. - -3. [start.sh](/benchmarks/common/tensorflow/start.sh) is a shell script - that is called by the `launch_benchmarks.py` script in the docker - container. This script installs dependencies that are required by - the model, sets up the `PYTHONPATH` environment variable, and then - calls the [run_tf_benchmark.py](/benchmarks/common/tensorflow/run_tf_benchmark.py) - script with the appropriate args. That run script will end up calling - the `model_init.py` file that you have defined in the previous step. - - To add support for a new model in the `start.sh` script, you will - need to add a function with the same name as your model. Note that - this function name should match the `` folder from the - first step where you setup the directories for your model. In this - function, add commands to install any third-party dependencies within - an `if [ ${NOINSTALL} != "True" ]; then` conditional block. The - purpose of the `--noinstall` flag or `NOINSTALL` env var is to be able - to skip the installs for quicker iteration when running on bare metal - or debugging. If your model requires the `PYTHONPATH` environment variable - to be setup to find model code or dependencies, that should be done in the - model's function. Next, setup the command that will be run. The - standard launch script args are already added to the `CMD` variable, - so your model function will only need to add on more args if you have - model-specific args defined in your `model_init.py`. Lastly, call the - `run_model` function with the `PYTHONPATH` and the `CMD` string. - - Below is a sample template of a `start.sh` model function that - installs dependencies from `requirements.txt` file, sets up the - `PYHTONPATH` to find model source files, adds on a custom steps flag - to the run command, and then runs the model: - ```bash - function () { - if [ ${PRECISION} == "fp32" ]; then - if [ ${NOINSTALL} != "True" ]; then - pip install -r ${MOUNT_EXTERNAL_MODELS_SOURCE}/requirements.txt - fi - - export PYTHONPATH=${PYTHONPATH}:${MOUNT_EXTERNAL_MODELS_SOURCE} - CMD="${CMD} $(add_steps_args)" - PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model - else - echo "PRECISION=${PRECISION} is not supported for ${MODEL_NAME}" - exit 1 - fi - } - ``` - -Optional step: -* If there is CPU-optimized model code that has not been upstreamed to - the original repository, then it can be added to the - [models](/models) directory in the zoo repo. As with the first step - in the previous section, the directory structure should be setup like: - `/models/////`. - - ![Models Directory Structure](models_directory_structure.png) - - If there are model files that can be shared by multiple modes or - precisions, they can be placed the higher-level directory. For - example, if a file could be shared by both `FP32` and `Int8` - precisions, then it could be placed in the directory at: - `/models////` (omitting the - `` directory). Note that if this is being done, you need to - ensure that the license that is associated with the original model - repository is compatible with the license of the model zoo. - -### Debugging - -There are a couple of options for debugging and quicker iteration when -developing new scripts: -* Use the `--debug` flag in the launch_benchmark.py script, which will - give you a shell into the docker container. See the - [debugging section](/docs/general/tensorflow/LaunchBenchmark.md#debugging) - of the launch script documentation for more information on using this - flag. -* Run the launch script on bare metal (without a docker container). The - launch script documentation also has a - [section](/docs/general/tensorflow/LaunchBenchmark.md#alpha-feature-running-on-bare-metal) - with instructions on how to do this. Note that when running without - docker, you are responsible for installing all dependencies on your - system before running the launch script. If you are using this option - during development, be sure to also test _with_ a docker container to - ensure that the `start.sh` script dependency installation is working - properly for your model. - -### Documentation updates - -1. Create a `README.md` file in the - `/benchmarks///` directory: - - ![Add README file](add_readme.png) - - This README file should describe all of the steps necessary to run - the model, including downloading and preprocessing the dataset, - downloading the pretrained model, cloning repositories, and running - the model script with the appropriate arguments. Most models - have best known settings for batch and online inference performance - testing as well as testing accuracy. The README file should specify - how to set these configs using the `launch_benchmark.py` script. - -2. Update the table in the [main `benchmarks` README](/benchmarks/README.md) - with a link to the model that you are adding. Note that the models - in this table are ordered alphabetically by use case, framework, and - model name. The model name should link to the original paper for the - model. The instructions column should link to the README - file that you created in the previous step. - -### Testing - -1. After you've completed the above steps, run the model according to - instructions in the README file for the new model. Ensure that the - performance and accuracy metrics are on par with what you would - expect. - -2. Add unit tests to cover the new model. - * For TensorFlow models, there is a - [parameterized test](/tests/unit/common/tensorflow/test_run_tf_benchmarks.py#L80) - that checks the flow running from `run_tf_benchmarks.py` to the - inference command that is executed by the `model_init.py` file. The - test ensures that the inference command has all of the expected - arguments. - - To add a new parameterized instance of the test for your - new model, add a new JSON file `tf__args.json` to the [tf_models_args](/tests/unit/common/tensorflow/tf_model_args) - directory. Each file has a list of dictionaries, a dictionary has three - items: (1) `_comment` a comment describes the command, - (2) `input` the `run_tf_benchmarks.py` command with the appropriate - flags to run the model (3) `output` the expected inference or training - command that should get run by the `model_init.py` file. - * If any launch script or base class files were changed, then - additional unit tests should be added. - * Unit tests and style checks are run when you post a GitHub PR, and - the tests must be passing before the PR is merged. - * For information on how to run the unit tests and style checks - locally, see the [tests documentation](/tests/README.md). diff --git a/Makefile b/Makefile index aab2b068d..e19dd069e 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,20 @@ unit_test: @echo "Running unit tests..." tox -e py3-py.test +test_tl_tf_notebook: venv + @. $(ACTIVATE) && pip install -r docs/notebooks/transfer_learning/requirements.txt && \ + bash docs/notebooks/transfer_learning/run_tl_notebooks.sh $(CURDIR)/docs/notebooks/transfer_learning/text_classification/tfhub_bert_text_classification/BERT_Binary_Text_Classification.ipynb remove_for_custom_dataset && \ + bash docs/notebooks/transfer_learning/run_tl_notebooks.sh $(CURDIR)/docs/notebooks/transfer_learning/image_classification/tf_image_classification/Image_Classification_Transfer_Learning.ipynb remove_for_custom_dataset && \ + bash docs/notebooks/transfer_learning/run_tl_notebooks.sh $(CURDIR)/docs/notebooks/transfer_learning/image_classification/huggingface_image_classification/HuggingFace_Image_Classification_Transfer_Learning.ipynb && \ + bash docs/notebooks/transfer_learning/run_tl_notebooks.sh $(CURDIR)/docs/notebooks/transfer_learning/question_answering/BERT_Question_Answering.ipynb && \ + bash docs/notebooks/transfer_learning/run_tl_notebooks.sh $(CURDIR)/docs/notebooks/transfer_learning/text_classification/tfhub_bert_text_classification/BERT_Multi_Text_Classification.ipynb remove_for_custom_dataset + +test_tl_pyt_notebook: venv + @. $(ACTIVATE) && pip install -r docs/notebooks/transfer_learning/requirements.txt && \ + bash docs/notebooks/transfer_learning/run_tl_notebooks.sh $(CURDIR)/docs/notebooks/transfer_learning/image_classification/pytorch_image_classification/PyTorch_Image_Classification_Transfer_Learning.ipynb remove_for_custom_dataset && \ + bash docs/notebooks/transfer_learning/run_tl_notebooks.sh $(CURDIR)/docs/notebooks/transfer_learning/object_detection/pytorch_object_detection/PyTorch_Object_Detection_Transfer_Learning.ipynb remove_for_custom_dataset && \ + bash docs/notebooks/transfer_learning/run_tl_notebooks.sh $(CURDIR)/docs/notebooks/transfer_learning/text_classification/pytorch_text_classification/PyTorch_Text_Classifier_fine_tuning.ipynb remove_for_custom_dataset + test: lint unit_test clean: diff --git a/README.md b/README.md index b1bef9ef4..35030f9e9 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,10 @@ For best performance on Intel® Data Center GPU Flex and Max Series, please chec | ------------------------------------------------------ | ---------- | ----------| ------------------- | ---------------------- | | [DenseNet169](https://arxiv.org/pdf/1608.06993.pdf) | TensorFlow | Inference | [FP32](/benchmarks/image_recognition/tensorflow/densenet169/inference/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | | [Inception V3](https://arxiv.org/pdf/1512.00567.pdf) | TensorFlow | Inference | [Int8 FP32](/benchmarks/image_recognition/tensorflow/inceptionv3/inference/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | -| [Inception V4](https://arxiv.org/pdf/1602.07261.pdf) | TensorFlow | Inference | [Int8 FP32](/benchmarks/image_recognition/tensorflow/inceptionv4/inference/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | | [MobileNet V1*](https://arxiv.org/pdf/1704.04861.pdf) | TensorFlow | Inference | [Int8 FP32 BFloat16](/benchmarks/image_recognition/tensorflow/mobilenet_v1/inference/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | | [MobileNet V1*](https://arxiv.org/pdf/1704.04861.pdf) [Sapphire Rapids](https://www.intel.com/content/www/us/en/newsroom/opinion/updates-next-gen-data-center-platform-sapphire-rapids.html#gs.blowcx) | TensorFlow | Inference | [Int8 FP32 BFloat16 BFloat32](/quickstart/image_recognition/tensorflow/mobilenet_v1/inference/cpu/README_SPR_baremetal.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | | [MobileNet V2](https://arxiv.org/pdf/1801.04381.pdf) | Tensorflow | Inference | [FP32 BFloat16 Int8](/benchmarks/image_recognition/tensorflow/mobilenet_v2/inference/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | [ResNet 101](https://arxiv.org/pdf/1512.03385.pdf) | TensorFlow | Inference | [Int8 FP32](/benchmarks/image_recognition/tensorflow/resnet101/inference/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | -| [ResNet 50](https://arxiv.org/pdf/1512.03385.pdf) | TensorFlow | Inference | [Int8 FP32](/benchmarks/image_recognition/tensorflow/resnet50/inference/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | | [ResNet 50v1.5](https://github.com/tensorflow/models/tree/v2.11.0/official/legacy/image_classification/resnet) | TensorFlow | Inference | [Int8 FP32 BFloat16 FP16](/benchmarks/image_recognition/tensorflow/resnet50v1_5/inference/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | | [ResNet 50v1.5](https://github.com/tensorflow/models/tree/v2.11.0/official/legacy/image_classification/resnet) [Sapphire Rapids](https://www.intel.com/content/www/us/en/newsroom/opinion/updates-next-gen-data-center-platform-sapphire-rapids.html#gs.blowcx) | TensorFlow | Inference | [Int8 FP32 BFloat16 BFloat32](/quickstart/image_recognition/tensorflow/resnet50v1_5/inference/cpu/README_SPR_baremetal.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | | [ResNet 50v1.5](https://github.com/tensorflow/models/tree/v2.11.0/official/legacy/image_classification/resnet) | TensorFlow | Training | [FP32 BFloat16 FP16](/benchmarks/image_recognition/tensorflow/resnet50v1_5/training/README.md) | [ImageNet 2012](https://github.com/IntelAI/models/tree/master/datasets/imagenet/README.md) | @@ -60,12 +58,12 @@ For best performance on Intel® Data Center GPU Flex and Max Series, please chec | [Inception v3](https://arxiv.org/pdf/1512.00567.pdf) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/inception_v3/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/inception_v3/inference/cpu/README.md#datasets) | | [MNASNet 0.5](https://arxiv.org/abs/1807.11626) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/mnasnet0_5/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/mnasnet0_5/inference/cpu/README.md#datasets) | | [MNASNet 1.0](https://arxiv.org/abs/1807.11626) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/mnasnet1_0/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/mnasnet1_0/inference/cpu/README.md#datasets) | -| [ResNet 50](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Inference | [FP32 BFloat16 BFloat32](/quickstart/image_recognition/pytorch/resnet50/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/resnet50/inference/cpu/README.md#datasets) | +| [ResNet 50](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Inference | [Int8 FP32 BFloat16 BFloat32](/quickstart/image_recognition/pytorch/resnet50/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/resnet50/inference/cpu/README.md#datasets) | | [ResNet 50](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Training | [FP32 BFloat16 BFloat32](/quickstart/image_recognition/pytorch/resnet50/training/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/resnet50/training/cpu/README.md#datasets) | | [ResNet 101](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/resnet101/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/resnet101/inference/cpu/README.md#datasets) | | [ResNet 152](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/resnet152/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/resnet152/inference/cpu/README.md#datasets) | | [ResNext 32x4d](https://arxiv.org/abs/1611.05431) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/resnext-32x4d/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/resnext-32x4d/inference/cpu/README.md#datasets) | -| [ResNext 32x16d](https://arxiv.org/abs/1611.05431) | PyTorch | Inference | [FP32 BFloat16 BFloat32](/quickstart/image_recognition/pytorch/resnext-32x16d/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/resnext-32x16d/inference/cpu/README.md#datasets) | +| [ResNext 32x16d](https://arxiv.org/abs/1611.05431) | PyTorch | Inference | [Int8 FP32 BFloat16 BFloat32](/quickstart/image_recognition/pytorch/resnext-32x16d/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/resnext-32x16d/inference/cpu/README.md#datasets) | | [VGG-11](https://arxiv.org/abs/1409.1556) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/vgg11/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/vgg11/inference/cpu/README.md#datasets) | | [VGG-11 with batch normalization](https://arxiv.org/abs/1409.1556) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/vgg11_bn/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/vgg11_bn/inference/cpu/README.md#datasets) | | [Wide ResNet-50-2](https://arxiv.org/pdf/1605.07146.pdf) | PyTorch | Inference | [FP32 BFloat16](/quickstart/image_recognition/pytorch/wide_resnet50_2/inference/cpu/README.md) | [ImageNet 2012](/quickstart/image_recognition/pytorch/wide_resnet50_2/inference/cpu/README.md#datasets) | @@ -92,7 +90,7 @@ For best performance on Intel® Data Center GPU Flex and Max Series, please chec | [BERT base](https://arxiv.org/pdf/1810.04805.pdf) | PyTorch | Inference | [FP32 BFloat16](/quickstart/language_modeling/pytorch/bert_base/inference/cpu/README.md) | [BERT Base SQuAD1.1](https://huggingface.co/csarron/bert-base-uncased-squad-v1) | | [BERT large](https://arxiv.org/pdf/1810.04805.pdf) | PyTorch | Inference | [FP32 Int8 BFloat16 BFloat32](/quickstart/language_modeling/pytorch/bert_large/inference/cpu/README.md) | BERT Large SQuAD1.1 | | [BERT large](https://arxiv.org/pdf/1810.04805.pdf) | PyTorch | Training | [FP32 BFloat16 BFloat32](/quickstart/language_modeling/pytorch/bert_large/training/cpu/README.md) | [preprocessed text dataset](https://drive.google.com/drive/folders/1cywmDnAsrP5-2vsr8GDc6QUc7VWe-M3v) | -| [DistilBERT base](https://arxiv.org/abs/1910.01108) | PyTorch | Inference | [FP32 Int8 BFloat16 BFloat32](/quickstart/language_modeling/pytorch/distilbert_base/inference/cpu/README.md) | [ DistilBERT Base SQuAD1.1](https://huggingface.co/distilbert-base-uncased-distilled-squad) | +| [DistilBERT base](https://arxiv.org/abs/1910.01108) | PyTorch | Inference | [FP32 Int8-FP32 Int8-BFloat16 BFloat16 BFloat32](/quickstart/language_modeling/pytorch/distilbert_base/inference/cpu/README.md) | [ DistilBERT Base SQuAD1.1](https://huggingface.co/distilbert-base-uncased-distilled-squad) | | [RNN-T](https://arxiv.org/abs/2007.15188) | PyTorch | Inference | [FP32 BFloat16 BFloat32](/quickstart/language_modeling/pytorch/rnnt/inference/cpu/README.md) | [RNN-T dataset](/quickstart/language_modeling/pytorch/rnnt/inference/cpu/download_dataset.sh) | | [RNN-T](https://arxiv.org/abs/2007.15188) | PyTorch | Training | [FP32 BFloat16 BFloat32](/quickstart/language_modeling/pytorch/rnnt/training/cpu/README.md) | [RNN-T dataset](/quickstart/language_modeling/pytorch/rnnt/training/cpu/download_dataset.sh) | | [RoBERTa base](https://arxiv.org/abs/1907.11692) | PyTorch | Inference | [FP32 BFloat16](/quickstart/language_modeling/pytorch/roberta_base/inference/cpu/README.md) | [RoBERTa Base SQuAD 2.0](https://huggingface.co/deepset/roberta-base-squad2) | @@ -103,7 +101,6 @@ For best performance on Intel® Data Center GPU Flex and Max Series, please chec | Model | Framework | Mode | Model Documentation | Benchmark/Test Dataset | | --------------------------------------------------------------- | ---------- | ----------| ------------------- | ---------------------- | | [BERT](https://arxiv.org/pdf/1810.04805.pdf) | TensorFlow | Inference | [FP32](/benchmarks/language_translation/tensorflow/bert/inference/README.md) | [MRPC](https://github.com/IntelAI/models/tree/master/datasets/bert_data/README.md#classification-training-with-bert) | -| [GNMT*](https://arxiv.org/pdf/1609.08144.pdf) | TensorFlow | Inference | [FP32](/benchmarks/language_translation/tensorflow/mlperf_gnmt/inference/README.md) | [MLPerf GNMT model benchmarking dataset](https://github.com/IntelAI/models/tree/master/benchmarks/language_translation/tensorflow/mlperf_gnmt/inference/fp32#datasets) | | [Transformer_LT_mlperf*](https://arxiv.org/pdf/1706.03762.pdf) | TensorFlow | Inference | [FP32 BFloat16 Int8](/benchmarks/language_translation/tensorflow/transformer_mlperf/inference/README.md) | [WMT English-German data](https://github.com/IntelAI/models/tree/master/datasets/transformer_data#transformer-language-mlperf-dataset) | | [Transformer_LT_mlperf*](https://arxiv.org/pdf/1706.03762.pdf) [Sapphire Rapids](https://www.intel.com/content/www/us/en/newsroom/opinion/updates-next-gen-data-center-platform-sapphire-rapids.html#gs.blowcx) | Tensorflow | Inference | [FP32 BFloat16 Int8 BFloat32](/quickstart/language_translation/tensorflow/transformer_mlperf/inference/cpu/README_SPR_Baremetal.md) | [WMT English-German dataset](https://github.com/IntelAI/models/tree/master/datasets/transformer_data#transformer-language-mlperf-dataset) | | [Transformer_LT_mlperf*](https://arxiv.org/pdf/1706.03762.pdf) | TensorFlow | Training | [FP32 BFloat16](/benchmarks/language_translation/tensorflow/transformer_mlperf/training/README.md) | [WMT English-German dataset](https://github.com/IntelAI/models/tree/master/datasets/transformer_data#transformer-language-mlperf-dataset) | @@ -115,7 +112,6 @@ For best performance on Intel® Data Center GPU Flex and Max Series, please chec | Model | Framework | Mode | Model Documentation | Benchmark/Test Dataset | | ----------------------------------------------------- | ---------- | ----------| ------------------- | ---------------------- | -| [R-FCN](https://arxiv.org/pdf/1605.06409.pdf) | TensorFlow | Inference | [Int8 FP32](/benchmarks/object_detection/tensorflow/rfcn/inference/README.md) | [COCO 2017 validation dataset](https://github.com/IntelAI/models/tree/master/datasets/coco#download-and-preprocess-the-coco-validation-images) | | [SSD-MobileNet*](https://arxiv.org/pdf/1704.04861.pdf)| TensorFlow | Inference | [Int8 FP32 BFloat16](/benchmarks/object_detection/tensorflow/ssd-mobilenet/inference/README.md) | [COCO 2017 validation dataset](https://github.com/IntelAI/models/tree/master/datasets/coco#download-and-preprocess-the-coco-validation-images) | | [SSD-MobileNet*](https://arxiv.org/pdf/1704.04861.pdf) [Sapphire Rapids](https://www.intel.com/content/www/us/en/newsroom/opinion/updates-next-gen-data-center-platform-sapphire-rapids.html#gs.blowcx) | TensorFlow | Inference | [Int8 FP32 BFloat16 BFloat32](/quickstart/object_detection/tensorflow/ssd-mobilenet/inference/cpu/README_SPR_baremetal.md) | [COCO 2017 validation dataset](https://github.com/IntelAI/models/tree/master/datasets/coco#download-and-preprocess-the-coco-validation-images) | | [SSD-ResNet34*](https://arxiv.org/pdf/1512.02325.pdf) | TensorFlow | Inference | [Int8 FP32 BFloat16](/benchmarks/object_detection/tensorflow/ssd-resnet34/inference/README.md) | [COCO 2017 validation dataset](https://github.com/IntelAI/models/tree/master/datasets/coco#download-and-preprocess-the-coco-validation-images) | @@ -139,21 +135,21 @@ For best performance on Intel® Data Center GPU Flex and Max Series, please chec | [DIEN](https://arxiv.org/abs/1809.03672) [Sapphire Rapids](https://www.intel.com/content/www/us/en/newsroom/opinion/updates-next-gen-data-center-platform-sapphire-rapids.html#gs.blowcx) | TensorFlow | Inference | [FP32 BFloat16 BFloat32](/quickstart/recommendation/tensorflow/dien/inference/cpu/README_SPR_baremetal.md) | [DIEN dataset](https://github.com/IntelAI/models/tree/master/benchmarks/recommendation/tensorflow/dien/inference#datasets) | | [DIEN](https://arxiv.org/abs/1809.03672) | TensorFlow | Training | [FP32](/benchmarks/recommendation/tensorflow/dien/training/README.md) | [DIEN dataset](https://github.com/IntelAI/models/tree/master/benchmarks/recommendation/tensorflow/dien#1-prepare-datasets-1) | | [DIEN](https://arxiv.org/abs/1809.03672) [Sapphire Rapids](https://www.intel.com/content/www/us/en/newsroom/opinion/updates-next-gen-data-center-platform-sapphire-rapids.html#gs.blowcx) | TensorFlow | Training | [FP32 BFloat16 BFloat32](/quickstart/recommendation/tensorflow/dien/training/cpu/README_SPR_baremetal.md) | [DIEN dataset](https://github.com/IntelAI/models/tree/master/benchmarks/recommendation/tensorflow/dien#1-prepare-datasets-1) | -| [NCF](https://arxiv.org/pdf/1708.05031.pdf) | TensorFlow | Inference | [FP32](/benchmarks/recommendation/tensorflow/ncf/inference/fp32/README.md) | [MovieLens 1M](https://github.com/IntelAI/models/tree/master/benchmarks/recommendation/tensorflow/ncf/inference/fp32#datasets) | | [Wide & Deep](https://arxiv.org/pdf/1606.07792.pdf) | TensorFlow | Inference | [FP32](/benchmarks/recommendation/tensorflow/wide_deep/inference/README.md) | [Census Income dataset](https://github.com/IntelAI/models/tree/master/benchmarks/recommendation/tensorflow/wide_deep/inference/fp32#dataset) | | [Wide & Deep Large Dataset](https://arxiv.org/pdf/1606.07792.pdf) | TensorFlow | Inference | [Int8 FP32](/benchmarks/recommendation/tensorflow/wide_deep_large_ds/inference/README.md) | [Large Kaggle Display Advertising Challenge dataset](https://github.com/IntelAI/models/tree/master/datasets/large_kaggle_advertising_challenge/README.md) | -| [Wide & Deep Large Dataset](https://arxiv.org/pdf/1606.07792.pdf) | TensorFlow | Training | [FP32](/benchmarks/recommendation/tensorflow/wide_deep_large_ds/training/README.md) | [Large Kaggle Display Advertising Challenge dataset](https://github.com/IntelAI/models/tree/master/benchmarks/recommendation/tensorflow/wide_deep_large_ds/training/fp32#dataset) | | [DLRM](https://arxiv.org/pdf/1906.00091.pdf) | PyTorch | Inference | [FP32 Int8 BFloat16 BFloat32](/quickstart/recommendation/pytorch/dlrm/inference/cpu/README.md) | [Criteo Terabyte](/quickstart/recommendation/pytorch/dlrm/inference/cpu/README.md#datasets) | | [DLRM](https://arxiv.org/pdf/1906.00091.pdf) | PyTorch | Training | [FP32 BFloat16 BFloat32](/quickstart/recommendation/pytorch/dlrm/training/cpu/README.md) | [Criteo Terabyte](/quickstart/recommendation/pytorch/dlrm/training/cpu/README.md#datasets) | | [DLRM v2](https://arxiv.org/pdf/1906.00091.pdf) | PyTorch | Inference | [FP32 FP16 BFloat16 BFloat32 Int8](/quickstart/recommendation/pytorch/torchrec_dlrm/inference/cpu/README.md) | [Criteo 1TB Click Logs dataset](/quickstart/recommendation/pytorch/torchrec_dlrm/inference/cpu#datasets) | | [DLRM v2](https://arxiv.org/pdf/1906.00091.pdf) | PyTorch | Training | [FP32 FP16 BFloat16 BFloat32](/quickstart/recommendation/pytorch/torchrec_dlrm/training/cpu/README.md) | [Random dataset](/quickstart/recommendation/pytorch/torchrec_dlrm/training/cpu#datasets) | | [MEMREC-DLRM](https://arxiv.org/pdf/2305.07205.pdf) | PyTorch | Inference | [FP32](/quickstart/recommendation/pytorch/memrec_dlrm/inference/cpu/README.md) | [Criteo Terabyte](/quickstart/recommendation/pytorch/memrec_dlrm/inference/cpu/README.md#datasets) | -### Text-to-Speech +### Diffusion | Model | Framework | Mode | Model Documentation | Benchmark/Test Dataset | | ----------------------------------------------- | ---------- | ----------| ------------------- | ---------------------- | -| [WaveNet](https://arxiv.org/pdf/1609.03499.pdf) | TensorFlow | Inference | [FP32](/benchmarks/text_to_speech/tensorflow/wavenet/inference/fp32/README.md) | +| [Stable Diffusion](https://keras.io/guides/keras_cv/generate_images_with_stable_diffusion/) | TensorFlow | Inference | [FP32 BFloat16 FP16](/benchmarks/diffusion/tensorflow/stable_diffusion/inference/README.md) | [COCO 2017 validation dataset](https://github.com/IntelAI/models/tree/master/datasets/coco#download-and-preprocess-the-coco-validation-images) +| [Stable Diffusion](https://huggingface.co/stabilityai/stable-diffusion-2-1) | PyTorch | Inference | [FP32 BFloat16 FP16 BFloat32 Int8-FP32 Int8-BFloat16](/quickstart/diffusion/pytorch/stable_diffusion/inference/cpu/README.md) | [COCO 2017 validation dataset](https://github.com/IntelAI/models/tree/master/datasets/coco#download-and-preprocess-the-coco-validation-images) +| [Stable Diffusion](https://huggingface.co/stabilityai/stable-diffusion-2-1) | PyTorch | Training | [FP32 BFloat16 FP16 BFloat32](/quickstart/diffusion/pytorch/stable_diffusion/training/cpu/README.md) | [cat images](https://huggingface.co/datasets/diffusers/cat_toy_example) ### Shot Boundary Detection @@ -174,26 +170,29 @@ For best performance on Intel® Data Center GPU Flex and Max Series, please chec ## Intel® Data Center GPU Workloads | Model | Framework | Mode | GPU Type | Model Documentation | | ----------------------------------| ---------- | ----------| -------- | ------------------- | -| [ResNet 50v1.5](https://github.com/tensorflow/models/tree/v2.11.0/official/legacy/image_classification/resnet) | TensorFlow | Inference | Flex Series | [Int8](/quickstart/image_recognition/tensorflow/resnet50v1_5/inference/gpu/README_Flex_series.md) | -| [ResNet 50 v1.5](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Inference | Flex Series |[Int8](/quickstart/image_recognition/pytorch/resnet50v1_5/inference/gpu/README_Flex_Series.md) | +| [ResNet 50v1.5](https://github.com/tensorflow/models/tree/v2.11.0/official/legacy/image_classification/resnet) | TensorFlow | Inference | Flex Series | [Float32 TF32 Float16 BFloat16 Int8](/models_v2/tensorflow/resnet50v1_5/inference/gpu/README.md) | +| [ResNet 50 v1.5](https://github.com/tensorflow/models/tree/v2.11.0/official/legacy/image_classification/resnet) | TensorFlow | Training | Max Series | [BFloat16 FP32](/models_v2/tensorflow/resnet50v1_5/training/gpu/README.md) | +| [ResNet 50 v1.5](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Inference | Flex Series, Max Series, ARC Series |[Int8 FP32 FP16 TF32](/models_v2/pytorch/resnet50v1_5/inference/gpu/README.md) | +| [ResNet 50 v1.5](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Training | Max Series, ARC Series |[BFloat16 TF32 FP32](/models_v2/pytorch/resnet50v1_5/training/gpu/README.md) | +| [DistilBERT](https://arxiv.org/pdf/1910.01108.pdf) | PyTorch | Inference | Flex Series, Max Series | [FP32 FP16 BF16 TF32](/models_v2/pytorch/distilbert/inference/gpu/README.md) | +| [DLRM v1](https://arxiv.org/pdf/1906.00091.pdf) | PyTorch | Inference | Flex Series | [FP16 FP32](/models_v2/pytorch/dlrm/inference/gpu/README.md) | | [SSD-MobileNet*](https://arxiv.org/pdf/1704.04861.pdf)| TensorFlow | Inference | Flex Series| [Int8](/quickstart/object_detection/tensorflow/ssd-mobilenet/inference/gpu/README.md) | -| [SSD-MobileNet](https://arxiv.org/pdf/1704.04861.pdf)| PyTorch | Inference | Flex Series | [Int8](/quickstart/object_detection/pytorch/ssd-mobilenet/inference/gpu/README.md) | -| [Yolo V4](https://arxiv.org/pdf/1704.04861.pdf)| PyTorch | Inference | Flex Series | [Int8](/quickstart/object_detection/pytorch/yolov4/inference/gpu/README.md) | -| [EfficientNet](https://arxiv.org/pdf/1905.11946.pdf) | TensorFlow | Inference | Flex Series | [FP16](/quickstart/image_recognition/tensorflow/efficientnet/inference/gpu/README.md) | -| [MaskRCNN](https://arxiv.org/pdf/1703.06870.pdf) | TensorFlow | Inference | Flex Series | [FP16](/quickstart/image_segmentation/tensorflow/maskrcnn/inference/gpu/README.md) | -| [Stable Diffusion](https://arxiv.org/pdf/2112.10752.pdf) | TensorFlow | Inference | Flex Series | [FP16 FP32](/quickstart/generative-ai/tensorflow/stable_diffusion/inference/gpu/README.md) | -| [Stable Diffusion](https://arxiv.org/pdf/2112.10752.pdf) | PyTorch | Inference | Flex Series | [FP16 FP32](/quickstart/generative-ai/pytorch/stable_diffusion/inference/gpu/README.md) | +| [SSD-MobileNet*](https://arxiv.org/pdf/1704.04861.pdf)| PyTorch | Inference | ARC Series| [INT8 FP16 FP32](/models_v2/pytorch/ssd-mobilenetv1/inference/gpu/README.md) | +| [EfficientNet](https://arxiv.org/pdf/1905.11946.pdf) | TensorFlow | Inference | Flex Series | [FP16](/models_v2/tensorflow/efficientnet/inference/gpu/README.md) | +| [Wide Deep Large Dataset](https://arxiv.org/pdf/2112.10752.pdf) | TensorFlow | Inference | Flex Series | [FP16](/models_v2/tensorflow/wide_deep_large_ds/inference/gpu/README.md) | | [Yolo V5](https://arxiv.org/pdf/2108.11539.pdf) | PyTorch | Inference | Flex Series | [FP16](/quickstart/object_detection/pytorch/yolov5/inference/gpu/README.md) | -| [ResNet 50v1.5](https://github.com/tensorflow/models/tree/v2.11.0/official/legacy/image_classification/resnet) | TensorFlow | Inference | Max Series | [Int8 FP32 FP16](/quickstart/image_recognition/tensorflow/resnet50v1_5/inference/gpu/README_Max_Series.md) | -| [ResNet 50 v1.5](https://github.com/tensorflow/models/tree/v2.11.0/official/legacy/image_classification/resnet) | TensorFlow | Training | Max Series | [BFloat16](/quickstart/image_recognition/tensorflow/resnet50v1_5/training/gpu/README.md) | -| [ResNet 50 v1.5](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Inference | Max Series |[Int8](/quickstart/image_recognition/pytorch/resnet50v1_5/inference/gpu/README_Max_Series.md) | -| [ResNet 50 v1.5](https://arxiv.org/pdf/1512.03385.pdf) | PyTorch | Training | Max Series |[BFloat16](/quickstart/image_recognition/pytorch/resnet50v1_5/training/gpu/README.md) | -| [BERT large](https://arxiv.org/pdf/1810.04805.pdf) | PyTorch | Inference | Max Series | [FP16](/quickstart/language_modeling/pytorch/bert_large/inference/gpu/README.md) | -| [BERT large](https://arxiv.org/pdf/1810.04805.pdf) | PyTorch | Training | Max Series | [BFloat16](/quickstart/language_modeling/pytorch/bert_large/training/gpu/README.md) | +| [BERT large](https://arxiv.org/pdf/1810.04805.pdf) | PyTorch | Inference | Max Series, ARC Series | [BFloat16 FP32 FP16](/models_v2/pytorch/bert_large/inference/gpu/README.md) | +| [BERT large](https://arxiv.org/pdf/1810.04805.pdf) | PyTorch | Training | Max Series, ARC Series | [BFloat16 FP32 TF32](/models_v2/pytorch/bert_large/training/gpu/README.md) | |[BERT large](https://arxiv.org/pdf/1810.04805.pdf) | TensorFlow | Inference | Max Series | [FP32 FP16](/quickstart/language_modeling/tensorflow/bert_large/inference/gpu/README.md) | -| [BERT large](https://arxiv.org/pdf/1810.04805.pdf) | TensorFlow | Training | Max Series | [BFloat16](/quickstart/language_modeling/tensorflow/bert_large/training/gpu/README.md) | -| [DLRM](https://arxiv.org/pdf/1906.00091.pdf) | TensorFlow | Inference | Max Series | [FP16](/quickstart/recommendation/pytorch/torchrec_dlrm/inference/gpu/README.md) | -| [DLRM](https://arxiv.org/pdf/1906.00091.pdf) | TensorFlow | Training | Max Series | [BFloat16](/quickstart/recommendation/pytorch/torchrec_dlrm/training/gpu/README.md) | +| [BERT large](https://arxiv.org/pdf/1810.04805.pdf) | TensorFlow | Training | Max Series | [BFloat16 TF32 FP32](/models_v2/tensorflow/bert_large/training/gpu/README.md) | +| [DLRM v2](https://arxiv.org/pdf/1906.00091.pdf) | PyTorch | Inference | Max Series | [FP16 FP32](/models_v2/pytorch/torchrec_dlrm/inference/gpu/README.md) | +| [DLRM v2](https://arxiv.org/pdf/1906.00091.pdf) | PyTorch | Training | Max Series | [BFloat16 FP32](/models_v2/pytorch/torchrec_dlrm/training/gpu/README.md) | +| [3D-Unet](https://arxiv.org/pdf/1606.06650.pdf) | PyTorch | Inference | Max Series | [FP16 INT8 FP32](/models_v2/pytorch/3d_unet/inference/gpu/README.md) | +| [3D-Unet](https://arxiv.org/pdf/1606.06650.pdf) | TensorFlow | Training | Max Series | [BFloat16 FP32](/models_v2/tensorflow/3d_unet/training/gpu/README.md) | +| [Stable Diffusion](https://arxiv.org/pdf/2112.10752.pdf) | PyTorch | Inference | Flex Series, Max Series, ARC Series | [FP16 FP32](/models_v2/pytorch/stable_diffusion/inference/gpu/README.md) | +| [Stable Diffusion](https://arxiv.org/pdf/2112.10752.pdf) | TensorFlow | Inference | Flex Series | [FP16 FP32](/models_v2/tensorflow/stable_diffusion/inference/gpu/README.md) | +| [MaskRCNN](https://arxiv.org/pdf/1703.06870.pdf) | TensorFlow | Inference | Flex Series | [FP32 Float16](/models_v2/tensorflow/maskrcnn/inference/gpu/README.md) | +| [MaskRCNN](https://arxiv.org/pdf/1703.06870.pdf) | TensorFlow | Training | Max Series | [FP32 BFloat16](/models_v2/tensorflow/maskrcnn/training/gpu/README.md) | ## How to Contribute -If you would like to add a new benchmarking script, please use [this guide](/Contribute.md). +If you would like to add a new benchmarking script, please use [this guide](/CONTRIBUTING.md). diff --git a/benchmarks/common/base_model_init.py b/benchmarks/common/base_model_init.py index ca0e3f26d..0795a3d37 100644 --- a/benchmarks/common/base_model_init.py +++ b/benchmarks/common/base_model_init.py @@ -219,9 +219,14 @@ def run_numactl_multi_instance(self, cmd, replace_unique_output_dir=None): if len(core_list) == 0: continue - prefix = ("{0}OMP_NUM_THREADS={1} " - "numactl --localalloc --physcpubind={2}").format( - ld_preload_prefix, len(core_list), ",".join(core_list)) + if "OMP_NUM_THREADS" in os.environ: + prefix = ("{0}OMP_NUM_THREADS={1} " + "numactl --localalloc --physcpubind={2}").format( + ld_preload_prefix, os.environ["OMP_NUM_THREADS"], ",".join(core_list)) + else: + prefix = ("{0}OMP_NUM_THREADS={1} " + "numactl --localalloc --physcpubind={2}").format( + ld_preload_prefix, len(core_list), ",".join(core_list)) instance_logfile = log_filename_format.format("instance" + str(instance_num)) unique_command = cmd diff --git a/benchmarks/common/tensorflow/start.sh b/benchmarks/common/tensorflow/start.sh index 80d338a6e..7bb50df68 100644 --- a/benchmarks/common/tensorflow/start.sh +++ b/benchmarks/common/tensorflow/start.sh @@ -1134,6 +1134,7 @@ function ssd_mobilenet() { done fi CMD="${CMD} $(add_steps_args)" + CMD="${CMD} $(add_arg "--input-subgraph" ${INPUT_SUBGRAPH})" PYTHONPATH=${PYTHONPATH} CMD=${CMD} run_model } @@ -1817,11 +1818,11 @@ function stable_diffusion() { "https://github.com/openai/CLIP/blob/main/clip/bpe_simple_vocab_16e6.txt.gz?raw=true", file_hash="924691ac288e54409236115652ad4aa250f48203de50a9e4722a6ecd48d6804a", )\n_ = keras.utils.get_file( - origin="https://huggingface.co/fchollet/stable-diffusion/resolve/main/kcv_encoder.h5", - file_hash="4789e63e07c0e54d6a34a29b45ce81ece27060c499a709d556c7755b42bb0dc4", + origin="https://huggingface.co/ianstenbit/keras-sd2.1/resolve/main/text_encoder_v2_1.h5", + file_hash="985002e68704e1c5c3549de332218e99c5b9b745db7171d5f31fcd9a6089f25b", )\n_ = keras.utils.get_file( - origin="https://huggingface.co/fchollet/stable-diffusion/resolve/main/kcv_diffusion_model.h5", - file_hash="8799ff9763de13d7f30a683d653018e114ed24a6a819667da4f5ee10f9e805fe", + origin="https://huggingface.co/ianstenbit/keras-sd2.1/resolve/main/diffusion_model_v2_1.h5", + file_hash="c31730e91111f98fe0e2dbde4475d381b5287ebb9672b1821796146a25c5132d", )\n_ = keras.utils.get_file( origin="https://huggingface.co/fchollet/stable-diffusion/resolve/main/kcv_decoder.h5", file_hash="ad350a65cc8bc4a80c8103367e039a3329b4231c2469a1093869a345f55b1962", @@ -1942,6 +1943,27 @@ function graphsage() { fi } +function yolov5() { + if [ ${MODE} == "inference" ]; then + if [ ${PRECISION} == "fp32" ] || [ ${PRECISION} == "bfloat16" ]; then + export PYTHONPATH=${PYTHONPATH}:${MOUNT_EXTERNAL_MODELS_SOURCE} + + if [ ${NUM_INTER_THREADS} != "None" ]; then + CMD="${CMD} $(add_arg "--num-inter-threads" ${NUM_INTER_THREADS})" + fi + + if [ ${NUM_INTRA_THREADS} != "None" ]; then + CMD="${CMD} $(add_arg "--num-intra-threads" ${NUM_INTRA_THREADS})" + fi + CMD="${CMD} $(add_arg "--steps" ${STEPS})" + CMD=${CMD} run_model + else + echo "PRECISION=${PRECISION} not supported for ${MODEL_NAME} in this repo." + exit 1 + fi + fi +} + LOGFILE=${OUTPUT_DIR}/${LOG_FILENAME} MODEL_NAME=$(echo ${MODEL_NAME} | tr 'A-Z' 'a-z') @@ -2021,6 +2043,8 @@ elif [ ${MODEL_NAME} == "rgat" ]; then rgat elif [ ${MODEL_NAME} == "stable_diffusion" ]; then stable_diffusion +elif [ ${MODEL_NAME} == "yolov5" ]; then + yolov5 else echo "Unsupported model: ${MODEL_NAME}" exit 1 diff --git a/benchmarks/diffusion/__init__.py b/benchmarks/diffusion/__init__.py new file mode 100644 index 000000000..eb0564d39 --- /dev/null +++ b/benchmarks/diffusion/__init__.py @@ -0,0 +1,17 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# diff --git a/benchmarks/diffusion/tensorflow/__init__.py b/benchmarks/diffusion/tensorflow/__init__.py new file mode 100644 index 000000000..f07dbaf88 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/__init__.py @@ -0,0 +1,19 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/__init__.py b/benchmarks/diffusion/tensorflow/stable_diffusion/__init__.py new file mode 100644 index 000000000..f07dbaf88 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/__init__.py @@ -0,0 +1,19 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/README.md b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/README.md new file mode 100644 index 000000000..2e1dc3ffe --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/README.md @@ -0,0 +1,53 @@ + +# Stable Diffusion Inference + + + +## Description +This document has instructions for running inference based on a text prompt using the [KerasCV implementation](https://keras.io/guides/keras_cv/generate_images_with_stable_diffusion/) of [stability.ai's](https://stability.ai/) text-to-image model, [Stable Diffusion](https://github.com/CompVis/stable-diffusion). Stable Diffusion is a powerful, open-source text-to-image generation model. + +## Run the model + +### Run on Linux + +Install the Intel-optimized TensorFlow along with model dependencies under [requirements.txt](../../../../../models/diffusion/tensorflow/stable_diffusion/inference/requirements.txt). + +``` +# cd to your model zoo directory +cd models +export PRECISION= +export OUTPUT_DIR= +# For a custom batch size, set env var `BATCH_SIZE` or it will run with a default value. +export BATCH_SIZE= +``` + +### Inference +1. `inference.sh` +Runs single-instance realtime inference (`batch_size=1`) with the specified precision (`fp32`, `bfloat16`, or `fp16`). +``` +./quickstart/diffusion/tensorflow/stable_diffusion/inference/cpu/inference.sh +``` + +2. `inference_realtime_multi_instance.sh` +Runs multi-instance realtime inference (`batch_size=1`) using 4 cores per instance with the specified precision (fp32, bfloat16, or fp16). Waits for all instances to complete, then prints a summarized throughput value. +``` +./quickstart/diffusion/tensorflow/stable_diffusion/inference/cpu/inference_realtime_multi_instance.sh +``` + +3. `inference_throughput_multi_instance.sh` +Runs multi instance batch inference using 1 socket per instance with the specified precision (fp32, bfloat16, or fp16) with 200 steps. Waits for all instances to complete, then prints a summarized throughput value. +``` +./quickstart/diffusion/tensorflow/stable_diffusion/inference/cpu/inference_throughput_multi_instance.sh +``` + +### Accuracy + +1. `accuracy.sh` +``` +# Additionally, set DATASET_DIR for accuracy runs. The original and the images generated by the model will be saved under OUTPUT_DIR. +export DATASET_DIR= +``` + +``` +./quickstart/diffusion/tensorflow/stable_diffusion/inference/cpu/accuracy.sh +``` diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/__init__.py b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/__init__.py new file mode 100644 index 000000000..f07dbaf88 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/__init__.py @@ -0,0 +1,19 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/bfloat16/__init__.py b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/bfloat16/__init__.py new file mode 100644 index 000000000..f07dbaf88 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/bfloat16/__init__.py @@ -0,0 +1,19 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# diff --git a/benchmarks/object_detection/tensorflow/faster_rcnn/inference/fp32/config.json b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/bfloat16/config.json similarity index 100% rename from benchmarks/object_detection/tensorflow/faster_rcnn/inference/fp32/config.json rename to benchmarks/diffusion/tensorflow/stable_diffusion/inference/bfloat16/config.json diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/bfloat16/model_init.py b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/bfloat16/model_init.py new file mode 100644 index 000000000..58abca295 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/bfloat16/model_init.py @@ -0,0 +1,93 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from common.base_model_init import BaseModelInitializer +from common.base_model_init import set_env_var + +import os +from argparse import ArgumentParser + + +class ModelInitializer(BaseModelInitializer): + """initialize mode and run benchmark""" + + def __init__(self, args, custom_args=[], platform_util=None): + super(ModelInitializer, self).__init__(args, custom_args, platform_util) + + self.benchmark_command = "" + if not platform_util: + raise ValueError("Did not find any platform info.") + + # use default batch size if -1 + if self.args.batch_size == -1: + self.args.batch_size = 1 + + arg_parser = ArgumentParser(description='Parse args') + + arg_parser.add_argument( + '--kmp-blocktime', dest='kmp_blocktime', + help='number of kmp block time', + type=int, default=1) + arg_parser.add_argument( + "--output-dir", dest='output_dir', + type=str, default='/tmp/stable_diffusion/', + help='Specify the location of the ' + 'output directory for saving original and generated images') + arg_parser.add_argument( + "--steps", dest='steps', + type=int, default=50, + help="number of steps for diffusion model") + + self.args = arg_parser.parse_args(self.custom_args, namespace=self.args) + + # Set KMP env vars, if they haven't already been set, but override the default KMP_BLOCKTIME value + config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json") + self.set_kmp_vars(config_file_path, kmp_blocktime=str(self.args.kmp_blocktime)) + + set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads) + + benchmark_script = os.path.join( + self.args.intelai_models, self.args.mode, "eval_inference.py") + + self.benchmark_command = self.get_command_prefix(args.socket_id) + \ + self.python_exe + " " + benchmark_script + + self.benchmark_command = \ + self.benchmark_command + \ + " --precision=" + str(self.args.precision) + \ + " --batch-size=" + str(self.args.batch_size) + \ + " --steps=" + str(self.args.steps) + \ + " --output-dir=" + str(self.args.output_dir) + + # if the data location directory is not empty, then include the arg + if self.args.data_location and os.listdir(self.args.data_location): + self.benchmark_command += " --data-location=" + self.args.data_location + + if self.args.accuracy_only: + self.benchmark_command += " --accuracy-only" + + print("Benchmark command: ", self.benchmark_command) + + def run(self): + if self.benchmark_command: + self.run_command(self.benchmark_command) diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp16/__init__.py b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp16/__init__.py new file mode 100644 index 000000000..f07dbaf88 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp16/__init__.py @@ -0,0 +1,19 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# diff --git a/benchmarks/recommendation/tensorflow/ncf/inference/fp32/config.json b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp16/config.json similarity index 100% rename from benchmarks/recommendation/tensorflow/ncf/inference/fp32/config.json rename to benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp16/config.json diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp16/model_init.py b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp16/model_init.py new file mode 100644 index 000000000..58abca295 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp16/model_init.py @@ -0,0 +1,93 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from common.base_model_init import BaseModelInitializer +from common.base_model_init import set_env_var + +import os +from argparse import ArgumentParser + + +class ModelInitializer(BaseModelInitializer): + """initialize mode and run benchmark""" + + def __init__(self, args, custom_args=[], platform_util=None): + super(ModelInitializer, self).__init__(args, custom_args, platform_util) + + self.benchmark_command = "" + if not platform_util: + raise ValueError("Did not find any platform info.") + + # use default batch size if -1 + if self.args.batch_size == -1: + self.args.batch_size = 1 + + arg_parser = ArgumentParser(description='Parse args') + + arg_parser.add_argument( + '--kmp-blocktime', dest='kmp_blocktime', + help='number of kmp block time', + type=int, default=1) + arg_parser.add_argument( + "--output-dir", dest='output_dir', + type=str, default='/tmp/stable_diffusion/', + help='Specify the location of the ' + 'output directory for saving original and generated images') + arg_parser.add_argument( + "--steps", dest='steps', + type=int, default=50, + help="number of steps for diffusion model") + + self.args = arg_parser.parse_args(self.custom_args, namespace=self.args) + + # Set KMP env vars, if they haven't already been set, but override the default KMP_BLOCKTIME value + config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json") + self.set_kmp_vars(config_file_path, kmp_blocktime=str(self.args.kmp_blocktime)) + + set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads) + + benchmark_script = os.path.join( + self.args.intelai_models, self.args.mode, "eval_inference.py") + + self.benchmark_command = self.get_command_prefix(args.socket_id) + \ + self.python_exe + " " + benchmark_script + + self.benchmark_command = \ + self.benchmark_command + \ + " --precision=" + str(self.args.precision) + \ + " --batch-size=" + str(self.args.batch_size) + \ + " --steps=" + str(self.args.steps) + \ + " --output-dir=" + str(self.args.output_dir) + + # if the data location directory is not empty, then include the arg + if self.args.data_location and os.listdir(self.args.data_location): + self.benchmark_command += " --data-location=" + self.args.data_location + + if self.args.accuracy_only: + self.benchmark_command += " --accuracy-only" + + print("Benchmark command: ", self.benchmark_command) + + def run(self): + if self.benchmark_command: + self.run_command(self.benchmark_command) diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp32/__init__.py b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp32/__init__.py new file mode 100644 index 000000000..f07dbaf88 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp32/__init__.py @@ -0,0 +1,19 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# diff --git a/benchmarks/recommendation/tensorflow/ncf/training/bfloat16/config.json b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp32/config.json similarity index 100% rename from benchmarks/recommendation/tensorflow/ncf/training/bfloat16/config.json rename to benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp32/config.json diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp32/model_init.py b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp32/model_init.py new file mode 100644 index 000000000..58abca295 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/fp32/model_init.py @@ -0,0 +1,93 @@ +# +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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 __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from common.base_model_init import BaseModelInitializer +from common.base_model_init import set_env_var + +import os +from argparse import ArgumentParser + + +class ModelInitializer(BaseModelInitializer): + """initialize mode and run benchmark""" + + def __init__(self, args, custom_args=[], platform_util=None): + super(ModelInitializer, self).__init__(args, custom_args, platform_util) + + self.benchmark_command = "" + if not platform_util: + raise ValueError("Did not find any platform info.") + + # use default batch size if -1 + if self.args.batch_size == -1: + self.args.batch_size = 1 + + arg_parser = ArgumentParser(description='Parse args') + + arg_parser.add_argument( + '--kmp-blocktime', dest='kmp_blocktime', + help='number of kmp block time', + type=int, default=1) + arg_parser.add_argument( + "--output-dir", dest='output_dir', + type=str, default='/tmp/stable_diffusion/', + help='Specify the location of the ' + 'output directory for saving original and generated images') + arg_parser.add_argument( + "--steps", dest='steps', + type=int, default=50, + help="number of steps for diffusion model") + + self.args = arg_parser.parse_args(self.custom_args, namespace=self.args) + + # Set KMP env vars, if they haven't already been set, but override the default KMP_BLOCKTIME value + config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json") + self.set_kmp_vars(config_file_path, kmp_blocktime=str(self.args.kmp_blocktime)) + + set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads) + + benchmark_script = os.path.join( + self.args.intelai_models, self.args.mode, "eval_inference.py") + + self.benchmark_command = self.get_command_prefix(args.socket_id) + \ + self.python_exe + " " + benchmark_script + + self.benchmark_command = \ + self.benchmark_command + \ + " --precision=" + str(self.args.precision) + \ + " --batch-size=" + str(self.args.batch_size) + \ + " --steps=" + str(self.args.steps) + \ + " --output-dir=" + str(self.args.output_dir) + + # if the data location directory is not empty, then include the arg + if self.args.data_location and os.listdir(self.args.data_location): + self.benchmark_command += " --data-location=" + self.args.data_location + + if self.args.accuracy_only: + self.benchmark_command += " --accuracy-only" + + print("Benchmark command: ", self.benchmark_command) + + def run(self): + if self.benchmark_command: + self.run_command(self.benchmark_command) diff --git a/benchmarks/diffusion/tensorflow/stable_diffusion/inference/requirements.txt b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/requirements.txt new file mode 100644 index 000000000..ead0e1463 --- /dev/null +++ b/benchmarks/diffusion/tensorflow/stable_diffusion/inference/requirements.txt @@ -0,0 +1,5 @@ +keras_cv==0.5.1 +matplotlib +scipy +scikit-image +pandas diff --git a/benchmarks/image_recognition/tensorflow/inceptionv4/__init__.py b/benchmarks/image_recognition/tensorflow/inceptionv4/__init__.py deleted file mode 100644 index 8cb0c8d8d..000000000 --- a/benchmarks/image_recognition/tensorflow/inceptionv4/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# -# -*- coding: utf-8 -*- -# -# Copyright (c) 2018 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# diff --git a/benchmarks/image_recognition/tensorflow/inceptionv4/inference/README.md b/benchmarks/image_recognition/tensorflow/inceptionv4/inference/README.md deleted file mode 100644 index 98033dbb5..000000000 --- a/benchmarks/image_recognition/tensorflow/inceptionv4/inference/README.md +++ /dev/null @@ -1,134 +0,0 @@ - -# Inception V4 inference - - -## Description - -This document has instructions for running Inception V4 inference using -Intel-optimized TensorFlow. - - -## Datasets - -Download and preprocess the ImageNet dataset using the [instructions here](/datasets/imagenet/README.md). -After running the conversion script you should have a directory with the -ImageNet dataset in the TF records format. - -Set the `DATASET_DIR` to point to this directory when running Inception V4. - - -## Quick Start Scripts - -| Script name | Description | -|-------------|-------------| -| [`online_inference.sh`](/quickstart/image_recognition/tensorflow/inceptionv4/inference/cpu/online_inference.sh) | Runs online inference (batch_size=1). | -| [`batch_inference.sh`](/quickstart/image_recognition/tensorflow/inceptionv4/inference/cpu/batch_inference.sh) | Runs batch inference (batch_size=240). | -| [`accuracy.sh`](/quickstart/image_recognition/tensorflow/inceptionv4/inference/cpu/accuracy.sh) | Measures the model accuracy (batch_size=100). | - - -## Run the model - -Setup your environment using the instructions below, depending on if you are -using [AI Tools](/docs/general/tensorflow/AITools.md): - - - - - - - - - - - - -
Setup using AI Tools on LinuxSetup without AI Tools on LinuxSetup without AI Tools on Windows
-

To run using AI Tools on Linux you will need:

-
    -
  • numactl -
  • wget -
  • Activate the tensorflow conda environment -
    conda activate tensorflow
    -
-
-

To run without AI Tools on Linux you will need:

-
    -
  • Python 3 -
  • intel-tensorflow>=2.5.0 -
  • git -
  • numactl -
  • wget -
  • A clone of the AI Reference Models repo
    -
    git clone https://github.com/IntelAI/models.git
    -
-
-

To run without AI Tools on Windows you will need:

- -
- -After finishing the setup above, download the pretrained model based on `PRECISION` and set the -`PRETRAINED_MODEL` environment var to the path to the frozen graph. -If you run on Windows, please use a browser to download the pretrained model using the link below. -For Linux, run: -``` -# Int8 Pretrained model -wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/inceptionv4_int8_pretrained_model.pb -export PRETRAINED_MODEL=$(pwd)/inceptionv4_int8_pretrained_model.pb - -# FP32 Pretrained model -wget https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_8/inceptionv4_fp32_pretrained_model.pb -export PRETRAINED_MODEL=$(pwd)/inceptionv4_fp32_pretrained_model.pb -``` - -Set the environment variables and run quickstart script on either Linux or Windows systems. See the [list of quickstart scripts](#quick-start-scripts) for details on the different options. - -### Run on Linux -``` -# cd to your AI Reference Models directory -cd models - -export PRETRAINED_MODEL= -export DATASET_DIR= -export PRECISION= -export OUTPUT_DIR= -# For a custom batch size, set env var `BATCH_SIZE` or it will run with a default value. -export BATCH_SIZE= - -./quickstart/image_recognition/tensorflow/inceptionv4/inference/cpu/