Skip to content

importer: fix usage after PyTorch update#1555

Merged
ashay merged 1 commit intollvm:mainfrom
ashay:ashay/fix-ivalue-importer
Nov 4, 2022
Merged

importer: fix usage after PyTorch update#1555
ashay merged 1 commit intollvm:mainfrom
ashay:ashay/fix-ivalue-importer

Conversation

@ashay
Copy link
Copy Markdown
Contributor

@ashay ashay commented Nov 4, 2022

Unless requested otherwise, PyTorch no longer installs most of the
header files under the caffe2 directory (see
pytorch/pytorch#87986). This breaks our
importer code since we need to use the MakeGuard() function to execute
statements in the event of exceptions.

To fix this issue, this patch implements a rudimentary version of
PyTorch's ScopeGuard, where once the class variable goes out of scope,
it executes a predefined method.

@ashay
Copy link
Copy Markdown
Contributor Author

ashay commented Nov 4, 2022

Btw, do we need do something special to conform with the PyTorch license if we add one of their files into our repository?

The most recent commit implements a rudimentary version of ScopeGuard that appears sufficient for our case, so I don't think we need to worry about licensing issues.

Unless requested otherwise, PyTorch no longer installs most of the
header files under the caffe2 directory (see
pytorch/pytorch#87986).  This breaks our
importer code since we need to use the `MakeGuard()` function to execute
statements in the event of exceptions.

To fix this issue, this patch implements a rudimentary version of
PyTorch's ScopeGuard, where once the class variable goes out of scope,
it executes a predefined method.
@ashay ashay merged commit d99b2dd into llvm:main Nov 4, 2022
@ashay ashay deleted the ashay/fix-ivalue-importer branch November 4, 2022 20:02
// RAII pattern to insert an operation before going out of scope.
class InserterGuard {
private:
MlirBlock _importBlock;
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.

nit: no leading _ per style guide. Yes this is weird but it works :)

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.

3 participants