pytorch/test
Andrew Or 8fab682e47 [Quant][fx][bc-breaking] Do not move models to CPU in convert (#80555)
Summary: Previously, we automatically moved the model to CPU in
torch.ao.quantization.fx.convert to work around the issue where
certain functions called by convert expect CPU arguments. This
commit pushes this responsibility to the caller since it is the
user's decision of which device to use.

Test Plan:
python test/test_quantization.py TestQuantizeFx
python test/test_quantization.py TestQuantizeFxOps

BC-breaking Notes:

Before:
```
model = resnet18(...)
model = prepare_fx(model, qconfig_mapping, example_inputs)
... # calibrate
model = convert_fx(model)
```
After:
```
model = resnet18(...)
model.cpu()
model = prepare_fx(model, qconfig_mapping, example_inputs)
... # calibrate
model = convert_fx(model)
```

Reviewers: jerryzh168

Subscribers: jerryzh168

Differential Revision: [D37528830](https://our.internmc.facebook.com/intern/diff/D37528830)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80555
Approved by: https://github.com/jerryzh168
2022-07-08 19:23:57 +00:00
..
ao/sparsity Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
autograd Fix autograd.functional tests to not fail with logging tensor 2022-04-20 20:32:40 +00:00
benchmark_utils Add CPU slow test job (#73748) 2022-03-23 21:17:27 +00:00
bottleneck_test
cpp Fix retains grad behavior after in-place (#79996) 2022-07-08 19:13:28 +00:00
cpp_api_parity
cpp_extensions Revert "Revert "Add support for directly passing symint to empty"" (#79954) 2022-07-04 20:08:55 +00:00
custom_backend [ROCM] Enable custom tests on rocm 2022-04-26 14:22:14 +00:00
custom_operator set data permits requires_grad=True on integer tensor 2022-06-01 15:56:32 +00:00
distributed Revert "Revert "[FSDP Optim State] Remove checkpoint prefix (#80480)"" (#80936) 2022-07-06 22:21:07 +00:00
distributions Setting validation flag for Distributions tests to work with TorchDynamo (#80081) 2022-06-24 04:51:51 +00:00
error_messages
expect Support compressed sparse tensors with dense dimensions (#80565) 2022-07-07 16:21:12 +00:00
forward_backward_compatibility [PyTorch Edge] Add serialization/deserialization of Sparse Quantize Linear Packed Params (#80474) 2022-07-07 15:30:02 +00:00
fx Define rules for additional operations needed for HF model (#80147) 2022-07-08 06:19:38 +00:00
jit Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
jit_hooks [ROCM] Enable custom tests on rocm 2022-04-26 14:22:14 +00:00
lazy functionalization <> LTC integration (take 3) (#80251) 2022-06-26 23:10:21 +00:00
mobile Fix backward of binary_cross_entropy_with_logits 2022-06-23 01:31:08 +00:00
onnx Remove split functional wrapper (#74727) 2022-07-08 19:21:22 +00:00
package Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
quantization [Quant][fx][bc-breaking] Do not move models to CPU in convert (#80555) 2022-07-08 19:23:57 +00:00
scripts
test_img
typing Add typing for torch.return_type 2022-03-29 02:17:21 +00:00
allowlist_for_publicAPI.json [Array API] Add linalg.vecdot (#70542) 2022-07-08 15:37:58 +00:00
create_dummy_torchscript_model.py Add test for FC/BC for torchscript file. 2022-04-13 23:23:13 +00:00
defs.bzl Add all bzl files per D36874458 2022-06-06 09:40:19 -07:00
delete.py
HowToWriteTestsUsingFileCheck.md
linear.py
load_torchscript_model.py Add test for FC/BC for torchscript file. 2022-04-13 23:23:13 +00:00
profiler_utils_mock_events.json [Profiler] Add heuristic to rank events base on computed metrics (#80094) 2022-07-05 22:06:02 +00:00
run_test.py Enable test: distributed/algorithms/quantization/test_quantization (#80097) 2022-07-01 01:32:33 +00:00
simulate_nccl_errors.py
test_ao_sparsity.py [ao][sparsity] removing leading '.' from fqn in utils (#79774) 2022-06-30 00:00:56 +00:00
test_autocast.py Update operator list for AutocastCPU (#68725) 2022-05-11 17:28:35 +00:00
test_autograd.py Fix retains grad behavior after in-place (#79996) 2022-07-08 19:13:28 +00:00
test_binary_ufuncs.py Don't check overflow for scalar arg in comparison ops (#78881) 2022-06-05 01:43:51 +00:00
test_bundled_images.py
test_bundled_inputs.py
test_complex.py [testing] Update dispatch macros (#74977) 2022-03-30 14:13:21 -07:00
test_cpp_api_parity.py
test_cpp_extensions_aot.py Allow relocatable device code linking in pytorch CUDA extensions (#78225) 2022-06-02 21:35:56 +00:00
test_cpp_extensions_jit.py Remove breakpad dependency 2022-05-03 20:21:55 +00:00
test_cuda_primary_ctx.py
test_cuda.py Add check for cuda lazy init (#80912) 2022-07-06 01:39:27 +00:00
test_dataloader.py Support percentages in random_split (#78877) 2022-06-16 02:00:25 +00:00
test_datapipe.py Expanding DataPipe to support DataFrames (#71931) 2022-07-08 18:46:10 +00:00
test_decomp.py Reference implementations for rsqrt and native_layer_norm (#79413) 2022-06-17 07:24:02 +00:00
test_deploy.py
test_determination.py
test_dispatch.py Make string serialization of C++ FunctionSchema consistent with torchgen.model.FunctionSchema 2022-05-24 19:39:26 +00:00
test_dynamic_shapes.py reinstate size and shape returning symints (#79560) 2022-07-08 01:17:33 +00:00
test_expanded_weights.py [Expanded Weights] fix unbatched support issue (#80891) 2022-07-07 14:56:32 +00:00
test_fake_tensor.py Revert "Allow returned tensor impls in fallback (#80545)" 2022-07-01 01:30:40 +00:00
test_foreach.py [testing] Update dispatch macros (#74977) 2022-03-30 14:13:21 -07:00
test_function_schema.py Expose is_out to python 2022-06-01 07:39:24 +00:00
test_functional_autograd_benchmark.py
test_functional_optim.py
test_functionalization.py Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
test_futures.py
test_fx_experimental.py Move serialize_module() out of OSS graph_manipulation.py to internal (#80785) 2022-07-05 23:39:13 +00:00
test_fx_passes.py FX graph partitioner and fuser (#79439) 2022-06-24 18:49:37 +00:00
test_fx.py Add Dropout1d module 2022-06-15 14:39:07 +00:00
test_hub.py torch.hub security improvement: add new trust_repo parameter 2022-04-05 09:29:25 +00:00
test_import_stats.py Revert "Revert "[ci] remove remaining RDS dependency"" 2022-06-15 10:04:13 -07:00
test_indexing.py fix set item to scalar tensor missing gradient info 2022-05-25 21:22:44 +00:00
test_jit_autocast.py Conv BN folding data type issue when conv has no bias (#78241) 2022-05-26 18:42:17 +00:00
test_jit_cuda_fuser.py Add OpInfo for torch.equal and fix support for non-standard bools 2022-06-20 23:48:39 +00:00
test_jit_disabled.py
test_jit_fuser_legacy.py
test_jit_fuser_te.py Add OpInfo for torch.equal and fix support for non-standard bools 2022-06-20 23:48:39 +00:00
test_jit_fuser.py
test_jit_legacy.py Remove mentions of non-existing test_jit_py3 (#78977) 2022-06-07 02:28:45 +00:00
test_jit_llga_fuser.py [Reland take-2] Add JIT graph fuser for oneDNN Graph API (v0.5) 2022-05-05 16:57:03 +00:00
test_jit_profiling.py Remove mentions of non-existing test_jit_py3 (#78977) 2022-06-07 02:28:45 +00:00
test_jit_simple.py Remove mentions of non-existing test_jit_py3 (#78977) 2022-06-07 02:28:45 +00:00
test_jit_string.py
test_jit.py Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
test_jiterator.py Python Jiterator supports multiple outputs (#78139) 2022-05-24 21:52:56 +00:00
test_kernel_launch_checks.py
test_license.py
test_linalg.py Make slogdet, linalg.sloget and logdet support metatensors (#79742) 2022-07-01 16:09:21 +00:00
test_logging.py [Codemod][Codemod deprecated unittest asserts] fbcode//caffe2/test (#71708) 2022-03-15 19:28:52 +00:00
test_masked.py Use scatter_reduce to support masked reductions on sparse COO tensors (sum, prod, amin, amax) 2022-05-06 15:40:22 +00:00
test_meta.py [Array API] Add linalg.vecdot (#70542) 2022-07-08 15:37:58 +00:00
test_metal.py
test_mkldnn.py Enable fp32/bf16 PRelu forward and backward in MkldnnCPU path (#60427) 2022-05-10 17:29:11 +00:00
test_mobile_optimizer.py
test_model_dump.py
test_module_init.py Revert "Add prelu op and module for quantized CPU backend (#73491)" 2022-06-30 12:54:39 +00:00
test_modules.py Support both train / eval modes for ModuleInfo 2022-06-09 20:57:17 +00:00
test_monitor.py
test_mps.py [MPS] Fix LSTM batch_first output transposed (#80597) 2022-07-07 07:18:00 +00:00
test_multiprocessing_spawn.py
test_multiprocessing.py Fix MPS interaction with autograd engine 2022-05-17 21:26:16 +00:00
test_namedtensor.py Revert "Enable dim=None for torch.sum (#75845)" 2022-06-16 22:01:41 +00:00
test_namedtuple_return_api.py Expose linalg.solve_ex (#80073) 2022-07-01 16:09:23 +00:00
test_native_functions.py
test_native_mha.py [PyTorch] Round T up to next multiple of 8 in NestedTensor case 2022-05-25 20:34:19 +00:00
test_nestedtensor.py implement numel and tests for nested tensor (#80424) 2022-06-28 18:02:44 +00:00
test_nn.py Don't implicitly convert to channels-first in MaxPool3D on CUDA (#80748) 2022-07-08 04:26:01 +00:00
test_nnapi.py
test_numba_integration.py
test_numpy_interop.py ENH: Add a force argument to numpy() (#78564) 2022-06-06 14:14:17 +00:00
test_openmp.py
test_ops_gradients.py Various OpInfo architecture improvements 2022-04-18 21:55:32 +00:00
test_ops_jit.py Minor fix in jit tests to pass TorchDynamo (#79903) 2022-06-21 00:42:02 +00:00
test_ops.py Register unregistered refs and add a test to check registration (#80497) 2022-07-08 16:29:52 +00:00
test_optim.py Revert "Adding maximize to ASGD (#80323)" 2022-07-08 13:35:31 +00:00
test_overrides.py Remove split functional wrapper (#74727) 2022-07-08 19:21:22 +00:00
test_package.py
test_per_overload_api.py Update __torch_dispatch__ to return op overload instead of the opoverload packet function (#72673) 2022-03-07 22:38:42 +00:00
test_prims.py Correct cbrt implementation (#80443) 2022-07-07 16:15:42 +00:00
test_profiler_tree.py [Profiler][Trivial] Update test_profiler_tree 2022-06-22 22:30:33 +00:00
test_profiler.py [Profiler] Add Pattern that detects extra cuda copy (#80572) 2022-07-07 20:22:42 +00:00
test_proxy_tensor.py Stopped ProxyTensor from turning aten::lift tensors into proxy objects (#81024) 2022-07-07 04:54:31 +00:00
test_pruning_op.py
test_public_bindings.py Wconstab/reland pysymint (#79795) 2022-06-20 22:55:06 +00:00
test_python_dispatch.py Remove split functional wrapper (#74727) 2022-07-08 19:21:22 +00:00
test_pytree.py Register torch.return_types.* as pytree nodes 2022-04-19 13:46:20 +00:00
test_quantization.py [ao] Added framework for ModelReport Outlier Detector (#80743) 2022-07-01 01:03:31 +00:00
test_reductions.py Add complex_to_float option in ReductionOpInfo 2022-06-01 09:31:45 +00:00
test_scatter_gather_ops.py Add integer support to scatter_reduce (#80324) 2022-06-29 21:10:26 +00:00
test_segment_reductions.py reland Add offsets-based reduction to segment_reduce (CPU, CUDA) 2022-06-17 15:49:31 +00:00
test_serialization.py Make sure requires_grad is propagated for all backend 2022-04-25 19:31:24 +00:00
test_set_default_mobile_cpu_allocator.py
test_shape_ops.py Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
test_show_pickle.py
test_sort_and_select.py MAINT: Harmonize argsort params with array_api (#75162) 2022-06-09 12:32:01 +00:00
test_sparse_csr.py Support sparse/dense_dim for Compressed Sparse tensors (#80901) 2022-07-08 15:49:35 +00:00
test_sparse.py Add spdiags sparse matrix initialization (#78439) 2022-07-01 01:11:54 +00:00
test_spectral_ops.py [complex32] fft support (cuda only) (#74857) 2022-05-12 04:28:55 +00:00
test_stateless.py Added setattr to functional_call. (#77137) 2022-05-17 05:40:46 +00:00
test_static_runtime.py [Static Runtime] test case for staticRuntime::runAsync() API (#80407) 2022-07-05 23:40:53 +00:00
test_subclass.py Throw a nice error when SubTensor.__torch_dispatch__() returns the wrong type for detach() 2022-05-18 20:00:42 +00:00
test_tensor_creation_ops.py Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
test_tensorboard.py [tensorboard] update assertion error for scalar() and fix docs (#76859) 2022-06-16 05:24:20 +00:00
test_tensorexpr_pybind.py [NNC] Lowering function generates the output buffer with the specified stride (#76529) 2022-05-04 20:04:22 +00:00
test_tensorexpr.py [NNC] channels last propagation within NNC fusion group (#76948) 2022-05-30 18:31:49 +00:00
test_testing.py Validate Sparse Compressed tensor inputs (#79385) 2022-06-27 17:19:54 +00:00
test_throughput_benchmark.py
test_torch.py Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
test_transformers.py Add test for torchscripting nn.TransformerEncoder, including fast path (#79796) 2022-06-17 22:00:49 +00:00
test_type_hints.py
test_type_info.py ENH: Convert finfo.tiny to finfo.smallest_normal (#76292) 2022-05-20 00:59:48 +00:00
test_type_promotion.py Make addcmul and addcdiv support different dtypes (#74234) 2022-07-06 10:20:33 +00:00
test_typing.py
test_unary_ufuncs.py update signbit docs and add -0. to reference testing for unary and binary functions. (#78349) 2022-06-06 13:48:08 +00:00
test_utils.py Revert "To add hipify_torch as a submodule in pytorch/third_party (#74704)" 2022-06-21 23:54:00 +00:00
test_view_ops.py Setup for running PyTorch tests with TorchDynamo and skips for known failing tests (#80106) 2022-07-07 18:57:33 +00:00
test_vmap.py
test_vulkan.py
test_xnnpack_integration.py