Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 1 | /* |
Yair Schwarzbaum | 298b2c0 | 2022-02-01 08:55:56 +0200 | [diff] [blame] | 2 | * Copyright (c) 2019-2022 Arm Limited. |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "arm_compute/core/Types.h" |
| 25 | #include "arm_compute/runtime/NEON/functions/NECast.h" |
| 26 | #include "arm_compute/runtime/Tensor.h" |
| 27 | #include "arm_compute/runtime/TensorAllocator.h" |
Yair Schwarzbaum | 298b2c0 | 2022-02-01 08:55:56 +0200 | [diff] [blame] | 28 | #include "src/common/cpuinfo/CpuIsaInfo.h" |
| 29 | #include "src/cpu/kernels/CpuCastKernel.h" |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 30 | #include "tests/NEON/Accessor.h" |
| 31 | #include "tests/PaddingCalculator.h" |
| 32 | #include "tests/datasets/ConvertPolicyDataset.h" |
| 33 | #include "tests/datasets/ShapeDatasets.h" |
| 34 | #include "tests/framework/Asserts.h" |
| 35 | #include "tests/framework/Macros.h" |
| 36 | #include "tests/framework/datasets/Datasets.h" |
| 37 | #include "tests/validation/Validation.h" |
| 38 | #include "tests/validation/fixtures/CastFixture.h" |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 39 | namespace arm_compute |
| 40 | { |
| 41 | namespace test |
| 42 | { |
| 43 | namespace validation |
| 44 | { |
| 45 | namespace |
| 46 | { |
| 47 | // Tolerance |
| 48 | constexpr AbsoluteTolerance<float> one_tolerance(1); |
| 49 | constexpr AbsoluteTolerance<float> zero_tolerance(0); |
| 50 | |
| 51 | /* |
| 52 | *This function ignores the scale and zeroPoint of quanized tensors,so QASYMM8 input is treated as uint8 values. |
| 53 | */ |
| 54 | |
| 55 | /** Input data sets **/ |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 56 | |
| 57 | // QASYMM8_SIGNED |
| 58 | const auto CastQASYMM8_SIGNEDtoS16Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8_SIGNED), framework::dataset::make("DataType", DataType::S16)); |
| 59 | const auto CastQASYMM8_SIGNEDtoS32Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8_SIGNED), framework::dataset::make("DataType", DataType::S32)); |
| 60 | const auto CastQASYMM8_SIGNEDtoF32Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8_SIGNED), framework::dataset::make("DataType", DataType::F32)); |
| 61 | const auto CastQASYMM8_SIGNEDtoF16Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8_SIGNED), framework::dataset::make("DataType", DataType::F16)); |
| 62 | |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 63 | // QASYMM8 |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 64 | const auto CastQASYMM8toF16Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::F16)); |
| 65 | const auto CastQASYMM8toF32Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::F32)); |
| 66 | const auto CastQASYMM8toS32Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::S32)); |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 67 | |
| 68 | // U8 |
| 69 | const auto CastU8toU16Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U16)); |
| 70 | const auto CastU8toS16Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::S16)); |
| 71 | const auto CastU8toS32Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::S32)); |
| 72 | const auto CastU8toF32Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::F32)); |
| 73 | |
| 74 | // U16 |
| 75 | const auto CastU16toU8Dataset = combine(framework::dataset::make("DataType", DataType::U16), framework::dataset::make("DataType", DataType::U8)); |
| 76 | const auto CastU16toU32Dataset = combine(framework::dataset::make("DataType", DataType::U16), framework::dataset::make("DataType", DataType::U32)); |
| 77 | |
| 78 | // S16 |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 79 | const auto CastS16toQASYMM8_SIGNEDDataset = combine(framework::dataset::make("DataType", DataType::S16), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
| 80 | const auto CastS16toU8Dataset = combine(framework::dataset::make("DataType", DataType::S16), framework::dataset::make("DataType", DataType::U8)); |
| 81 | const auto CastS16toS32Dataset = combine(framework::dataset::make("DataType", DataType::S16), framework::dataset::make("DataType", DataType::S32)); |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 82 | |
| 83 | //S32 |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 84 | const auto CastS32toF16Dataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::F16)); |
| 85 | const auto CastS32toU8Dataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::U8)); |
| 86 | const auto CastS32toF32Dataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::F32)); |
| 87 | const auto CastS32toQASYMM8Dataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::QASYMM8)); |
| 88 | const auto CastS32toQASYMM8_SIGNEDDataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 89 | |
| 90 | // F16 |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 91 | const auto CastF16toF32Dataset = combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::F32)); |
| 92 | const auto CastF16toS32Dataset = combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::S32)); |
| 93 | const auto CastF16toQASYMM8Dataset = combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::QASYMM8)); |
| 94 | const auto CastF16toQASYMM8_SIGNEDDataset = combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 95 | |
| 96 | // F32 |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 97 | const auto CastF32toU8Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::U8)); |
| 98 | const auto CastF32toF16Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::F16)); |
| 99 | const auto CastF32toS32Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::S32)); |
| 100 | const auto CastF32toQASYMM8Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::QASYMM8)); |
| 101 | const auto CastF32toQASYMM8_SIGNEDDataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)); |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 102 | |
| 103 | } // namespace |
| 104 | |
| 105 | TEST_SUITE(NEON) |
| 106 | TEST_SUITE(Cast) |
| 107 | template <typename T> |
| 108 | using NECastToU8Fixture = CastValidationFixture<Tensor, Accessor, NECast, T, uint8_t>; |
| 109 | template <typename T> |
| 110 | using NECastToU16Fixture = CastValidationFixture<Tensor, Accessor, NECast, T, uint16_t>; |
| 111 | template <typename T> |
| 112 | using NECastToS16Fixture = CastValidationFixture<Tensor, Accessor, NECast, T, int16_t>; |
| 113 | template <typename T> |
| 114 | using NECastToU32Fixture = CastValidationFixture<Tensor, Accessor, NECast, T, uint32_t>; |
| 115 | template <typename T> |
| 116 | using NECastToS32Fixture = CastValidationFixture<Tensor, Accessor, NECast, T, int32_t>; |
| 117 | template <typename T> |
| 118 | using NECastToF16Fixture = CastValidationFixture<Tensor, Accessor, NECast, T, half>; |
| 119 | template <typename T> |
| 120 | using NECastToF32Fixture = CastValidationFixture<Tensor, Accessor, NECast, T, float>; |
| 121 | template <typename T> |
| 122 | using NECastToQASYMM8Fixture = CastValidationFixture<Tensor, Accessor, NECast, T, uint8_t>; |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 123 | template <typename T> |
| 124 | using NECastToQASYMM8_SIGNEDFixture = CastValidationFixture<Tensor, Accessor, NECast, T, int8_t>; |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 125 | |
| 126 | #define CAST_SUITE(NAME, idt, odt, type, dataset, tolerance) \ |
| 127 | TEST_SUITE(NAME) \ |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 128 | FIXTURE_DATA_TEST_CASE(RunSmall, type, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), dataset), \ |
| 129 | datasets::ConvertPolicies())) \ |
| 130 | { \ |
| 131 | validate(Accessor(_target), _reference, tolerance); \ |
| 132 | } \ |
| 133 | TEST_SUITE_END() |
| 134 | |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 135 | //QASYMM8_SIGNED |
| 136 | CAST_SUITE(QASYMM8_SIGNED_to_S16, DataType::QASYMM8_SIGNED, DataType::S16, NECastToS16Fixture<int8_t>, CastQASYMM8_SIGNEDtoS16Dataset, one_tolerance) |
| 137 | CAST_SUITE(QASYMM8_SIGNED_to_S32, DataType::QASYMM8_SIGNED, DataType::S32, NECastToS32Fixture<int8_t>, CastQASYMM8_SIGNEDtoS32Dataset, one_tolerance) |
| 138 | CAST_SUITE(QASYMM8_SIGNED_to_F32, DataType::QASYMM8_SIGNED, DataType::F32, NECastToF32Fixture<int8_t>, CastQASYMM8_SIGNEDtoF32Dataset, one_tolerance) |
| 139 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 140 | CAST_SUITE(QASYMM8_SIGNED_to_F16, DataType::QASYMM8_SIGNED, DataType::F16, NECastToF16Fixture<int8_t>, CastQASYMM8_SIGNEDtoF16Dataset, one_tolerance) |
| 141 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 142 | |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 143 | //QASYMM8 |
| 144 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 145 | CAST_SUITE(QASYMM8_to_F16, DataType::QASYMM8, DataType::F16, NECastToF16Fixture<uint8_t>, CastQASYMM8toF16Dataset, one_tolerance) |
| 146 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 147 | CAST_SUITE(QASYMM8_to_F32, DataType::QASYMM8, DataType::F32, NECastToF32Fixture<uint8_t>, CastQASYMM8toF32Dataset, one_tolerance) |
| 148 | CAST_SUITE(QASYMM8_to_S32, DataType::QASYMM8, DataType::S32, NECastToS32Fixture<uint8_t>, CastQASYMM8toS32Dataset, one_tolerance) |
| 149 | |
| 150 | // U8 |
| 151 | CAST_SUITE(U8_to_U16, DataType::U8, DataType::U16, NECastToU16Fixture<uint8_t>, CastU8toU16Dataset, zero_tolerance) |
| 152 | CAST_SUITE(U8_to_S16, DataType::U8, DataType::S16, NECastToS16Fixture<uint8_t>, CastU8toS16Dataset, zero_tolerance) |
| 153 | CAST_SUITE(U8_to_S32, DataType::U8, DataType::S32, NECastToS32Fixture<uint8_t>, CastU8toS32Dataset, zero_tolerance) |
| 154 | CAST_SUITE(U8_to_F32, DataType::U8, DataType::F32, NECastToF32Fixture<uint8_t>, CastU8toF32Dataset, zero_tolerance) |
| 155 | |
| 156 | // U16 |
| 157 | CAST_SUITE(U16_to_U8, DataType::U16, DataType::U8, NECastToU8Fixture<uint16_t>, CastU16toU8Dataset, zero_tolerance) |
| 158 | CAST_SUITE(U16_to_U32, DataType::U16, DataType::U32, NECastToU32Fixture<uint16_t>, CastU16toU32Dataset, zero_tolerance) |
| 159 | |
| 160 | // S16 |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 161 | CAST_SUITE(S16_to_QASYMM8_SIGNED, DataType::S16, DataType::QASYMM8_SIGNED, NECastToQASYMM8_SIGNEDFixture<int16_t>, CastS16toQASYMM8_SIGNEDDataset, zero_tolerance) |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 162 | CAST_SUITE(S16_to_U8, DataType::S16, DataType::U8, NECastToU8Fixture<int16_t>, CastS16toU8Dataset, zero_tolerance) |
| 163 | CAST_SUITE(S16_to_S32, DataType::S16, DataType::S32, NECastToS32Fixture<int16_t>, CastS16toS32Dataset, zero_tolerance) |
| 164 | |
| 165 | // S32 |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 166 | CAST_SUITE(S32_to_QASYMM8_SIGNED, DataType::S32, DataType::QASYMM8_SIGNED, NECastToQASYMM8_SIGNEDFixture<int32_t>, CastS32toQASYMM8_SIGNEDDataset, one_tolerance) |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 167 | CAST_SUITE(S32_to_QASYMM8, DataType::S32, DataType::QASYMM8, NECastToQASYMM8Fixture<int32_t>, CastS32toQASYMM8Dataset, one_tolerance) |
| 168 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 169 | CAST_SUITE(S32_to_F16, DataType::S32, DataType::F16, NECastToF16Fixture<int32_t>, CastS32toF16Dataset, zero_tolerance) |
| 170 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 171 | CAST_SUITE(S32_to_F32, DataType::S32, DataType::F32, NECastToF32Fixture<int32_t>, CastS32toF32Dataset, one_tolerance) |
| 172 | CAST_SUITE(S32_to_U8, DataType::S32, DataType::U8, NECastToU8Fixture<int32_t>, CastS32toU8Dataset, one_tolerance) |
| 173 | |
| 174 | // F16 |
| 175 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 176 | CAST_SUITE(F16_to_QASYMM8_SIGNED, DataType::F16, DataType::QASYMM8_SIGNED, NECastToQASYMM8_SIGNEDFixture<half>, CastF16toQASYMM8_SIGNEDDataset, one_tolerance) |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 177 | CAST_SUITE(F16_to_QASYMM8, DataType::F16, DataType::QASYMM8, NECastToQASYMM8Fixture<half>, CastF16toQASYMM8Dataset, one_tolerance) |
| 178 | CAST_SUITE(F16_to_F32, DataType::F16, DataType::F32, NECastToF32Fixture<half>, CastF16toF32Dataset, zero_tolerance) |
| 179 | CAST_SUITE(F16_to_S32, DataType::F16, DataType::S32, NECastToS32Fixture<half>, CastF16toS32Dataset, one_tolerance) |
| 180 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 181 | |
| 182 | // F32 |
Luca Foschiani | daa3aba | 2020-01-08 15:55:08 +0000 | [diff] [blame] | 183 | CAST_SUITE(F32_to_QASYMM8_SIGNED, DataType::F32, DataType::QASYMM8_SIGNED, NECastToQASYMM8_SIGNEDFixture<float>, CastF32toQASYMM8_SIGNEDDataset, one_tolerance) |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 184 | CAST_SUITE(F32_to_QASYMM8, DataType::F32, DataType::QASYMM8, NECastToQASYMM8Fixture<float>, CastF32toQASYMM8Dataset, one_tolerance) |
| 185 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 186 | CAST_SUITE(F32_to_F16, DataType::F32, DataType::F16, NECastToF16Fixture<float>, CastF32toF16Dataset, zero_tolerance) |
| 187 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 188 | CAST_SUITE(F32_to_S32, DataType::F32, DataType::S32, NECastToS32Fixture<float>, CastF32toS32Dataset, one_tolerance) |
| 189 | CAST_SUITE(F32_to_U8, DataType::F32, DataType::S32, NECastToS32Fixture<float>, CastF32toS32Dataset, one_tolerance) |
| 190 | |
Yair Schwarzbaum | 298b2c0 | 2022-02-01 08:55:56 +0200 | [diff] [blame] | 191 | DATA_TEST_CASE(KernelSelectionDstFP16, framework::DatasetMode::ALL, |
| 192 | combine(framework::dataset::make("CpuExt", std::string("NEON")), |
| 193 | framework::dataset::make("DataType", |
| 194 | { |
| 195 | DataType::F16, |
| 196 | DataType::U8, |
| 197 | DataType::S32, |
| 198 | DataType::QASYMM8, |
| 199 | DataType::QASYMM8_SIGNED, |
| 200 | DataType::BFLOAT16, |
| 201 | })), |
| 202 | cpu_ext, data_type) |
| 203 | { |
| 204 | using namespace cpu::kernels; |
| 205 | const CpuCastKernel::CastKernel *selected_impl; |
| 206 | |
| 207 | cpuinfo::CpuIsaInfo cpu_isa{}; |
| 208 | cpu_isa.neon = (cpu_ext == "NEON"); |
| 209 | |
| 210 | cpu_isa.bf16 = (data_type == DataType::BFLOAT16); |
| 211 | |
| 212 | /* bf16 cast is different from all the others being converted to fp32 and not to fp16 */ |
| 213 | if(cpu_isa.bf16) |
| 214 | { |
| 215 | cpu_isa.fp16 = false; |
| 216 | selected_impl = CpuCastKernel::get_implementation(CastDataTypeISASelectorData{ data_type, DataType::F32, cpu_isa }, cpu::KernelSelectionType::Preferred); |
| 217 | } |
| 218 | else |
| 219 | { |
| 220 | cpu_isa.fp16 = true; |
| 221 | selected_impl = CpuCastKernel::get_implementation(CastDataTypeISASelectorData{ data_type, DataType::F16, cpu_isa }, cpu::KernelSelectionType::Preferred); |
| 222 | } |
| 223 | |
| 224 | ARM_COMPUTE_ERROR_ON_NULLPTR(selected_impl); |
| 225 | |
| 226 | std::string expected = lower_string(cpu_ext) + "_" + cpu_impl_dt(data_type) + "_cast"; |
| 227 | std::string actual = selected_impl->name; |
| 228 | |
| 229 | ARM_COMPUTE_EXPECT_EQUAL(expected, actual, framework::LogLevel::ERRORS); |
| 230 | } |
| 231 | |
| 232 | DATA_TEST_CASE(KernelSelectionSrcFP32, framework::DatasetMode::ALL, |
| 233 | combine(framework::dataset::make("CpuExt", std::string("NEON")), |
| 234 | framework::dataset::make("DataType", |
| 235 | { |
| 236 | DataType::F16, |
| 237 | DataType::BFLOAT16, |
| 238 | })), |
| 239 | cpu_ext, data_type) |
| 240 | { |
| 241 | using namespace cpu::kernels; |
| 242 | |
| 243 | cpuinfo::CpuIsaInfo cpu_isa{}; |
| 244 | cpu_isa.neon = (cpu_ext == "NEON"); |
| 245 | cpu_isa.fp16 = (data_type == DataType::F16); |
| 246 | cpu_isa.bf16 = (data_type == DataType::BFLOAT16); |
| 247 | |
| 248 | const auto *selected_impl = CpuCastKernel::get_implementation(CastDataTypeISASelectorData{ DataType::F32, data_type, cpu_isa }, cpu::KernelSelectionType::Preferred); |
| 249 | |
| 250 | ARM_COMPUTE_ERROR_ON_NULLPTR(selected_impl); |
| 251 | |
| 252 | std::string expected = lower_string(cpu_ext) + "_fp32_to_" + cpu_impl_dt(data_type) + "_cast"; |
| 253 | std::string actual = selected_impl->name; |
| 254 | |
| 255 | ARM_COMPUTE_EXPECT_EQUAL(expected, actual, framework::LogLevel::ERRORS); |
| 256 | } |
| 257 | |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 258 | TEST_SUITE_END() // Cast |
Sheri Zhang | ac6499a | 2021-02-10 15:32:38 +0000 | [diff] [blame] | 259 | TEST_SUITE_END() // Neon |
Usama Arif | 9e631c2 | 2019-05-14 17:10:40 +0100 | [diff] [blame] | 260 | } // namespace validation |
| 261 | } // namespace test |
| 262 | } // namespace arm_compute |