forked from mindspore-Ecosystem/mindspore
[MSLITE] bias add int accuracy bug
This commit is contained in:
parent
2102e4c822
commit
f9341b99dc
|
@ -107,6 +107,7 @@ int ArithmeticInferShape(const TensorC *const *inputs, size_t inputs_size, Tenso
|
|||
}
|
||||
|
||||
REG_INFER(Add, PrimType_AddFusion, ArithmeticInferShape)
|
||||
REG_INFER(BiasAdd, PrimType_BiasAdd, ArithmeticInferShape)
|
||||
REG_INFER(Div, PrimType_DivFusion, ArithmeticInferShape)
|
||||
REG_INFER(Eltwise, PrimType_Eltwise, ArithmeticInferShape)
|
||||
REG_INFER(FloorDiv, PrimType_FloorDiv, ArithmeticInferShape)
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "nnacl/infer/bias_infer.h"
|
||||
#include "nnacl/infer/infer_register.h"
|
||||
|
||||
int BiasInferShape(const TensorC *const *inputs, size_t inputs_size, TensorC **outputs, size_t outputs_size,
|
||||
OpParameter *parameter) {
|
||||
int check_ret = CheckAugmentNullSize(inputs, inputs_size, outputs, outputs_size, parameter, 2, 1);
|
||||
if (check_ret != NNACL_OK) {
|
||||
return check_ret;
|
||||
}
|
||||
SetDataTypeFormat(outputs[0], inputs[0]);
|
||||
if (!InferFlag(inputs, inputs_size)) {
|
||||
return NNACL_INFER_INVALID;
|
||||
}
|
||||
|
||||
MS_CHECK_TRUE_RET(inputs[0]->shape_size_ >= 1, NNACL_ERR);
|
||||
MS_CHECK_TRUE_RET(inputs[1]->shape_size_ == 1, NNACL_ERR);
|
||||
size_t dim = inputs[0]->shape_size_ - 1;
|
||||
if (inputs[0]->format_ == Format_KCHW || inputs[0]->format_ == Format_NCHW) {
|
||||
dim = 1;
|
||||
}
|
||||
if (inputs[0]->shape_[dim] != inputs[1]->shape_[0]) {
|
||||
return NNACL_ERR;
|
||||
}
|
||||
SetShapeTensor(outputs[0], inputs[0]);
|
||||
|
||||
return NNACL_OK;
|
||||
}
|
||||
|
||||
REG_INFER(BiasAdd, PrimType_BiasAdd, BiasInferShape)
|
|
@ -1,31 +0,0 @@
|
|||
/**
|
||||
* Copyright 2022 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MINDSPORE_NNACL_BIAS_INFER_H
|
||||
#define MINDSPORE_NNACL_BIAS_INFER_H
|
||||
|
||||
#include "nnacl/infer/common_infer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int BiasInferShape(const TensorC *const *inputs, size_t inputs_size, TensorC **outputs, size_t outputs_size,
|
||||
OpParameter *parameter);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // MINDSPORE_NNACL_BIAS_INFER_H
|
|
@ -25,6 +25,7 @@ using mindspore::lite::KernelRegistrar;
|
|||
using mindspore::lite::RET_ERROR;
|
||||
using mindspore::lite::RET_OK;
|
||||
using mindspore::schema::PrimitiveType_AddFusion;
|
||||
using mindspore::schema::PrimitiveType_BiasAdd;
|
||||
|
||||
namespace mindspore::kernel {
|
||||
namespace {
|
||||
|
@ -255,5 +256,6 @@ int QuantizedAddCPUKernel::Run() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_BiasAdd, LiteKernelCreator<QuantizedAddCPUKernel>)
|
||||
REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_AddFusion, LiteKernelCreator<QuantizedAddCPUKernel>)
|
||||
} // namespace mindspore::kernel
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "src/runtime/kernel/arm/int8/bias_add_int8.h"
|
||||
#include "src/kernel_registry.h"
|
||||
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
using mindspore::lite::RET_ERROR;
|
||||
using mindspore::lite::RET_OK;
|
||||
using mindspore::schema::PrimitiveType_BiasAdd;
|
||||
|
||||
namespace mindspore::kernel {
|
||||
REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_BiasAdd, LiteKernelCreator<BiasAddInt8CPUKernel>)
|
||||
} // namespace mindspore::kernel
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_ARM_INT8_BAIS_ADD_INT8_H_
|
||||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_ARM_INT8_BAIS_ADD_INT8_H_
|
||||
|
||||
#include <vector>
|
||||
#include "src/runtime/kernel/arm/int8/add_int8.h"
|
||||
|
||||
namespace mindspore::kernel {
|
||||
class BiasAddInt8CPUKernel : public QuantizedAddCPUKernel {
|
||||
public:
|
||||
BiasAddInt8CPUKernel(OpParameter *parameter, const std::vector<lite::Tensor *> &inputs,
|
||||
const std::vector<lite::Tensor *> &outputs, const lite::InnerContext *ctx)
|
||||
: QuantizedAddCPUKernel(parameter, inputs, outputs, ctx) {}
|
||||
~BiasAddInt8CPUKernel() override = default;
|
||||
};
|
||||
} // namespace mindspore::kernel
|
||||
|
||||
#endif // MINDSPORE_LITE_SRC_RUNTIME_KERNEL_ARM_INT8_BAIS_ADD_INT8_H_
|
Loading…
Reference in New Issue