提交 542008c0 编写于 作者: J jameswu2014 提交者: Jiaying Zhao

io+softmax update for FPGA V1 track (#1613)

* V2-conv-hellocase pass & V1 verify-pass

* V1 paralvl equal to 2

* softmax channel =2 bug

* softmaxbug update2

* io update2
上级 c014bdbf
...@@ -33,6 +33,7 @@ namespace paddle_mobile { ...@@ -33,6 +33,7 @@ namespace paddle_mobile {
namespace fpga { namespace fpga {
int open_device(); int open_device();
int close_device();
void* fpga_malloc(size_t size); void* fpga_malloc(size_t size);
void fpga_free(void* ptr); void fpga_free(void* ptr);
......
...@@ -47,7 +47,22 @@ bool SoftmaxKernel<FPGA, float>::Init(SoftmaxParam<FPGA> *param) { ...@@ -47,7 +47,22 @@ bool SoftmaxKernel<FPGA, float>::Init(SoftmaxParam<FPGA> *param) {
input->Resize(framework::make_ddim(dims)); input->Resize(framework::make_ddim(dims));
float_input->Resize(framework::make_ddim(dims)); float_input->Resize(framework::make_ddim(dims));
if (channel != 2) { // Use CPU if (channel == 2 && input->type() == type_id<half>()) { // Use FPGA
fpga::format_fp16_ofm(out);
fpga::BypassArgs args = {fpga::DATA_TYPE_FP16};
args.input_layout_type = fpga::LAYOUT_HWC;
args.output_layout_type = fpga::LAYOUT_CHW;
args.input_data_type = fpga::DATA_TYPE_FP16;
args.output_data_type = fpga::DATA_TYPE_FP16;
args.image.address = input_ptr;
args.image.height = (uint32_t)input->dims()[1];
args.image.width = (uint32_t)input->dims()[2];
args.image.channels = (uint32_t)input->dims()[3];
args.output.address = out->data<half>();
args.output.scale_address = out->scale;
args.output.activation.activation_type = fpga::SOFTMAX;
param->SetFpgaArgs(args);
} else { // Use CPU
out->Resize(framework::make_ddim(dims)); out->Resize(framework::make_ddim(dims));
out->mutable_data<float>(framework::make_ddim(dims)); out->mutable_data<float>(framework::make_ddim(dims));
float_input->init(type_id<float>().hash_code()); float_input->init(type_id<float>().hash_code());
...@@ -68,21 +83,6 @@ bool SoftmaxKernel<FPGA, float>::Init(SoftmaxParam<FPGA> *param) { ...@@ -68,21 +83,6 @@ bool SoftmaxKernel<FPGA, float>::Init(SoftmaxParam<FPGA> *param) {
args.output.scale_address = float_input->scale; args.output.scale_address = float_input->scale;
param->SetFloatInput(float_input); param->SetFloatInput(float_input);
param->SetFpgaArgs(args); param->SetFpgaArgs(args);
} else { // Use FPGA
fpga::format_fp16_ofm(out);
fpga::BypassArgs args = {fpga::DATA_TYPE_FP16};
args.input_layout_type = fpga::LAYOUT_HWC;
args.output_layout_type = fpga::LAYOUT_CHW;
args.input_data_type = fpga::DATA_TYPE_FP16;
args.output_data_type = fpga::DATA_TYPE_FP16;
args.image.address = input_ptr;
args.image.height = (uint32_t)input->dims()[1];
args.image.width = (uint32_t)input->dims()[2];
args.image.channels = (uint32_t)input->dims()[3];
args.output.address = out->data<half>();
args.output.scale_address = out->scale;
args.output.activation.activation_type = fpga::SOFTMAX;
param->SetFpgaArgs(args);
} }
return true; return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册