Skip to content

Introduce type variables to implement generic list operators - #12040

Closed
zdevito wants to merge 3 commits into
pytorch:masterfrom
zdevito:pr/any_list
Closed

zdevito wants to merge 3 commits into
pytorch:masterfrom
zdevito:pr/any_list

Conversation

@zdevito

@zdevito zdevito commented Sep 25, 2018

Copy link
Copy Markdown
Contributor

We generate specialized list operations for int, float, and Tensor lists so that small lists of integers like the arguments to conv do not involve tons of boxing code.

This PR adds a fallback GenericList for List types that contain any other type. It does so by adding type variables to jit::Type, and machinery for matching/replacing the type variables during tryMatchSchema and operator lookup.

It also modifies the builtin list ops to include a fallback that works on a GenericList object that simply holds IValues. This is distinguished from IValue's tuple type so that conversion to/from Python still happens losslessly.

@zdevito zdevito changed the title [WIP] Introduce type variables to implement generic list operators Introduce type variables to implement generic list operators Sep 25, 2018

@apaszke apaszke left a comment

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.

(not a complete review, since it's WIP)

Comment thread torch/csrc/jit/operator.cpp Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread torch/csrc/jit/type.h Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

@facebook-github-bot facebook-github-bot left a comment

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.

zdevito has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@apaszke apaszke left a comment

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.

LGTM, but two commented out lines in the compiler look fishy.

Comment thread torch/csrc/jit/import.cpp Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread torch/csrc/jit/script/compiler.cpp Outdated

This comment was marked as off-topic.

Comment thread torch/csrc/jit/script/compiler.cpp Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread torch/csrc/jit/type.h Outdated

This comment was marked as off-topic.

Comment thread torch/csrc/jit/type.cpp Outdated

This comment was marked as off-topic.

@facebook-github-bot facebook-github-bot left a comment

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.

zdevito has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot left a comment

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.

zdevito has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito added a commit to zdevito/ATen that referenced this pull request Sep 27, 2018
Summary:
We generate specialized list operations for int, float, and Tensor lists so that small lists of integers like the arguments to conv do not involve tons of boxing code.

This PR adds a fallback GenericList for List types that contain any other type. It does so by adding type variables to `jit::Type`, and machinery for matching/replacing the type variables during `tryMatchSchema` and operator lookup.

It also modifies the builtin list ops to include a fallback that works on a GenericList object that simply holds IValues. This is distinguished from IValue's tuple type so that conversion to/from Python still happens losslessly.
Pull Request resolved: pytorch/pytorch#12040

Differential Revision: D10037098

Pulled By: zdevito

fbshipit-source-id: 0c5f2864d12e7d33554bf34cc29e5fb700dde150
@ezyang ezyang added the merged label Jun 26, 2019
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
…#12040)

Summary:
We generate specialized list operations for int, float, and Tensor lists so that small lists of integers like the arguments to conv do not involve tons of boxing code.

This PR adds a fallback GenericList for List types that contain any other type. It does so by adding type variables to `jit::Type`, and machinery for matching/replacing the type variables during `tryMatchSchema` and operator lookup.

It also modifies the builtin list ops to include a fallback that works on a GenericList object that simply holds IValues. This is distinguished from IValue's tuple type so that conversion to/from Python still happens losslessly.
Pull Request resolved: pytorch#12040

Differential Revision: D10037098

Pulled By: zdevito

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants