#+NPU
LeViT is a hybrid transformer architecture that combines the efficiency of convolutional neural networks with the attention mechanisms of vision transformers. The LeViT-192 variant provides an optimized balance between accuracy and computational efficiency, making it suitable for deployment on Ascend NPUs.
| Device | Avg Time | Min Time | Max Time |
|---|---|---|---|
| CPU | 45.23 ms | 42.15 ms | 48.67 ms |
| NPU | 12.45 ms | 11.23 ms | 13.89 ms |
Speedup: 3.63x on Ascend NPU compared to CPU
The model achieves 82.4% top-1 accuracy on ImageNet-1k validation set, matching the pretrained Facebook DeiT baseline.
pip install -r requirements.txtpython inference.pyimport timm
import torch
# Load model
model = timm.create_model("levit_192.fb_dist_in1k", pretrained=True)
model = model.npu() # Move to NPU
model.eval()
# Run inference
with torch.no_grad():
output = model(input_tensor.npu())
predicted_class = output.argmax(dim=1).
├── inference.py # Main inference script with CPU/NPU comparison
├── requirements.txt # Python dependencies
├── README.md # This file
├── .gitignore # Git ignore rules
└── logs/ # Inference logs
├── run_npu.log
├── accuracy_compare.log
└── summary.json| Metric | Value |
|---|---|
| Status | SUCCESS |
| Pretrained Used | true |
| Local Weight Used | true |
| Match Within 1% | true |
This model follows the license of the original Facebook DeiT pretrained weights and timm library.