Skip to content

[hannk] Ensure Model transforms are valid#6317

Closed
steven-johnson wants to merge 11 commits intomasterfrom
srj/model-checker
Closed

[hannk] Ensure Model transforms are valid#6317
steven-johnson wants to merge 11 commits intomasterfrom
srj/model-checker

Conversation

@steven-johnson
Copy link
Copy Markdown
Contributor

  • Add a Model validity checker to ensure that all the input tensors to a given op are outputs of some previous op (or a constant)
  • Revamp OpGroup::add() and remove() to properly handle nested groups (they were previously producing Models that didn't pass the new validity checker)

Minor hygiene: add explicit override annotations and enable the compiler warnings. (I was about to tweak some of the virtual functions and this has been bothering me for a while.)
- Add a Model validity checker to ensure that all the input tensors to a given op are outputs of some previous op (or a constant)
- Revamp OpGroup::add() and remove() to properly handle nested groups (they were previously producing Models that didn't pass the new validity checker)
Comment thread apps/hannk/interpreter/model.cpp Outdated
os << "\n";
}

bool Op::consumes_output_of(const Op *op) const {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At some point, I had a free function helper index_of_output (and index_of_input). It looks like those were probably unused and removed, but I still think they should be free functions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this a request to change to a free function?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes I think it should be a free function, and return an index (or -1 if not found), we'll surely need that again soon anyways.

Comment thread apps/hannk/interpreter/model.h Outdated

// Inserts `to_add` in front of the first op that consumes at least one of its outputs, and returns nullptr.
// If no such op is found, does nothing and returns the original OpPtr.
[[nodiscard]] virtual OpPtr add(OpPtr to_add) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this need to be in Op (and not OpGroup)? I think it's strange to attempt to add/remove ops from things that might not have any notion of nested ops.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's there strictly to avoid having to use something like cast_op in the implementation; having an empty virtual base case simplifies the implementation.

Base automatically changed from srj/override to master October 18, 2021 16:47
@steven-johnson
Copy link
Copy Markdown
Contributor Author

Gentle review ping

@steven-johnson
Copy link
Copy Markdown
Contributor Author

PTAL

Minor optimization to avoid identical overrides for OpGroup in multiple places (when all we want to process are the leaf ops)
@steven-johnson
Copy link
Copy Markdown
Contributor Author

Gentle review ping

@steven-johnson steven-johnson mentioned this pull request Nov 3, 2021
@steven-johnson
Copy link
Copy Markdown
Contributor Author

Obsoleted by #6379

@steven-johnson steven-johnson deleted the srj/model-checker branch November 12, 2021 19:05
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