From bf8e7e00f846e1c43eb8741860509160a7339fa1 Mon Sep 17 00:00:00 2001 From: Elen Kalda Date: Fri, 4 Mar 2022 06:27:15 +0000 Subject: [PATCH] [microNPU] Remove unused code from testing infra (#10462) Removing some legacy code from infra.py that is not called by anything. --- tests/python/contrib/test_ethosu/infra.py | 93 ----------------------- 1 file changed, 93 deletions(-) diff --git a/tests/python/contrib/test_ethosu/infra.py b/tests/python/contrib/test_ethosu/infra.py index be5466c2f9a9..f46792c1e6e5 100644 --- a/tests/python/contrib/test_ethosu/infra.py +++ b/tests/python/contrib/test_ethosu/infra.py @@ -59,14 +59,6 @@ class AttachType(IntEnum): kScanUpdate = 5 -class VelaArtifacts: - def __init__(self): - self.cs = dict() - self.flash = dict() - self.sram = dict() - self.npu_ops = set() - - def print_payload(payload): cmds = deserialize_command_stream(payload) for cmd_val in cmds: @@ -90,84 +82,6 @@ def parse_cmd(binary_cmd): return command, value -def check_cmms_equivalency(vela_cmd, vela_value, tvm_value, ignore_cmds=None): - if ignore_cmds is None: - ignore_cmds = [] - if vela_value != tvm_value and vela_cmd not in ignore_cmds: - raise RuntimeError( - "ValueMismatch :: vela={}, tvm={} for command:{}".format( - vela_value, tvm_value, vela_cmd - ) - ) - - -def verify_cmms(cmms_tvm_blob, cmms_vela_blob): - vela_cmm = deserialize_command_stream(cmms_vela_blob) - tvm_cmm = deserialize_command_stream(cmms_tvm_blob) - cmms_zip = zip(vela_cmm, tvm_cmm) - - first_ifm_found = False - last_ofm_found = False - - ignore_commands = ( - cmd1.NPU_SET_DMA0_SRC, - cmd1.NPU_SET_DMA0_DST, - cmd1.NPU_SET_WEIGHT_BASE, - cmd1.NPU_SET_OFM_BASE0, - cmd1.NPU_SET_IFM_BASE0, - cmd1.NPU_SET_SCALE_BASE, - ) - - ofm_region_params = [] - ofm_bases = [] - for vela_cmm, tvm_cmm in cmms_zip: - vela_cmd, vela_value = parse_cmd(vela_cmm) - tvm_cmd, tvm_value = parse_cmd(tvm_cmm) - - assert vela_cmd == tvm_cmd - - # The first IFM region could be different, but it needs to be 1 and 3. - if vela_cmd == cmd0.NPU_SET_IFM_REGION and not first_ifm_found: - if vela_value == 1 and tvm_value == 3: - first_ifm_found = True - continue - - if vela_cmd == cmd1.NPU_SET_IFM_BASE0 and not first_ifm_found: - if tvm_value != 0: - raise RuntimeError("ValueError :: tvm primary ifm base should be zero") - continue - - # OFM regions should be cached to be checked later - if vela_cmd == cmd0.NPU_SET_OFM_REGION: - ofm_region_params.append((vela_value, tvm_value)) - continue - - # OFM bases should be cached to be checked later - if vela_cmd == cmd1.NPU_SET_OFM_BASE0: - ofm_bases.append((vela_value, tvm_value)) - continue - - check_cmms_equivalency(vela_cmd, vela_value, tvm_value, ignore_commands) - - # The last OFM region could be different but it should be 1 and 4. - last_vela_ofm_region, last_tvm_ofm_region = ofm_region_params.pop(-1) - if not (last_vela_ofm_region == 1 and last_tvm_ofm_region == 4): - raise RuntimeError( - "ValueMismatch :: vela={}, tvm={} for last ofm region it should be 1 and 4 respectively".format( - last_vela_ofm_region, last_tvm_ofm_region - ) - ) - - # The rest of the OFM regions should be the same. - for vela_value, tvm_value in ofm_region_params: - check_cmms_equivalency(vela_cmd, vela_value, tvm_value, ignore_commands) - - # The last OFM base should be zero for tvm - _, last_tvm_ofm_base = ofm_bases.pop(-1) - if not last_tvm_ofm_base == 0: - raise RuntimeError("ValueError :: tvm primary ofm base should be zero") - - def deserialize_command_stream(blob): assert isinstance(blob, bytes) payload_bytes = struct.unpack("<{0}I".format(len(blob) // 4), blob) @@ -260,13 +174,6 @@ def verify_source( ) -def flatten_numpy_data(data): - """Flatten the numpy tensor to be single dimensional""" - total_elements = data.size - reshaped_data = numpy.reshape(data, [total_elements]) - return reshaped_data - - class InputGenerator: def __init__(self, random_state): self._random_state = random_state