Skip to content

Commit 4839324

Browse files
committed
[CPU] I64 initial support.
1 parent 33bb2b2 commit 4839324

10 files changed

+334
-5
lines changed

include/oneapi/dnnl/dnnl.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,8 @@ struct memory : public handle<dnnl_memory_t> {
864864
f64 = dnnl_f64,
865865
/// 32-bit signed integer.
866866
s32 = dnnl_s32,
867+
/// 64-bit signed integer.
868+
s64 = dnnl_s64,
867869
/// 8-bit signed integer.
868870
s8 = dnnl_s8,
869871
/// 8-bit unsigned integer.

include/oneapi/dnnl/dnnl_common_types.h

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ typedef enum {
9494
dnnl_boolean = 8,
9595
/// 1-bit integer.
9696
dnnl_bin = 9,
97+
/// 64-bit signed integer.
98+
dnnl_s64 = 10,
9799
/// Parameter to allow internal only data_types without undefined behavior.
98100
/// This parameter is chosen to be valid for so long as sizeof(int) >= 2.
99101
dnnl_data_type_max = 0x7fff,

src/common/c_types_map.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ const data_type_t bf16 = dnnl_bf16;
160160
const data_type_t f32 = dnnl_f32;
161161
const data_type_t f64 = dnnl_f64;
162162
const data_type_t s32 = dnnl_s32;
163+
const data_type_t s64 = dnnl_s64;
163164
const data_type_t s8 = dnnl_s8;
164165
const data_type_t u8 = dnnl_u8;
165166
const data_type_t boolean = dnnl_boolean;

src/common/dnnl_traits.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ struct prec_traits<data_type::s32> {
6363
typedef int32_t type;
6464
};
6565
template <>
66+
struct prec_traits<data_type::s64> {
67+
typedef int64_t type;
68+
};
69+
template <>
6670
struct prec_traits<data_type::s8> {
6771
typedef int8_t type;
6872
};
@@ -96,6 +100,10 @@ struct data_traits<int32_t> {
96100
static constexpr data_type_t data_type = data_type::s32;
97101
};
98102
template <>
103+
struct data_traits<int64_t> {
104+
static constexpr data_type_t data_type = data_type::s64;
105+
};
106+
template <>
99107
struct data_traits<int8_t> {
100108
static constexpr data_type_t data_type = data_type::s8;
101109
};

src/common/memory_zero_pad.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ static status_t zero_pad(const memory_t *memory, const exec_ctx_t &ctx) {
285285
case f16: return typed_zero_pad<f16>(memory, ctx);
286286
case bf16: return typed_zero_pad<bf16>(memory, ctx);
287287
case f32: return typed_zero_pad<f32>(memory, ctx);
288+
case f64: return typed_zero_pad<f64>(memory, ctx);
288289
case s32: return typed_zero_pad<s32>(memory, ctx);
290+
case s64: return typed_zero_pad<s64>(memory, ctx);
289291
case s8: return typed_zero_pad<s8>(memory, ctx);
290292
case u8: return typed_zero_pad<u8>(memory, ctx);
291293
case bin: return typed_zero_pad<u8>(memory, ctx);

src/common/type_helpers.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ inline size_t data_type_size(data_type_t data_type) {
8989
case f32: return sizeof(prec_traits<f32>::type);
9090
case f64: return sizeof(prec_traits<f64>::type);
9191
case s32: return sizeof(prec_traits<s32>::type);
92+
case s64: return sizeof(prec_traits<s64>::type);
9293
case s8: return sizeof(prec_traits<s8>::type);
9394
case u8: return sizeof(prec_traits<u8>::type);
9495
case boolean: return sizeof(prec_traits<boolean>::type);
@@ -948,7 +949,7 @@ inline bool memory_desc_sanity_check(int ndims, const dims_t dims,
948949
if (ndims == 0) return true;
949950

950951
bool ok = dims != nullptr && 0 < ndims && ndims <= DNNL_MAX_NDIMS
951-
&& utils::one_of(data_type, f16, bf16, f32, f64, s32, s8, u8, bin);
952+
&& utils::one_of(data_type, f16, bf16, f32, f64, s32, s64, s8, u8, bin);
952953
if (!ok) return false;
953954

954955
bool has_runtime_dims = false;

src/cpu/reorder/cpu_reorder.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ regular_impl_list_map() {
3434
{{f32, bin, 0}, &regular_f32_bin_impl_list_map()},
3535
{{bf16, data_type::undef, 0}, &regular_bf16_impl_list_map()},
3636
{{f16, data_type::undef, 0}, &regular_f16_impl_list_map()},
37+
{{s64, data_type::undef, 0}, &regular_s64_impl_list_map()},
3738
{{s32, data_type::undef, 0}, &regular_s32_impl_list_map()},
3839
{{s8, data_type::undef, 0}, &regular_s8_impl_list_map()},
3940
{{u8, data_type::undef, 0}, &regular_u8_impl_list_map()},

src/cpu/reorder/cpu_reorder.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ extern const impl_list_map_t &regular_f32_u8_impl_list_map();
7676
extern const impl_list_map_t &regular_f32_bin_impl_list_map();
7777
extern const impl_list_map_t &regular_bf16_impl_list_map();
7878
extern const impl_list_map_t &regular_f16_impl_list_map();
79+
extern const impl_list_map_t &regular_s64_impl_list_map();
7980
extern const impl_list_map_t &regular_s32_impl_list_map();
8081
extern const impl_list_map_t &regular_s8_impl_list_map();
8182
extern const impl_list_map_t &regular_u8_impl_list_map();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*******************************************************************************
2+
* Copyright 2020-2023 Intel Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
17+
#include "cpu/reorder/cpu_reorder.hpp"
18+
19+
namespace dnnl {
20+
namespace impl {
21+
namespace cpu {
22+
23+
// clang-format off
24+
25+
const impl_list_map_t &regular_s64_impl_list_map() {
26+
static const impl_list_map_t the_map = REG_REORDER_P({
27+
// s32 ->
28+
{{s64, data_type::undef, 0}, {
29+
REG_FAST_DIRECT_COPY(s64, f32)
30+
REG_FAST_DIRECT_COPY(s64, s64)
31+
REG_FAST_DIRECT_COPY(s64, s32)
32+
REG_FAST_DIRECT_COPY(s64, s8)
33+
REG_FAST_DIRECT_COPY(s64, u8)
34+
35+
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64_jit_blk_reorder_t))
36+
DNNL_X64_ONLY(CPU_REORDER_INSTANCE(x64_jit_uni_reorder_t))
37+
38+
DNNL_AARCH64_ONLY(CPU_REORDER_INSTANCE(aarch64_jit_uni_reorder_t))
39+
40+
DNNL_NON_X64_ONLY(REG_SR_BIDIR(s64, any, f32, nChw16c))
41+
DNNL_NON_X64_ONLY(REG_SR_BIDIR(s64, any, s32, nChw16c))
42+
DNNL_NON_X64_ONLY(REG_SR_BIDIR(s64, any, s8, nChw16c))
43+
DNNL_NON_X64_ONLY(REG_SR_BIDIR(s64, any, u8, nChw16c))
44+
45+
REG_SR(s64, any, f32, any, fmt_order_any, spec_reference)
46+
REG_SR(s64, any, s64, any, fmt_order_any, spec_reference)
47+
REG_SR(s64, any, s32, any, fmt_order_any, spec_reference)
48+
REG_SR(s64, any, s8, any, fmt_order_any, spec_reference)
49+
REG_SR(s64, any, u8, any, fmt_order_any, spec_reference)
50+
51+
nullptr,
52+
}},
53+
});
54+
return the_map;
55+
}
56+
57+
// clang-format on
58+
59+
} // namespace cpu
60+
} // namespace impl
61+
} // namespace dnnl

0 commit comments

Comments
 (0)