提交 af27bfff 编写于 作者: Y yongqiang

add calib kernel to support int64 to float32. test=develop

上级 6d2b2a40
......@@ -44,6 +44,17 @@ void CalibComputeInt64ToInt32<DLType>::Run() {
}
}
template <DataLayoutType DLType>
void CalibComputeInt64ToFloat32<DLType>::Run() {
auto& param = this->template Param<operators::CalibParam>();
const auto* din = param.input->template data<int64_t>();
std::vector<float> scale = {param.scale};
auto* dout = param.output->template mutable_data<float>();
for (auto i = 0; i < param.input->numel(); ++i) {
dout[i] = din[i];
}
}
template <DataLayoutType DLType>
void CalibComputeInt8ToFp32<DLType>::Run() {
auto& param = this->template Param<operators::CalibParam>();
......@@ -133,6 +144,40 @@ REGISTER_LITE_KERNEL(
DATALAYOUT(kNCHW))})
.Finalize();
REGISTER_LITE_KERNEL(
calib,
kARM,
kFloat,
kNCHW,
paddle::lite::kernels::arm::CalibComputeInt64ToFloat32<DATALAYOUT(kNCHW)>,
int64_to_float32)
.BindInput("Input",
{LiteType::GetTensorTy(TARGET(kAny),
PRECISION(kInt64),
DATALAYOUT(kNCHW))})
.BindOutput("Out",
{LiteType::GetTensorTy(TARGET(kARM),
PRECISION(kFloat),
DATALAYOUT(kNCHW))})
.Finalize();
REGISTER_LITE_KERNEL(
calib,
kARM,
kInt64,
kNCHW,
paddle::lite::kernels::arm::CalibComputeInt64ToFloat32<DATALAYOUT(kNCHW)>,
int64_to_float32)
.BindInput("Input",
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt64),
DATALAYOUT(kNCHW))})
.BindOutput("Out",
{LiteType::GetTensorTy(TARGET(kARM),
PRECISION(kFloat),
DATALAYOUT(kNCHW))})
.Finalize();
REGISTER_LITE_KERNEL(
calib_once,
kARM,
......@@ -206,3 +251,37 @@ REGISTER_LITE_KERNEL(
PRECISION(kInt32),
DATALAYOUT(kNCHW))})
.Finalize();
REGISTER_LITE_KERNEL(
calib_once,
kARM,
kFloat,
kNCHW,
paddle::lite::kernels::arm::CalibComputeInt64ToFloat32<DATALAYOUT(kNCHW)>,
int64_to_float32)
.BindInput("Input",
{LiteType::GetTensorTy(TARGET(kARM),
PRECISION(kInt64),
DATALAYOUT(kNCHW))})
.BindOutput("Out",
{LiteType::GetTensorTy(TARGET(kARM),
PRECISION(kFloat),
DATALAYOUT(kNCHW))})
.Finalize();
REGISTER_LITE_KERNEL(
calib_once,
kARM,
kInt64,
kNCHW,
paddle::lite::kernels::arm::CalibComputeInt64ToFloat32<DATALAYOUT(kNCHW)>,
int64_to_float32)
.BindInput("Input",
{LiteType::GetTensorTy(TARGET(kHost),
PRECISION(kInt64),
DATALAYOUT(kNCHW))})
.BindOutput("Out",
{LiteType::GetTensorTy(TARGET(kARM),
PRECISION(kFloat),
DATALAYOUT(kNCHW))})
.Finalize();
......@@ -47,6 +47,19 @@ class CalibComputeInt64ToInt32
private:
};
template <DataLayoutType DLType>
class CalibComputeInt64ToFloat32
: public KernelLite<TARGET(kARM), PRECISION(kInt64), DLType> {
public:
using param_t = operators::CalibParam;
void Run() override;
~CalibComputeInt64ToFloat32() override{};
private:
};
template <DataLayoutType DLType>
class CalibComputeInt8ToFp32
: public KernelLite<TARGET(kARM), PRECISION(kInt8), DLType> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册