forked from google/XNNPACK
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathf16-velu.cc
80 lines (76 loc) · 6.42 KB
/
f16-velu.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// 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!
// Microkernel: f16-velu
// Generator: tools/generate-vunary-test.py
#include <array>
#include <cmath>
#include <cstdint>
#include <cstddef>
#include <limits>
#include <gtest/gtest.h>
#include "xnnpack.h"
#include "xnnpack/common.h"
#include "xnnpack/isa-checks.h"
#include "xnnpack/microparams-init.h"
#include "xnnpack/microparams.h"
#include "xnnpack/vunary.h"
#include "next_prime.h"
#include "vunary-microkernel-tester.h"
#define XNN_UKERNEL_WITH_PARAMS(arch_flags, ukernel, batch_tile, vector_tile, datatype, params_type, init_params)\
\
XNN_TEST_UNARY_BATCH_EQ(ukernel, arch_flags, batch_tile, datatype, ukernel, init_params); \
XNN_TEST_UNARY_BATCH_DIV(ukernel, arch_flags, batch_tile, datatype, ukernel, init_params); \
XNN_TEST_UNARY_BATCH_LT(ukernel, arch_flags, batch_tile, datatype, ukernel, init_params); \
XNN_TEST_UNARY_BATCH_GT(ukernel, arch_flags, batch_tile, datatype, ukernel, init_params); \
\
XNN_TEST_UNARY_INPLACE(ukernel, arch_flags, batch_tile, datatype, ukernel, init_params); \
TEST(ukernel, prescale) { \
TEST_REQUIRES_ARCH_FLAGS(arch_flags); \
const size_t batch_scale = get_batch_scale<datatype>(); \
const size_t batch_end = batch_tile * batch_scale; \
const size_t batch_step = std::max(1, batch_tile - 1); \
for (float prescale : std::array<float, 2>({0.1f, 10.0f})) { \
for (size_t batch_size = 1; batch_size <= 5 * batch_end; batch_size += batch_step) { \
VUnaryMicrokernelTester() \
.batch_size(batch_size) \
.prescale(prescale) \
.Test(ukernel, init_params); \
} \
} \
} \
\
TEST(ukernel, alpha) { \
TEST_REQUIRES_ARCH_FLAGS(arch_flags); \
const size_t batch_scale = get_batch_scale<datatype>(); \
const size_t batch_end = batch_tile * batch_scale; \
const size_t batch_step = std::max(1, batch_tile - 1); \
for (float alpha : std::array<float, 2>({0.3f, 3.0f})) { \
for (size_t batch_size = 1; batch_size <= 5 * batch_end; batch_size += batch_step) { \
VUnaryMicrokernelTester() \
.batch_size(batch_size) \
.alpha(alpha) \
.Test(ukernel, init_params); \
} \
} \
} \
\
TEST(ukernel, beta) { \
TEST_REQUIRES_ARCH_FLAGS(arch_flags); \
const size_t batch_scale = get_batch_scale<datatype>(); \
const size_t batch_end = batch_tile * batch_scale; \
const size_t batch_step = std::max(1, batch_tile - 1); \
for (float beta : std::array<float, 2>({0.3f, 3.0f})) { \
for (size_t batch_size = 1; batch_size <= 5 * batch_end; batch_size += batch_step) { \
VUnaryMicrokernelTester() \
.batch_size(batch_size) \
.beta(beta) \
.Test(ukernel, init_params); \
} \
} \
}
#include "src/f16-velu/f16-velu.h"
#undef XNN_UKERNEL_WITH_PARAMS