Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions ci/jenkins/docker-images.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

# This data file is read during when Jenkins runs job to determine docker images.
[jenkins]
ci_arm: tlcpack/ci-arm:20250214-034537-bd1411f8
ci_cpu: tlcpack/ci_cpu:20250214-034537-bd1411f8
ci_gpu: tlcpack/ci-gpu:20250214-034537-bd1411f8
ci_hexagon: tlcpack/ci-hexagon:20250214-034537-bd1411f8
ci_i386: tlcpack/ci-i386:20250214-034537-bd1411f8
ci_lint: tlcpack/ci-lint:20250214-034537-bd1411f8
ci_wasm: tlcpack/ci-wasm:20250214-034537-bd1411f8
ci_arm: tlcpack/ci-arm:20250225-035137-aeadc31c
ci_cpu: tlcpack/ci_cpu:20250225-035137-aeadc31c
ci_gpu: tlcpack/ci-gpu:20250225-035137-aeadc31c
ci_hexagon: tlcpack/ci-hexagon:20250225-035137-aeadc31c
ci_i386: tlcpack/ci-i386:20250225-035137-aeadc31c
ci_lint: tlcpack/ci-lint:20250225-035137-aeadc31c
ci_wasm: tlcpack/ci-wasm:20250225-035137-aeadc31c
28 changes: 4 additions & 24 deletions ci/jenkins/unity_jenkinsfile.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils

// NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. -->
ci_lint = 'tlcpack/ci_lint:20250214-034537-bd1411f8'
ci_gpu = 'tlcpack/ci_gpu:20250214-034537-bd1411f8'
ci_cpu = 'tlcpack/ci_cpu:20250214-034537-bd1411f8'
ci_wasm = 'tlcpack/ci-wasm:v0.72'
ci_i386 = 'tlcpack/ci-i386:v0.75'
ci_qemu = 'tlcpack/ci-qemu:v0.11'
ci_arm = 'tlcpack/ci-arm:v0.08'
ci_hexagon = 'tlcpack/ci_hexagon:20250214-034537-bd1411f8'
ci_lint = 'tlcpack/ci_lint:20250225-035137-aeadc31c'
ci_gpu = 'tlcpack/ci_gpu:20250225-035137-aeadc31c'
ci_cpu = 'tlcpack/ci_cpu:20250225-035137-aeadc31c'
// <--- End of regex-scanned config.

// Parameters to allow overriding (in Jenkins UI), the images
Expand All @@ -47,12 +42,7 @@ properties([
parameters([
string(name: 'ci_lint_param', defaultValue: ''),
string(name: 'ci_cpu_param', defaultValue: ''),
string(name: 'ci_gpu_param', defaultValue: ''),
string(name: 'ci_wasm_param', defaultValue: ''),
string(name: 'ci_i386_param', defaultValue: ''),
string(name: 'ci_qemu_param', defaultValue: ''),
string(name: 'ci_arm_param', defaultValue: ''),
string(name: 'ci_hexagon_param', defaultValue: '')
string(name: 'ci_gpu_param', defaultValue: '')
])
])

Expand Down Expand Up @@ -178,22 +168,12 @@ def lint(node_type) {
ci_lint = params.ci_lint_param ?: ci_lint
ci_cpu = params.ci_cpu_param ?: ci_cpu
ci_gpu = params.ci_gpu_param ?: ci_gpu
ci_wasm = params.ci_wasm_param ?: ci_wasm
ci_i386 = params.ci_i386_param ?: ci_i386
ci_qemu = params.ci_qemu_param ?: ci_qemu
ci_arm = params.ci_arm_param ?: ci_arm
ci_hexagon = params.ci_hexagon_param ?: ci_hexagon

sh(script: """
echo "Docker images being used in this build:"
echo " ci_lint = ${ci_lint}"
echo " ci_cpu = ${ci_cpu}"
echo " ci_gpu = ${ci_gpu}"
echo " ci_wasm = ${ci_wasm}"
echo " ci_i386 = ${ci_i386}"
echo " ci_qemu = ${ci_qemu}"
echo " ci_arm = ${ci_arm}"
echo " ci_hexagon = ${ci_hexagon}"
""", label: 'Docker image names')
}
}
Expand Down
18 changes: 10 additions & 8 deletions docs/how_to/tutorials/e2e_opt_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@
# Give an example argument to torch.export
example_args = (torch.randn(1, 3, 224, 224, dtype=torch.float32),)

# Convert the model to IRModule
with torch.no_grad():
exported_program = export(torch_model, example_args)
mod = from_exported_program(exported_program, keep_params_as_input=True)
# Skip running in CI environment
IS_IN_CI = os.getenv("CI", "") == "true"

mod, params = relax.frontend.detach_params(mod)
mod.show()
if not IS_IN_CI:
# Convert the model to IRModule
with torch.no_grad():
exported_program = export(torch_model, example_args)
mod = from_exported_program(exported_program, keep_params_as_input=True)

mod, params = relax.frontend.detach_params(mod)
mod.show()

######################################################################
# IRModule Optimization
Expand All @@ -96,8 +100,6 @@
target = tvm.target.Target("nvidia/geforce-rtx-3090-ti") # Change to your target device
work_dir = "tuning_logs"

# Skip running in CI environment
IS_IN_CI = os.getenv("CI", "") == "true"
if not IS_IN_CI:
mod = relax.get_pipeline("static_shape_tuning", target=target, total_trials=TOTAL_TRIALS)(mod)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def create_convert_map(
relax.op.expand_dims(self.env[node.args[0]], node.args[1])
),
"view.default": self._reshape,
"reshape.default": self._reshape,
# tensor creation
"_to_copy.default": self._to_copy,
"arange.start": self._arange,
Expand Down
27 changes: 21 additions & 6 deletions tests/python/relax/test_frontend_dynamo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
from tvm.script import ir as I
from tvm.script import relax as R
from tvm.script import tir as T
from packaging import version

torch_version = torch.__version__


def test_relax_dynamo():
Expand Down Expand Up @@ -154,6 +157,10 @@ def Func1(x, y):
tvm.testing.assert_allclose(opt_func(x, y), opt_func(x, y))


@pytest.mark.skipif(
version.parse(torch_version) >= version.parse("2.6.0"),
reason="Tests not compatible with PyTorch >= 2.6",
)
def test_subgraph_capture():
import torch
from tvm.relax.frontend.torch.dynamo import dynamo_capture_subgraphs
Expand Down Expand Up @@ -268,6 +275,10 @@ def subgraph_0(
tvm.ir.assert_structural_equal(mod, expected)


@pytest.mark.skipif(
version.parse(torch_version) >= version.parse("2.6.0"),
reason="Tests not compatible with PyTorch >= 2.6",
)
def verify_dynamo_model(torch_model, input_info, binding, expected):
import torch
import torch._dynamo as dynamo
Expand All @@ -276,7 +287,7 @@ def verify_dynamo_model(torch_model, input_info, binding, expected):
args = []
for info in input_info:
args.append(torch.zeros(*info[0], dtype=_convert_data_type(info[1])))
graph_model = dynamo.export(torch_model, *args)[0]
graph_model = dynamo.export(torch_model)(*args)[0]
mod = from_fx(graph_model, input_info, unwrap_unit_return_tuple=True)
binding = {k: tvm.nd.array(v) for k, v in binding.items()}
expected = relax.transform.BindParams("main", binding)(expected)
Expand Down Expand Up @@ -315,7 +326,7 @@ def forward(self, input):
class Expected1:
@R.function
def main(
inp_0: R.Tensor((256, 256), dtype="float32")
inp_0: R.Tensor((256, 256), dtype="float32"),
) -> R.Tensor((10, 10), dtype="float32"):
with R.dataflow():
lv: R.Tensor((10, 10), dtype="float32") = R.full(
Expand Down Expand Up @@ -346,7 +357,7 @@ def forward(self, input):
class Expected1:
@R.function
def main(
inp_0: R.Tensor((256, 256), dtype="float32")
inp_0: R.Tensor((256, 256), dtype="float32"),
) -> R.Tensor((10, 10), dtype="float32"):
with R.dataflow():
lv: R.Tensor((10, 10), dtype="float32") = R.full(
Expand Down Expand Up @@ -381,7 +392,7 @@ def forward(self, input):
class ExpectedGeLU:
@R.function
def main(
inp_0: R.Tensor((128, 256), dtype="float32")
inp_0: R.Tensor((128, 256), dtype="float32"),
) -> R.Tensor((128, 256), dtype="float32"):
with R.dataflow():
lv: R.Tensor((128, 256), dtype="float32") = R.nn.gelu(inp_0)
Expand All @@ -393,7 +404,7 @@ def main(
class ExpectedGeLUTanh:
@R.function
def main(
inp_0: R.Tensor((128, 256), dtype="float32")
inp_0: R.Tensor((128, 256), dtype="float32"),
) -> R.Tensor((128, 256), dtype="float32"):
with R.dataflow():
lv: R.Tensor((128, 256), dtype="float32") = R.nn.gelu_tanh(inp_0)
Expand Down Expand Up @@ -490,7 +501,7 @@ def main(
class Expected2:
@R.function
def main(
inp_0: R.Tensor((1, 77, 1280), dtype="float32")
inp_0: R.Tensor((1, 77, 1280), dtype="float32"),
) -> R.Tensor((1, 77, 1280), dtype="float32"):
with R.dataflow():
lv: R.Tensor((1,), dtype="int64") = R.arange(
Expand Down Expand Up @@ -525,6 +536,10 @@ def forward(self, input1):
verify_dynamo_model(Select2(), [([1, 77, 1280], "float32")], {}, Expected2)


@pytest.mark.skipif(
version.parse(torch_version) >= version.parse("2.6.0"),
reason="Need to support dynamic arange in Relax",
)
@tvm.testing.requires_gpu
def test_arange():
import torch
Expand Down
19 changes: 19 additions & 0 deletions tests/python/relax/test_frontend_from_exported_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
from tvm.script import relax as R
from tvm.script import tir as T
from tvm.relax.frontend.torch import from_exported_program
from packaging import version

torch_version = torch.__version__


def verify_model(torch_model, example_args, binding, expected):
Expand Down Expand Up @@ -905,6 +908,10 @@ def main(
verify_model(Sub2(), example_args2, {}, expected_sub2)


@pytest.mark.skipif(
version.parse(torch_version) >= version.parse("2.6.0"),
reason="Tests not compatible with PyTorch >= 2.6",
)
def test_batchnorm2d():
class BatchNorm2d(Module):
def __init__(self):
Expand Down Expand Up @@ -2582,6 +2589,10 @@ def main(
verify_model(Expand2(), example_args, {}, expected1)


@pytest.mark.skipif(
version.parse(torch_version) >= version.parse("2.6.0"),
reason="Tests not compatible with PyTorch >= 2.6",
)
def test_flatten():
class Flatten(Module):
def __init__(self):
Expand Down Expand Up @@ -2783,6 +2794,10 @@ def main(
verify_model(Slice2(), example_args, {}, expected2)


@pytest.mark.skipif(
version.parse(torch_version) >= version.parse("2.6.0"),
reason="Tests not compatible with PyTorch >= 2.6",
)
def test_split():
class Chunk(Module):
def forward(self, input):
Expand Down Expand Up @@ -3192,6 +3207,10 @@ def main(
verify_model(NewOnes(), example_args, {}, expected1)


@pytest.mark.skipif(
version.parse(torch_version) >= version.parse("2.6.0"),
reason="Tests not compatible with PyTorch >= 2.6",
)
def test_to_copy():
# float
class ToFloat(Module):
Expand Down
Loading