Exemplo n.º 1
0
def generate_test_cases(ukernel, row_tile, channel_tile, isa):
    """Generates all tests cases for a PRELU micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    row_tile: Number of rows (pixels) processed per one iteration of the outer
              loop of the micro-kernel.
    channel_tile: Number of channels processed per one iteration of the inner
                  loop of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, _ = ukernel.split("_", 3)
    test_args = [ukernel]
    if not isa or isa == "psimd":
        test_args.append("PReLUMicrokernelTester::Variant::Scalar")
    return xngen.preprocess(
        PRELU_TEST_TEMPLATE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "DATATYPE": datatype,
            "ROW_TILE": row_tile,
            "CHANNEL_TILE": channel_tile,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
        })
Exemplo n.º 2
0
def generate_test_cases(ukernel, cr, c_block, m_block, isa):
    """Generates all tests cases for a VMULCADDC micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    cr: CR parameter of the DWCONV micro-kernel.
    c_block: Number of C values processed per one iteration of the inner loop of
             the micro-kernel.
    m_block: Number of M values processed per one iteration of the outer loop of
             the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, _ = ukernel.split("_", 3)
    test_args = [ukernel]
    if not isa or isa == "psimd":
        test_args.append("VMulCAddCMicrokernelTester::Variant::Scalar")
    return xngen.preprocess(
        VMULCADDC_TEST_CODE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "DATATYPE": datatype,
            "CR": cr,
            "CBLOCK": c_block,
            "MBLOCK": m_block,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
            "sqrt": math.sqrt,
        })
def generate_test_cases(ukernel, channel_tile, row_tile, init_fn, isa):
    """Generates all tests cases for a VMULCADDC micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    channel_tile: Number of channels processed per one iteration of the inner
                  loop of the micro-kernel.
    row_tile: Number of rows processed per one iteration of the outer loop of
              the micro-kernel.
    init_fn: C name of the function to initialize microkernel parameters.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, _ = ukernel.split("_", 3)
    test_args = [ukernel]
    if init_fn:
        test_args.append(init_fn)
    return xngen.preprocess(
        VMULCADDC_TEST_TEMPLATE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "DATATYPE": datatype,
            "CHANNEL_TILE": channel_tile,
            "ROW_TILE": row_tile,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
        })
def generate_test_cases(ukernel, init_fn, primary_tile, incremental_tile,
                        channel_tile, isa):
    """Generates all tests cases for a MAXPOOL micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    init_fn: C name of the function to initialize microkernel parameters.
    primary_tile: Number of rows (pixels) processed per one iteration of the
                  primary outer loop of the micro-kernel.
    incremental_tile: Number of rows (pixels) processed per one iteration of
                      the incremental outer loop of the micro-kernel.
    channel_tile: Number of channels processed per one iteration of the inner
                  loops of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, _ = ukernel.split("_", 3)
    test_args = [ukernel, init_fn]
    return xngen.preprocess(
        MAXPOOL_TEST_TEMPLATE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "DATATYPE": datatype,
            "PRIMARY_TILE": primary_tile,
            "INCREMENTAL_TILE": incremental_tile,
            "CHANNEL_TILE": channel_tile,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
        })
Exemplo n.º 5
0
def generate_test_cases(ukernel, mr, k_block, isa):
    """Generates all tests cases for a GEMM micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    mr: MR parameter of the PACK micro-kernel.
    k_block: Number of K values processed per one iteration of the main loop of
             the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, _ = ukernel.split("_", 3)
    test_args = [ukernel]
    return xngen.preprocess(
        PACK_TEST_CODE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "UKERNEL_TYPE": ukernel_type.upper(),
            "UKERNEL_NAME": ukernel,
            "DATATYPE": datatype,
            "MR": mr,
            "KBLOCK": k_block,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
        })
Exemplo n.º 6
0
def generate_test_cases(ukernel, batch_tile, isa):
  """Generates all tests cases for a Vector Binary Operation micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    batch_tile: Number of batch elements processed per one iteration of the
                inner loop of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
  _, test_name = ukernel.split("_", 1)
  _, datatype, _ = ukernel.split("_", 2)
  test_args = [ukernel]
  if not isa:
    test_args.append("HSwishMicrokernelTester::Variant::Scalar")
  return xngen.preprocess(HSWISH_TEST_TEMPLATE, {
      "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
      "TEST_ARGS": test_args,
      "DATATYPE": datatype,
      "BATCH_TILE": batch_tile,
      "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
    })
