I have a post-training statically quantized NN. I want to change a couple of weight values of one of the convolution layer before the inference. The weight change should be based on int8 values and not on the save-format (which is torch.qint8 with corresponding scales and zero points). So far I have done the following:
# instantiate the quantized net (not shown here).

# get one of the conv layers
tmp = model_int8.state_dict()['features.0.weight']

# get int repr
tmp_int8 = tmp.int_repr()

# change value (value change is dependent on the int8 value)
tmp_int8[0][0][0][0] = new_value

# TODO: how to convert tmp_int8 to torch.qint8 type?
new_tmp = convert_int8_to_qint8(tmp_int8) # how to do this

# TODO: based on the above step:
model_int8.state_dict()['features.0.weight'] = new_tmp

My question is how to change the int8 tensor to torch.qint8 based on the scales and zero_points of the original weight tensor (something similar to torch.quantized_per_channel() but for int8 to qint8)? OR is there another way to do this?
Thank you.