Home / Class/ aliasInfo Class — pytorch Architecture

aliasInfo Class — pytorch Architecture

Architecture documentation for the aliasInfo class in alias_info.h from the pytorch codebase.

Entity Profile

Source Code

aten/src/ATen/core/alias_info.h lines 134–161

template <>
  struct hash<c10::AliasInfo> {
    size_t operator()(const c10::AliasInfo& aliasInfo) const {
      auto hash = std::hash<bool>()(aliasInfo.isWrite());

      // NOTE: for unordered_set hashes, we couldn't use hash_combine
      // because hash_combine is order dependent. Instead, we choose to
      // use XOR as the combining function as XOR is commutative.
      size_t before_set_hash_seed = 0;
      for (auto &e: aliasInfo.beforeSets()) {
        auto symbol_hash = std::hash<c10::Symbol>()(e);
        before_set_hash_seed = before_set_hash_seed ^ symbol_hash;
      }
      size_t after_set_hash_seed = 0;
      for (auto &e: aliasInfo.afterSets()) {
        auto symbol_hash = std::hash<c10::Symbol>()(e);
        after_set_hash_seed = after_set_hash_seed ^ symbol_hash;
      }

      hash = c10::hash_combine(hash, before_set_hash_seed);
      hash = c10::hash_combine(hash, after_set_hash_seed);
      for (auto &e: aliasInfo.containedTypes()) {
        auto contained_type_hash = std::hash<c10::AliasInfo>()(e);
        hash = c10::hash_combine(hash, contained_type_hash);
      }
      return hash;
    }
  };

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free