未验证 提交 7fb9339a 编写于 作者: J jameswu2014 提交者: GitHub

concat+fetch bug for FPGA V1 track (#1678)

* marker1-anchor update

* concat-fetch bug
上级 a10c01f7
...@@ -273,6 +273,7 @@ void format_concat_output(framework::Tensor *out, int height, int width, ...@@ -273,6 +273,7 @@ void format_concat_output(framework::Tensor *out, int height, int width,
auto ddim = framework::make_ddim({1, sum_channel, height, width}); auto ddim = framework::make_ddim({1, sum_channel, height, width});
out->Resize(ddim); out->Resize(ddim);
out->reset_data_ptr(data_ptr); out->reset_data_ptr(data_ptr);
out->fpga_data_num = sum_cw * height;
out->set_type(type_id<half>().hash_code()); out->set_type(type_id<half>().hash_code());
} }
void format_conv_data(framework::Tensor *filter_tensor, void format_conv_data(framework::Tensor *filter_tensor,
......
...@@ -561,9 +561,9 @@ template <typename Device, typename T> ...@@ -561,9 +561,9 @@ template <typename Device, typename T>
void Executor<Device, T>::FeedData(const std::vector<void *> &v) { void Executor<Device, T>::FeedData(const std::vector<void *> &v) {
auto input_size = v.size(); auto input_size = v.size();
int index = 0; int index = 0;
auto vars = program_.scope->VarContain("feed", &index); // auto vars = program_.scope->VarContain("feed", &index);
PADDLE_MOBILE_ENFORCE(input_size == vars.size(), // PADDLE_MOBILE_ENFORCE(input_size == vars.size(),
"input data number not correct"); // "input data number not correct");
for (int i = 0; i < input_size; i++) { for (int i = 0; i < input_size; i++) {
auto var = program_.scope->Var("feed", i + index); auto var = program_.scope->Var("feed", i + index);
auto feed_tensor = var->template GetMutable<LoDTensor>(); auto feed_tensor = var->template GetMutable<LoDTensor>();
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#include <vector> #include <vector>
#include "common/enforce.h" #include "common/enforce.h"
#include "framework/tensor.h" #include "framework/tensor.h"
#ifdef PADDLE_MOBILE_FPGA
#include <fpga/common/fpga_common.h>
#endif
namespace paddle_mobile { namespace paddle_mobile {
...@@ -179,6 +182,19 @@ void PaddleMobilePredictor<Device, T>::FetchPaddleTensors(PaddleTensor *output, ...@@ -179,6 +182,19 @@ void PaddleMobilePredictor<Device, T>::FetchPaddleTensors(PaddleTensor *output,
int id) { int id) {
std::shared_ptr<framework::Tensor> tensor_ptr = std::shared_ptr<framework::Tensor> tensor_ptr =
paddle_mobile_->FetchResult(id); paddle_mobile_->FetchResult(id);
void *data_addr = nullptr;
int data_sizeof = 1;
if (tensor_ptr.get()->type() == type_id<half>().hash_code()) {
data_addr = tensor_ptr.get()->data<half>();
data_sizeof = sizeof(half);
} else if (tensor_ptr.get()->type() == type_id<float>().hash_code()) {
data_addr = tensor_ptr.get()->data<float>();
data_sizeof = sizeof(float);
} else {
PADDLE_MOBILE_ENFORCE(0, "output typeid is not supported");
}
size_t size = tensor_ptr.get()->numel() * data_sizeof;
fpga::fpga_invalidate(data_addr, size);
ConvertTensors(*(tensor_ptr.get()), output); ConvertTensors(*(tensor_ptr.get()), output);
return; return;
} }
......
...@@ -26,7 +26,9 @@ bool ReluKernel<FPGA, float>::Init(ReluParam<FPGA> *param) { ...@@ -26,7 +26,9 @@ bool ReluKernel<FPGA, float>::Init(ReluParam<FPGA> *param) {
} }
template <> template <>
void ReluKernel<FPGA, float>::Compute(const ReluParam<FPGA> &param) {} void ReluKernel<FPGA, float>::Compute(const ReluParam<FPGA> &param) {
PADDLE_MOBILE_ENFORCE(0, "relu as a single op is wrong");
}
} // namespace operators } // namespace operators
} // namespace paddle_mobile } // namespace paddle_mobile
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册