Browse Source

Extract on CPU without pack/fp16fp32 (#2288)

* Add readme for keras2ncnn

* Add supported model variants

* Fix supported model variants

* Add extract without convert pack/fp1632
tags/20201208
Martin Han GitHub 5 years ago
parent
commit
b441f738bd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions
  1. +6
    -6
      src/net.cpp
  2. +6
    -2
      src/net.h

+ 6
- 6
src/net.cpp View File

@@ -2640,13 +2640,13 @@ int Extractor::input(const char* blob_name, const Mat& in)
return input(blob_index, in);
}

int Extractor::extract(const char* blob_name, Mat& feat)
int Extractor::extract(const char* blob_name, Mat& feat, int type)
{
int blob_index = net->find_blob_index_by_name(blob_name);
if (blob_index == -1)
return -1;

return extract(blob_index, feat);
return extract(blob_index, feat, type);
}
#endif // NCNN_STRING

@@ -2660,7 +2660,7 @@ int Extractor::input(int blob_index, const Mat& in)
return 0;
}

int Extractor::extract(int blob_index, Mat& feat)
int Extractor::extract(int blob_index, Mat& feat, int type)
{
if (blob_index < 0 || blob_index >= (int)blob_mats.size())
return -1;
@@ -2765,7 +2765,7 @@ int Extractor::extract(int blob_index, Mat& feat)

feat = blob_mats[blob_index];

if (opt.use_packing_layout)
if (opt.use_packing_layout && (type == 0))
{
Mat bottom_blob_unpacked;
convert_packing(feat, bottom_blob_unpacked, 1, opt);
@@ -2775,7 +2775,7 @@ int Extractor::extract(int blob_index, Mat& feat)
// clang-format off
// *INDENT-OFF*
#if NCNN_ARM82
if (opt.use_fp16_storage && cpu_support_arm_asimdhp())
if (opt.use_fp16_storage && cpu_support_arm_asimdhp() && (type == 0))
{
if (feat.elembits() == 16)
{
@@ -2786,7 +2786,7 @@ int Extractor::extract(int blob_index, Mat& feat)
}
else
#endif // NCNN_ARM82
if (opt.use_bf16_storage)
if (opt.use_bf16_storage && (type == 0))
{
if (feat.elembits() == 16)
{


+ 6
- 2
src/net.h View File

@@ -209,7 +209,9 @@ public:

// get result by blob name
// return 0 if success
int extract(const char* blob_name, Mat& feat);
// type = 0, default
// type = 1, do not convert fp16/bf16 or / and packing
int extract(const char* blob_name, Mat& feat, int type = 0);
#endif // NCNN_STRING

// set input by blob index
@@ -218,7 +220,9 @@ public:

// get result by blob index
// return 0 if success
int extract(int blob_index, Mat& feat);
// type = 0, default
// type = 1, do not convert fp16/bf16 or / and packing
int extract(int blob_index, Mat& feat, int type = 0);

#if NCNN_VULKAN
#if NCNN_STRING


Loading…
Cancel
Save