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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add named tuple's error message and workaround for RET failure #46347

Closed
wants to merge 4 commits into from

Commits on Oct 14, 2020

  1. Add named tuple's error message and workaround for RET failure

    Added the named tuple's error messages & workarounds when it returns from a function of a class in Pytorch Mobile.
    
    To identify the error cases (returning NamedTuple type), I used the following coditions:
    1) ins.op == RET  (for returing)
    2) type->kind() == TypeKind::TupleType  (for pruning non-tuple types)
    3) type->cast<TupleType>().name()  (for pruning Tuple type)
      - I could use the type's str (str() or repr_str()) directly, but I used whether it has the "name" attribute. Please give the comment for this.
    
    
    [Information of Tuple and NamedTuple types]
    1. Tuple
    type->str(): (int, int)
    type->repr_str(): Tuple[int, int]
    type->kind():  TypeKind::TupleType         # different with other types
    type()->cast<NamedType>(): True
    type()->cast<NamedType>()>name(): False    # different with NamedTuple
    
    2. NamedTuple
    type->str():  __torch__.myNamedTuple
    type->repr_str(): __torch__.myNamedTuple
    type->kind():  TypeKind::TupleType         # different with other types
    type()->cast<NamedType>(): True
    type->cast<TupleType>().name() = True      # different with Tuple
    
    (From the next diff, I will handle the other error cases: 1) returning List<module class>, Dict<module class> and 2) accessing Module class's member functions)
    
    Differential Revision: [D24291962](https://our.internmc.facebook.com/intern/diff/D24291962/)
    
    [ghstack-poisoned]
    jinwoop committed Oct 14, 2020
    Configuration menu
    Copy the full SHA
    dbf9fbe View commit details
    Browse the repository at this point in the history
  2. Update on "Add named tuple's error message and workaround for RET fai…

    …lure"
    
    Added the named tuple's error messages & workarounds when it returns from a function of a class in Pytorch Mobile.
    
    To identify the error cases (returning NamedTuple type), I used the following coditions:
    1) ins.op == RET  (for returing)
    2) type->kind() == TypeKind::TupleType  (for pruning non-tuple types)
    3) type->cast<TupleType>().name()  (for pruning Tuple type)
      - I could use the type's str (str() or repr_str()) directly, but I used whether it has the "name" attribute. Please give the comment for this.
    
    
    [Information of Tuple and NamedTuple types]
    1. Tuple
    type->str(): (int, int)
    type->repr_str(): Tuple[int, int]
    type->kind():  TypeKind::TupleType         # different with other types
    type()->cast<NamedType>(): True
    type()->cast<NamedType>()>name(): False    # different with NamedTuple
    
    2. NamedTuple
    type->str():  __torch__.myNamedTuple
    type->repr_str(): __torch__.myNamedTuple
    type->kind():  TypeKind::TupleType         # different with other types
    type()->cast<NamedType>(): True
    type->cast<TupleType>().name() = True      # different with Tuple
    
    (From the next diff, I will handle the other error cases: 1) returning List<module class>, Dict<module class> and 2) accessing Module class's member functions)
    
    Differential Revision: [D24291962](https://our.internmc.facebook.com/intern/diff/D24291962/)
    
    [ghstack-poisoned]
    jinwoop committed Oct 14, 2020
    Configuration menu
    Copy the full SHA
    9f49ca0 View commit details
    Browse the repository at this point in the history
  3. Update on "Add named tuple's error message and workaround for RET fai…

    …lure"
    
    Added the named tuple's error messages & workarounds when it returns from a function of a class in Pytorch Mobile.
    
    To identify the error cases (returning NamedTuple type), I used the following coditions:
    1) ins.op == RET  (for returing)
    2) type->kind() == TypeKind::TupleType  (for pruning non-tuple types)
    3) type->cast<TupleType>().name()  (for pruning Tuple type)
      - I could use the type's str (str() or repr_str()) directly, but I used whether it has the "name" attribute. Please give the comment for this.
    
    
    [Information of Tuple and NamedTuple types]
    1. Tuple
    type->str(): (int, int)
    type->repr_str(): Tuple[int, int]
    type->kind():  TypeKind::TupleType         # different with other types
    type()->cast<NamedType>(): True
    type()->cast<NamedType>()>name(): False    # different with NamedTuple
    
    2. NamedTuple
    type->str():  __torch__.myNamedTuple
    type->repr_str(): __torch__.myNamedTuple
    type->kind():  TypeKind::TupleType         # different with other types
    type()->cast<NamedType>(): True
    type->cast<TupleType>().name() = True      # different with Tuple
    
    (From the next diff, I will handle the other error cases: 1) returning List<module class>, Dict<module class> and 2) accessing Module class's member functions)
    
    Differential Revision: [D24291962](https://our.internmc.facebook.com/intern/diff/D24291962/)
    
    [ghstack-poisoned]
    jinwoop committed Oct 14, 2020
    Configuration menu
    Copy the full SHA
    f78062c View commit details
    Browse the repository at this point in the history

Commits on Oct 15, 2020

  1. Update on "Add named tuple's error message and workaround for RET fai…

    …lure"
    
    Added the named tuple's error messages & workarounds when it returns from a function of a class in Pytorch Mobile.
    
    To identify the error cases (returning NamedTuple type), I used the following coditions:
    1) ins.op == RET  (for returing)
    2) type->kind() == TypeKind::TupleType  (for pruning non-tuple types)
    3) type->cast<TupleType>().name()  (for pruning Tuple type)
      - I could use the type's str (str() or repr_str()) directly, but I used whether it has the "name" attribute. Please give the comment for this.
    
    
    [Information of Tuple and NamedTuple types]
    1. Tuple
    type->str(): (int, int)
    type->repr_str(): Tuple[int, int]
    type->kind():  TypeKind::TupleType         # different with other types
    type()->cast<NamedType>(): True
    type()->cast<NamedType>()>name(): False    # different with NamedTuple
    
    2. NamedTuple
    type->str():  __torch__.myNamedTuple
    type->repr_str(): __torch__.myNamedTuple
    type->kind():  TypeKind::TupleType         # different with other types
    type()->cast<NamedType>(): True
    type->cast<TupleType>().name() = True      # different with Tuple
    
    (From the next diff, I will handle the other error cases: 1) returning List<module class>, Dict<module class> and 2) accessing Module class's member functions)
    
    Differential Revision: [D24291962](https://our.internmc.facebook.com/intern/diff/D24291962/)
    
    [ghstack-poisoned]
    jinwoop committed Oct 15, 2020
    Configuration menu
    Copy the full SHA
    8f12b8b View commit details
    Browse the repository at this point in the history