Skip to content

[Formal][PropertyAnnotation] Annotating IOG-based invariants#855

Open
Basmet0 wants to merge 7 commits intoEPFL-LAP:mainfrom
Basmet0:invariant5
Open

[Formal][PropertyAnnotation] Annotating IOG-based invariants#855
Basmet0 wants to merge 7 commits intoEPFL-LAP:mainfrom
Basmet0:invariant5

Conversation

@Basmet0
Copy link
Copy Markdown
Collaborator

@Basmet0 Basmet0 commented Apr 13, 2026

No description provided.

void step() {
if (partials.empty())
return;
auto checkpoint = partials.back();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe std::move is more efficient

auto checkpoint = std::move(partials.back());
partials.pop_back();

llvm::DenseSet<mlir::Value> illegals;
// Is the partial IOG still following the rules? Note that DONE does not
// actually mean done, as the `unhandled` stack should also be empty.
enum PROGRESS { ILLEGAL, PARTIAL, DONE };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum Status {...}

// Is the partial IOG still following the rules? Note that DONE does not
// actually mean done, as the unhandled stack should also be empty.

I still don't get the difference between DONE and ACTUALLY_DONE?

}
};

struct IOGFinderCheckpoint {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not do something like

struct IOGCandidate {
  Operation *entry;
  std::vector<Operation *> units;
  std::vector<Value> channels;

  DenseSet<Value> illegalChannels;

  // What you called "unhandled."
  std::vector<Value> bfsQueue;

  IOG getIOG() const {
    return IOG{this->units, this->channels, this->entry};
  }
};

illegals.insert(channel);
}

Operation *getNextOp() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::optional<Operation *> ...

Comment on lines +381 to +384
// Handle the `endOp` if it has not yet been inserted into the IOG
if (!partial.contains(endOp)) {
return endOp;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this candidate class should be constructed from an endOp (so partial already contains the endOp to begin with

Comment on lines +407 to +413
// To fully handle a channel, both the operation before and after have to be
// handled
Operation *before = channel.getDefiningOp();
if (before && !partial.contains(before)) {
partial.units.insert(before);
return before;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks quite messy that both getNextOp and step are taking care of both sides of a channel. Is it possible that we only handle the value owner here?

enum PROGRESS { ILLEGAL, PARTIAL, DONE };
PROGRESS progress = PARTIAL;
Operation *endOp;
std::vector<mlir::Value> entries;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be a const reference to avoid copying it everytime we create a new one

also can be unordered (DenseMap) so we can check if(entries.count(...))

Comment on lines +437 to +453
// This function takes a checkpoint and a list of channels. For each channel
// c, it pushes the IOG where *only* channel c is taken, and all the rest are
// illegal. Used for forks (which only allow exactly one of its outputs) and
// join operations (which only allow exactly one of its inputs)
template <typename T>
void followSingle(const IOGFinderCheckpoint &checkpoint, T options) {
for (mlir::Value channel : options) {
IOGFinderCheckpoint goHere = checkpoint;
goHere.follow(channel);
for (mlir::Value other : options) {
if (channel == other)
continue;
goHere.makeIllegal(other);
}
partials.push_back(goHere);
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a thing called static method that returns a new instance of ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants