forked from uxlfoundation/oneDNN
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathgemm_convolution_utils.cpp
2396 lines (2177 loc) · 111 KB
/
gemm_convolution_utils.cpp
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright 2016-2021 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#include "oneapi/dnnl/dnnl_types.h"
#include "common/bfloat16.hpp"
#include "common/c_types_map.hpp"
#include "common/dnnl_thread.hpp"
#include "common/type_helpers.hpp"
#include "common/utils.hpp"
#include "cpu/gemm_convolution_utils.hpp"
#include "ref_eltwise.hpp"
#include "ref_depthwise_injector.hpp"
#if DNNL_X64
#include "cpu/x64/injectors/jit_uni_postops_injector.hpp"
#endif
#include "cpu/platform.hpp"
#if DNNL_X64
#include "cpu/x64/jit_gemm_convolution_utils.hpp"
#include "cpu/x64/cpu_isa_traits.hpp"
#endif
namespace dnnl {
namespace impl {
namespace cpu {
using namespace dnnl::impl::status;
using namespace dnnl::impl::utils;
using namespace prop_kind;
using namespace data_type;
single_gemm_conv_chunk_desc_t::single_gemm_conv_chunk_desc_t(dim_t d_off,
dim_t d_size, dim_t h_off, dim_t h_size, dim_t w_off, dim_t w_size)
: d_off_(d_off)
, d_size_(d_size)
, h_off_(h_off)
, h_size_(h_size)
, w_off_(w_off)
, w_size_(w_size) {}
namespace gemm_convolution_utils {
struct ref_pp_kernel_t : pp_kernel_t {
ref_pp_kernel_t(const convolution_pd_t *pd, const conv_gemm_conf_t &jcp)
: pp_kernel_t(pd, jcp) {
for (int i = 0; i < post_ops_.len(); i++) {
auto &post_op = post_ops_.entry_[i];
if (post_op.is_eltwise()) {
ref_eltwise_injectors_.push_back(new ref_eltwise_scalar_fwd_t(post_op.eltwise));
} else if (post_op.is_depthwise()) {
ref_depthwise_injectors_.push_back(new ref_depthwise_scalar_fwd_t(
post_op.depthwise.alg));
}
}
}
~ref_pp_kernel_t() {
for (auto impl : ref_eltwise_injectors_)
delete impl;
ref_eltwise_injectors_.clear();
for (auto impl : ref_depthwise_injectors_)
delete impl;
ref_depthwise_injectors_.clear();
}
virtual void operator()(float *dst, const float *bias, const int len, const int oc_start, const int oc_work, const int oc_stride) const override;
private:
nstl::vector<ref_eltwise_scalar_fwd_t*> ref_eltwise_injectors_;
nstl::vector<ref_depthwise_scalar_fwd_t*> ref_depthwise_injectors_;
};
void ref_pp_kernel_t::operator()(float *dst, const float *bias, const int len,const int oc_start, const int oc_work, const int oc_stride) const {
// TODO: for "outer threading" we have parallel section within
// outermost "parallel". It is not good. Consider to use
// "parallel" here with number of threads passed as parameter
const auto &p = post_ops_;
bool need_bias = do_bias_;
if (p.len() > 0) {
int eltwise_inj_idx = 0;
int depthwise_inj_idx = 0;
for (int i = 0; i < p.len(); i++) {
auto &post_op = p.entry_[i];
// todo: sum?
if (post_op.is_eltwise()) {
parallel_nd(oc_work, [&](const int oc) {
float b = need_bias ? bias[oc_start + oc] : 0;
float *d_ = dst + oc * oc_stride;
for (int oS = 0; oS < len; ++oS) {
d_[oS] += b;
d_[oS] = ref_eltwise_injectors_[eltwise_inj_idx]->compute_scalar(d_[oS]);
}
});
eltwise_inj_idx++;
need_bias = false;
} else if (post_op.is_depthwise()) {
auto depthwise_weights = post_op.depthwise.weights_data;
auto depthwise_bias = post_op.depthwise.biases_data;
parallel_nd(oc_work, [&](const int oc) {
float b = need_bias ? bias[oc_start + oc] : 0;
float *d_ = dst + oc * oc_stride;
for (int oS = 0; oS < len; ++oS) {
d_[oS] += b;
d_[oS] = ref_depthwise_injectors_[depthwise_inj_idx]->compute_scalar(d_[oS],
depthwise_weights + oc_start + oc,
depthwise_bias + oc_start + oc);
}
});
depthwise_inj_idx++;
need_bias = false;
} else if (post_op.is_quantization()) {
auto quant = post_op.quantization;
auto pcl = quant.crop_low_data->shifts_;
auto pch = quant.crop_high_data->shifts_;
auto pisc = quant.input_scale_data->scales_;
auto pish = quant.input_shift_data->shifts_;
auto posc = quant.output_scale_data->scales_;
auto posh = quant.output_shift_data->shifts_;
parallel_nd(oc_work, [&](const int oc) {
float b = need_bias ? bias[oc_start + oc] : 0;
float *d_ = dst + oc * oc_stride;
int cl_idx = quant.crop_low_data->count_ == 1 ? 0 : oc_start + oc;
int ch_idx = quant.crop_high_data->count_ == 1 ? 0 : oc_start + oc;
int isc_idx = quant.input_scale_data->count_ == 1 ? 0 : oc_start + oc;
int ish_idx = quant.input_shift_data->count_ == 1 ? 0 : oc_start + oc;
int osc_idx = quant.output_scale_data->count_ == 1 ? 0 : oc_start + oc;
int osh_idx = quant.output_shift_data->count_ == 1 ? 0 : oc_start + oc;
PRAGMA_OMP_SIMD()
for (int oS = 0; oS < len; ++oS) {
d_[oS] += b;
d_[oS] = nstl::min(pch[ch_idx], nstl::max(pcl[cl_idx], d_[oS]));
d_[oS] = d_[oS] * pisc[isc_idx] + pish[ish_idx];
d_[oS] = roundf(d_[oS]);
d_[oS] = d_[oS] * posc[osc_idx] + posh[osh_idx];
}
});
need_bias = false;
}
}
}
if (need_bias) {
parallel_nd(oc_work, [&](const int oc) {
float b = bias[oc_start + oc];
float *d_ = dst + oc * oc_stride;
PRAGMA_OMP_SIMD()
for (int oS = 0; oS < len; ++oS) {
d_[oS] += b;
}
});
}
}
// Interface section
pp_kernel_t::pp_kernel_t(const convolution_pd_t *pd, const conv_gemm_conf_t &jcp)
: do_bias_(pd->with_bias()), post_ops_(pd->attr()->post_ops_) {}
pp_kernel_t *pp_kernel_t::create(
const convolution_pd_t *pd, const conv_gemm_conf_t &jcp) {
#if DNNL_X64
auto *res
= x64::gemm_convolution_utils::jit_pp_kernel_create(pd, jcp);
if (res) return res;
#endif
return new ref_pp_kernel_t(pd, jcp);
}
} // namespace gemm_convolution_utils
namespace jit_gemm_convolution_utils {
template <typename data_type_t>
void im2col_3d(const conv_gemm_conf_t &jcp, const data_type_t *im,
data_type_t *col, dim_t od, int spatial_step, int spatial_block) {
using data_t =
typename conditional<data_traits<data_type_t>::data_type == bf16,
uint16_t, data_type_t>::type;
const data_t *__restrict _im
= reinterpret_cast<const data_t *__restrict>(im);
data_t *__restrict _col = reinterpret_cast<data_t *__restrict>(col);
const size_t OHW = spatial_block;
const size_t im_step = jcp.ih * jcp.iw * jcp.id;
const size_t col_step = jcp.ks * OHW;
auto compute_im2col_outer_padding = [&](dim_t ic) {
const data_t *__restrict im_loc = _im + ic * im_step;
data_t *__restrict col_loc = _col + ic * col_step;
dim_t id = od * jcp.stride_d - jcp.f_pad;
for (dim_t kd = 0; kd < jcp.kd; ++kd) {
data_t *__restrict col_ = col_loc + kd * jcp.kh * jcp.kw * OHW;
if (id < 0 || id >= jcp.id) {
dim_t ih_ = -jcp.t_pad;
for (dim_t kh = 0; kh < jcp.kh; ++kh) {
dim_t ih = ih_;
for (dim_t oh = 0; oh < jcp.oh; ++oh) {
if (ih < 0 || ih >= jcp.ih) {
ih += jcp.stride_h;
continue;
}
dim_t iw_ = -jcp.l_pad;
for (dim_t kw = 0; kw < jcp.kw; ++kw) {
dim_t iw = iw_;
for (dim_t ow = 0; ow < jcp.ow; ++ow) {
if (iw < 0 || iw >= jcp.iw) {
iw += jcp.stride_w;
continue;
}
const size_t col_idx
= kw * OHW + oh * jcp.ow + ow;
col_[col_idx] = 0;
iw += jcp.stride_w;
}
iw_ += (1 + jcp.dilate_w);
}
ih += jcp.stride_h;
}
ih_ += (1 + jcp.dilate_h);
col_ += jcp.kw * OHW;
}
} else {
const data_t *__restrict im_ = im_loc + id * jcp.ih * jcp.iw;
dim_t ih_ = -jcp.t_pad;
for (dim_t kh = 0; kh < jcp.kh; ++kh) {
dim_t ih = ih_;
for (dim_t oh = 0; oh < jcp.oh; ++oh) {
if (ih < 0 || ih >= jcp.ih) {
ih += jcp.stride_h;
continue;
}
dim_t iw_ = -jcp.l_pad;
for (dim_t kw = 0; kw < jcp.kw; ++kw) {
dim_t iw = iw_;
for (dim_t ow = 0; ow < jcp.ow; ++ow) {
if (iw < 0 || iw >= jcp.iw) {
iw += jcp.stride_w;
continue;
}
const size_t col_idx
= kw * OHW + oh * jcp.ow + ow;
const size_t im_idx = ih * jcp.iw + iw;
col_[col_idx] = im_[im_idx];
iw += jcp.stride_w;
}
iw_ += (1 + jcp.dilate_w);
}
ih += jcp.stride_h;
}
ih_ += (1 + jcp.dilate_h);
col_ += jcp.kw * OHW;
}
}
id += (1 + jcp.dilate_d);
}
};
auto compute_im2col_padding = [&](dim_t ic) {
const dim_t first_oh = spatial_step / jcp.ow;
const dim_t last_oh = (spatial_step + spatial_block - 1) / jcp.ow;
const dim_t oh_begin = first_oh;
const dim_t oh_end = last_oh + 1;
const dim_t first_ow = spatial_step % jcp.ow;
const dim_t last_ow = (spatial_step + spatial_block - 1) % jcp.ow;
const data_t *__restrict im_loc = _im + ic * im_step;
data_t *__restrict col_loc = _col + ic * col_step;
dim_t id = od * jcp.stride_d - jcp.f_pad;
for (dim_t kd = 0; kd < jcp.kd; ++kd) {
data_t *__restrict col_ = col_loc + kd * jcp.kh * jcp.kw * OHW;
if (id < 0 || id >= jcp.id) {
for (dim_t kh = 0; kh < jcp.kh; ++kh) {
for (dim_t oh = oh_begin; oh < oh_end; ++oh) {
const dim_t ow_begin = (oh == first_oh) ? first_ow : 0;
const dim_t ow_end
= (oh == last_oh) ? (last_ow + 1) : jcp.ow;
for (dim_t kw = 0; kw < jcp.kw; ++kw) {
for (dim_t ow = ow_begin; ow < ow_end; ++ow) {
const size_t col_idx = kw * OHW + oh * jcp.ow
+ ow - spatial_step;
col_[col_idx] = 0;
}
}
}
col_ += jcp.kw * OHW;
}
} else {
const data_t *__restrict im_ = im_loc + id * jcp.ih * jcp.iw;
dim_t ih_ = oh_begin * jcp.stride_h - jcp.t_pad;
for (dim_t kh = 0; kh < jcp.kh; ++kh) {
dim_t ih = ih_;
for (dim_t oh = oh_begin; oh < oh_end; ++oh) {
const dim_t ow_begin = (oh == first_oh) ? first_ow : 0;
const dim_t ow_end
= (oh == last_oh) ? (last_ow + 1) : jcp.ow;
if (ih < 0 || ih >= jcp.ih) {
for (dim_t kw = 0; kw < jcp.kw; ++kw) {
for (dim_t ow = ow_begin; ow < ow_end; ++ow) {
const size_t col_idx = kw * OHW
+ oh * jcp.ow + ow - spatial_step;
col_[col_idx] = 0;
}
}
ih += jcp.stride_h;
continue;
}
dim_t iw_ = ow_begin * jcp.stride_w - jcp.l_pad;
for (dim_t kw = 0; kw < jcp.kw; ++kw) {
dim_t iw = iw_;
for (dim_t ow = ow_begin; ow < ow_end; ++ow) {
const size_t col_idx = kw * OHW + oh * jcp.ow
+ ow - spatial_step;
if (iw < 0 || iw >= jcp.iw) {
col_[col_idx] = 0;
iw += jcp.stride_w;
continue;
}
const size_t im_idx = ih * jcp.iw + iw;
col_[col_idx] = im_[im_idx];
iw += jcp.stride_w;
}
iw_ += (1 + jcp.dilate_w);
}
ih += jcp.stride_h;
}
ih_ += (1 + jcp.dilate_h);
col_ += jcp.kw * OHW;
}
}
id += (1 + jcp.dilate_d);
}
};
// zero padding is handled outside im2col
const bool outer_padding = jcp.os_nb_block == 1;
if (outer_padding)
parallel_nd(jcp.ic, compute_im2col_outer_padding);
else
parallel_nd(jcp.ic, compute_im2col_padding);
}
template void im2col_3d(const conv_gemm_conf_t &jcp, const float *im,
float *col, dim_t od, int spatial_step, int spatial_block);
template void im2col_3d(const conv_gemm_conf_t &jcp, const bfloat16_t *im,
bfloat16_t *col, dim_t od, int spatial_step, int spatial_block);
/* imtr[ic][od][oh][ow] <-- im[id][ih][iw][ic]*/
template <typename T>
void transpose_dt(const conv_gemm_conf_t &jcp, const T *__restrict im,
T *__restrict imtr) {
uint8_t shift = jcp.signed_input ? 128 : 0;
const dim_t ic_stride = jcp.id * jcp.ih * jcp.iw;
const dim_t IC = jcp.ngroups * jcp.ic;
const dim_t IHW = jcp.ih * jcp.iw;
constexpr dim_t ic_block = platform::get_cache_line_size();
const dim_t nb_ic = jcp.ic / ic_block;
const dim_t ic_blocked = nb_ic * ic_block;
parallel_nd(jcp.id, jcp.ih, [&](dim_t id, dim_t ih) {
const T *__restrict im_h = im + id * IHW * IC + ih * jcp.iw * IC;
T *__restrict imtr_h = imtr + id * IHW + ih * jcp.iw;
for (dim_t iw = 0; iw < jcp.iw; iw++) {
const T *__restrict im_w = im_h + iw * IC;
T *__restrict imtr_w = imtr_h + iw;
for (dim_t icb = 0; icb < nb_ic; icb++) {
const T *__restrict im_icb = im_w + icb * ic_block;
T *__restrict imtr_icb = imtr_w + icb * ic_block * ic_stride;
PRAGMA_OMP_SIMD()
for (dim_t ic = 0; ic < ic_block; ic++) {
imtr_icb[ic * ic_stride] = im_icb[ic] + shift;
}
}
for (dim_t ic = ic_blocked; ic < jcp.ic; ic++) {
imtr_w[ic * ic_stride] = im_w[ic] + shift;
}
}
});
}
template void transpose_dt(const conv_gemm_conf_t &jcp,
const int8_t *__restrict im, int8_t *__restrict imtr);
template void transpose_dt(const conv_gemm_conf_t &jcp,
const uint8_t *__restrict im, uint8_t *__restrict imtr);
template void transpose_dt(const conv_gemm_conf_t &jcp,
const char *__restrict im, char *__restrict imtr);
template void transpose_dt(const conv_gemm_conf_t &jcp,
const float *__restrict im, float *__restrict imtr);
template void transpose_dt(const conv_gemm_conf_t &jcp,
const bfloat16_t *__restrict im, bfloat16_t *__restrict imtr);
/* col[kd][kh][kw][g][ic][od][oh][ow] <-- im2col_dt_3d(im[id][ih][iw][g][ic]) */
template <typename orig_im_dt, typename orig_col_dt>
void im2col_dt_3d(const conv_gemm_conf_t &jcp, const void *__restrict _imtr,
orig_col_dt *__restrict _col, dim_t od, const uint8_t *__restrict input_zp) {
// For performance reasons, use uint16_t as a proxy for bfloat16_t
using im_dt = typename utils::conditional<data_traits<orig_im_dt>::data_type
== bf16,
uint16_t, orig_im_dt>::type;
using col_dt =
typename utils::conditional<data_traits<orig_col_dt>::data_type
== bf16,
uint16_t, orig_col_dt>::type;
const im_dt *__restrict imtr
= reinterpret_cast<const im_dt *__restrict>(_imtr);
col_dt *__restrict col = reinterpret_cast<col_dt *__restrict>(_col);
col_dt shift = static_cast<col_dt>(jcp.signed_input ? 128 : 0);
const dim_t dd = 1 + jcp.dilate_d;
const dim_t dh = 1 + jcp.dilate_h;
const dim_t dw = 1 + jcp.dilate_w;
const dim_t sd = jcp.stride_d;
const dim_t sh = jcp.stride_h;
const dim_t sw = jcp.stride_w;
const dim_t fp = jcp.f_pad;
const dim_t tp = jcp.t_pad;
const dim_t lp = jcp.l_pad;
const dim_t col_ic_s = jcp.oh * jcp.ow;
const dim_t col_kw_s = jcp.ic * col_ic_s;
const dim_t col_kh_s = jcp.kw * col_kw_s;
const dim_t col_kd_s = jcp.kh * col_kh_s;
const dim_t IHW = jcp.ih * jcp.iw;
const dim_t OHW = jcp.oh * jcp.ow;
bool with_input_zp = input_zp != nullptr;
if (sd == 1 && sh == 1 && sw == 1 && dd == 1 && dh == 1 && dw == 1)
parallel_nd(jcp.kd, jcp.kh, jcp.kw, jcp.ic,
[&](dim_t kd, dim_t kh, dim_t kw, dim_t ic) {
col_dt *__restrict col_loc = col + kd * col_kd_s
+ kh * col_kh_s + kw * col_kw_s + ic * col_ic_s;
const dim_t id = od - fp + kd;
if (id < 0 || id >= jcp.id) {
col_dt izp = with_input_zp ? (col_dt)input_zp[ic] : shift;
for (ptrdiff_t i = 0; i < OHW; i++)
col_loc[i] = izp;
return;
}
const im_dt *__restrict imtr_loc
= imtr + (ic * jcp.id + id) * IHW;
const dim_t oh_start = saturate(dim_t(0), jcp.oh, tp - kh);
const dim_t oh_end
= saturate(dim_t(0), jcp.oh, jcp.ih + tp - kh);
const dim_t ow_start = saturate(dim_t(0), jcp.ow, lp - kw);
const dim_t ow_end
= saturate(dim_t(0), jcp.ow, jcp.iw + lp - kw);
for (dim_t oh = oh_start, ih = oh_start - tp + kh;
oh < oh_end; oh++, ih++) {
col_dt *__restrict col_h = col_loc + oh * jcp.ow;
const im_dt *__restrict imtr_h = imtr_loc + ih * jcp.iw;
for (dim_t ow = ow_start, iw = ow_start - lp + kw;
ow < ow_end; ow++, iw++) {
col_h[ow] = imtr_h[iw];
}
}
});
else if (sd == 2 && sh == 2 && sw == 2 && dd == 1 && dh == 1 && dw == 1)
parallel_nd(jcp.kd, jcp.kh, jcp.kw, jcp.ic,
[&](dim_t kd, dim_t kh, dim_t kw, dim_t ic) {
col_dt *__restrict col_loc = col + kd * col_kd_s
+ kh * col_kh_s + kw * col_kw_s + ic * col_ic_s;
const dim_t id = od * 2 - fp + kd;
if (id < 0 || id >= jcp.id) {
col_dt izp = with_input_zp ? (col_dt)input_zp[ic] : shift;
for (ptrdiff_t i = 0; i < OHW; i++)
col_loc[i] = izp;
return;
}
const im_dt *__restrict imtr_loc
= imtr + (ic * jcp.id + id) * IHW;
const dim_t oh_start
= saturate(dim_t(0), jcp.oh, div_up(tp - kh, 2));
const dim_t oh_end = saturate(
dim_t(0), jcp.oh, div_up(jcp.ih + tp - kh, 2));
const dim_t ow_start
= saturate(dim_t(0), jcp.ow, div_up(lp - kw, 2));
const dim_t ow_end = saturate(
dim_t(0), jcp.ow, div_up(jcp.iw + lp - kw, 2));
for (dim_t oh = oh_start, ih = oh_start * 2 - tp + kh;
oh < oh_end; ++oh, ih += 2) {
col_dt *__restrict col_h = col_loc + oh * jcp.ow;
const im_dt *__restrict imtr_h = imtr_loc + ih * jcp.iw;
for (dim_t ow = ow_start, iw = ow_start * 2 - lp + kw;
ow < ow_end; ++ow, iw += 2) {
col_h[ow] = imtr_h[iw];
}
}
});
else
parallel_nd(jcp.kd, jcp.kh, jcp.kw, jcp.ic,
[&](dim_t kd, dim_t kh, dim_t kw, dim_t ic) {
col_dt *__restrict col_loc = col + kd * col_kd_s
+ kh * col_kh_s + kw * col_kw_s + ic * col_ic_s;
const dim_t id = od * sd - fp + kd * dd;
if (id < 0 || id >= jcp.id) {
col_dt izp = with_input_zp ? (col_dt)input_zp[ic] : shift;
for (ptrdiff_t i = 0; i < OHW; i++)
col_loc[i] = izp;
return;
}
const im_dt *__restrict imtr_loc
= imtr + (ic * jcp.id + id) * IHW;
const dim_t oh_start = saturate(
dim_t(0), jcp.oh, div_up(tp - kh * dh, sh));
const dim_t oh_end = saturate(dim_t(0), jcp.oh,
div_up(jcp.ih + tp - kh * dh, sh));
const dim_t ow_start = saturate(
dim_t(0), jcp.ow, div_up(lp - kw * dw, sw));
const dim_t ow_end = saturate(dim_t(0), jcp.ow,
div_up(jcp.iw + lp - kw * dw, sw));
for (dim_t oh = oh_start, ih = oh_start * sh - tp + kh * dh;
oh < oh_end; ++oh, ih += sh) {
col_dt *__restrict col_h = col_loc + oh * jcp.ow;
const im_dt *__restrict imtr_h = imtr_loc + ih * jcp.iw;
for (dim_t ow = ow_start,
iw = ow_start * sw - lp + kw * dw;
ow < ow_end; ++ow, iw += sw) {
col_h[ow] = imtr_h[iw];
}
}
});
}
template void im2col_dt_3d<int8_t, uint8_t>(const conv_gemm_conf_t &jcp,
const void *__restrict im, uint8_t *__restrict col, dim_t od, const uint8_t *__restrict input_zp);
template void im2col_dt_3d<uint8_t, uint8_t>(const conv_gemm_conf_t &jcp,
const void *__restrict im, uint8_t *__restrict col, dim_t od, const uint8_t *__restrict input_zp);
template void im2col_dt_3d<float, float>(const conv_gemm_conf_t &jcp,
const void *__restrict im, float *__restrict col, dim_t od, const uint8_t *__restrict input_zp);
template void im2col_dt_3d<bfloat16_t, bfloat16_t>(const conv_gemm_conf_t &jcp,
const void *__restrict im, bfloat16_t *__restrict col, dim_t od, const uint8_t *__restrict input_zp);
/* col[ic][kh][kw][oh][ow] <-- im2col(im[ic][ih][iw]) */
template <typename data_type_t>
void im2col(const conv_gemm_conf_t &jcp, const data_type_t *__restrict im,
data_type_t *__restrict col, dim_t ss, dim_t sb, dim_t cs, dim_t cb) {
using data_t =
typename utils::conditional<data_traits<data_type_t>::data_type
== bf16,
uint16_t, data_type_t>::type;
const data_t *__restrict _im
= reinterpret_cast<const data_t *__restrict>(im);
data_t *__restrict _col = reinterpret_cast<data_t *__restrict>(col);
const size_t im_step = jcp.is;
const size_t col_step = jcp.ks * sb;
const dim_t dh = 1 + jcp.dilate_h;
const dim_t dw = 1 + jcp.dilate_w;
const dim_t sh = jcp.stride_h;
const dim_t sw = jcp.stride_w;
const dim_t tp = jcp.t_pad;
const dim_t lp = jcp.l_pad;
const dim_t first_oh = ss / jcp.ow;
const dim_t last_oh = (ss + sb - 1) / jcp.ow;
const dim_t oh_begin = first_oh;
const dim_t oh_end = last_oh + 1;
const dim_t first_ow = ss % jcp.ow;
const dim_t last_ow = (ss + sb - 1) % jcp.ow;
const data_t zero_val = 0;
if (jcp.outer_threading) {
if (sw == 1) {
// Generated code is more optimized for stride_w == 1
// because innermost loop is by width
for (dim_t ic = 0; ic < cb; ic++) {
const data_t *__restrict im_ic = _im + (ic + cs) * im_step;
for (dim_t kh = 0; kh < jcp.kh; kh++) {
for (dim_t kw = 0; kw < jcp.kw; kw++) {
data_t *__restrict col_k = _col + ic * col_step
+ (kh * jcp.kw + kw) * sb;
for (dim_t oh = oh_begin; oh < oh_end; oh++) {
const dim_t ih = oh * sh - tp + kh * dh;
const data_t *__restrict im_
= im_ic + ih * jcp.iw - lp + kw * dw;
const dim_t ow_begin
= (oh == first_oh) ? first_ow : 0;
const dim_t ow_end
= (oh == last_oh) ? (last_ow + 1) : jcp.ow;
data_t *__restrict col_ = col_k + oh * jcp.ow - ss;
if (ih < 0 || ih >= jcp.ih)
for (dim_t ow = ow_begin; ow < ow_end; ow++)
col_[ow] = zero_val;
else {
for (dim_t ow = ow_begin; ow < ow_end; ++ow) {
const dim_t iw = ow;
if (iw < lp - kw * dw
|| iw >= jcp.iw + lp - kw * dw)
col_[ow] = zero_val;
else
col_[ow] = im_[iw];
}
}
}
}
}
}
} else {
for (dim_t ic = 0; ic < cb; ic++) {
const data_t *__restrict im_ = _im + (ic + cs) * im_step;
for (dim_t kh = 0; kh < jcp.kh; kh++) {
for (dim_t kw = 0; kw < jcp.kw; kw++) {
data_t *__restrict col_k = _col + ic * col_step
+ (kh * jcp.kw + kw) * sb;
for (dim_t oh = oh_begin; oh < oh_end; oh++) {
const dim_t ih = oh * sh - tp + kh * dh;
const dim_t ow_begin
= (oh == first_oh) ? first_ow : 0;
const dim_t ow_end
= (oh == last_oh) ? (last_ow + 1) : jcp.ow;
data_t *__restrict col_oh
= col_k + oh * jcp.ow - ss;
if (ih < 0 || ih >= jcp.ih)
for (dim_t ow = ow_begin; ow < ow_end; ow++)
col_oh[ow] = zero_val;
else
for (dim_t ow = ow_begin; ow < ow_end; ow++) {
const dim_t iw = ow * sw - lp + kw * dw;
if (iw < 0 || iw >= jcp.iw)
col_oh[ow] = zero_val;
else {
const ptrdiff_t im_idx
= ih * jcp.iw + iw;
col_oh[ow] = im_[im_idx];
}
}
}
}
}
}
}
} else {
// TODO: optimize threading if jcp.ic*jcp.kh*jcp.kw*oh_range is small
// comparing to number of threads
const dim_t oh_range = oh_end - oh_begin;
// Generated code is more optimized for stride_w == 1
// because innermost loop is by width
if (sw == 1)
parallel_nd(cb, jcp.kh, jcp.kw, oh_range,
[&](dim_t ic, dim_t kh, dim_t kw, dim_t ohr) {
const dim_t oh = ohr + oh_begin;
const dim_t ih = oh * sh - tp + kh * dh;
const dim_t ow_start = (oh == first_oh) ? first_ow : 0;
const dim_t ow_end
= (oh == last_oh) ? (last_ow + 1) : jcp.ow;
data_t *__restrict col_oh = _col + ic * col_step
+ (kh * jcp.kw + kw) * sb + oh * jcp.ow - ss;
const data_t *__restrict im_
= _im + (ic + cs) * im_step + ih * jcp.iw;
const dim_t iw_shift = kw * dw - lp;
if (ih < 0 || ih >= jcp.ih)
for (dim_t ow = ow_start; ow < ow_end; ow++)
col_oh[ow] = zero_val;
else
for (dim_t ow = ow_start; ow < ow_end; ow++) {
const dim_t iw = ow + iw_shift;
if (iw < 0 || iw >= jcp.iw)
col_oh[ow] = zero_val;
else
col_oh[ow] = im_[iw];
}
});
else
parallel_nd(cb, jcp.kh, jcp.kw, oh_range,
[&](dim_t ic, dim_t kh, dim_t kw, dim_t ohr) {
const dim_t oh = ohr + oh_begin;
const dim_t ih = oh * sh - tp + kh * dh;
const dim_t ow_start = (oh == first_oh) ? first_ow : 0;
const dim_t ow_end
= (oh == last_oh) ? (last_ow + 1) : jcp.ow;
data_t *__restrict col_oh = _col + ic * col_step
+ (kh * jcp.kw + kw) * sb + oh * jcp.ow - ss;
const data_t *__restrict im_
= _im + (ic + cs) * im_step;
if (ih < 0 || ih >= jcp.ih)
for (dim_t ow = ow_start; ow < ow_end; ow++)
col_oh[ow] = zero_val;
else
for (dim_t ow = ow_start; ow < ow_end; ow++) {
const dim_t iw = ow * sw - lp + kw * dw;
if (iw < 0 || iw >= jcp.iw)
col_oh[ow] = zero_val;
else {
const ptrdiff_t im_idx = ih * jcp.iw + iw;
col_oh[ow] = im_[im_idx];
}
}
});
}
}
template void im2col(const conv_gemm_conf_t &jcp, const float *__restrict im,
float *__restrict col, dim_t hs, dim_t hb, dim_t ws, dim_t wb);
template void im2col(const conv_gemm_conf_t &jcp,
const bfloat16_t *__restrict im, bfloat16_t *__restrict col, dim_t hs,
dim_t hb, dim_t ws, dim_t wb);
/* col[kh][kw][ic][oh][ow] <-- im2col_dt(im[ih][iw][ic]) */
template <typename orig_im_dt, typename orig_col_dt>
void im2col_dt(const conv_gemm_conf_t &jcp, const void *__restrict _im,
void *__restrict _imtr, orig_col_dt *__restrict _col, dim_t hs,
dim_t hb, dim_t ws, dim_t wb, const uint8_t *__restrict input_zp) {
// For performance reasons, use uint16_t as a proxy for bfloat16_t
using im_dt = typename utils::conditional<data_traits<orig_im_dt>::data_type
== bf16,
uint16_t, orig_im_dt>::type;
using col_dt =
typename utils::conditional<data_traits<orig_col_dt>::data_type
== bf16,
uint16_t, orig_col_dt>::type;
const im_dt *__restrict im = reinterpret_cast<const im_dt *__restrict>(_im);
im_dt *__restrict imtr = reinterpret_cast<im_dt *__restrict>(_imtr);
col_dt *__restrict col = reinterpret_cast<col_dt *__restrict>(_col);
col_dt shift = static_cast<col_dt>(jcp.signed_input ? 128 : 0);
const dim_t dh = 1 + jcp.dilate_h;
const dim_t dw = 1 + jcp.dilate_w;
const dim_t sh = jcp.stride_h;
const dim_t sw = jcp.stride_w;
const dim_t im_iw_stride = jcp.ic * jcp.ngroups;
const dim_t im_ih_stride = jcp.iw * im_iw_stride;
const dim_t tp = jcp.t_pad;
const dim_t lp = jcp.l_pad;
bool with_input_zp = input_zp != nullptr;
if (jcp.outer_threading && sh == 1 && sw == 1 && dh == 1 && dw == 1) {
/* im[ih][iw][ic] --> imtr[ic][ih][iw] --> col[kh][kw][ic][oh][ow] */
const dim_t hp = hs - tp;
const dim_t wp = ws - lp;
const dim_t ih_start = saturate(dim_t(0), jcp.ih, hp);
const dim_t ih_end = saturate(dim_t(0), jcp.ih, hp + hb + jcp.kh);
const dim_t iw_start = saturate(dim_t(0), jcp.iw, wp);
const dim_t iw_end = saturate(dim_t(0), jcp.iw, wp + wb + jcp.kw);
const dim_t ihb = ih_end - ih_start;
const dim_t iwb = iw_end - iw_start;
const dim_t imtr_ic_stride = ihb * iwb;
const ptrdiff_t imtr_idx_shift = ih_start * iwb + iw_start;
for (dim_t ic = 0; ic < jcp.ic; ic++) {
const ptrdiff_t imtr_idx_ic = ic * imtr_ic_stride - imtr_idx_shift;
for (dim_t ih = ih_start; ih < ih_end; ih++) {
const ptrdiff_t im_idx_ih = ic + ih * im_ih_stride;
const ptrdiff_t imtr_idx_ih = imtr_idx_ic + ih * iwb;
for (dim_t iw = iw_start; iw < iw_end; iw++)
imtr[imtr_idx_ih + iw] = im[im_idx_ih + iw * im_iw_stride];
}
}
const dim_t col_ic_str = hb * wb;
const dim_t col_kw_stride = jcp.ic * col_ic_str;
const dim_t col_kh_stride = jcp.kw * col_kw_stride;
const dim_t oh_init = ih_start - hp;
const dim_t ow_init = iw_start - wp;
for (dim_t kh = 0; kh < jcp.kh; kh++) {
const ptrdiff_t col_idx_kh = kh * col_kh_stride;
const dim_t oh_kh = oh_init - kh;
const dim_t oh_start = saturate(dim_t(0), hb, oh_kh);
const dim_t oh_end = saturate(dim_t(0), hb, oh_kh + ihb);
for (dim_t kw = 0; kw < jcp.kw; kw++) {
const ptrdiff_t col_idx_kw
= col_idx_kh + kw * jcp.ic * col_ic_str;
const dim_t ow_kw = ow_init - kw;
const dim_t imtr_shift = oh_kh * iwb + ow_kw;
const dim_t ow_start = saturate(dim_t(0), wb, ow_kw);
const dim_t ow_end = saturate(dim_t(0), wb, ow_kw + iwb);
for (dim_t ic = 0; ic < jcp.ic; ic++) {
uint8_t izp = with_input_zp ? input_zp[ic] : (uint8_t) 0;
const ptrdiff_t col_idx_ic = col_idx_kw + ic * col_ic_str;
const dim_t imtr_idx_ic = ic * imtr_ic_stride - imtr_shift;
for (dim_t oh = 0; oh < oh_start; oh++) {
const ptrdiff_t col_idx_oh = col_idx_ic + oh * wb;
if (with_input_zp) {
for (dim_t ow = 0; ow < wb; ++ow)
col[col_idx_oh + ow] = izp;
} else {
for (dim_t ow = 0; ow < wb; ++ow)
col[col_idx_oh + ow] = shift;
}
}
for (dim_t oh = oh_start; oh < oh_end; oh++) {
const ptrdiff_t col_idx_oh = col_idx_ic + oh * wb;
const ptrdiff_t imtr_idx_oh = imtr_idx_ic + oh * iwb;
if (with_input_zp) {
for (dim_t ow = 0; ow < ow_start; ++ow)
col[col_idx_oh + ow] = izp;
for (dim_t ow = ow_start; ow < ow_end; ++ow)
col[col_idx_oh + ow]
= imtr[imtr_idx_oh + ow];
for (dim_t ow = ow_end; ow < wb; ++ow)
col[col_idx_oh + ow] = izp;
} else {
for (dim_t ow = 0; ow < ow_start; ++ow)
col[col_idx_oh + ow] = shift;
for (dim_t ow = ow_start; ow < ow_end; ++ow)
col[col_idx_oh + ow]
= imtr[imtr_idx_oh + ow] + shift;
for (dim_t ow = ow_end; ow < wb; ++ow)
col[col_idx_oh + ow] = shift;
}
}
for (dim_t oh = oh_end; oh < hb; oh++) {
const ptrdiff_t col_idx_oh = col_idx_ic + oh * wb;
if (with_input_zp) {
for (dim_t ow = 0; ow < wb; ++ow)
col[col_idx_oh + ow] = izp;
} else {
for (dim_t ow = 0; ow < wb; ++ow)
col[col_idx_oh + ow] = shift;
}
}
}
}
}
} else {
parallel_nd(jcp.kh, jcp.kw, jcp.ic, hb,
[&](dim_t kh, dim_t kw, dim_t ic, dim_t oh) {
const dim_t hp = tp - kh * dh;
const dim_t ih = (oh + hs) * sh - hp;
const ptrdiff_t col_idx_base
= (((kh * jcp.kw + kw) * jcp.ic + ic) * hb + oh)
* wb;
uint8_t izp = with_input_zp ? input_zp[ic] : (uint8_t) 0;
if (ih < 0 || ih >= jcp.ih)
if (with_input_zp) {
for (dim_t ow = 0; ow < wb; ow++)
col[col_idx_base + ow] = izp;
} else {
for (dim_t ow = 0; ow < wb; ow++)
col[col_idx_base + ow] = shift;
}
else {
const dim_t wp = lp - kw * dw;
const dim_t ow_start
= saturate(dim_t(0), wb, div_up(wp, sw) - ws);
const dim_t ow_end = saturate(
dim_t(0), wb, div_up(jcp.iw + wp, sw) - ws);
if (with_input_zp) {
for (dim_t ow = 0; ow < ow_start; ow++)
col[col_idx_base + ow] = izp;
const dim_t iw_base = ws * sw - wp;
const ptrdiff_t im_idx_base = ih * im_ih_stride + ic;
for (dim_t ow = ow_start; ow < ow_end; ow++) {
const dim_t iw = iw_base + ow * sw;
const ptrdiff_t im_idx
= im_idx_base + iw * im_iw_stride;
col[col_idx_base + ow] = im[im_idx];
}
for (dim_t ow = ow_end; ow < wb; ow++)
col[col_idx_base + ow] = izp;
} else {
for (dim_t ow = 0; ow < ow_start; ow++)
col[col_idx_base + ow] = shift;
const dim_t iw_base = ws * sw - wp;
const ptrdiff_t im_idx_base = ih * im_ih_stride + ic;
for (dim_t ow = ow_start; ow < ow_end; ow++) {
const dim_t iw = iw_base + ow * sw;
const ptrdiff_t im_idx
= im_idx_base + iw * im_iw_stride;
col[col_idx_base + ow] = im[im_idx] + shift;
}
for (dim_t ow = ow_end; ow < wb; ow++)
col[col_idx_base + ow] = shift;
}
}
});
}
}
template void im2col_dt<int8_t, uint8_t>(const conv_gemm_conf_t &jcp,
const void *__restrict im, void *__restrict imtr,
uint8_t *__restrict col, dim_t hs, dim_t hb, dim_t ws, dim_t wb, const uint8_t *__restrict input_zp);
template void im2col_dt<uint8_t, uint8_t>(const conv_gemm_conf_t &jcp,
const void *__restrict im, void *__restrict imtr,
uint8_t *__restrict col, dim_t hs, dim_t hb, dim_t ws, dim_t wb, const uint8_t *__restrict input_zp);
template void im2col_dt<float, float>(const conv_gemm_conf_t &jcp,
const void *__restrict im, void *__restrict imtr, float *__restrict col,
dim_t hs, dim_t hb, dim_t ws, dim_t wb, const uint8_t *__restrict input_zp);
template void im2col_dt<bfloat16_t, bfloat16_t>(const conv_gemm_conf_t &jcp,
const void *__restrict im, void *__restrict imtr,
bfloat16_t *__restrict col, dim_t hs, dim_t hb, dim_t ws, dim_t wb, const uint8_t *__restrict input_zp);
/* im[id][ih][iw][ic] <-- col2im_dt_3d(col[od][oh][ow][kd][kh][kw][ic]) */
template <typename orig_T>
void col2im_dt(const conv_gemm_conf_t &jcp, const orig_T *__restrict _col,
orig_T *__restrict _im) {
// For performance reasons, use uint16_t as a proxy for bfloat16_t
using T =
typename utils::conditional<data_traits<orig_T>::data_type == bf16,
uint16_t, orig_T>::type;
const T *__restrict col = reinterpret_cast<const T *__restrict>(_col);
T *__restrict im = reinterpret_cast<T *__restrict>(_im);
parallel(0, [&](const int ithr, const int nthr) {
dim_t d_nthr = nstl::min(jcp.id, dim_t(nthr));
dim_t h_nthr = nstl::min(jcp.ih, dim_t(nthr) / d_nthr);
dim_t w_nthr = nstl::min(jcp.iw, dim_t(nthr) / (d_nthr * h_nthr));
dim_t d_ithr = 1, d_s = 0, d_e = 0, h_ithr = 1, h_s = 0, h_e = 0,
w_ithr = 1, w_s = 0, w_e = 0;
if (ithr < d_nthr * h_nthr * w_nthr) {
d_ithr = ithr / (h_nthr * w_nthr);
h_ithr = (ithr % (h_nthr * w_nthr)) / w_nthr;
w_ithr = (ithr % (h_nthr * w_nthr)) % w_nthr;
balance211(jcp.id, d_nthr, d_ithr, d_s, d_e);
balance211(jcp.ih, h_nthr, h_ithr, h_s, h_e);
balance211(jcp.iw, w_nthr, w_ithr, w_s, w_e);
} else {
d_nthr = h_ithr = w_ithr = -ithr;
d_s = d_e = h_s = h_e = w_s = w_e = -1;
}
for_(dim_t id = d_s; id < d_e; ++id)
for_(dim_t ih = h_s; ih < h_e; ++ih)
for (dim_t iw = w_s; iw < w_e; ++iw) {
PRAGMA_OMP_SIMD()
for (dim_t ic = 0; ic < jcp.ic; ++ic) {
im[((id * jcp.ih + ih) * jcp.iw + iw) * jcp.ic + ic] = 0;
}
}
// TODO: reduce region: [0.. oh] --> [h_s * sh .. h_e * sh]
for_(dim_t od = 0; od < jcp.od; ++od)
for_(dim_t oh = 0; oh < jcp.oh; ++oh)
for_(dim_t ow = 0; ow < jcp.ow; ++ow)
for (dim_t kd = 0; kd < jcp.kd; ++kd) {
const dim_t id
= od * jcp.stride_d - jcp.f_pad + kd * (1 + jcp.dilate_d);
if (id < d_s || id >= d_e) continue;
for (dim_t kh = 0; kh < jcp.kh; ++kh) {
const dim_t ih = oh * jcp.stride_h - jcp.t_pad
+ kh * (1 + jcp.dilate_h);
if (ih < h_s || ih >= h_e) continue;
for (dim_t kw = 0; kw < jcp.kw; ++kw) {
const dim_t iw = ow * jcp.stride_w - jcp.l_pad
+ kw * (1 + jcp.dilate_w);
if (iw < w_s || iw >= w_e) continue;
const size_t col_idx
= (((((od * jcp.oh + oh) * jcp.ow + ow) * jcp.kd
+ kd) * jcp.kh
+ kh) * jcp.kw
+ kw)
* jcp.ic;
const size_t im_idx
= ((id * jcp.ih + ih) * jcp.iw + iw) * jcp.ic;
PRAGMA_OMP_SIMD()
for (dim_t ic = 0; ic < jcp.ic; ++ic) {
im[im_idx + ic] += col[col_idx + ic];
}
}
}
}
});
}
template void col2im_dt<int32_t>(const conv_gemm_conf_t &jcp,
const int32_t *__restrict col, int32_t *__restrict im);
template void col2im_dt<float>(const conv_gemm_conf_t &jcp,
const float *__restrict col, float *__restrict im);
template void col2im_dt<bfloat16_t>(const conv_gemm_conf_t &jcp,
const bfloat16_t *__restrict col, bfloat16_t *__restrict im);
void col2im_3d(const conv_gemm_conf_t &jcp, const float *col, float *im,