Skip to content

Use static type information to restore type tags#25447

Closed
zdevito wants to merge 10 commits intogh/zdevito/102/basefrom
gh/zdevito/102/head
Closed

Use static type information to restore type tags#25447
zdevito wants to merge 10 commits intogh/zdevito/102/basefrom
gh/zdevito/102/head

Conversation

@zdevito
Copy link
Contributor

@zdevito zdevito commented Aug 30, 2019

Stack from ghstack:

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

Differential Revision: D17127872

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.
@zdevito zdevito requested a review from apaszke as a code owner August 30, 2019 03:20
@pytorchbot pytorchbot added oncall: jit Add this issue/PR to JIT oncall triage queue module: internals Related to internal abstractions in c10 and ATen labels Aug 30, 2019
Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

emitModuleHook now has a check that the tags in saved/load modules
are the same.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

emitModuleHook now has a check that the tags in saved/load modules
are the same.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

emitModuleHook now has a check that the tags in saved/load modules
are the same.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

emitModuleHook now has a check that the tags in saved/load modules
are the same.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

emitModuleHook now has a check that the tags in saved/load modules
are the same.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
Copy link
Member

@suo suo left a comment

Choose a reason for hiding this comment

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

ngnt, just want more comments for posterity

TypePtr keyType() const;
TypePtr valueType() const;

void unsafeSetKeyType(TypePtr t);
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment explaining where this is used (and why not to use it in other circumstances)?


TypePtr elementType() const;

void unsafeSetElementType(TypePtr t);
Copy link
Member

Choose a reason for hiding this comment

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

same

}
}

static void restoreAccurateTypeTagsIfPossible(const IValue& root) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a comment explaining what this is for? What happens if restoring accurate type tags is not possible? The name alone is so tantalizing and full of mystery!

Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

emitModuleHook now has a check that the tags in saved/load modules
are the same.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

emitModuleHook now has a check that the tags in saved/load modules
are the same.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
Use static type information to restore type tags

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

emitModuleHook now has a check that the tags in saved/load modules
are the same.

gh-metadata: pytorch pytorch 25447 gh/zdevito/102/head
zdevito added a commit to zdevito/ATen that referenced this pull request Sep 19, 2019
Summary:
Pull Request resolved: pytorch/pytorch#25447

When we unpickle IValues, we lose type information for List[T]
and Dict[K, V]. We can restore this information using the static
type information contained in the top-level Module/Class type.

This ensures that even after serialization we can always get the
dynamic type of an ivalue using its type() method.

Test Plan: Imported from OSS

Differential Revision: D17127872

Pulled By: zdevito

fbshipit-source-id: 1ffb5e37a7c35c71ac9d3fb7b2edbc7ce3fbec72
@facebook-github-bot
Copy link
Contributor

@zdevito merged this pull request in 12762cd.

@facebook-github-bot facebook-github-bot deleted the gh/zdevito/102/head branch October 28, 2019 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: internals Related to internal abstractions in c10 and ATen oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants