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

How to check the value in constant when using pattern matching in onnx-graphsurgeon #4303

Closed
peanutPod opened this issue Dec 26, 2024 · 2 comments

Comments

@peanutPod
Copy link

for example:
onnx model op:
Image

pattern=gs.GraphPattern()
pow_in = pattern.constant()
in_0=pattern.variable()
pow=pattern.add("Node6",op="Pow",inputs=[in_0,pow_in],num_output_tensors=1, check_func=check_constant)

How do I verify that pow_in has a value of 2 when matching

@peanutPod peanutPod changed the title How to check the value in constant when using pattern matching in onnx_graphsurgeon How to check the value in constant when using pattern matching in onnx-graphsurgeon Dec 26, 2024
@peanutPod
Copy link
Author

@kevinch-nv could you help me?

@peanutPod
Copy link
Author

peanutPod commented Dec 27, 2024

solver:

  def check_constant(node):
      y_value=node.inputs[1].inputs[0].attrs["value"].values
      if y_value.size==1 and y_value==2:
          return True
      return False

  pow_y = pattern.add("ConstantNode", "Constant")

  pow=pattern.add("Node6",op="Pow",inputs=[sub,pow_y],check_func=check_constant,num_output_tensors=1)

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

No branches or pull requests

1 participant