Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b52182f
Update resnet_quantization.ipynb
bmyrcha Oct 2, 2023
d3f3366
Move dependencies to requirements.txt
bmyrcha Oct 3, 2023
8e4bc23
Check env variables
bmyrcha Oct 4, 2023
0092500
Revert "Check env variables"
bmyrcha Oct 4, 2023
4f75237
Change way of passing HuggingFace token
bmyrcha Oct 4, 2023
5684561
Add pyOpenSSL to requirements
bmyrcha Oct 4, 2023
659bf4f
Add requirements.txt to tensorflow vgg19 notebook
bmyrcha Oct 4, 2023
b71a472
Connection test change
bmyrcha Oct 9, 2023
e717816
Remove redundant code
bmyrcha Oct 9, 2023
b46e7c6
Notebook updates
bmyrcha Oct 11, 2023
5cb6e2b
[pre-commit.ci] pre-commit autoupdate (#1297)
pre-commit-ci[bot] Oct 8, 2023
7288ed2
Fix typo in download_librispeech.py (#1296)
eltociear Oct 8, 2023
176dd02
Update DyNAS-T to 1.6 (#1292)
macsz Oct 8, 2023
2e63951
Enhance config for DML EP (#1286)
mengniwang95 Oct 8, 2023
c089bae
update sq doc (#1301)
yintong-lu Oct 9, 2023
6da8fb2
Add example of PyTorch model tensor dump with Neural Insights (#1305)
bmyrcha Oct 9, 2023
000e0d6
CI FWs/PyThon version update (#1272)
chensuyue Oct 9, 2023
c4fd8b6
fix hpo ut (#1307)
n1ck-guo Oct 10, 2023
ef0f8f3
support Coverity scan with oneCICD repo (#1309)
chensuyue Oct 11, 2023
e59f150
update onnxrt notebook (#1312)
yuwenzho Oct 11, 2023
b925555
fix tensorflow scripts typo (#1315)
chensuyue Oct 12, 2023
ff1b941
Support MatMulFpQ4 for onnxruntime 1.16.0 (#1293)
mengniwang95 Oct 12, 2023
5028747
Sample code of SignRound (#1313)
wenhuach21 Oct 13, 2023
167d37e
sq readme update (#1306)
yintong-lu Oct 13, 2023
3bfc9a5
publication update and hyper link fix (#1318)
chensuyue Oct 13, 2023
2796a86
fix deps versions for TF example gpt2-medium (#1319)
Spycsh Oct 16, 2023
31c903c
add lwq doc in quantization_weight_only (#1311)
n1ck-guo Oct 16, 2023
3f1bc4f
update CONTRIBUTING.md (#1325)
chensuyue Oct 17, 2023
0f5a5d1
Add table-transformer-detection ONNXRT example (#1314)
yuwenzho Oct 17, 2023
b244f81
Update gptj example with the newest GPTQ API. (#1277)
YIYANGCAI Oct 18, 2023
7b20588
update Neural Insights deps version(#1331)
aradys Oct 19, 2023
83805b2
Remove 1.x API (1/N) (#1323)
yiliu30 Oct 19, 2023
4d39d74
Update ITREX version in ONNXRT WOQ example and fix bugs in hf models …
yuwenzho Oct 19, 2023
e7715bd
Enable the tuning of WOQ algorithm (#1328)
Kaihui-intel Oct 20, 2023
13b540c
Bump postcss from 7.0.39 to 8.4.31 in /neural_insights/gui (#1343)
dependabot[bot] Oct 23, 2023
de099ab
Update v2.3 release data (#1344)
chensuyue Oct 23, 2023
3cdaa07
add notebook example for pytorch (#1300)
violetch24 Oct 24, 2023
c6167d8
Support MatMulNBit op for ort 1.17 (#1327)
mengniwang95 Oct 24, 2023
6f6aa7a
refine release binary build for 3.0 API (#1336)
chensuyue Oct 24, 2023
b1a6f1c
fix bug in sq torch backend (#1342)
xin3he Oct 24, 2023
18fdb08
Adjust pytorch distilbert notebook
bmyrcha Oct 24, 2023
6767d79
Merge branch 'master' of github.com:intel/neural-compressor into bmyr…
bmyrcha Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@
"outputs": [],
"source": [
"# install neural-compressor from source\n",
"import sys\n",
"!git clone https://github.com/intel/neural-compressor.git\n",
"%cd ./neural-compressor\n",
"!pip install -r requirements.txt\n",
"!python setup.py install\n",
"!{sys.executable} -m pip install -r requirements.txt\n",
"!{sys.executable} setup.py install\n",
"%cd ..\n",
"# or install stable basic version from pypi\n",
"# pip install neural-compressor"
"# pip install neural-compressor\n"
]
},
{
Expand All @@ -65,10 +66,8 @@
},
"outputs": [],
"source": [
"# install onnx related packages\n",
"!pip install onnx onnxruntime onnxruntime-extensions\n",
"# install other packages used in this notebook.\n",
"!pip install torch transformers accelerate coloredlogs sympy numpy sentencepiece protobuf optimum"
"# install required packages\n",
"!{sys.executable} install -r requirements.txt\n"
]
},
{
Expand Down Expand Up @@ -168,7 +167,7 @@
"source": [
"!export GLUE_DIR=./glue_data\n",
"!wget https://raw.githubusercontent.com/Shimao-Zhang/Download_GLUE_Data/master/download_glue_data.py\n",
"!python download_glue_data.py --data_dir=GLUE_DIR --tasks=SST"
"!{sys.executable} download_glue_data.py --data_dir=GLUE_DIR --tasks=SST\n"
]
},
{
Expand All @@ -193,7 +192,7 @@
"int8_model_path = \"onnx-model/int8-model.onnx\"\n",
"data_path = \"./GLUE_DIR/SST-2\"\n",
"task = \"sst-2\"\n",
"batch_size = 8"
"batch_size = 8\n"
]
},
{
Expand Down Expand Up @@ -343,7 +342,7 @@
" label=label\n",
" )\n",
" features.append(feats)\n",
" return features"
" return features\n"
]
},
{
Expand Down Expand Up @@ -377,7 +376,7 @@
" model_name_or_path=model_name_or_path,\n",
" model_type=\"distilbert\",\n",
" task=task)\n",
"dataloader = DataLoader(framework=\"onnxruntime\", dataset=dataset, batch_size=batch_size)"
"dataloader = DataLoader(framework=\"onnxruntime\", dataset=dataset, batch_size=batch_size)\n"
]
},
{
Expand Down Expand Up @@ -448,7 +447,7 @@
" elif output_mode == \"regression\":\n",
" processed_preds = np.squeeze(self.pred_list)\n",
" result = transformers.glue_compute_metrics(self.task, processed_preds, self.label_list)\n",
" return result[self.return_key[self.task]]"
" return result[self.return_key[self.task]]\n"
]
},
{
Expand Down Expand Up @@ -486,7 +485,7 @@
" ort_inputs.update({inputs_names[i]: inputs[i]})\n",
" predictions = session.run(None, ort_inputs)\n",
" metric.update(predictions[0], labels)\n",
" return metric.result()"
" return metric.result()\n"
]
},
{
Expand Down Expand Up @@ -567,7 +566,7 @@
" num_heads=num_heads,\n",
" hidden_size=hidden_size,\n",
" optimization_options=opt_options)\n",
"model = model_optimizer.model"
"model = model_optimizer.model\n"
]
},
{
Expand Down Expand Up @@ -722,7 +721,7 @@
" config,\n",
" eval_func=eval_func,\n",
" calib_dataloader=dataloader)\n",
"q_model.save(int8_model_path)"
"q_model.save(int8_model_path)\n"
]
},
{
Expand Down
12 changes: 12 additions & 0 deletions examples/notebook/onnxruntime/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
onnx
onnxruntime
onnxruntime-extensions
torch
transformers
accelerate
coloredlogs
sympy
numpy
sentencepiece
protobuf
optimum
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
"outputs": [],
"source": [
"# install neural-compressor from source\n",
"import sys\n",
"!git clone https://github.com/intel/neural-compressor.git\n",
"%cd ./neural-compressor\n",
"!pip install -r requirements.txt\n",
"!python setup.py install\n",
"!{sys.executable} -m pip install -r requirements.txt\n",
"!{sys.executable} setup.py install\n",
"%cd ..\n",
"\n",
"# or install stable basic version from pypi\n",
"!pip install neural-compressor"
"!{sys.executable} -m pip install neural-compressor\n"
]
},
{
Expand All @@ -62,7 +63,7 @@
"outputs": [],
"source": [
"# install other packages used in this notebook.\n",
"!pip install torch>=1.9.0 transformers>=4.16.0 accelerate sympy numpy sentencepiece!=0.1.92 protobuf<=3.20.3 datasets>=1.1.3 scipy scikit-learn Keras-Preprocessing"
"!{sys.executable} -m pip install -r requirements.txt\n"
]
},
{
Expand Down Expand Up @@ -303,10 +304,10 @@
"outputs": [],
"source": [
"# fp32 benchmark\n",
"!python benchmark.py --input_model ./pytorch_model.bin 2>&1|tee fp32_benchmark.log\n",
"!{sys.executable} benchmark.py --input_model ./pytorch_model.bin 2>&1|tee fp32_benchmark.log\n",
"\n",
"# int8 benchmark\n",
"!python benchmark.py --input_model ./saved_results/best_model.pt 2>&1|tee int8_benchmark.log\n"
"!{sys.executable} benchmark.py --input_model ./saved_results/best_model.pt 2>&1|tee int8_benchmark.log\n"
]
}
],
Expand Down
11 changes: 11 additions & 0 deletions examples/notebook/pytorch/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
torch>=1.9.0
transformers>=4.16.0
accelerate
sympy
numpy
sentencepiece!=0.1.92
protobuf<=3.20.3
datasets>=1.1.3
scipy
scikit-learn
Keras-Preprocessing
8 changes: 8 additions & 0 deletions examples/notebook/tensorflow/resnet/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
numpy
neural-compressor
tensorflow
datasets
requests
urllib3
pyOpenSSL
git+https://github.com/huggingface/huggingface_hub
33 changes: 17 additions & 16 deletions examples/notebook/tensorflow/resnet/resnet_quantization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"!conda install python==3.10 -y\n",
"!pip install neural-compressor\n",
"!wget -nc https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_6/resnet50_fp32_pretrained_model.pb\n",
"!pip install tensorflow\n",
"!pip install datasets\n",
"!pip install git+https://github.com/huggingface/huggingface_hub"
"!{sys.executable} -m pip install -r requirements.txt \n",
"\n",
"!wget -nc https://storage.googleapis.com/intel-optimized-tensorflow/models/v1_6/resnet50_fp32_pretrained_model.pb\n"
]
},
{
Expand All @@ -43,9 +42,11 @@
"metadata": {},
"outputs": [],
"source": [
"print(sys.executable)\n",
"!{sys.executable} -m pip list\n",
"import tensorflow as tf\n",
"import numpy as np\n",
"import datasets"
"import datasets\n"
]
},
{
Expand All @@ -63,8 +64,8 @@
"source": [
"# login to huggingface to download the imagenet-1k dataset\n",
"# you should replace this read-only token with your own by create one on (https://huggingface.co/settings/tokens)\n",
"# !huggingface-cli login --token <YOUR HUGGINGFACE TOKEN>\n",
"!huggingface-cli login --token hf_xxxxxxxxxxxxxxxxxxxxxx"
"from huggingface_hub.hf_api import HfFolder\n",
"HfFolder.save_token('hf_xxxxxxxxxxxxxxxxxxxxxx')\n"
]
},
{
Expand All @@ -75,8 +76,8 @@
"source": [
"from datasets import load_dataset\n",
"# load dataset in streaming way will get an IterableDatset\n",
"calib_dataset = load_dataset('imagenet-1k', split='train', streaming=True, use_auth_token=True)\n",
"eval_dataset = load_dataset('imagenet-1k', split='validation', streaming=True, use_auth_token=True)"
"calib_dataset = load_dataset('imagenet-1k', split='train', streaming=True, token=True)\n",
"eval_dataset = load_dataset('imagenet-1k', split='validation', streaming=True, token=True)\n"
]
},
{
Expand All @@ -97,7 +98,7 @@
" return datasets.Dataset.from_dict(data)\n",
"\n",
"sub_calib_dataset = sample_data(calib_dataset, MAX_SAMPLE_LENGTG)\n",
"sub_eval_dataset = sample_data(eval_dataset, MAX_SAMPLE_LENGTG)"
"sub_eval_dataset = sample_data(eval_dataset, MAX_SAMPLE_LENGTG)\n"
]
},
{
Expand Down Expand Up @@ -136,7 +137,7 @@
" batch_inputs = []\n",
" labels = []\n",
" def __len__(self):\n",
" return self.length"
" return self.length\n"
]
},
{
Expand All @@ -146,7 +147,7 @@
"outputs": [],
"source": [
"calib_dataloader = CustomDataloader(dataset=sub_calib_dataset, batch_size=32)\n",
"eval_dataloader = CustomDataloader(dataset=sub_eval_dataset, batch_size=32)"
"eval_dataloader = CustomDataloader(dataset=sub_eval_dataset, batch_size=32)\n"
]
},
{
Expand Down Expand Up @@ -193,7 +194,7 @@
" return acc\n",
"\n",
"q_model = quantization.fit(\"./resnet50_fp32_pretrained_model.pb\", conf=conf, calib_dataloader=calib_dataloader, eval_func=eval_func)\n",
"q_model.save(\"resnet50_int8.pb\")"
"q_model.save(\"resnet50_int8.pb\")\n"
]
},
{
Expand Down Expand Up @@ -221,7 +222,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python resnet_benchmark.py --input_model resnet50_fp32_pretrained_model.pb 2>&1|tee fp32_benchmark.log"
"!{sys.executable} resnet_benchmark.py --input_model resnet50_fp32_pretrained_model.pb 2>&1|tee fp32_benchmark.log\n"
]
},
{
Expand All @@ -237,7 +238,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python resnet_benchmark.py --input_model resnet50_int8.pb 2>&1|tee int8_benchmark.log"
"!{sys.executable} resnet_benchmark.py --input_model resnet50_int8.pb 2>&1|tee int8_benchmark.log\n"
]
},
{
Expand Down
5 changes: 5 additions & 0 deletions examples/notebook/tensorflow/vgg19_ibean/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
numpy
matplotlib
tensorflow
tensorflow-hub
tensorflow-datasets