Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Jun 5, 2019

Stack from ghstack:

AliasDb::getReads() now considers contained types to be part of the
read set.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:

l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above

This can be improved (e.g. we can track tuple contained aliasing
precisely) but I will defer that to the future.

gh-metadata: pytorch pytorch 21431 gh/suo/53/head

Differential Revision: D15718560

Container types now track the aliasing information of their contained
elements. Creating a pointer from one container to another should
correctly create a pointer between their contained types as well.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

I think this change also makes it so that we can be more explicit with
schema annotations (wildcards can become implementation details
finally!) A follow-on PR will try to make that happen
@pytorchbot pytorchbot added oncall: jit Add this issue/PR to JIT oncall triage queue module: cpp Related to C++ API labels Jun 5, 2019
@suo suo requested review from zdevito and removed request for zdevito June 5, 2019 21:00
@suo
Copy link
Member Author

suo commented Jun 5, 2019

actually this is not ready for review yet

suo added 4 commits June 5, 2019 15:35
[jit] Track contained elements in alias analysis.

Container types now track the aliasing information of their contained
elements. Creating a pointer from one container to another should
correctly create a pointer between their contained types as well.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

I think this change also makes it so that we can be more explicit with
schema annotations (wildcards can become implementation details
finally!) A follow-on PR will try to make that happen

gh-metadata: pytorch pytorch 21431 gh/suo/53/head
[jit] Track contained elements in alias analysis.

Container types now track the aliasing information of their contained
elements. Creating a pointer from one container to another should
correctly create a pointer between their contained types as well.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

I think this change also makes it so that we can be more explicit with
schema annotations (wildcards can become implementation details
finally!) A follow-on PR will try to make that happen

gh-metadata: pytorch pytorch 21431 gh/suo/53/head
[jit] Track contained elements in alias analysis.

Container types now track the aliasing information of their contained
elements. Creating a pointer from one container to another should
correctly create a pointer between their contained types as well.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

I think this change also makes it so that we can be more explicit with
schema annotations (wildcards can become implementation details
finally!) A follow-on PR will try to make that happen

gh-metadata: pytorch pytorch 21431 gh/suo/53/head
[jit] Track contained elements in alias analysis.

Container types now track the aliasing information of their contained
elements. Creating a pointer from one container to another should
correctly create a pointer between their contained types as well.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

I think this change also makes it so that we can be more explicit with
schema annotations (wildcards can become implementation details
finally!) A follow-on PR will try to make that happen

gh-metadata: pytorch pytorch 21431 gh/suo/53/head
@zdevito
Copy link
Contributor

zdevito commented Jun 6, 2019

I am going to need a refresher on our alias analysis pass before I have enough context to review for correctness.

@suo suo removed the request for review from zdevito June 6, 2019 22:53
[jit] Consider contained types in alias analysis

`AliasDb::getReads()` now considers contained types to be part of the
read set.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

This can be improved (e.g. we can track tuple contained aliasing
precisely) but I will defer that to the future.

gh-metadata: pytorch pytorch 21431 gh/suo/53/head
@suo suo changed the title [jit] Track contained elements in alias analysis. [jit] Consider contained types in alias analysis Jun 7, 2019
@suo
Copy link
Member Author

suo commented Jun 7, 2019

@zdevito: Changed this as we discussed offline. Not doing any of the container elements stuff—just adding the appropriate wildcards to the getReads() set.

@suo suo requested a review from zdevito June 7, 2019 16:33
[jit] Consider contained types in alias analysis

`AliasDb::getReads()` now considers contained types to be part of the
read set.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

This can be improved (e.g. we can track tuple contained aliasing
precisely) but I will defer that to the future.

gh-metadata: pytorch pytorch 21431 gh/suo/53/head
suo added 2 commits June 10, 2019 09:47
[jit] Consider contained types in alias analysis

`AliasDb::getReads()` now considers contained types to be part of the
read set.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

This can be improved (e.g. we can track tuple contained aliasing
precisely) but I will defer that to the future.

gh-metadata: pytorch pytorch 21431 gh/suo/53/head
[jit] Consider contained types in alias analysis

`AliasDb::getReads()` now considers contained types to be part of the
read set.

This is necessary because we need to consider reads of List[Tensor] to
be reads both of the outer List and the inner Tensor. Otherwise
something like this might happen:
```
l = [...]
l[0].add_(...)
print(l)  # could reorder this read across the write above
```

This can be improved (e.g. we can track tuple contained aliasing
precisely) but I will defer that to the future.

gh-metadata: pytorch pytorch 21431 gh/suo/53/head
@zou3519 zou3519 deleted the gh/suo/53/head branch June 10, 2019 19:45
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in a436822.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: cpp Related to C++ API oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants