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

[Bug] Inconsistent Transformation Results in TVM's DivToMul Optimization #16819

Open
Jupiterghy opened this issue Mar 29, 2024 · 0 comments
Open
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug

Comments

@Jupiterghy
Copy link

I have encountered an issue while using the relay.transform.DivToMul() optimization in TVM. I don’t know why there exists an inconsistency. I think the two methods should yield the same result while actually not.

Expected behavior

The modules after transformation should be structural equal.

Actual behavior

The two transformed modules (module and module_once) are not structurally equal.

Environment

  • Operating System: Ubuntu 18.04.5
  • TVM version: 0.15.dev0
  • ONNX: 1.15.0

Steps to reproduce

  1. Download the ONNX model
  2. Execute the script:
import onnx
import tvm
from tvm import relay

def apply_optimizations(module, opt, num_iterations=1):
    for _ in range(num_iterations):
        module = opt(module)
    return module


if __name__ == "__main__":
    onnx_file = "model.onnx"
    onnx_model = onnx.load(onnx_file)

    shape_dict = {'v25_0': [1, 1, 1], 'v4_0': [12, 2, 45, 1, 1], 'v19_0': [12, 1, 45, 1, 1], 'v15_0': [12, 1, 45, 1, 1], 'v14_0': [12, 52, 45, 1, 1]}

    mod, params = relay.frontend.from_onnx(onnx_model, shape_dict, freeze_params=True)

    opt = relay.transform.DivToMul()
    module = opt(mod)
    module_once = apply_optimizations(mod, opt, num_iterations=1)
    assert tvm.ir.structural_equal(module, module_once)

Triage

  • needs-triage
@Jupiterghy Jupiterghy added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug labels Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug
Projects
None yet
Development

No branches or pull requests

1 participant