Skip to content

[Bug] Customize Optimization Tutorial Error #18584

@alexxony

Description

@alexxony

Thanks for participating in the TVM community! We use https://discuss.tvm.ai for any general usage questions and discussions. The issue tracker is used for actionable items such as feature proposals discussion, roadmaps, and bug tracking. You are always welcomed to post on the forum first 😸

Issues that are inactive for a period of time may get closed. We adopt this policy so that we won't lose track of actionable issues that may fall at the bottom of the pile. Feel free to reopen a new one if you feel there is an additional problem that needs attention when an old one gets closed.

Expected behavior

I tried to show mod.

Actual behavior

but as you see below, it occurred error

Image

Environment

Any environment details, such as: Operating System, TVM version, etc

tvm_02.ipynb

Steps to reproduce

Import cublas pattern

import tvm.relax.backend.cuda.cublas as _cublas

Define a new pass for CUBLAS dispatch

@tvm.transform.module_pass(opt_level=0, name="CublasDispatch")
class CublasDispatch:
def transform_module(self, mod: IRModule, _ctx: tvm.transform.PassContext) -> IRModule:
# Check if CUBLAS is enabled
if not tvm.get_global_func("relax.ext.cublas", True):
raise Exception("CUBLAS is not enabled.")

    # Get interested patterns
    patterns = [relax.backend.get_pattern("cublas.matmul_transposed_bias_relu")]
    # Note in real-world cases, we usually get all patterns
    # patterns = relax.backend.get_patterns_with_prefix("cublas")

    # Fuse ops by patterns and then run codegen
    mod = relax.transform.FuseOpsByPattern(patterns, annotate_codegen=True)(mod)
    mod = relax.transform.RunCodegen()(mod)
    return mod

mod = CublasDispatch()(mod)
mod.show()

Triage

Please refer to the list of label tags here to find the relevant tags and add them below in a bullet format (example below).

  • needs-triage

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions