!43690 [MSLite][CPU]Fuzz Fix

Merge pull request !43690 from 陈宇/dev_master_fuzz_fix
This commit is contained in:
i-robot 2022-11-02 03:52:46 +00:00 committed by Gitee
commit bbd5354459
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 16 additions and 1 deletions

View File

@ -26,6 +26,10 @@ int HashtableLoopupInferShape(const TensorC *const *inputs, size_t inputs_size,
const TensorC *input = inputs[0];
const TensorC *values = inputs[2];
if (input == NULL || values == NULL) {
return NNACL_NULL_PTR;
}
TensorC *output = outputs[0];
TensorC *hits = outputs[1];

View File

@ -331,6 +331,9 @@ Status ModelImpl::Predict(const std::vector<MSTensor> &inputs, std::vector<MSTen
return kLiteError;
}
std::vector<void *> old_data;
for (size_t i = 0; i < inputs.size(); i++) {
old_data.push_back(input_tensors.at(i)->data());
}
for (size_t i = 0; i < inputs.size(); i++) {
auto input = input_tensors.at(i);
auto user_input = inputs.at(i);
@ -349,7 +352,6 @@ Status ModelImpl::Predict(const std::vector<MSTensor> &inputs, std::vector<MSTen
MS_LOG(WARNING) << "Tensor " << user_input.Name() << " has a different name from input" << input->tensor_name()
<< ".";
}
old_data.push_back(input->data());
if (input->data_type() == kObjectTypeString) {
#ifndef STRING_KERNEL_CLIP
std::vector<int32_t> shape = TruncateShape(user_input.Shape(), input->data_type(), user_input.DataSize(), false);

View File

@ -214,6 +214,14 @@ int ScaleInt8CPUKernel::Prepare() {
return RET_ERROR;
}
for (auto tensor : in_tensors_) {
if (tensor->data_type() != TypeId::kNumberTypeInt8) {
MS_LOG(ERROR) << " in tensors type to scale_int8 should be int8, but type id " << tensor->data_type()
<< " is given";
}
return RET_ERROR;
}
if (!InferShapeDone()) {
return RET_OK;
}

View File

@ -269,6 +269,7 @@ int BenchmarkUnifiedApi::GenerateInputData() {
return RET_ERROR;
}
tensor = *input;
delete input;
} else {
auto input_data = tensor.MutableData();
if (input_data == nullptr) {