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

I'm having a weird match failure problem when I use onnx-graphsurgeon tools #4337

Closed
peanutPod opened this issue Jan 24, 2025 · 2 comments
Closed

Comments

@peanutPod
Copy link

peanutPod commented Jan 24, 2025

onnxmodel.zip

I'm experiencing a strange pattern matching failure, can anyone help me see what the problem is there.
when using this pattern ,can find slice ,but matmul can not found.

    def get_plugin_pattern(self):
        def check_constant_value(val):
            def check(node):
                if not hasattr(node, "attrs") or "value" not in node.attrs:
                    return False
                value = node.attrs["value"].values
                return value.size == 1 and value == val
            return check

        
        pattern=gs.GraphPattern()

        input = pattern.variable()
        #first matmul add relu layernoemalization branch
        starts_b01 = pattern.add("B01_slice_start", "Constant", check_func=check_constant_value(0))
        ends_b01 = pattern.add("B01_slice_end", "Constant", check_func=check_constant_value(3))
        axes_b01 = pattern.add("B01_slice_axes", "Constant",check_func=check_constant_value(2))
        steps_b01 = pattern.add("B01_slice_step", "Constant", check_func=check_constant_value(1))
        slice0_b01 = pattern.add("slice0_b01", 
                            op="Slice",
                            inputs=[input, starts_b01, ends_b01, axes_b01, steps_b01],
                            num_output_tensors=1)
        matmul01_constant_input_b01 = pattern.constant()#128

        matmul01_b01=pattern.add("matmul01_b01",op="MatMul",inputs=[slice0_b01,matmul01_constant_input_b01],num_output_tensors=1)

        pattern.set_output_tensors([matmul01_b01])
        return pattern    
@peanutPod peanutPod changed the title onnx-graphsurgeon can not find pattern onnx-graphsurgeon pattern match failed Jan 24, 2025
@peanutPod
Copy link
Author

My onnx model info :
I want to match the red box.

Image
matmul ifno:

Image

@peanutPod peanutPod changed the title onnx-graphsurgeon pattern match failed I'm having a weird match failure problem when I use onnx-graphsurgeon tools Jan 24, 2025
@peanutPod
Copy link
Author

starts_b01 = pattern.add("B01_slice_start", "Constant", check_func=check_constant_value(0)) and starts_b01 =pattern.constant()#128 isdifferent ,case the problem

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