CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
91 lines
2.7 KiB
Python
91 lines
2.7 KiB
Python
# Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
from copy import deepcopy
|
|
|
|
from rocisa.asmpass import rocIsaPass, rocIsaPassOption
|
|
from rocisa.code import KernelBody, Label, Module
|
|
from rocisa.container import sgpr
|
|
from rocisa.instruction import SSwapPCB64
|
|
|
|
|
|
def test_swappc_callee_funcs_survive_deepcopy():
|
|
inst = SSwapPCB64(dst=sgpr(26, 2), src=sgpr(12, 2))
|
|
inst.calleeFuncs = ["label_Activation_Relu_VW1", "label_Activation_Gelu_VW1"]
|
|
|
|
copied = deepcopy(inst)
|
|
inst.calleeFuncs[0] = "changed"
|
|
|
|
assert copied.calleeFuncs == ["label_Activation_Relu_VW1", "label_Activation_Gelu_VW1"]
|
|
|
|
|
|
def test_module_callable_metadata_survives_deepcopy():
|
|
mod = Module("label_Activation_Relu_VW1")
|
|
mod.isCallable = True
|
|
mod.callableName = "label_Activation_Relu_VW1"
|
|
|
|
copied = deepcopy(mod)
|
|
|
|
assert copied.isCallable
|
|
assert copied.callableName == "label_Activation_Relu_VW1"
|
|
|
|
|
|
def test_remove_duplicated_function_canonicalizes_swappc_callees():
|
|
body = Module("body")
|
|
|
|
for label in ("Activation_Relu_VW1_0", "Activation_Relu_VW1_1"):
|
|
act_func = Module("ActFunc_VW1_Sgpr0_Tmp0_0")
|
|
label_module = Module(f"{label}_module")
|
|
label_module.add(Label(label, ""))
|
|
act_func.add(label_module)
|
|
body.add(act_func)
|
|
|
|
swappc = SSwapPCB64(dst=sgpr(26, 2), src=sgpr(12, 2))
|
|
swappc.calleeFuncs = ["label_Activation_Relu_VW1_1"]
|
|
body.add(swappc)
|
|
|
|
kernel = KernelBody("test")
|
|
kernel.addBody(body)
|
|
options = rocIsaPassOption()
|
|
options.insertDelayAlu = False
|
|
options.removeDupFunc = True
|
|
options.removeDupAssign = False
|
|
options.getCycles = False
|
|
|
|
rocIsaPass(kernel, options)
|
|
|
|
assert swappc.calleeFuncs == ["label_Activation_Relu_VW1_0"]
|
|
|
|
|
|
def test_remove_duplicated_function_preserves_non_duplicate_swappc_callees():
|
|
body = Module("body")
|
|
|
|
for label in ("Activation_Relu_VW1_0", "Activation_Relu_VW1_1"):
|
|
act_func = Module("ActFunc_VW1_Sgpr0_Tmp0_0")
|
|
label_module = Module(f"{label}_module")
|
|
label_module.add(Label(label, ""))
|
|
act_func.add(label_module)
|
|
body.add(act_func)
|
|
|
|
swappc = SSwapPCB64(dst=sgpr(26, 2), src=sgpr(12, 2))
|
|
swappc.calleeFuncs = [
|
|
"label_Activation_Relu_VW1_1",
|
|
"label_Activation_Gelu_VW1_1",
|
|
]
|
|
body.add(swappc)
|
|
|
|
kernel = KernelBody("test")
|
|
kernel.addBody(body)
|
|
options = rocIsaPassOption()
|
|
options.insertDelayAlu = False
|
|
options.removeDupFunc = True
|
|
options.removeDupAssign = False
|
|
options.getCycles = False
|
|
|
|
rocIsaPass(kernel, options)
|
|
|
|
assert swappc.calleeFuncs == [
|
|
"label_Activation_Relu_VW1_0",
|
|
"label_Activation_Gelu_VW1_1",
|
|
]
|