Skip to content

BoxedKernelWrapper triggers MSVC bug in internal Windows build #48763

@ezyang

Description

@ezyang

Steps to reproduce: patch in ac56371 most relevant segment is

REGISTER_OPERATOR_FUNCTOR(aten::add, aten_add, [](Node* n) -> SROperator {
  // TODO: Introduce TypedKernelFunction to make this more type safe
  auto op = c10::Dispatcher::singleton().findSchemaOrThrow("aten::add", "out");
  const auto& kernel = c10::Dispatcher::singleton().getKernel(op, c10::DispatchKey::CPU);
  return [op, &kernel](const ProcessedNode* p_node, std::vector<IValue>& reg) {
    auto in0_t = p_node->Input(0, reg).toTensor();
    auto in1_t = p_node->Input(1, reg).toTensor();
    auto in2_s = p_node->Input(2, reg).toScalar();
    if (p_node->Output(0, reg).isNone()) {
      p_node->Output(0, reg) = create_empty_from(in0_t);
    }
    auto out_t = p_node->Output(0, reg).toTensor();
    out_t.resize_({0});
    kernel.call<at::Tensor &, at::Tensor &, const at::Tensor &, const at::Tensor &, at::Scalar>(op, out_t, in0_t, in1_t, in2_s);
  };
});

Run build-arvr-diff-windows job (FB internal). Triggers this error:


command: [C:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\buck-out\gen\arvr\tools\buck\cl_tmp_override\cl_tmp_override, C:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\third-party\toolchains\vs2017_15.9\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe, @\\?\C:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\buck-out\bin\xplat\caffe2\torch_lib_ovrsource#compile-ops.cpp.obj311570ba,default\ppandcompile.argsfile]

stderr: c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\impl\boxing.h(152): error C2066: cast to function type is illegal
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\kernelfunction_impl.h(47): note: see reference to class template instantiation 'c10::impl::BoxedKernelWrapper<Return (at::Tensor &,const at::Tensor &,const at::Tensor &,c10::Scalar),void>' being compiled
        with
        [
            Return=at::Tensor &
        ]
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\torch\csrc\jit\runtime\static\ops.cpp(63): note: see reference to function template instantiation 'Return &c10::KernelFunction::call<at::Tensor&,at::Tensor&,const at::Tensor&,const at::Tensor&,c10::Scalar>(const c10::OperatorHandle &,at::Tensor &,const at::Tensor &,const at::Tensor &,c10::Scalar) const' being compiled
        with
        [
            Return=at::Tensor &
        ]
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\jit_type.h(2205): note: see reference to class template instantiation 'c10::ArrayRef<c10::IValue>' being compiled
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\c10\core\memoryformat.h(56): note: see reference to class template instantiation 'c10::ArrayRef<int64_t>' being compiled
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\c10\core\dispatchkeyset.h(57): note: see reference to class template instantiation 'std::initializer_list<c10::DispatchKey>' being compiled
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\impl\boxing.h(152): error C2070: 'FuncType': illegal sizeof operand
        with
        [
            FuncType=at::Tensor &(at::Tensor &,const at::Tensor &,const at::Tensor &,c10::Scalar)
        ]
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\impl\boxing.h(152): error C2338: Function signature contains one or more unsupported parameter and/or return types. Look for a nearby error like "'call' is not a member of 'c10::impl::BoxedKernelWrapper<(your function type), void>'" - (your function type) is the unsupported signature.
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\kernelfunction_impl.h(61): error C2039: 'call': is not a member of 'c10::impl::BoxedKernelWrapper<Return (at::Tensor &,const at::Tensor &,const at::Tensor &,c10::Scalar),void>'
        with
        [
            Return=at::Tensor &
        ]
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\kernelfunction_impl.h(61): note: see declaration of 'c10::impl::BoxedKernelWrapper<Return (at::Tensor &,const at::Tensor &,const at::Tensor &,c10::Scalar),void>'
        with
        [
            Return=at::Tensor &
        ]
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\kernelfunction_impl.h(47): error C2672: 'c10::KernelFunction::call': no matching overloaded function found
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\kernelfunction_impl.h(47): error C2783: 'Return c10::KernelFunction::call(const c10::OperatorHandle &,Args...) const': could not deduce template argument for 'Return'
c:\cygwin\data\sandcastle\boxes\trunk-hg-ovrsource-null\xplat\caffe2\aten\src\aten\core\boxing\kernelfunction.h(99): note: see declaration of 'c10::KernelFunction::call'
    When running <c++ preprocess_and_compile>.
    When building rule //xplat/caffe2:torch_lib_ovrsource#compile-ops.cpp.obj311570ba,default..Rule 

Open source Windows MSVC does not seem to have any problems. Internal build appears to be running MSVC 15.9.12 (for reference, our standard OSS Windows build is MSVC 19.27.29112.0)

cc @malfet @seemethere @walterddr @peterjc123 @maxluk @nbcsm @guyang3532 @gunandrose4u @mszhanyi @skyline75489

Metadata

Metadata

Labels

module: buildBuild system issuesmodule: windowsWindows support for PyTorchtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions