4
4
5
5
#include " openvino/reference/convert.hpp"
6
6
7
- #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
7
+ #if OV_CORE_USE_XBYAK_JIT
8
8
# include " jit_generator.hpp"
9
9
10
10
using namespace ov ::runtime;
11
- #endif
11
+ #endif // OV_CORE_USE_XBYAK_JIT
12
12
13
13
namespace ov {
14
14
namespace reference {
15
- #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
15
+ #if OV_CORE_USE_XBYAK_JIT
16
16
namespace {
17
17
template <typename src_t , typename dst_t , bool clamp = false >
18
18
void jit_convert_vec (jit::Generator&, const Xbyak::RegExp&, const Xbyak::RegExp&);
@@ -521,19 +521,6 @@ void convert<float, float16>(const float* arg, float16* out, size_t count) {
521
521
convert_impl (arg, out, count);
522
522
}
523
523
524
- template <>
525
- void convert<int32_t , float16>(const int32_t * arg, float16* out, size_t count) {
526
- for (size_t i = 0 ; i < count; ++i) {
527
- if (arg[i] > std::numeric_limits<ov::float16>::max ()) {
528
- out[i] = std::numeric_limits<ov::float16>::max ();
529
- } else if (arg[i] < std::numeric_limits<ov::float16>::lowest ()) {
530
- out[i] = std::numeric_limits<ov::float16>::lowest ();
531
- } else {
532
- out[i] = static_cast <ov::float16>(arg[i]);
533
- }
534
- }
535
- }
536
-
537
524
template <>
538
525
void convert<float , int8_t >(const float * arg, int8_t * out, size_t count) {
539
526
convert_impl (arg, out, count);
@@ -554,10 +541,10 @@ void convert<bfloat16, float>(const bfloat16* arg, float* out, size_t count) {
554
541
convert_impl (arg, out, count);
555
542
}
556
543
557
- #endif // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64
544
+ #endif // OV_CORE_USE_XBYAK_JIT
558
545
559
546
void convert_from_f32_to_f16_with_clamp (const float * arg, float16* out, size_t count) {
560
- #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
547
+ #if OV_CORE_USE_XBYAK_JIT
561
548
convert_impl<float , float16, true >(arg, out, count);
562
549
#else
563
550
// FIXME CVS-125496: duplicate and stub for ARM, provide optimized solution
@@ -570,11 +557,24 @@ void convert_from_f32_to_f16_with_clamp(const float* arg, float16* out, size_t c
570
557
out[i] = static_cast <ov::float16>(arg[i]);
571
558
}
572
559
}
573
- #endif // defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
560
+ #endif // OV_CORE_USE_XBYAK_JIT
561
+ }
562
+
563
+ template <>
564
+ void convert<int32_t , float16>(const int32_t * arg, float16* out, size_t count) {
565
+ for (size_t i = 0 ; i < count; ++i) {
566
+ if (arg[i] > std::numeric_limits<ov::float16>::max ()) {
567
+ out[i] = std::numeric_limits<ov::float16>::max ();
568
+ } else if (arg[i] < std::numeric_limits<ov::float16>::lowest ()) {
569
+ out[i] = std::numeric_limits<ov::float16>::lowest ();
570
+ } else {
571
+ out[i] = static_cast <ov::float16>(arg[i]);
572
+ }
573
+ }
574
574
}
575
575
576
576
void convert_from_bf16_to_f16_with_clamp (const bfloat16* arg, float16* out, size_t count) {
577
- #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
577
+ #if OV_CORE_USE_XBYAK_JIT
578
578
convert_impl<bfloat16, float16, true >(arg, out, count);
579
579
#else
580
580
// FIXME CVS-125496: duplicate and stub for ARM, provide optimized solution
@@ -587,20 +587,20 @@ void convert_from_bf16_to_f16_with_clamp(const bfloat16* arg, float16* out, size
587
587
out[i] = static_cast <ov::float16>(arg[i]);
588
588
}
589
589
}
590
- #endif // defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
590
+ #endif // OV_CORE_USE_XBYAK_JIT
591
591
}
592
592
593
593
size_t count_out_of_f16_range (const float * arg, size_t count) {
594
594
size_t num_out_of_range = 0 ;
595
595
596
- #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
596
+ #if OV_CORE_USE_XBYAK_JIT
597
597
auto converter = jit_count_out_of_range::get<float , float16>();
598
598
if (converter) {
599
599
jit_count_out_of_range::args_t args = {arg, &num_out_of_range, count};
600
600
converter (&args);
601
601
return num_out_of_range;
602
602
}
603
- #endif
603
+ #endif // OV_CORE_USE_XBYAK_JIT
604
604
for (size_t i = 0 ; i < count; ++i) {
605
605
// if abs value is smaller than the smallest positive fp16, but not zero
606
606
if (std::abs (arg[i]) < ov::float16::from_bits (0x0001 ) && arg[i] != 0 .0f ) {
0 commit comments