Skip to content

Commit 689be57

Browse files
committed
Fix reference to possibly disposed reference.
1 parent 77190d9 commit 689be57

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

torch_xla/csrc/dynamic_shape_detector.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ namespace torch_xla {
99
// Maximum number of allowed graphs per function (i.e. session).
1010
static std::size_t max_different_graphs = 1;
1111

12+
TrieNode::TrieNode(const TrieValue& value, bool is_graph_boundary) : TrieNode() {
13+
common_sequence_.push_back(value);
14+
is_graph_boundary_ = is_graph_boundary;
15+
}
16+
1217
TrieNode::TrieNode(absl::Span<const TrieValue> common_sequence,
1318
bool is_graph_boundary)
1419
: common_sequence_(common_sequence.begin(), common_sequence.end()),
@@ -112,8 +117,7 @@ TrieBuilder TrieNode::AddValue(TrieValue value, std::size_t matched,
112117
bool did_split = MaybeSplitAt(matched);
113118

114119
// Create a new node that contains only the given value.
115-
std::unique_ptr<TrieNode> node =
116-
std::make_unique<TrieNode>(absl::Span<const TrieValue>{value});
120+
std::unique_ptr<TrieNode> node = std::make_unique<TrieNode>(value);
117121

118122
// Associate the given value with the created node in the children's map.
119123
children_[value.hash] = std::move(node);

torch_xla/csrc/dynamic_shape_detector.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ struct TrieBuilder {
9898
struct TrieNode {
9999
using ChildrenMap = std::map<torch::lazy::hash_t, std::unique_ptr<TrieNode>>;
100100

101+
// Create a TrieNode with one value as its common_sequence_.
102+
TrieNode(const TrieValue& value, bool is_graph_boundary = false);
103+
104+
// Create a TrieNode with a specific common_sequence_.
101105
TrieNode(absl::Span<const TrieValue> common_sequence = {},
102106
bool is_graph_boundary = false);
103107

0 commit comments

Comments
 (0)