Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

op.Pad: inconsistency between @script and rewriter #2036

Open
leshabirukov opened this issue Jan 24, 2025 · 3 comments
Open

op.Pad: inconsistency between @script and rewriter #2036

leshabirukov opened this issue Jan 24, 2025 · 3 comments
Labels
enhancement New feature or request topic: rewriter

Comments

@leshabirukov
Copy link

leshabirukov commented Jan 24, 2025

@script()
def dw_patch( in_X  ):
    X = op.Pad( in_X, pads=[0, 0, 1, 1, 0, 0, 0, 0] )
    return X

This one translates to:

dw_patch ( in_X) => ( return_val) {
   const = Constant <value: tensor = int64[8] const {0,0,1,1,0,0,0,0}> ()
   return_val = Pad (in_X, const)
}
def patch( op, in_X, ):
    return op.Pad( in_X, pads=[0, 0, 1, 1, 0, 0, 0, 0] )

And this one, (used as replace part in rewriter) to

ini_mod (float[1,3,28,28] in_X) => (float[1,3,29,29] return_val) {
   return_val = Pad <pads: ints = [0, 0, 1, 1, 0, 0, 0, 0]> (in_X)
}

Here, input becomes attribute.

what_the_pad.py.txt

log.txt

@justinchuby
Copy link
Collaborator

In the rewriter, all kwargs are turned into attributes, whereas in script mode the logic understands the op schema and is able to know that it should be an input. We will work the bridge this gap but it may take some time

@justinchuby justinchuby added enhancement New feature or request topic: rewriter labels Jan 24, 2025
@leshabirukov
Copy link
Author

Can I pass @script()-ed function to rewriter.pattern.RewriteRule?

Get

TypeError: Unexpected input type <class 'onnxscript.rewriter.pattern.OpsetPatternBuilder'>.

@justinchuby
Copy link
Collaborator

Not yet. We are going to bridge this gap later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic: rewriter
Projects
None yet
Development

No branches or pull requests

2 participants