mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/20593 ghimport-source-id: e1e9a7f98158c23adf02d5ed2763ab1e33bb2997 Differential Revision: D15375134 Pulled By: ZolotukhinM fbshipit-source-id: 8d8e0c1e0ef7697ded59a4b19e2d9de7c5230294
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#pragma once
|
|
#include <ATen/core/interned_strings.h>
|
|
#include <c10/util/intrusive_ptr.h>
|
|
#include <torch/csrc/WindowsTorchApiMacro.h>
|
|
|
|
namespace torch {
|
|
namespace jit {
|
|
|
|
// Scope is a node of a trie that represents the tree of nested scopes.
|
|
// Individual scopes are pushed and popped from Graph, which holds a
|
|
// pointer to the current scope. Each Node in Graph holds a pointer
|
|
// to the scope that was current when the node was created.
|
|
// The trie never needs to shrink, it only grows until it is disposed
|
|
// of when Graph is deallocated. Hence, pointers to scopes held by nodes
|
|
// will always be valid as long as Graph is alive.
|
|
struct Scope;
|
|
using ScopePtr = c10::intrusive_ptr<Scope>;
|
|
using c10::Symbol;
|
|
|
|
struct TORCH_API Scope : public c10::intrusive_ptr_target {
|
|
private:
|
|
ScopePtr parent_;
|
|
Symbol name_;
|
|
ScopePtr intrusive_from_this();
|
|
|
|
public:
|
|
Scope();
|
|
|
|
Scope(ScopePtr parent, Symbol name);
|
|
|
|
ScopePtr push(Symbol name);
|
|
|
|
ScopePtr parent();
|
|
|
|
bool isRoot() const;
|
|
|
|
bool isBlank() const;
|
|
|
|
ScopePtr getRoot();
|
|
|
|
size_t getDepth();
|
|
|
|
Symbol name() const;
|
|
|
|
std::string namesFromRoot(const std::string& separator = "/") const;
|
|
};
|
|
|
|
} // namespace jit
|
|
} // namespace torch
|