torch/csrc/jit/import.cpp
// TODO: this should be removed once we'll be able to serialize value types
this should be removed once we'll be able to serialize value types
this should be removed once we ' ll be able to serialize value types
void GraphDecoder::reconstructOutputTypes(Block *b) {
  for (Node * n : b->nodes()) {
    if (n->kind() == prim::Constant) {
      switch (n->kindOf(attr::value)) {
        case AttributeKind::i:
          n->output()->setType(IntType::get());
          break;
        case AttributeKind::f:
          n->output()->setType(FloatType::get());
          break;
        case AttributeKind::is:
          n->output()->setType(ListType::ofInts());
          break;
        case AttributeKind::t:
          n->output()->setType(DynamicType::get());
          break;
        default:
          throw std::runtime_error("Unsupported case in reconstructOutputTypes. File a bug report");
      }
    } else if (n->kind() == prim::ListConstruct && n->inputs().size() > 0) {
      auto input_types = fmap(n->inputs(), [](Value *v) -> TypePtr {
        return v->node()->kind() == prim::Constant ? v->type() : nullptr;
      });
      if (std::equal(std::next(input_types.begin()), input_types.end(), input_types.begin())) {
        auto elem_type = input_types[0];
        if (elem_type == IntType::get()) {
          n->output()->setType(ListType::ofInts());
        }
      }
    }
    for (Block * b : n->blocks()) {
      reconstructOutputTypes(b);
    }
  }
}
void GraphDecoder :: reconstructOutputTypes ( Block * b ) { for ( Node * n : b -> nodes ( ) ) { if ( n -> kind ( ) == prim :: Constant ) { switch ( n -> kindOf ( attr :: value ) ) { case AttributeKind :: i : n -> output ( ) -> setType ( IntType :: get ( ) ) ; break ; case AttributeKind :: f : n -> output ( ) -> setType ( FloatType :: get ( ) ) ; break ; case AttributeKind :: is : n -> output ( ) -> setType ( ListType :: ofInts ( ) ) ; break ; case AttributeKind :: t : n -> output ( ) -> setType ( DynamicType :: get ( ) ) ; break ; default : throw std :: runtime_error ( " " ) ; } } else if ( n -> kind ( ) == prim :: ListConstruct && n -> inputs ( ) . size ( ) > 0 ) { auto input_types = fmap ( n -> inputs ( ) , [ ] ( Value * v ) -> TypePtr { return v -> node ( ) -> kind ( ) == prim :: Constant ? v -> type ( ) : nullptr ; } ) ; if ( std :: equal ( std :: next ( input_types . begin ( ) ) , input_types . end ( ) , input_types . begin ( ) ) ) { auto elem_type = input_types [ 0 ] ; if ( elem_type == IntType :: get ( ) ) { n -> output ( ) -> setType ( ListType :: ofInts ( ) ) ; } } } for ( Block * b : n -> blocks ( ) ) { reconstructOutputTypes ( b ) ; } } }
TODO: this should be removed once we'll be able to serialize value types
TODO : this should be removed once we ' ll be able to serialize value types
// Check that all types are equal