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

Specify the cutlass codegen for TVM #1

Closed
YukeWang96 opened this issue Jan 9, 2022 · 6 comments
Closed

Specify the cutlass codegen for TVM #1

YukeWang96 opened this issue Jan 9, 2022 · 6 comments

Comments

@YukeWang96
Copy link

How does this part of code specify the cutlasscodegen for code generation?

mod = partition_for_cutlass(mod, params)
print(mod)
mod, num_cutlass_partition = tune_cutlass_kernels(
mod, sm, profile_all=True, use_multiprocessing=True, tmp_dir=tmp_dir
)
with tvm.transform.PassContext(opt_level=3):
lib = relay.build(mod, target="cuda", params=params)
lib = build_cutlass_kernels(lib, sm, tmp_dir, lib_path)
rt_mod = tvm.contrib.graph_executor.GraphModule(lib["default"](dev))
return rt_mod, dev, num_cutlass_partition

@masahi
Copy link
Owner

masahi commented Jan 9, 2022

It is done by partition_for_cutlass.
https://github.com/apache/tvm/blob/e7f36487dfdb6c4b7b544be155d3869002d7281b/python/tvm/relay/op/contrib/cutlass.py#L175

Each pattern is prefixed with cutlass. and transform.AnnotateTarget(["cutlass"]) tells the graph partitioner what ops to partition.

@YukeWang96
Copy link
Author

Thanks for your quick reply, I encounter another problem, after using annotateTarget on the defined mod

AssertionError: annotation.compiler_begin doesn't have an FTVMStrategy registered. You can register one in python with `tvm.relay.op.register_strategy`.

is this because of a missing strategy for the operator?

@masahi
Copy link
Owner

masahi commented Jan 9, 2022

I don't think so. annotation.compiler_begin is not a real op, so there is no strategy for it. This op is supposed to disappear after you run PartitionGraph, have you run it?

@YukeWang96
Copy link
Author

May I know which line or code snippet eliminates this annotation.compiler_begin.
Does this line make difference?
https://github.com/apache/tvm/blob/e7f36487dfdb6c4b7b544be155d3869002d7281b/python/tvm/relay/op/contrib/cutlass.py#L256

@masahi
Copy link
Owner

masahi commented Jan 9, 2022

As I said above, it's PartitionGraph's job https://github.com/apache/tvm/blob/e7f36487dfdb6c4b7b544be155d3869002d7281b/python/tvm/relay/op/contrib/cutlass.py#L258

@YukeWang96
Copy link
Author

It works, thanks a lot!

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

2 participants