Exemplo n.º 7
0
def generate_test_cases(ukernel, channel_tile, pixel_tile, isa):
  """Generates all tests cases for a BILINEAR micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    channel_tile: Number of channels processed per one iteration of the inner
                  loop of the micro-kernel.
    pixel_tile: Number of pixels processed per one iteration of the outer loop
                of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
  _, test_name = ukernel.split("_", 1)
  _, datatype, ukernel_type, _ = ukernel.split("_", 3)
  test_args = [ukernel]
  return xngen.preprocess(BILINEAR_TEST_TEMPLATE, {
      "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
      "TEST_FUNC": ukernel,
      "UKERNEL_TYPE": ukernel_type.upper(),
      "DATATYPE": datatype,
      "CHANNEL_TILE": channel_tile,
      "PIXEL_TILE": pixel_tile,
      "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
      "next_prime": next_prime,
    })
def generate_test_cases(ukernel, init_fn, elements_tile, isa):
    """Generates all tests cases for a RAddStoreExpMinusMax micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    init_fn: C name of the function to initialize microkernel parameters.
    elements_tile: Number of batch elements processed per one iteration of the
                   inner loop of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, _ = ukernel.split("_", 2)
    return xngen.preprocess(
        RADDSTOREEXPMINUSMAX_TEST_TEMPLATE, {
            "TEST_FUNCTION": ukernel,
            "INIT_FUNCTION": init_fn,
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "DATATYPE": datatype,
            "ELEMENTS_TILE": elements_tile,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
        })
Exemplo n.º 9
0
def generate_test_cases(ukernel, op_type, init_fn, batch_tile, isa):
  """Generates all tests cases for a Vector Unary Operation micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    op_type: Operation type.
    init_fn: C name of the function to initialize microkernel parameters.
    batch_tile: Number of batch elements processed per one iteration of the
                inner loop of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
  _, test_name = ukernel.split("_", 1)
  _, datatype, _ = ukernel.split("_", 2)
  test_args = [ukernel]
  if init_fn or op_type.startswith("Round"):
    if op_type.startswith("Round"):
      test_args.append("VUnaryMicrokernelTester::OpType::" + op_type)
    if init_fn is not None:
      test_args.append(init_fn)
  elif op_type not in ["Abs", "Negate", "Square", "SquareRoot"]:
    test_args.append("VUnaryMicrokernelTester::OpType::" + op_type)
    if not isa:
      test_args.append("VUnaryMicrokernelTester::Variant::Scalar")
  return xngen.preprocess(BINOP_TEST_TEMPLATE, {
      "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
      "TEST_ARGS": test_args,
      "DATATYPE": datatype,
      "BATCH_TILE": batch_tile,
      "OP_TYPE": op_type,
      "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
    })
Exemplo n.º 10
0
def generate_test_cases(ukernel, init_fn, input_datatype, output_datatype,
                        batch_tile, isa):
    """Generates all tests cases for a Vector Convert Operation micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    init_fn: C name of the function to initialize microkernel parameters.
    input_datatype: input conversion data type.
    output_datatype: output conversion data type.
    batch_tile: Number of batch elements processed per one iteration of the
                inner loop of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    test_args = [ukernel]
    if init_fn:
        test_args.append(init_fn)
    return xngen.preprocess(
        CVT_TEST_TEMPLATE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "BATCH_TILE": batch_tile,
            "INPUT_DATATYPE": input_datatype.upper(),
            "OUTPUT_DATATYPE": output_datatype.upper(),
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
        })
Exemplo n.º 11
0
def generate_test_cases(ukernel, op_type, activation_type, tester, batch_tile,
                        isa):
    """Generates all tests cases for a Vector Binary Operation micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    op_type: Operation type (ADD/MUL/SUB/etc).
    activation_type: Activation type (LINEAR/MINMAX/RELU).
    tester: C++ name of the tester class.
    batch_tile: Number of batch elements processed per one iteration of the
                inner loop of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, _ = ukernel.split("_", 2)
    test_args = [ukernel]
    if tester in ["VBinOpMicrokernelTester", "VBinOpCMicrokernelTester"]:
        test_args.append("%s::OpType::%s" % (tester, op_type))
    if not isa or isa == "psimd":
        test_args.append("%s::Variant::Scalar" % tester)
    return xngen.preprocess(
        BINOP_TEST_TEMPLATE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "TESTER": tester,
            "DATATYPE": datatype.upper(),
            "BATCH_TILE": batch_tile,
            "OP_TYPE": op_type,
            "ACTIVATION_TYPE": activation_type,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
        })
def generate_test_cases(ukernel, mr, nr, kr, sr, xw, k_block, init_fn,
                        requantization, is_pipelined, isa):
    """Generates all tests cases for a GEMM micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    mr: MR parameter of the GEMM micro-kernel.
    nr: NR parameter of the GEMM micro-kernel.
    kr: KR parameter of the GEMM micro-kernel.
    sr: SR parameter of the GEMM micro-kernel.
    xw: boolean indicator for microkernel with extended weights.
    k_block: Number of K values processed per one iteration of the main loop of
             the micro-kernel.
    init_fn: C name of the function to initialize microkernel parameters.
    requantization: name of the requantization scheme used by the microkernel.
    is_pipelined: Indicates if the micro-kernel is implemented with software
                  pipelining. Additional test cases are generated for software
                  pipelined micro-kernels to separately test prologue + epiloque
                  of the pipelined loop and iteration of the pipelined loop.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, activation, _ = ukernel.split("_", 4)
    if activation == "ukernel":
        activation = "linear"
    test_args = [ukernel]
    if init_fn:
        test_args.append(init_fn)
        if requantization:
            requantization_datatype = {"qc8": "qs8"}.get(datatype, datatype)
            test_args += [
              "xnn_init_%s_requantization_%s_params" % \
                (requantization_datatype, requantization),
              "xnn_%s_requantize_%s" % (requantization_datatype, requantization)
            ]
    return xngen.preprocess(
        GEMM_TEST_CODE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "UKERNEL_TYPE": ukernel_type.upper(),
            "DATATYPE": datatype,
            "ACTIVATION": activation.upper(),
            "MR": mr,
            "NR": nr,
            "KR": kr,
            "SR": sr,
            "EXTENDED_WEIGHTS": xw,
            "KBLOCK": k_block,
            "ADJKBLOCK": 2 * k_block if is_pipelined else k_block,
            "IS_PIPELINED": is_pipelined,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
        })
