Hi,
I’ve tried to export simple model using ONNX export and faced an error that ask me to report a bug.
import torch 
import onnx 
import io

import torch._C as _C
OperatorExportTypes = _C._onnx.OperatorExportTypes

class Net(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.quant = torch.quantization.QuantStub()
        self.cnn = torch.nn.Conv2d(1,1,1)
    def forward(self, x):
        x = self.quant(x)
        return self.cnn(x)

model = Net()
model.qconfig = torch.quantization.get_default_qconfig('fbgemm')
torch.backends.quantized.engine = 'fbgemm'
model = torch.quantization.prepare(model, inplace=False)
torch.quantization.convert(model, inplace=True)
print(model)
inputs = torch.ones((1,10,224,224))
with torch.no_grad():
    with io.BytesIO() as f:
        torch.onnx.export(
            model,
            inputs,
            f,
            operator_export_type=OperatorExportTypes.ONNX_ATEN_FALLBACK,
#             verbose=True,  # NOTE: uncomment this for debugging
#             export_params=True,
        )
        onnx_model = onnx.load_from_string(f.getvalue())

Net(
  (quant): Quantize(scale=tensor([1.]), zero_point=tensor([0]), dtype=torch.quint8)
  (cnn): QuantizedConv2d(1, 1, kernel_size=(1, 1), stride=(1, 1), scale=1.0, zero_point=0)
)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-42-9f9e68519c44> in <module>
     27             model,
     28             inputs,
---> 29             f,
     30 #             operator_export_type=OperatorExportTypes.ONNX_ATEN_FALLBACK,
     31 #             verbose=True,  # NOTE: uncomment this for debugging

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/onnx/__init__.py in export(model, args, f, export_params, verbose, training, input_names, output_names, aten, export_raw_ir, operator_export_type, opset_version, _retain_param_name, do_constant_folding, example_outputs, strip_doc_string, dynamic_axes, keep_initializers_as_inputs, custom_opsets, enable_onnx_checker, use_external_data_format)
    170                         do_constant_folding, example_outputs,
    171                         strip_doc_string, dynamic_axes, keep_initializers_as_inputs,
--> 172                         custom_opsets, enable_onnx_checker, use_external_data_format)
    173 
    174 

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/onnx/utils.py in export(model, args, f, export_params, verbose, training, input_names, output_names, aten, export_raw_ir, operator_export_type, opset_version, _retain_param_name, do_constant_folding, example_outputs, strip_doc_string, dynamic_axes, keep_initializers_as_inputs, custom_opsets, enable_onnx_checker, use_external_data_format)
     90             dynamic_axes=dynamic_axes, keep_initializers_as_inputs=keep_initializers_as_inputs,
     91             custom_opsets=custom_opsets, enable_onnx_checker=enable_onnx_checker,
---> 92             use_external_data_format=use_external_data_format)
     93 
     94 

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/onnx/utils.py in _export(model, args, f, export_params, verbose, training, input_names, output_names, operator_export_type, export_type, example_outputs, propagate, opset_version, _retain_param_name, do_constant_folding, strip_doc_string, dynamic_axes, keep_initializers_as_inputs, fixed_batch_size, custom_opsets, add_node_names, enable_onnx_checker, use_external_data_format)
    508                                                             example_outputs, propagate,
    509                                                             _retain_param_name, val_do_constant_folding,
--> 510                                                             fixed_batch_size=fixed_batch_size)
    511 
    512             # TODO: Don't allocate a in-memory string for the protobuf

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/onnx/utils.py in _model_to_graph(model, args, verbose, input_names, output_names, operator_export_type, example_outputs, propagate, _retain_param_name, do_constant_folding, _disable_torch_constant_prop, fixed_batch_size)
    348             model.graph, tuple(in_vars), False, propagate)
    349     else:
--> 350         graph, torch_out = _trace_and_get_graph_from_model(model, args)
    351         state_dict = _unique_state_dict(model)
    352         params = list(state_dict.values())

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/onnx/utils.py in _trace_and_get_graph_from_model(model, args)
    305 
    306     trace_graph, torch_out, inputs_states = \
--> 307         torch.jit._get_trace_graph(model, args, _force_outplace=False, _return_inputs_states=True)
    308     warn_on_static_input_change(inputs_states)
    309 

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/jit/__init__.py in _get_trace_graph(f, args, kwargs, _force_outplace, return_inputs, _return_inputs_states)
    275     if not isinstance(args, tuple):
    276         args = (args,)
--> 277     outs = ONNXTracedModule(f, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
    278     return outs
    279 

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    556             result = self._slow_forward(*input, **kwargs)
    557         else:
--> 558             result = self.forward(*input, **kwargs)
    559         for hook in self._forward_hooks.values():
    560             hook_result = hook(self, input, result)

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/jit/__init__.py in forward(self, *args)
    358             in_vars + module_state,
    359             _create_interpreter_name_lookup_fn(),
--> 360             self._force_outplace,
    361         )
    362 

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/jit/__init__.py in wrapper(*args)
    342             trace_inputs = _unflatten(args[:len(in_vars)], in_desc)
    343 
--> 344             ret_inputs.append(tuple(x.clone(memory_format=torch.preserve_format) for x in args))
    345             if self._return_inputs_states:
    346                 inputs_states.append(_unflatten(args[:len(in_vars)], in_desc))

~/anaconda2/envs/pytorch-gpu/lib/python3.7/site-packages/torch/jit/__init__.py in <genexpr>(.0)
    342             trace_inputs = _unflatten(args[:len(in_vars)], in_desc)
    343 
--> 344             ret_inputs.append(tuple(x.clone(memory_format=torch.preserve_format) for x in args))
    345             if self._return_inputs_states:
    346                 inputs_states.append(_unflatten(args[:len(in_vars)], in_desc))

RuntimeError: self.qscheme() == at::kPerTensorAffine INTERNAL ASSERT FAILED at /opt/conda/conda-bld/pytorch_1586761698468/work/aten/src/ATen/native/quantized/QTensor.cpp:190, please report a bug to PyTorch. clone for quantized Tensor only works for PerTensorAffine scheme right now

What do I do incorrectly?