@@ -305,6 +305,8 @@ int Gemm::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& top_bl
305305 {
306306 // transpose A to row-major
307307 A.create ((A0.dims == 3 ? A0.c : A0.h ), A0.w , elemsize, opt.workspace_allocator );
308+ if (A.empty ())
309+ return -100 ;
308310
309311 const size_t A0_hstep = A0.dims == 3 ? A0.cstep : (size_t )A0.w ;
310312
@@ -323,6 +325,8 @@ int Gemm::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& top_bl
323325 {
324326 // transpose B to col-major
325327 BT.create ((B0.dims == 3 ? B0.c : B0.h ), B0.w , elemsize, opt.workspace_allocator );
328+ if (BT.empty ())
329+ return -100 ;
326330
327331 const size_t B0_hstep = B0.dims == 3 ? B0.cstep : (size_t )B0.w ;
328332
@@ -441,6 +445,8 @@ int Gemm::forward_int8(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& t
441445 if (A0.elemsize == 1 )
442446 {
443447 A.create (A0.h , A0.w , (size_t )1u , 1 , opt.workspace_allocator );
448+ if (A.empty ())
449+ return -100 ;
444450
445451 for (int i = 0 ; i < A.h ; i++)
446452 {
@@ -454,6 +460,8 @@ int Gemm::forward_int8(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& t
454460 else
455461 {
456462 A.create (A0.dims == 3 ? A0.c : A0.h , A0.w , (size_t )4u , 1 , opt.workspace_allocator );
463+ if (A.empty ())
464+ return -100 ;
457465
458466 for (int i = 0 ; i < A.h ; i++)
459467 {
@@ -472,7 +480,11 @@ int Gemm::forward_int8(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& t
472480 if (A_int8.elemsize != 1 )
473481 {
474482 A_int8.create (A.w , A.dims == 3 ? A.c : A.h , (size_t )1u , 1 , opt.workspace_allocator );
483+ if (A_int8.empty ())
484+ return -100 ;
475485 A_int8_scales.create (A_int8.h , (size_t )4u , 1 , opt.workspace_allocator );
486+ if (A_int8_scales.empty ())
487+ return -100 ;
476488
477489 for (int i = 0 ; i < A_int8.h ; i++)
478490 {
@@ -503,6 +515,8 @@ int Gemm::forward_int8(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& t
503515 if (B0_int8.elemsize != 1 )
504516 {
505517 B0_int8.create (B0.w , B0.dims == 3 ? B0.c : B0.h , (size_t )1u , 1 , opt.workspace_allocator );
518+ if (B0_int8.empty ())
519+ return -100 ;
506520
507521 float absmax = 0 .f ;
508522 for (int i = 0 ; i < B0_int8.h ; i++)
@@ -537,6 +551,8 @@ int Gemm::forward_int8(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& t
537551 {
538552 // transpose B to col-major
539553 BT_int8.create (B0_int8.h , B0_int8.w , (size_t )1u , 1 , opt.workspace_allocator );
554+ if (BT_int8.empty ())
555+ return -100 ;
540556
541557 for (int i = 0 ; i < BT_int8.h ; i++)
542558 {
0 commit comments