def generate_test_cases(ukernel, primary_tile, cr, kr, c_block, init_fn,
                        requantization, is_pipelined, isa):
    """Generates all tests cases for a DWCONV micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    cr: CR parameter of the DWCONV micro-kernel.
    kr: KR parameter of the DWCONV micro-kernel.
    k_block: Number of C values processed per one iteration of the main loop of
             the micro-kernel.
    init_fn: C name of the function to initialize microkernel parameters.
    requantization: name of the requantization scheme used by the microkernel.
    is_pipelined: Indicates if the micro-kernel is implemented with software
                  pipelining. Additional test cases are generated for software
                  pipelined micro-kernels to separately test prologue + epiloque
                  of the pipelined loop and iteration of the pipelined loop.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, activation, _ = ukernel.split("_", 4)
    if activation == "ukernel":
        activation = "linear"
    test_args = [ukernel]
    if init_fn:
        test_args.append(init_fn)
        if requantization:
            requantization_datatype = {"qc8": "qs8"}.get(datatype, datatype)
            test_args += [
              "xnn_init_%s_requantization_%s_params" % \
                (requantization_datatype, requantization),
              "xnn_%s_requantize_%s" % (requantization_datatype, requantization)
            ]
    return xngen.preprocess(
        DWCONV_TEST_CODE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "UKERNEL_TYPE": ukernel_type.upper(),
            "DATATYPE": datatype,
            "ACTIVATION": activation.upper(),
            "PRIMARY_TILE": primary_tile,
            "CR": cr,
            "KR": kr,
            "CBLOCK": c_block,
            "ADJCBLOCK": 2 * c_block if is_pipelined else c_block,
            "IS_PIPELINED": is_pipelined,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
            "sqrt": math.sqrt,
        })
def generate_test_cases(ukernel, kernel_height, kernel_width, subsampling, \
  padding, isa, height_tile, width_tile):
    """Generates all tests cases for a DWCONV2D CHW micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    kernel_height: convolution kernel height assumed by the micro-kernel.
    kernel_width: convolution kernel width assumed by the micro-kernel.
    subsampling: convolution subsampling (stride) assumed by the micro-kernel.
                 The same subsampling factor is assumed for both horizontal and
                 vertical directions.
    padding: convolution padding value assumed by the micro-kernel for right,
             bottom, and left padding. If convolution stride is 1, the same
             padding value is assumed for the top padding. If convolution stride
             is different than 1, top padding is specified via micro-kernel
             parameter, and can be either padding or (padding - 1).
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.
    height_tile: number of output rows processed in one iteration of the main
                 loop of the micro-kernel.
    width_tile: number of output columns processed in one iteration of the main
                loop of the micro-kernel.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, _ = ukernel.split("_", 3)
    test_args = [ukernel]
    if not isa:
        test_args.append("DWConv2DMicrokernelTester::Variant::Scalar")
    return xngen.preprocess(
        TEST_TEMPLATE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "UKERNEL_TYPE": ukernel_type.upper(),
            "DATATYPE": datatype,
            "KERNEL_HEIGHT": kernel_height,
            "KERNEL_WIDTH": kernel_width,
            "SUBSAMPLING": subsampling,
            "PADDING": padding,
            "HEIGHT_TILE": height_tile,
            "WIDTH_TILE": width_tile,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
        })
Exemplo n.º 15
0
def generate_test_cases(ukernel, mr, nr, kr, sr, k_block, is_pipelined, isa):
    """Generates all tests cases for a GEMM micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    mr: MR parameter of the GEMM micro-kernel.
    nr: NR parameter of the GEMM micro-kernel.
    kr: KR parameter of the GEMM micro-kernel.
    sr: SR parameter of the GEMM micro-kernel.
    k_block: Number of K values processed per one iteration of the main loop of
             the micro-kernel.
    is_pipelined: Indicates if the micro-kernel is implemented with software
                  pipelining. Additional test cases are generated for software
                  pipelined micro-kernels to separately test prologue + epiloque
                  of the pipelined loop and iteration of the pipelined loop.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, activation, _ = ukernel.split("_", 4)
    if activation == "ukernel":
        activation = "linear"
    test_args = [ukernel]
    if activation not in ["linear", "relu"] and (not isa or isa == "psimd"):
        test_args.append("GemmMicrokernelTester::Variant::Scalar")
    return xngen.preprocess(
        GEMM_TEST_CODE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "UKERNEL_TYPE": ukernel_type.upper(),
            "DATATYPE": datatype,
            "ACTIVATION": activation.upper(),
            "MR": mr,
            "NR": nr,
            "KR": kr,
            "SR": sr,
            "KBLOCK": k_block,
            "ADJKBLOCK": 2 * k_block if is_pipelined else k_block,
            "IS_PIPELINED": is_pipelined,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
        })
Exemplo n.º 16
0
def generate_test_cases(ukernel, cr, kr, c_block, is_pipelined, isa):
    """Generates all tests cases for a DWCONV micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    cr: CR parameter of the DWCONV micro-kernel.
    kr: KR parameter of the DWCONV micro-kernel.
    k_block: Number of C values processed per one iteration of the main loop of
             the micro-kernel.
    is_pipelined: Indicates if the micro-kernel is implemented with software
                  pipelining. Additional test cases are generated for software
                  pipelined micro-kernels to separately test prologue + epiloque
                  of the pipelined loop and iteration of the pipelined loop.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, activation, _ = ukernel.split("_", 4)
    if activation == "ukernel":
        activation = "linear"
    test_args = [ukernel]
    if activation != "linear" and not isa:
        test_args.append("DWConvMicrokernelTester::Variant::Scalar")
    return xngen.preprocess(
        DWCONV_TEST_CODE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "UKERNEL_TYPE": ukernel_type.upper(),
            "DATATYPE": datatype,
            "ACTIVATION": activation.upper(),
            "CR": cr,
            "KR": kr,
            "CBLOCK": c_block,
            "ADJCBLOCK": 2 * c_block if is_pipelined else c_block,
            "IS_PIPELINED": is_pipelined,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
            "next_prime": next_prime,
            "sqrt": math.sqrt,
        })
Exemplo n.º 17
0
def generate_test_cases(ukernel, batch_tile, isa):
    """Generates all tests cases for a LUT micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    batch_tile: Number of batch elements processed per one iteration of the
                inner loop of the micro-kernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    return xngen.preprocess(
        LUT_TEST_TEMPLATE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "BATCH_TILE": batch_tile,
            "UKERNEL_NAME": ukernel,
            "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
        })
Exemplo n.º 18
0
def generate_test_cases(ukernel, mr, nr, k_block, is_pipelined, isa):
    """Generates all tests cases for a GEMM micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    mr: MR parameter of the GEMM micro-kernel.
    nr: NR parameter of the GEMM micro-kernel.
    k_block: Number of K values processed per one iteration of the main loop of
             the micro-kernel.
    is_pipelined: Indicates if the micro-kernel is implemented with software
                  pipelining. Additional test cases are generated for software
                  pipelined micro-kernels to separately test prologue + epiloque
                  of the pipelined loop and iteration of the pipelined loop.
    isa: instruction set required to run the micro-kernel. Generated unit test
         will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
    _, test_name = ukernel.split("_", 1)
    _, datatype, ukernel_type, _ = ukernel.split("_", 3)
    test_args = [ukernel]
    if not isa or isa == "psimd":
        test_args.append("SpMMMicrokernelTester::Variant::Scalar")
    return xngen.preprocess(
        TEST_TEMPLATE, {
            "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
            "TEST_ARGS": test_args,
            "UKERNEL_TYPE": ukernel_type.upper(),
            "DATATYPE": datatype,
            "MR": mr,
            "NR": nr,
            "KBLOCK": k_block,
            "ADJKBLOCK": 2 * k_block if is_pipelined else k_block,
            "IS_PIPELINED": is_pipelined,
            "ISA_CHECK": ISA_TO_CHECK_MAP.get(isa, ""),
            "next_prime": next_prime,
        })
Exemplo n.º 19
0
def generate_test_cases(ukernel, tile_height, tile_width, isa):
  """Generates all tests cases for a Vector Convert Operation micro-kernel.

  Args:
    ukernel: C name of the micro-kernel function.
    tile_height: Number of vertical elements processed by the ukernel.
    tile_width: Number of horizontal elements processed by the ukernel.
    isa: instruction set required to run the micro-kernel. Generated unit test
      will skip execution if the host processor doesn't support this ISA.

  Returns:
    Code for the test case.
  """
  _, test_name = ukernel.split("_", 1)
  test_args = [ukernel]
  return xngen.preprocess(
      TRANSPOSE_TEST_TEMPLATE, {
          "TEST_NAME": test_name.upper().replace("UKERNEL_", ""),
          "KERNEL": ukernel,
          "TILE_HEIGHT": tile_height,
          "TILE_WIDTH": tile_width,
          "ISA_CHECK": xnncommon.generate_isa_check_macro(isa),
      })