Repository: pytorch
Issue: [bug] nn.functional.pad (circular) ubsan failure
Labels: module: nn,triaged,module: padding

## 🐛 Bug

Build with ASAN
```python
import torch
t = torch.ones((1, 3, 4, 4), dtype=torch.bool)
pad = (-1, 1, -2, 1)
out = torch.nn.functional.pad(t, pad, 'circular')
```

<details>

<summary> bt </summary>

Output
```
 run_with_asan python test/test_pad.py 
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/tuple:133:17: runtime error: load of value 190, which is not a valid value for type 'bool'
    #0 0x7f6f3765437d in std::_Head_base<0ul, bool, false>::_Head_base<bool&>(bool&) /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/tuple:133:17
    #1 0x7f6f4155d8ed in std::_Tuple_impl<0ul, bool>::_Tuple_impl<bool&>(bool&) /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/tuple:349:4
    #2 0x7f6f4155d80d in std::tuple<bool>::tuple<bool&, true>(bool&) /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/tuple:627:11
    #3 0x7f6f4155d72a in std::tuple<std::__decay_and_strip<bool&>::__type> std::make_tuple<bool&>(bool&) /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/tuple:1474:14
    #4 0x7f6f508d723b in function_traits<at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)>::ArgsTuple at::native::(anonymous namespace)::dereference_impl<function_traits<at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)>, 0ul>(char* restrict*, long const*, long, std::integer_sequence<unsigned long, 0ul>) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/cpu/Loops.h:50:10
    #5 0x7f6f508d6e13 in function_traits<at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)>::ArgsTuple at::native::(anonymous namespace)::dereference<function_traits<at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)> >(char* restrict*, long const*, long) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/cpu/Loops.h:59:10
    #6 0x7f6f508d6baa in void at::native::(anonymous namespace)::execute_op<at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), (void*)0>(char* restrict*, long const*, long, long, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/cpu/Loops.h:92:59
    #7 0x7f6f508d54f6 in void at::native::(anonymous namespace)::basic_loop<at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)>(char* restrict*, long const*, long, long, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/cpu/Loops.h:127:3
    #8 0x7f6f508d46d2 in void at::native::(anonymous namespace)::vectorized_loop<at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(char**, long, long, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/cpu/Loops.h:226:5
    #9 0x7f6f508d31ea in void at::native::(anonymous namespace)::cpu_kernel_vec<true, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(at::TensorIteratorBase&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&, long)::'lambda'(char**, long const*, long)::operator()(char**, long const*, long) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/cpu/Loops.h:302:7
    #10 0x7f6f508d2c26 in auto at::TensorIteratorBase::loop_2d_from_1d<void at::native::(anonymous namespace)::cpu_kernel_vec<true, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(at::TensorIteratorBase&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&, long)::'lambda'(char**, long const*, long)>(void at::native::(anonymous namespace)::cpu_kernel_vec<true, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(at::TensorIteratorBase&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&, long)::'lambda'(char**, long const*, long) const&)::'lambda'(char**, long const*, long, long)::operator()(char**, long const*, long, long) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/TensorIterator.h:255:9
    #11 0x7f6f508d236d in void c10::function_ref<void (char**, long const*, long, long)>::callback_fn<auto at::TensorIteratorBase::loop_2d_from_1d<void at::native::(anonymous namespace)::cpu_kernel_vec<true, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(at::TensorIteratorBase&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&, long)::'lambda'(char**, long const*, long)>(void at::native::(anonymous namespace)::cpu_kernel_vec<true, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(at::TensorIteratorBase&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&, long)::'lambda'(char**, long const*, long) const&)::'lambda'(char**, long const*, long, long)>(long, char**, long const*, long, long) /home/kshiteej/Pytorch/pytorch_opinfo/c10/util/FunctionRef.h:43:12
    #12 0x7f6f36a47e85 in c10::function_ref<void (char**, long const*, long, long)>::operator()(char**, long const*, long, long) const /home/kshiteej/Pytorch/pytorch_opinfo/c10/util/FunctionRef.h:64:12
    #13 0x7f6f36a34a08 in at::internal::serial_for_each(c10::ArrayRef<long>, c10::ArrayRef<long>, char**, unsigned long, c10::function_ref<void (char**, long const*, long, long)>, at::Range) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/TensorIteratorInternal.h:57:7
    #14 0x7f6f36a04d1f in at::TensorIteratorBase::serial_for_each(c10::function_ref<void (char**, long const*, long, long)>, at::Range) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/TensorIterator.cpp:695:3
    #15 0x7f6f36a03e97 in at::TensorIteratorBase::for_each(c10::function_ref<void (char**, long const*, long, long)>, long) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/TensorIterator.cpp:667:12
    #16 0x7f6f508d125f in void at::TensorIteratorBase::for_each<void at::native::(anonymous namespace)::cpu_kernel_vec<true, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(at::TensorIteratorBase&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&, long)::'lambda'(char**, long const*, long), 0>(void at::native::(anonymous namespace)::cpu_kernel_vec<true, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(at::TensorIteratorBase&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&, long)::'lambda'(char**, long const*, long), long) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/TensorIterator.h:266:5
    #17 0x7f6f508d0bdd in void at::native::(anonymous namespace)::cpu_kernel_vec<true, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool), at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)>(at::TensorIteratorBase&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(bool)&&, at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const::'lambda'(at::vec::(anonymous namespace)::Vectorized<bool>)&&, long) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/cpu/Loops.h:300:8
    #18 0x7f6f508952f4 in at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const::'lambda14'()::operator()() const /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/native/cpu/CopyKernel.cpp.AVX2.cpp:57:9
    #19 0x7f6f5084bae6 in at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool)::$_2::operator()() const /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/native/cpu/CopyKernel.cpp.AVX2.cpp:57:9
    #20 0x7f6f5084779d in at::native::(anonymous namespace)::copy_kernel(at::TensorIterator&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/native/cpu/CopyKernel.cpp.AVX2.cpp:57:9
    #21 0x7f6f378ccd3f in void at::native::DispatchStub<void (*)(at::TensorIterator&, bool), at::native::copy_stub>::operator()<at::TensorIterator&, bool&>(c10::DeviceType, at::TensorIterator&, bool&) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/DispatchStub.h:146:12
    #22 0x7f6f378a38a3 in at::native::copy_impl(at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/Copy.cpp:242:3
    #23 0x7f6f3789efe1 in at::native::copy_(at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/native/Copy.cpp:250:5
    #24 0x7f6f3e2ceed3 in at::(anonymous namespace)::(anonymous namespace)::wrapper__copy_(at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/RegisterCompositeExplicitAutograd.cpp:1614:10
    #25 0x7f6f3e480799 in c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor& (at::Tensor&, at::Tensor const&, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper__copy_(at::Tensor&, at::Tensor const&, bool))>, at::Tensor&, c10::guts::typelist::typelist<at::Tensor&, at::Tensor const&, bool> >::operator()(at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/impl/WrapFunctionIntoFunctor.h:13:16
    #26 0x7f6f3e480799 in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor& (at::Tensor&, at::Tensor const&, bool), &(at::(anonymous namespace)::(anonymous namespace)::wrapper__copy_(at::Tensor&, at::Tensor const&, bool))>, at::Tensor&, c10::guts::typelist::typelist<at::Tensor&, at::Tensor const&, bool> >, at::Tensor& (at::Tensor&, at::Tensor const&, bool)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:423
    #27 0x7f6f3bbadd70 in at::Tensor& c10::callUnboxedKernelFunction<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(void*, c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool&&) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/KernelFunction_impl.h:57:12
    #28 0x7f6f3bbaf6fb in at::Tensor& c10::KernelFunction::call<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/KernelFunction_impl.h:67:16
    #29 0x7f6f3bbaf6fb in at::Tensor& c10::Dispatcher::redispatch<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(c10::TypedOperatorHandle<at::Tensor& (at::Tensor&, at::Tensor const&, bool)> const&, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/dispatch/Dispatcher.h:536
    #30 0x7f6f39df81a0 in c10::TypedOperatorHandle<at::Tensor& (at::Tensor&, at::Tensor const&, bool)>::redispatch(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/dispatch/Dispatcher.h:398:41
    #31 0x7f6f39df81a0 in at::_ops::copy_::redispatch(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/Operators.cpp:5249
    #32 0x7f6f4ca20545 in at::redispatch::copy_(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/RedispatchFunctions.h:1714:16
    #33 0x7f6f4ca02664 in torch::ADInplaceOrView::copy_(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/torch/csrc/autograd/VariableTypeManual.cpp:269:7
    #34 0x7f6f4ca2b9a8 in c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor& (c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool), &(torch::ADInplaceOrView::copy_(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool))>, at::Tensor&, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool> >::operator()(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/impl/WrapFunctionIntoFunctor.h:13:16
    #35 0x7f6f4ca2b9a8 in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor& (c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool), &(torch::ADInplaceOrView::copy_(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool))>, at::Tensor&, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool> >, at::Tensor& (c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:440
    #36 0x7f6f3bbadd70 in at::Tensor& c10::callUnboxedKernelFunction<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(void*, c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool&&) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/KernelFunction_impl.h:57:12
    #37 0x7f6f3bbaf6fb in at::Tensor& c10::KernelFunction::call<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/KernelFunction_impl.h:67:16
    #38 0x7f6f3bbaf6fb in at::Tensor& c10::Dispatcher::redispatch<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(c10::TypedOperatorHandle<at::Tensor& (at::Tensor&, at::Tensor const&, bool)> const&, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/dispatch/Dispatcher.h:536
    #39 0x7f6f39df81a0 in c10::TypedOperatorHandle<at::Tensor& (at::Tensor&, at::Tensor const&, bool)>::redispatch(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/dispatch/Dispatcher.h:398:41
    #40 0x7f6f39df81a0 in at::_ops::copy_::redispatch(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/Operators.cpp:5249
    #41 0x7f6f4ca20545 in at::redispatch::copy_(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/RedispatchFunctions.h:1714:16
    #42 0x7f6f4ca15985 in torch::autograd::VariableType::(anonymous namespace)::copy_(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/torch/csrc/autograd/VariableTypeManual.cpp:129:5
    #43 0x7f6f4ca17ee8 in c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor& (c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool), &(torch::autograd::VariableType::(anonymous namespace)::copy_(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool))>, at::Tensor&, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool> >::operator()(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/impl/WrapFunctionIntoFunctor.h:13:16
    #44 0x7f6f4ca17ee8 in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor& (c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool), &(torch::autograd::VariableType::(anonymous namespace)::copy_(c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool))>, at::Tensor&, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool> >, at::Tensor& (c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/impl/make_boxed_from_unboxed_functor.h:440
    #45 0x7f6f3bbadd70 in at::Tensor& c10::callUnboxedKernelFunction<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(void*, c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool&&) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/KernelFunction_impl.h:57:12
    #46 0x7f6f39df70ce in at::Tensor& c10::KernelFunction::call<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(c10::OperatorHandle const&, c10::DispatchKeySet, at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/boxing/KernelFunction_impl.h:67:16
    #47 0x7f6f39df70ce in at::Tensor& c10::Dispatcher::call<at::Tensor&, at::Tensor&, at::Tensor const&, bool>(c10::TypedOperatorHandle<at::Tensor& (at::Tensor&, at::Tensor const&, bool)> const&, at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/dispatch/Dispatcher.h:527
    #48 0x7f6f39df70ce in c10::TypedOperatorHandle<at::Tensor& (at::Tensor&, at::Tensor const&, bool)>::call(at::Tensor&, at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/core/dispatch/Dispatcher.h:393
    #49 0x7f6f39df70ce in at::_ops::copy_::call(at::Tensor&, at::Tensor const&, bool) /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/Operators.cpp:5241
    #50 0x7f6fae53a5f4 in at::Tensor::copy_(at::Tensor const&, bool) const /home/kshiteej/Pytorch/pytorch_opinfo/build/aten/src/ATen/core/TensorBody.h:2374:12
    #51 0x7f6fb01b50bd in at::indexing::copy_to(at::Tensor const&, at::Tensor const&) /home/kshiteej/Pytorch/pytorch_opinfo/aten/src/ATen/TensorIndexing.h:353:9
    #52 0x7f6fb01af613 in torch::autograd::THPVariable_setitem(_object*, _object*, _object*) /home/kshiteej/Pytorch/pytorch_opinfo/torch/csrc/autograd/python_variable_indexing.cpp:431:5
    #53 0x555da398ff32 in _PyEval_EvalFrameDefault /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:1576
    #54 0x555da3904e93 in PyEval_EvalFrameEx /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:547:12
    #55 0x555da3904e93 in function_code_fastcall /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Objects/call.c:283:14
    #56 0x555da3904e93 in _PyFunction_FastCallKeywords /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Objects/call.c:408
    #57 0x555da39689c7 in call_function /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:4616
    #58 0x555da398f4ab in _PyEval_EvalFrameDefault /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:3124
    #59 0x555da38d6af1 in PyEval_EvalFrameEx /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:547:12
    #60 0x555da38d6af1 in _PyEval_EvalCodeWithName /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:3930:14
    #61 0x555da390502f in _PyFunction_FastCallKeywords /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Objects/call.c:433
    #62 0x555da39689c7 in call_function /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:4616
    #63 0x555da3993749 in _PyEval_EvalFrameDefault /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:3093
    #64 0x555da38d6af1 in PyEval_EvalFrameEx /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:547:12
    #65 0x555da38d6af1 in _PyEval_EvalCodeWithName /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:3930:14
    #66 0x555da38d7d08 in PyEval_EvalCodeEx /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:3959:12
    #67 0x555da39b28aa in PyEval_EvalCode /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/ceval.c:524:12
    #68 0x555da3a16f52 in run_mod /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/pythonrun.c:1035
    #69 0x555da3a20fd6 in PyRun_FileExFlags /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/pythonrun.c:988
    #70 0x555da3a211ab in PyRun_SimpleFileExFlags /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Python/pythonrun.c:429
    #71 0x555da3a21708 in pymain_run_file /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Modules/main.c:456
    #72 0x555da3a21708 in pymain_run_filename /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Modules/main.c:1646
    #73 0x555da3a21708 in pymain_run_python /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Modules/main.c:2907
    #74 0x555da3a21708 in pymain_main /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Modules/main.c:3068
    #75 0x555da3a2185b in _Py_UnixMain /home/conda/feedstock_root/build_artifacts/python_1613748395163/work/Modules/main.c:3103
    #76 0x7f6fbbdb90b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #77 0x555da399e900 in _start (/home/kshiteej/miniconda3/bin/python3.7+0x1c5900)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/tuple:133:17 in 
```

</details>

Discovered in https://github.com/pytorch/pytorch/pull/62814
Reference: https://github.com/pytorch/pytorch/pull/62814#issuecomment-894156562

```
PyTorch built with:
  - GCC 4.2
  - C++ Version: 201402
  - clang 8.0.0
  - Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
  - OpenMP 201107 (a.k.a. OpenMP 3.1)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - Build settings: BUILD_TYPE=Debug, CXX_COMPILER=/home/kshiteej/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang++, CXX_FLAGS=-fsanitize=undefined -fsanitize=address  -fno-sanitize-recover=all -shared-libasan -pthread -Wno-deprecated -fvisibility-inlines-hidden -fsanitize=address -fPIE -DUSE_PTHREADPOOL -fopenmp=libomp -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.0, USE_CUDA=0, USE_CUDNN=OFF, USE_EIGEN_FOR_BLAS=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=OFF, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=ON, USE_OPENMP=1, 
  -
```


cc @albanD @mruberry @jbschlosser