Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambiguous overload for TORCH_LIBRARY def #126519

Open
ngc92 opened this issue May 17, 2024 · 1 comment
Open

ambiguous overload for TORCH_LIBRARY def #126519

ngc92 opened this issue May 17, 2024 · 1 comment
Labels
module: internals Related to internal abstractions in c10 and ATen triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@ngc92
Copy link

ngc92 commented May 17, 2024

馃悰 Describe the bug

The two overloads of library.def,

template <typename Schema>
Library& def(
      Schema&& raw_schema,
      const std::vector<at::Tag>& tags = {},
      _RegisterOrVerify rv = _RegisterOrVerify::REGISTER) & {
    c10::FunctionSchema s = schema(std::forward<Schema>(raw_schema));
    return _def(std::move(s), nullptr, tags, rv);
}
  
template <typename NameOrSchema, typename Func>
Library& def(NameOrSchema&& raw_name_or_schema, Func&& raw_f,
      const std::vector<at::Tag>& tags = {}) & {
    CppFunction f(std::forward<Func>(raw_f));
    return _def(
        detail::constructSchemaOrName(
            ::std::forward<NameOrSchema>(raw_name_or_schema)),
        ::std::move(f), tags);
}

are ambiguous when tags are used: Func&& matches anything, so both options appear as viable overloads.

The second overload should be SFINAEd away if Func is a vector of tags.

Versions

PyTorch version: 2.3.0+cu121

cc @ezyang @bhosmer @smessmer @ljk53 @bdhirsh

@mikaylagawarecki mikaylagawarecki added module: internals Related to internal abstractions in c10 and ATen triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels May 20, 2024
@ezyang
Copy link
Contributor

ezyang commented May 20, 2024

Whoops. Do you think you could send us a patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: internals Related to internal abstractions in c10 and ATen triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants