// Copyright 2019 Google LLC
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
//
// Auto-generated file. Do not edit!
//   Specification: test/f16-prelu.yaml
//   Generator: tools/generate-prelu-test.py


#include <gtest/gtest.h>

#include <xnnpack/common.h>
#include <xnnpack/isa-checks.h>

#include <xnnpack/prelu.h>
#include "prelu-microkernel-tester.h"


#if XNN_ENABLE_ARM_FP16 && (XNN_ARCH_ARM || XNN_ARCH_ARM64)
  TEST(F16_PRELU__NEONFP16ARITH_2X8, channels_eq_8) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    PReLUMicrokernelTester()
      .rows(2)
      .channels(8)
      .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, channels_div_8) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t channels = 16; channels < 80; channels += 8) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, channels_lt_8) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t channels = 1; channels < 8; channels++) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, channels_gt_8) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t channels = 9; channels < 16; channels++) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, rows_lt_2) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 1; rows < 2; rows++) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, rows_div_2) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 4; rows <= 8; rows += 2) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, rows_gt_2) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 3; rows < 4; rows++) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, input_stride) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .input_stride(43)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, output_stride) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .output_stride(43)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X8, inplace) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .inplace(true)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x8);
      }
    }
  }
#endif  // XNN_ENABLE_ARM_FP16 && (XNN_ARCH_ARM || XNN_ARCH_ARM64)


#if XNN_ENABLE_ARM_FP16 && (XNN_ARCH_ARM || XNN_ARCH_ARM64)
  TEST(F16_PRELU__NEONFP16ARITH_2X16, channels_eq_16) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    PReLUMicrokernelTester()
      .rows(2)
      .channels(16)
      .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, channels_div_16) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t channels = 32; channels < 160; channels += 16) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, channels_lt_16) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t channels = 1; channels < 16; channels++) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, channels_gt_16) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t channels = 17; channels < 32; channels++) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, rows_lt_2) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 1; rows < 2; rows++) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, rows_div_2) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 4; rows <= 8; rows += 2) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, rows_gt_2) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 3; rows < 4; rows++) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, input_stride) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .input_stride(83)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, output_stride) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .output_stride(83)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
      }
    }
  }

  TEST(F16_PRELU__NEONFP16ARITH_2X16, inplace) {
    TEST_REQUIRES_ARM_NEON_FP16_ARITH;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .inplace(true)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__neonfp16arith_2x16);
      }
    }
  }
#endif  // XNN_ENABLE_ARM_FP16 && (XNN_ARCH_ARM || XNN_ARCH_ARM64)


#if XNN_ARCH_X86 || XNN_ARCH_X86_64
  TEST(F16_PRELU__F16C_2X8, channels_eq_8) {
    TEST_REQUIRES_X86_F16C;
    PReLUMicrokernelTester()
      .rows(2)
      .channels(8)
      .Test(xnn_f16_prelu_ukernel__f16c_2x8);
  }

  TEST(F16_PRELU__F16C_2X8, channels_div_8) {
    TEST_REQUIRES_X86_F16C;
    for (size_t channels = 16; channels < 80; channels += 8) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__f16c_2x8);
    }
  }

  TEST(F16_PRELU__F16C_2X8, channels_lt_8) {
    TEST_REQUIRES_X86_F16C;
    for (size_t channels = 1; channels < 8; channels++) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__f16c_2x8);
    }
  }

  TEST(F16_PRELU__F16C_2X8, channels_gt_8) {
    TEST_REQUIRES_X86_F16C;
    for (size_t channels = 9; channels < 16; channels++) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__f16c_2x8);
    }
  }

  TEST(F16_PRELU__F16C_2X8, rows_lt_2) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 1; rows < 2; rows++) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__f16c_2x8);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X8, rows_div_2) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 4; rows <= 8; rows += 2) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__f16c_2x8);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X8, rows_gt_2) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 3; rows < 4; rows++) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__f16c_2x8);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X8, input_stride) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .input_stride(43)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__f16c_2x8);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X8, output_stride) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .output_stride(43)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__f16c_2x8);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X8, inplace) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 40; channels += 7) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .inplace(true)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__f16c_2x8);
      }
    }
  }
#endif  // XNN_ARCH_X86 || XNN_ARCH_X86_64


#if XNN_ARCH_X86 || XNN_ARCH_X86_64
  TEST(F16_PRELU__F16C_2X16, channels_eq_16) {
    TEST_REQUIRES_X86_F16C;
    PReLUMicrokernelTester()
      .rows(2)
      .channels(16)
      .Test(xnn_f16_prelu_ukernel__f16c_2x16);
  }

  TEST(F16_PRELU__F16C_2X16, channels_div_16) {
    TEST_REQUIRES_X86_F16C;
    for (size_t channels = 32; channels < 160; channels += 16) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__f16c_2x16);
    }
  }

  TEST(F16_PRELU__F16C_2X16, channels_lt_16) {
    TEST_REQUIRES_X86_F16C;
    for (size_t channels = 1; channels < 16; channels++) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__f16c_2x16);
    }
  }

  TEST(F16_PRELU__F16C_2X16, channels_gt_16) {
    TEST_REQUIRES_X86_F16C;
    for (size_t channels = 17; channels < 32; channels++) {
      PReLUMicrokernelTester()
        .rows(2)
        .channels(channels)
        .Test(xnn_f16_prelu_ukernel__f16c_2x16);
    }
  }

  TEST(F16_PRELU__F16C_2X16, rows_lt_2) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 1; rows < 2; rows++) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__f16c_2x16);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X16, rows_div_2) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 4; rows <= 8; rows += 2) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__f16c_2x16);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X16, rows_gt_2) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 3; rows < 4; rows++) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .Test(xnn_f16_prelu_ukernel__f16c_2x16);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X16, input_stride) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .input_stride(83)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__f16c_2x16);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X16, output_stride) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .output_stride(83)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__f16c_2x16);
      }
    }
  }

  TEST(F16_PRELU__F16C_2X16, inplace) {
    TEST_REQUIRES_X86_F16C;
    for (size_t rows = 1; rows <= 6; rows += 1) {
      for (size_t channels = 1; channels <= 80; channels += 15) {
        PReLUMicrokernelTester()
          .rows(rows)
          .channels(channels)
          .inplace(true)
          .iterations(1)
          .Test(xnn_f16_prelu_ukernel__f16c_2x16);
      }
    }
  }
#endif  // XNN_ARCH_X86 || XNN_ARCH_X86_64
