Skip to content

Commit 92bc457

Browse files
[cherry-pick] fix int16 store in fc-bias bug and add sa8155/sa8195 devices support (#8955)
* [int16_store_pass]fix bias on fc using int16-type to store error (#8918) * [device_info] add sa8155 and sa8195 info support (#8937)
1 parent 99150c4 commit 92bc457

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

lite/api/light_api.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,14 @@ void LightPredictor::DequantizeWeight() {
316316
} else if (op_type == "fc" || op_type == "mul" ||
317317
op_type == "lookup_table") {
318318
int64_t chin = input_tensor->dims()[0];
319-
int64_t chout = input_tensor->dims()[1];
319+
int64_t chout = input_tensor->numel() / chin;
320+
if (input_tensor->dims().size() > 1) {
321+
chout = input_tensor->dims()[1];
322+
} else {
323+
// swap
324+
chout = chin;
325+
chin = 1;
326+
}
320327
CHECK_EQ(scale_list.size(), chout);
321328
if (quantize_weight_bits == 8) {
322329
const int8_t* int_data = tmp_tensor.data<int8_t>();

lite/core/device_info.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,21 @@ bool DeviceInfo::SetCPUInfoByName() {
706706
big_core_ids_ = {4, 5, 6, 7};
707707
little_core_ids_ = {0, 1, 2, 3};
708708
cluster_ids_ = {1, 1, 1, 1, 0, 0, 0, 0};
709-
SetArchInfo(2, kA76, kA55);
710-
SetCacheInfo(0, 2, 192 * 1024, 256 * 1024);
709+
SetArchInfo(3, kGold_Prime, kGold, kSilver);
710+
SetCacheInfo(0, 3, 512 * 1024, 256 * 1024, 128 * 1024);
711+
SetCacheInfo(1, 3, 512 * 1024, 256 * 1024, 128 * 1024);
712+
SetCacheInfo(2, 1, 2 * 1024 * 1024);
713+
SetFP16Info(1, 1);
714+
SetDotInfo(2, 1, 1);
715+
return true;
716+
} else if (dev_name_.find("SA8195") != std::string::npos) { // sa8195
717+
core_num_ = 8;
718+
core_ids_ = {0, 1, 2, 3, 4, 5, 6, 7};
719+
big_core_ids_ = {4, 5, 6, 7};
720+
little_core_ids_ = {0, 1, 2, 3};
721+
cluster_ids_ = {1, 1, 1, 1, 0, 0, 0, 0};
722+
SetArchInfo(2, kGold_Prime, kSilver);
723+
SetCacheInfo(0, 2, 512 * 1024, 128 * 1024);
711724
SetCacheInfo(1, 2, 512 * 1024, 128 * 1024);
712725
SetCacheInfo(2, 1, 4 * 1024 * 1024);
713726
SetFP16Info(1, 1);

lite/core/device_info.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ typedef enum {
4949
kA76 = 76,
5050
kA77 = 77,
5151
kA78 = 78,
52+
kGold = 79,
53+
kGold_Prime = 80,
54+
kSilver = 81,
5255
kARMArch_UNKOWN = -1
5356
} ARMArch;
5457

lite/core/optimizer/mir/fusion/flatten_fc_fuser.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ cpp::OpDesc FlattenFcFuser::GenOpDesc(const key2nodes_t& matched) {
9797
op_desc.SetOutput("Out", {matched.at("fc_out")->arg()->name});
9898
auto in_num_col_dim = op_desc.GetAttr<int>("in_num_col_dims");
9999
op_desc.SetAttr("in_num_col_dims", in_num_col_dim);
100+
std::string op_type = "mul";
101+
op_desc.SetAttr("op_type", op_type);
100102
return op_desc;
101103
}
102104

lite/core/optimizer/mir/post_quant_dynamic_pass.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const std::vector<std::string> PostQuantDynamicPass::quant_axis1_ops = {
2929
"fc", "mul", "matmul", "matmul_v2", "lookup_table"};
3030

3131
std::vector<std::string> PostQuantDynamicPass::quant_ops = {
32-
"conv2d", "mul", "lookup_table"};
32+
"fc", "conv2d", "mul", "matmul", "matmul_v2", "lookup_table"};
3333

3434
static bool abs_compare(float a, float b) {
3535
return std::fabs(a) < std::fabs(b);
@@ -202,6 +202,9 @@ void PostQuantDynamicPass::Apply(const std::unique_ptr<SSAGraph>& graph) {
202202
auto iter =
203203
std::find(quant_axis1_ops.begin(), quant_axis1_ops.end(), op_type);
204204
int quant_axis = iter != quant_axis1_ops.end() ? 1 : 0;
205+
if (weight->dims().size() == 1) {
206+
quant_axis = 0;
207+
}
205208
PostQuantDynamicPerChannel(
206209
op_info, weight, weight_name, quant_axis, quant_bits);
207210
}

0 commit comments

Comments
 (0)