Skip to content

Commit c4f23ae

Browse files
committed
rename Mat packing to elempack
1 parent 8da6e60 commit c4f23ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+597
-597
lines changed

src/command.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,9 @@ VkTransfer::~VkTransfer()
847847

848848
void VkTransfer::record_upload(const Mat& src, VkMat& dst, const Option& opt)
849849
{
850-
if (src.elemsize / src.packing == 4)
850+
if (src.elemsize / src.elempack == 4)
851851
{
852-
if (opt.use_fp16_storage || (opt.use_fp16_packed && src.packing % 4 == 0))
852+
if (opt.use_fp16_storage || (opt.use_fp16_packed && src.elempack % 4 == 0))
853853
{
854854
Mat src_fp16;
855855
cast_float32_to_float16(src, src_fp16);

src/layer/arm/absval_arm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ int AbsVal_arm::forward_inplace(Mat& bottom_top_blob, const Option& opt) const
3535
int h = bottom_top_blob.h;
3636
int channels = bottom_top_blob.c;
3737
int size = w * h;
38-
int packing = bottom_top_blob.packing;
38+
int elempack = bottom_top_blob.elempack;
3939

4040
#if __ARM_NEON
41-
if (packing == 4)
41+
if (elempack == 4)
4242
{
4343
#pragma omp parallel for num_threads(opt.num_threads)
4444
for (int q=0; q<channels; q++)

src/layer/arm/batchnorm_arm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ int BatchNorm_arm::forward_inplace(Mat& bottom_top_blob, const Option& opt) cons
4242
int w = bottom_top_blob.w;
4343
int h = bottom_top_blob.h;
4444
int size = w * h;
45-
int packing = bottom_top_blob.packing;
45+
int elempack = bottom_top_blob.elempack;
4646

4747
#if __ARM_NEON
48-
if (packing == 4)
48+
if (elempack == 4)
4949
{
5050
const float* a_data_ptr = a_data;
5151
const float* b_data_ptr = b_data;

src/layer/arm/clip_arm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ int Clip_arm::forward_inplace(Mat &bottom_top_blob, const Option &opt) const
3535
int h = bottom_top_blob.h;
3636
int channels = bottom_top_blob.c;
3737
int size = w * h;
38-
int packing = bottom_top_blob.packing;
38+
int elempack = bottom_top_blob.elempack;
3939

4040
#if __ARM_NEON
41-
if (packing == 4)
41+
if (elempack == 4)
4242
{
4343
#pragma omp parallel for num_threads(opt.num_threads)
4444
for (int q=0; q<channels; q++)

src/layer/arm/convolution_arm.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ int Convolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option
471471
int h = bottom_blob.h;
472472
int channels = bottom_blob.c;
473473
size_t elemsize = bottom_blob.elemsize;
474-
int packing = bottom_blob.packing;
474+
int elempack = bottom_blob.elempack;
475475

476476
// fprintf(stderr, "Convolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d\n", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h);
477477

@@ -505,8 +505,8 @@ int Convolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option
505505

506506
int outw = (w - kernel_extent_w) / stride_w + 1;
507507
int outh = (h - kernel_extent_h) / stride_h + 1;
508-
int out_packing = num_output % 4 == 0 ? 4 : 1;
509-
size_t out_elemsize = elemsize / packing * out_packing;
508+
int out_elempack = num_output % 4 == 0 ? 4 : 1;
509+
size_t out_elemsize = elemsize / elempack * out_elempack;
510510

511511
const int maxk = kernel_w * kernel_h;
512512

@@ -530,15 +530,15 @@ int Convolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option
530530
}
531531

532532
// float32
533-
top_blob.create(outw, outh, num_output / out_packing, out_elemsize, out_packing, opt.blob_allocator);
533+
top_blob.create(outw, outh, num_output / out_elempack, out_elemsize, out_elempack, opt.blob_allocator);
534534
if (top_blob.empty())
535535
return -100;
536536

537-
if (packing == 4 && out_packing == 4)
537+
if (elempack == 4 && out_elempack == 4)
538538
{
539539
// num_output
540540
#pragma omp parallel for num_threads(opt.num_threads)
541-
for (int p=0; p<num_output / out_packing; p++)
541+
for (int p=0; p<num_output / out_elempack; p++)
542542
{
543543
float* outptr = top_blob.channel(p);
544544

@@ -628,11 +628,11 @@ int Convolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option
628628
return 0;
629629
}
630630

631-
if (packing == 1 && out_packing == 4)
631+
if (elempack == 1 && out_elempack == 4)
632632
{
633633
// num_output
634634
#pragma omp parallel for num_threads(opt.num_threads)
635-
for (int p=0; p<num_output / out_packing; p++)
635+
for (int p=0; p<num_output / out_elempack; p++)
636636
{
637637
float* outptr = top_blob.channel(p);
638638

@@ -707,7 +707,7 @@ int Convolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option
707707
return 0;
708708
}
709709

710-
if (packing == 4 && out_packing == 1)
710+
if (elempack == 4 && out_elempack == 1)
711711
{
712712
// num_output
713713
#pragma omp parallel for num_threads(opt.num_threads)

src/layer/arm/convolutiondepthwise_arm.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ int ConvolutionDepthWise_arm::forward(const Mat& bottom_blob, Mat& top_blob, con
397397
int h = bottom_blob.h;
398398
int channels = bottom_blob.c;
399399
size_t elemsize = bottom_blob.elemsize;
400-
int packing = bottom_blob.packing;
400+
int elempack = bottom_blob.elempack;
401401

402402
const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1;
403403
const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1;
@@ -455,8 +455,8 @@ int ConvolutionDepthWise_arm::forward(const Mat& bottom_blob, Mat& top_blob, con
455455

456456
int outw = (w - kernel_extent_w) / stride_w + 1;
457457
int outh = (h - kernel_extent_h) / stride_h + 1;
458-
int out_packing = num_output % 4 == 0 ? 4 : 1;
459-
size_t out_elemsize = elemsize / packing * out_packing;
458+
int out_elempack = num_output % 4 == 0 ? 4 : 1;
459+
size_t out_elemsize = elemsize / elempack * out_elempack;
460460

461461
if (opt.use_packing_layout)
462462
{
@@ -482,17 +482,17 @@ int ConvolutionDepthWise_arm::forward(const Mat& bottom_blob, Mat& top_blob, con
482482
}
483483
}
484484

485-
top_blob.create(outw, outh, num_output / out_packing, out_elemsize, out_packing, opt.blob_allocator);
485+
top_blob.create(outw, outh, num_output / out_elempack, out_elemsize, out_elempack, opt.blob_allocator);
486486
if (top_blob.empty())
487487
return -100;
488488

489489
// depth-wise
490-
if (channels == group / packing && group / packing == num_output / packing)
490+
if (channels == group / elempack && group / elempack == num_output / elempack)
491491
{
492-
if (packing == 4)
492+
if (elempack == 4)
493493
{
494494
#pragma omp parallel for num_threads(opt.num_threads)
495-
for (int g=0; g<group / packing; g++)
495+
for (int g=0; g<group / elempack; g++)
496496
{
497497
float* outptr = top_blob.channel(g);
498498
const float* kptr = (const float*)weight_data_pack4 + maxk * g * 4;
@@ -561,20 +561,20 @@ int ConvolutionDepthWise_arm::forward(const Mat& bottom_blob, Mat& top_blob, con
561561
}
562562
}
563563

564-
const int channels_g = channels * packing / group;
564+
const int channels_g = channels * elempack / group;
565565
const int num_output_g = num_output / group;
566566

567567
// unpacking
568568
Mat bottom_blob_bordered_unpacked = bottom_blob_bordered;
569-
if (packing == 4 && channels_g % 4 != 0)
569+
if (elempack == 4 && channels_g % 4 != 0)
570570
{
571571
convert_packing(bottom_blob_bordered, bottom_blob_bordered_unpacked, 1, opt.workspace_allocator, opt.num_threads);
572572
}
573573

574574
Mat top_blob_unpacked = top_blob;
575-
if (num_output_g % 4 != 0 && out_packing == 4)
575+
if (num_output_g % 4 != 0 && out_elempack == 4)
576576
{
577-
top_blob_unpacked.create(outw, outh, num_output, elemsize / packing, 1, opt.workspace_allocator);
577+
top_blob_unpacked.create(outw, outh, num_output, elemsize / elempack, 1, opt.workspace_allocator);
578578
if (top_blob_unpacked.empty())
579579
return -100;
580580
}
@@ -843,7 +843,7 @@ int ConvolutionDepthWise_arm::forward(const Mat& bottom_blob, Mat& top_blob, con
843843
}
844844

845845
// packing
846-
if (num_output_g % 4 != 0 && out_packing == 4)
846+
if (num_output_g % 4 != 0 && out_elempack == 4)
847847
{
848848
convert_packing(top_blob_unpacked, top_blob, 4, opt.blob_allocator, opt.num_threads);
849849
}

src/layer/arm/innerproduct_arm.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,26 +160,26 @@ int InnerProduct_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Optio
160160
int h = bottom_blob.h;
161161
int channels = bottom_blob.c;
162162
size_t elemsize = bottom_blob.elemsize;
163-
int packing = bottom_blob.packing;
163+
int elempack = bottom_blob.elempack;
164164
int size = w * h;
165165

166166
if (opt.use_packing_layout)
167167
{
168168

169169
int num_input = bottom_blob.w;
170170

171-
int out_packing = num_output % 4 == 0 ? 4 : 1;
172-
size_t out_elemsize = elemsize / packing * out_packing;
171+
int out_elempack = num_output % 4 == 0 ? 4 : 1;
172+
size_t out_elemsize = elemsize / elempack * out_elempack;
173173

174-
top_blob.create(num_output / out_packing, out_elemsize, out_packing, opt.blob_allocator);
174+
top_blob.create(num_output / out_elempack, out_elemsize, out_elempack, opt.blob_allocator);
175175
if (top_blob.empty())
176176
return -100;
177177

178-
if (packing == 4 && out_packing == 4)
178+
if (elempack == 4 && out_elempack == 4)
179179
{
180180
// num_output
181181
#pragma omp parallel for num_threads(opt.num_threads)
182-
for (int p=0; p<num_output / out_packing; p++)
182+
for (int p=0; p<num_output / out_elempack; p++)
183183
{
184184
const float* w = (const float*)weight_data_pack4 + num_input * p * 16;
185185
const float* m = bottom_blob;
@@ -256,11 +256,11 @@ int InnerProduct_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Optio
256256
return 0;
257257
}
258258

259-
if (packing == 1 && out_packing == 4)
259+
if (elempack == 1 && out_elempack == 4)
260260
{
261261
// num_output
262262
#pragma omp parallel for num_threads(opt.num_threads)
263-
for (int p=0; p<num_output / out_packing; p++)
263+
for (int p=0; p<num_output / out_elempack; p++)
264264
{
265265
const float* w = (const float*)weight_data_pack1to4 + num_input * p * 4;
266266
const float* m = bottom_blob;
@@ -321,7 +321,7 @@ int InnerProduct_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Optio
321321
return 0;
322322
}
323323

324-
if (packing == 4 && out_packing == 1)
324+
if (elempack == 4 && out_elempack == 1)
325325
{
326326
// num_output
327327
#pragma omp parallel for num_threads(opt.num_threads)

src/layer/arm/packing_arm.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ int Packing_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option& op
3434
return Packing::forward(bottom_blob, top_blob, opt);
3535
}
3636

37-
int packing = bottom_blob.packing;
37+
int elempack = bottom_blob.elempack;
3838

39-
if (packing == out_packing)
39+
if (elempack == out_elempack)
4040
{
4141
top_blob = bottom_blob;
4242
return 0;
4343
}
4444

45-
bool pack1to4 = packing == 1 && out_packing == 4;
46-
bool pack4to1 = packing == 4 && out_packing == 1;
45+
bool pack1to4 = elempack == 1 && out_elempack == 4;
46+
bool pack4to1 = elempack == 4 && out_elempack == 1;
4747

4848
if (!pack1to4 && !pack4to1)
4949
{
@@ -59,17 +59,17 @@ int Packing_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option& op
5959
if (!use_padding)
6060
{
6161
// identity if use_padding not allowed
62-
if (dims == 1 && w * packing % out_packing != 0)
62+
if (dims == 1 && w * elempack % out_elempack != 0)
6363
{
6464
top_blob = bottom_blob;
6565
return 0;
6666
}
67-
if (dims == 2 && h * packing % out_packing != 0)
67+
if (dims == 2 && h * elempack % out_elempack != 0)
6868
{
6969
top_blob = bottom_blob;
7070
return 0;
7171
}
72-
if (dims == 3 && channels * packing % out_packing != 0)
72+
if (dims == 3 && channels * elempack % out_elempack != 0)
7373
{
7474
top_blob = bottom_blob;
7575
return 0;
@@ -79,19 +79,19 @@ int Packing_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option& op
7979
if (dims == 1)
8080
{
8181
top_blob = bottom_blob;
82-
top_blob.w = w * packing / out_packing;
83-
top_blob.cstep = w * packing / out_packing;
84-
top_blob.elemsize = elemsize / packing * out_packing;
85-
top_blob.packing = out_packing;
82+
top_blob.w = w * elempack / out_elempack;
83+
top_blob.cstep = w * elempack / out_elempack;
84+
top_blob.elemsize = elemsize / elempack * out_elempack;
85+
top_blob.elempack = out_elempack;
8686
return 0;
8787
}
8888

8989
if (dims == 2)
9090
{
91-
int outh = h * packing / out_packing;
92-
size_t out_elemsize = elemsize / packing * out_packing;
91+
int outh = h * elempack / out_elempack;
92+
size_t out_elemsize = elemsize / elempack * out_elempack;
9393

94-
top_blob.create(w, outh, out_elemsize, out_packing, opt.blob_allocator);
94+
top_blob.create(w, outh, out_elemsize, out_elempack, opt.blob_allocator);
9595
if (top_blob.empty())
9696
return -100;
9797

@@ -195,10 +195,10 @@ int Packing_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option& op
195195
if (dims == 3)
196196
{
197197
int size = w * h;
198-
int outc = channels * packing / out_packing;
199-
size_t out_elemsize = elemsize / packing * out_packing;
198+
int outc = channels * elempack / out_elempack;
199+
size_t out_elemsize = elemsize / elempack * out_elempack;
200200

201-
top_blob.create(w, h, outc, out_elemsize, out_packing, opt.blob_allocator);
201+
top_blob.create(w, h, outc, out_elemsize, out_elempack, opt.blob_allocator);
202202
if (top_blob.empty())
203203
return -100;
204204

src/layer/arm/padding_arm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ int Padding_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option& op
162162
int channels = bottom_blob.c;
163163
int dims = bottom_blob.dims;
164164
size_t elemsize = bottom_blob.elemsize;
165-
int packing = bottom_blob.packing;
165+
int elempack = bottom_blob.elempack;
166166

167167
#if __ARM_NEON
168-
if (packing == 4)
168+
if (elempack == 4)
169169
{
170170
int outw = w + left + right;
171171

src/layer/arm/relu_arm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ int ReLU_arm::forward_inplace(Mat& bottom_top_blob, const Option& opt) const
119119
int h = bottom_top_blob.h;
120120
int channels = bottom_top_blob.c;
121121
int size = w * h;
122-
int packing = bottom_top_blob.packing;
122+
int elempack = bottom_top_blob.elempack;
123123

124124
#if __ARM_NEON
125-
if (packing == 4)
125+
if (elempack == 4)
126126
{
127127
if (slope == 0.f)
128128
{

0 commit comments

Comments
 (0)