Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions torch/csrc/jit/codegen/cuda/fusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,11 @@ std::unordered_set<Val*> InputsOf::output(Fusion* fusion, Val* output_) {
}

Fusion::~Fusion() {
{
auto it = val_set_.begin();
while (it != val_set_.end()) {
auto del = it;
it = ++it;
delete (*del);
}
for (auto ptr : val_set_) {
delete ptr;
}
auto it = expr_set_.begin();
while (it != expr_set_.end()) {
auto del = it;
it = ++it;
delete (*del);
for (auto ptr : expr_set_) {
delete ptr;
}
};

Expand Down Expand Up @@ -191,20 +183,16 @@ std::unordered_set<Val*> Fusion::inputsOf(Val* val) {
void Fusion::validateInputs() {
std::unordered_set<Val*> all_inputs;
for (Val* out : outputs()) {
auto outs_inputs = inputsOf(out);
std::set_union(
all_inputs.begin(),
all_inputs.end(),
outs_inputs.begin(),
outs_inputs.end(),
std::inserter(all_inputs, all_inputs.begin()));
for (Val* input : inputsOf(out)) {
all_inputs.insert(input);
}
}
for (Val* inp : all_inputs) {
if (!inp->isConstScalar())
for (Val* input : all_inputs) {
if (!input->isConstScalar())
TORCH_CHECK(
hasInput(inp),
hasInput(input),
"Could not figure out how ",
inp,
input,
" is generated, however it was not specified as an input.");
}
}
Expand Down
1 change: 1 addition & 0 deletions torch/csrc/jit/codegen/cuda/fusion.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ struct TORCH_CUDA_API Fusion : public IRInputOutput {

private:
// Sets of all Vals/Exprs registered with this fusion
// (val_deque_ is not owning the objects)
std::unordered_set<Val*> val_set_;
std::deque<Val*> val_deque_;
std::unordered_set<Expr*> expr_set_;
Expand Down