diff --git a/docs/swin_guide.md b/docs/swin_guide.md index a96c9a15d..3bf5ba766 100644 --- a/docs/swin_guide.md +++ b/docs/swin_guide.md @@ -219,10 +219,10 @@ pip install timm==0.4.12 pip install termcolor==1.1.0 bash -x run_test_v1_int8.sh ##profile of swin-v1 INT8 model -bash -x run_test_v1_int8_accuracy.sh ##test accuracy of swin-v1 INT8 model +bash -x run_test_v1_int8_accuracy.sh ##test accuracy of swin-v1 INT8 model bash -x run_test_v2_int8.sh ##profile of swin-v2 INT8 model -bash -x run_test_v2_int8_accuracy.sh ##test accuracy of swin-v2 INT8 model +bash -x run_test_v2_int8_accuracy.sh ##test accuracy of swin-v2 INT8 model ``` Note: When testing PTQ accuracy for INT8 swin-v1-LARGE, we have to specify `--int8-mode 2` instead of `--int8-mode 1` in **run_test_int8.sh**. @@ -517,4 +517,4 @@ On chips with Ampere architectures (like A30, A100), user can use `export NVIDIA | BASE | 16 | 256 | 19.27 | 14.97 | 1.29 | | BASE | 24 | 384 | - | 135.38 | - | | LARGE | 16 | 256 | 31.37 | 24.20 | 1.30 | -| LARGE | 24 | 384 | - | - | - | \ No newline at end of file +| LARGE | 24 | 384 | - | - | - | diff --git a/examples/pytorch/swin/Swin-Transformer-Quantization/README.md b/examples/pytorch/swin/Swin-Transformer-Quantization/README.md index 4679cb9fb..657f37af4 100644 --- a/examples/pytorch/swin/Swin-Transformer-Quantization/README.md +++ b/examples/pytorch/swin/Swin-Transformer-Quantization/README.md @@ -172,7 +172,7 @@ For example, to evaluate the `Swin-T` with a single GPU. You can see **run.sh** python -m torch.distributed.launch --nproc_per_node 1 \ --master_port 12345 main.py \ --eval \ - --cfg SwinTransformer/configs/swin_tiny_patch4_window7_224.yaml \ + --cfg SwinTransformer/configs/swin/swin_tiny_patch4_window7_224.yaml \ --resume ./calib-checkpoint/swin_tiny_patch4_window7_224_calib.pth \ --data-path \ --int8-mode 1\ @@ -214,4 +214,4 @@ python -m torch.distributed.launch --nproc_per_node 4 \ --batch-size 128 \ --num-epochs 5 \ --qat-lr 1e-5 -``` \ No newline at end of file +``` diff --git a/examples/pytorch/swin/SwinTransformerWeightTransposeQKVWeight.py b/examples/pytorch/swin/SwinTransformerWeightTransposeQKVWeight.py index 1319e2600..97f34fe51 100644 --- a/examples/pytorch/swin/SwinTransformerWeightTransposeQKVWeight.py +++ b/examples/pytorch/swin/SwinTransformerWeightTransposeQKVWeight.py @@ -146,7 +146,9 @@ def __init__(self, layer_num, window_size, depths, num_heads, ths_path, weights= if version == 2: logit_scale_name = 'layers.{}.blocks.{}.attn.logit_scale'.format(layer_idx, block_idx) if logit_scale_name in weights: - self.weights.append(torch.clamp(weights[logit_scale_name], max=torch.log(torch.tensor(1. / 0.01))).exp()) + device = weights[logit_scale_name].device + max_value = torch.log(torch.tensor(1. / 0.01)).to(device) + self.weights.append(torch.clamp(weights[logit_scale_name], max=max_value).exp()) else: print("[ERROR][SwinTransformerWeights::__init__] missing weight {}.".format(logit_scale_name)) exit(-1)