RuntimeError: shape '[64, 1, 1, 1]' is invalid for input of size 1
Closed this issue · 3 comments
Hello, when i run the demo code, i meet a error RuntimeError: shape '[64, 1, 1, 1]' is invalid for input of size 1 and i feel confused.....
code is :
import torchvision.models as models
from mqbench.prepare_by_platform import prepare_by_platform, BackendType
from mqbench.utils.state import enable_calibration, enable_quantization
from mqbench.convert_deploy import convert_deploy
model = models.dict'resnet18'
model.eval()
backend = BackendType.Tensorrt
model = prepare_by_platform(model, backend)
enable_quantization(model)
input_shape = {'data': [1, 3, 224, 224]}
convert_deploy(model, backend, input_shape)
after modify reshape -> expand in _fake_quantize_learnable_per_channel_affine_training function, in lsq.py, bugs fixed
zero_point = grad_scale(zero_point, grad_factor).expand(new_shape) # reshape -> expand
scale = grad_scale(scale, grad_factor).expand(new_shape) # reshape -> expand
The specific reason is that you skip the calibration
stage, which scale
shape modified in.
Anyway, replace reshape to expand looks great.
This issue has not received any updates in 120 days. Please reply to this issue if this still unresolved!