Skip to content

Restrict conversion to SmallVector#42694

Closed
smessmer wants to merge 1 commit intogh/smessmer/248/basefrom
gh/smessmer/248/head
Closed

Restrict conversion to SmallVector#42694
smessmer wants to merge 1 commit intogh/smessmer/248/basefrom
gh/smessmer/248/head

Conversation

@smessmer
Copy link
Copy Markdown
Contributor

@smessmer smessmer commented Aug 6, 2020

Stack from ghstack:

The old implementation allowed calling SmallVector constructor and operator= for any type without restrictions,
but then failed with a compiler error when the type wasn't a collection.

Instead, we should only use it if Container follows a container concept and just not match the constructor otherwise.

This fixes an issue @kimishpatel was running into.

Differential Revision: D22983020

The old implementation allowed calling SmallVector constructor and operator= for any type without restrictions,
but then failed with a compiler error when the type wasn't a collection.

Instead, we should only use it if Container follows a container concept and just not match the constructor otherwise.

This fixes an issue @kimishpatel was running into.

Differential Revision: [D22983020](https://our.internmc.facebook.com/intern/diff/D22983020/)

[ghstack-poisoned]
smessmer added a commit that referenced this pull request Aug 6, 2020
The old implementation allowed calling SmallVector constructor and operator= for any type without restrictions,
but then failed with a compiler error when the type wasn't a collection.

Instead, we should only use it if Container follows a container concept and just not match the constructor otherwise.

This fixes an issue @kimishpatel was running into.

Differential Revision: [D22983020](https://our.internmc.facebook.com/intern/diff/D22983020/)

ghstack-source-id: 109370513
Pull Request resolved: #42694
@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Aug 6, 2020

💊 CI failures summary and remediations

As of commit cc41a65 (more details on the Dr. CI page):


  • 2/2 failures introduced in this PR

🕵️ 2 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_build (1/2)

Step: "(Optional) Merge target branch" (full log | diagnosis details | 🔁 rerun)

Automatic merge failed; fix conflicts and then commit the result.
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/simple/nightly_android.py 
Auto-merging .circleci/cimodel/data/simple/nightly_android.py 
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/simple/mobile_definitions.py 
Auto-merging .circleci/cimodel/data/simple/mobile_definitions.py 
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/simple/bazel_definitions.py 
Auto-merging .circleci/cimodel/data/simple/bazel_definitions.py 
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/simple/android_definitions.py 
Auto-merging .circleci/cimodel/data/simple/android_definitions.py 
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/pytorch_build_definitions.py 
Auto-merging .circleci/cimodel/data/pytorch_build_definitions.py 
Automatic merge failed; fix conflicts and then commit the result. 

See CircleCI build pytorch_xla_linux_bionic_py3_6_clang9_build (2/2)

Step: "(Optional) Merge target branch" (full log | diagnosis details | 🔁 rerun)

Automatic merge failed; fix conflicts and then commit the result.
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/simple/nightly_android.py 
Auto-merging .circleci/cimodel/data/simple/nightly_android.py 
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/simple/mobile_definitions.py 
Auto-merging .circleci/cimodel/data/simple/mobile_definitions.py 
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/simple/bazel_definitions.py 
Auto-merging .circleci/cimodel/data/simple/bazel_definitions.py 
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/simple/android_definitions.py 
Auto-merging .circleci/cimodel/data/simple/android_definitions.py 
CONFLICT (add/add): Merge conflict in .circleci/cimodel/data/pytorch_build_definitions.py 
Auto-merging .circleci/cimodel/data/pytorch_build_definitions.py 
Automatic merge failed; fix conflicts and then commit the result. 

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 1 time.

Comment thread c10/util/SmallVector.h
}

template <typename Container>
// note: The enable_if restricts Container to types that have a .begin() and .end()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this locally. It works.

Copy link
Copy Markdown
Contributor

@kimishpatel kimishpatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix Sebastian.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 95f4f67.

@facebook-github-bot facebook-github-bot deleted the gh/smessmer/248/head branch August 11, 2020 14:16
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Pull Request resolved: pytorch#42694

The old implementation allowed calling SmallVector constructor and operator= for any type without restrictions,
but then failed with a compiler error when the type wasn't a collection.

Instead, we should only use it if Container follows a container concept and just not match the constructor otherwise.

This fixes an issue kimishpatel was running into.
ghstack-source-id: 109370513

Test Plan: unit tests

Reviewed By: kimishpatel, ezyang

Differential Revision: D22983020

fbshipit-source-id: c31264f5c393762d822f3d64dd2a8e3279d8da44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants