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

[XPU] fix device version in unittests #64414

Merged
Merged
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
30 changes: 23 additions & 7 deletions test/xpu/get_test_cover_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ def create_classes(self):
return base_class, classes


def get_version_str(xpu_version):
if xpu_version == core.XPUVersion.XPU1:
return "xpu1"
if xpu_version == core.XPUVersion.XPU2:
return "xpu2"
if xpu_version == core.XPUVersion.XPU3:
return "xpu3"
raise ValueError("unknown xpu version, not 1, 2, or 3")


def get_op_white_list():
op_white_list = xpu_test_op_white_list
if os.getenv('XPU_TEST_OP_WHITE_LIST') is not None:
Expand All @@ -117,19 +127,25 @@ def get_op_white_list():

def get_type_white_list():
xpu_version = core.get_xpu_device_version(0)
version_str = "xpu2" if xpu_version == core.XPUVersion.XPU2 else "xpu1"
version_str = get_version_str(xpu_version)
xpu1_type_white_list = []
xpu2_type_white_list = []
xpu3_type_white_list = []
for device_type in xpu_test_device_type_white_list:
device, t_type = device_type.split("_")
if "xpu1" == device:
xpu1_type_white_list.append(t_type)
else:
elif "xpu2" == device:
xpu2_type_white_list.append(t_type)
elif "xpu3" == device:
xpu3_type_white_list.append(t_type)
if version_str == "xpu1":
type_white_list = xpu1_type_white_list
elif version_str == "xpu2":
type_white_list = xpu2_type_white_list
elif version_str == "xpu3":
type_white_list = xpu3_type_white_list

type_white_list = (
xpu1_type_white_list if version_str == "xpu1" else xpu2_type_white_list
)
if os.getenv('XPU_TEST_TYPE_WHITE_LIST') is not None:
type_white_list.extend(
os.getenv('XPU_TEST_TYPE_WHITE_LIST').strip().split(',')
Expand Down Expand Up @@ -167,7 +183,7 @@ def get_device_op_type_white_list():
def make_xpu_op_list(xpu_version):
ops = []
raw_op_list = core.get_xpu_device_op_list(xpu_version)
version_str = "xpu2" if xpu_version == core.XPUVersion.XPU2 else "xpu1"
version_str = get_version_str(xpu_version)
op_white_list = get_op_white_list()
type_white_list = get_type_white_list()
op_type_white_list = get_op_type_white_list()
Expand Down Expand Up @@ -310,7 +326,7 @@ def create_test_class(

def get_test_cover_info():
xpu_version = core.get_xpu_device_version(0)
version_str = "xpu2" if xpu_version == core.XPUVersion.XPU2 else "xpu1"
version_str = get_version_str(xpu_version)
xpu_op_list = make_xpu_op_list(xpu_version)
xpu_op_covered = []

Expand Down