You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "elvin-n (via GitHub)" <gi...@apache.org> on 2023/05/24 13:29:48 UTC
[GitHub] [tvm] elvin-n opened a new issue, #14936: [Bug] [Unity] [Metascheduler] cannot tune relax linear/matmul with M > 1 for cuda
elvin-n opened a new issue, #14936:
URL: https://github.com/apache/tvm/issues/14936
Unable to tune linear/matmul having M value bigger than 1.
The error message looks the same as in Issue#14935, but below is a definition through relax.linear
If reasons the same, probably make sense to close this one as "same as" status
``` python
import tvm
from tvm import meta_schedule as ms
from tvm.relay.backend import Executor
from tvm import relax
from tvm.relax.testing import nn
# -------- Func definition
class Linear(nn.Module):
def __init__(self, in_features, out_features, dtype: str, bias=False):
self.in_features = in_features
self.out_features = out_features
self.weight = nn.Parameter(
(out_features, in_features), dtype=dtype, name="linear_weight"
)
if bias:
self.bias = nn.Parameter((out_features,), dtype=dtype, name="linear_bias")
else:
self.bias = None
def forward(self, input: relax.Expr) -> relax.Var:
return nn.emit(relax.op.linear(input, self.weight, self.bias))
bb = relax.BlockBuilder()
seq_len = 4
with bb.function("func1"):
model = Linear(2048, 768, "float16")
input = nn.Placeholder((seq_len, 2048), dtype="float16", name="input")
with bb.dataflow():
res = model(input)
params = [
input,
] + model.parameters()
gv = bb.emit_output((res,))
bb.emit_func_output(gv, params)
mod = bb.get()
gv = mod.get_global_var("func1")
bb.update_func(gv, mod[gv].with_attr("func1", 1))
mod = relax.pipeline.get_pipeline()(mod)
mod = relax.transform.LiftTransformParams()(mod)
mod = tvm.tir.transform.ForceNarrowIndexToInt32()(mod)
# ------ Metascheduler starts here
database = None
strategy_name = "evolutionary"
name = f"relax_linear_{seq_len}_2048_2048_768"
work_dir = f"./{name}/"
module_equality_name = "ignore-ndarray"
target = tvm.target.Target("nvidia/geforce-rtx-2060", host="llvm")
executor = Executor("graph")
mod = mod.with_attr("executor", executor)
ndk_builder = ms.builder.LocalBuilder(timeout_sec=60)
evaluator_config=ms.runner.EvaluatorConfig(
number=3,
repeat=1,
min_repeat_ms=100,
enable_cpu_cache_flush=False,
)
ms_rpc_runner = ms.runner.LocalRunner(evaluator_config=evaluator_config,
alloc_repeat=1,
)
ms.relax_integration.tune_relax(
mod=mod,
target=target,
params={},
work_dir=work_dir,
max_trials_global=1024,
strategy=strategy_name,
builder=ndk_builder,
runner=ms_rpc_runner,
module_equality=module_equality_name,
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org