Skip to content

Commit b044739

Browse files
committed
Did some naming changes in response to review
1 parent 99674d1 commit b044739

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

torch/csrc/jit/passes/alias_analysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ void AliasDb::dump() const {
162162
if (!element->pointsTo.empty()) {
163163
std::cout << getElementName(element) << " points to: ";
164164
for (const auto pointedTo : element->pointsTo) {
165-
std::cout << getElementName(Element::toElement(pointedTo)) << ", ";
165+
std::cout << getElementName(Element::fromIndex(pointedTo)) << ", ";
166166
}
167167
std::cout << "\n";
168168
}
169169
if (!element->contained_elements.empty()) {
170170
std::cout << getElementName(element) << " contains: ";
171171
for (const auto contained : element->contained_elements) {
172-
std::cout << getElementName(Element::toElement(contained)) << ", ";
172+
std::cout << getElementName(Element::fromIndex(contained)) << ", ";
173173
}
174174
std::cout << "\n";
175175
}
@@ -540,7 +540,7 @@ void AliasDb::analyzeWait(Node* node) {
540540
const auto el = pr.second;
541541
const auto& pointedFrom = el->pointedFrom;
542542
TORCH_INTERNAL_ASSERT(!pointedFrom.empty());
543-
const auto wildcardValue = Element::toElement(*pointedFrom.begin())->value;
543+
const auto wildcardValue = Element::fromIndex(*pointedFrom.begin())->value;
544544
TORCH_INTERNAL_ASSERT(wildcardValue);
545545
registerWrite(wildcardValue, node);
546546
}

torch/csrc/jit/passes/utils/memory_dag.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
namespace torch {
99
namespace jit {
1010
namespace {
11-
std::vector<const Element*> decomprMap;
11+
std::vector<const Element*> indexToElementMap;
1212
} // namespace
1313
unsigned Element::indexCount = 0;
1414
Element::Element(const Value* value_) : value(value_), index(indexCount++) {
15-
decomprMap.push_back(this);
15+
indexToElementMap.push_back(this);
1616
}
1717

18-
const Element* Element::toElement(unsigned x) {
19-
TORCH_INTERNAL_ASSERT(x < decomprMap.size());
20-
auto res = decomprMap[x];
18+
const Element* Element::fromIndex(unsigned x) {
19+
TORCH_INTERNAL_ASSERT(x < indexToElementMap.size());
20+
auto res = indexToElementMap[x];
2121
return res;
2222
}
2323

@@ -55,11 +55,11 @@ void collectAllContainedMemoryLocations(
5555
cont.set(compIdx);
5656

5757
for (const auto& mem_loc : elem->getMemoryLocations()) {
58-
collectAllContainedMemoryLocations(Element::toElement(mem_loc), cont);
58+
collectAllContainedMemoryLocations(Element::fromIndex(mem_loc), cont);
5959
}
6060

6161
for (const auto& contained : elem->contained_elements) {
62-
collectAllContainedMemoryLocations(Element::toElement(contained), cont);
62+
collectAllContainedMemoryLocations(Element::fromIndex(contained), cont);
6363
}
6464
}
6565

@@ -131,25 +131,25 @@ void Element::bfs(BfsDirection dir, MemoryLocations& res) const {
131131
ska::flat_hash_set<int> seen;
132132
queue.push(this->index);
133133
while (!queue.empty()) {
134-
const auto el = queue.front();
134+
const auto index = queue.front();
135135
queue.pop();
136-
seen.insert(el);
137-
auto decompEl = Element::toElement(el);
138-
if (decompEl->pointsTo.empty()) {
139-
res.set(el);
136+
seen.insert(index);
137+
auto el = Element::fromIndex(index);
138+
if (el->pointsTo.empty()) {
139+
res.set(index);
140140
}
141141

142142
switch (dir) {
143143
case BfsDirection::POINTS_TO: {
144-
for (auto ptr : decompEl->pointsTo) {
144+
for (auto ptr : el->pointsTo) {
145145
if (!seen.count(ptr)) {
146146
queue.push(ptr);
147147
}
148148
}
149149
} break;
150150

151151
case BfsDirection::POINTED_FROM: {
152-
for (auto ptr : decompEl->pointedFrom) {
152+
for (auto ptr : el->pointedFrom) {
153153
if (!seen.count(ptr)) {
154154
queue.push(ptr);
155155
}

torch/csrc/jit/passes/utils/memory_dag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct Element {
142142
void bfs(BfsDirection dir, MemoryLocations& res) const;
143143

144144
// Converts from the compressed index representation
145-
static const Element* toElement(unsigned x);
145+
static const Element* fromIndex(unsigned x);
146146
};
147147
} // namespace jit
148148
} // namespace torch

0 commit comments

Comments
 (0)