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

Horizontal fusion Conv->add->sigmoid->mul issue in YoloX #3844

Open
CharlieL7 opened this issue Feb 25, 2025 · 0 comments
Open

Horizontal fusion Conv->add->sigmoid->mul issue in YoloX #3844

CharlieL7 opened this issue Feb 25, 2025 · 0 comments
Assignees

Comments

@CharlieL7
Copy link
Collaborator

Sigmoid not being merged into horizontally fused convolution because of multiple outputs. Minimal example program:

import migraphx
import numpy as np

p = migraphx.program()
mm = p.get_main_module()

shape_1 = migraphx.shape(lens=[1, 128, 160, 160], type='float_type')
shape_2 = migraphx.shape(lens=[1, 64, 160, 160], type='float_type')

x1 = mm.add_parameter('x1', shape_1)

w1 = mm.add_literal(np.ones([64, 128, 1, 1], dtype=np.float32) * 0.5)
w2 = mm.add_literal(np.ones([64, 128, 1, 1], dtype=np.float32) * 0.75)

conv1 = mm.add_instruction(migraphx.op('convolution', padding=[0, 0, 0, 0], stride=[1, 1], dilation=[1, 1], padding_mode=0, group=1), [x1, w1])
conv2 = mm.add_instruction(migraphx.op('convolution', padding=[0, 0, 0, 0], stride=[1, 1], dilation=[1, 1], padding_mode=0, group=1), [x1, w2])

lit1 = mm.add_literal(np.ones([64], dtype=np.float32) * 0.5)
lit2 = mm.add_literal(np.ones([64], dtype=np.float32) * 0.25)

broadcast1 = mm.add_instruction(migraphx.op('broadcast', axis=1, out_lens=[1, 64, 160, 160]), [lit1])
broadcast2 = mm.add_instruction(migraphx.op('broadcast', axis=1, out_lens=[1, 64, 160, 160]), [lit2])

add1 = mm.add_instruction(migraphx.op('add'), [conv1, broadcast1])
sig1 = mm.add_instruction(migraphx.op('sigmoid'), [add1])
mul1 = mm.add_instruction(migraphx.op('mul'), [sig1, add1])

add2 = mm.add_instruction(migraphx.op('add'), [conv2, broadcast2])
sig2 = mm.add_instruction(migraphx.op('sigmoid'), [add2])
mul2 = mm.add_instruction(migraphx.op('mul'), [sig2, add2])

mm.add_return([mul1, mul2])
@CharlieL7 CharlieL7 self-assigned this Feb 25, 2025
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