提交 2b90556b 编写于 作者: Z zhangyang

Modify FPGA kernels to comply to Gtype

上级 ff7fc7a3
cmake_minimum_required(VERSION 3.6)
option(USE_OPENMP "openmp support" ON)
option(USE_OPENMP "openmp support" OFF)
project(paddle-mobile)
option(DEBUGING "enable debug mode" OFF)
option(DEBUGING "enable debug mode" ON)
option(USE_EXCEPTION "use std exception" OFF)
option(LOG_PROFILE "log profile" OFF)
# select the platform to build
option(CPU "armv7 with neon" ON)
option(CPU "armv7 with neon" OFF)
option(MALI_GPU "mali gpu" OFF)
option(FPGA "fpga" OFF)
option(FPGA "fpga" ON)
file(GLOB_RECURSE PADDLE_MOBILE_CC src/*.cc src/*.cpp src/*.c src/*.mm)
file(GLOB_RECURSE PADDLE_MOBILE_H src/*.h)
......@@ -94,6 +94,8 @@ else()
endif()
if(FPGA)
set(DEBUGING ON)
add_definitions(-DPADDLE_MOBILE_DEBUG)
add_definitions(-DPADDLE_MOBILE_FPGA)
else()
file(GLOB_RECURSE _tmp_list src/operators/kernel/fpga/*.cpp src/operators/kernel/fpga/*.cc)
......@@ -140,7 +142,12 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build)
# NET default
set(NET "default" CACHE STRING "select net type")
if (FPGA)
set(NET "FPGAnets" CACHE STRING "select net type")
else()
set(NET "default" CACHE STRING "select net type")
endif()
set_property(CACHE NET PROPERTY STRINGS "default" "googlenet" "mobilenet" "yolo" "squeezenet" "FPGAnets" "NLP")
include("${CMAKE_CURRENT_LIST_DIR}/tools/op.cmake")
......
......@@ -35,6 +35,7 @@ class FeedOp : public framework::OperatorBase<DeviceType> {
auto out_dims = param_.Out()->dims();
out_dims[0] = param_.BatchSize();
param_.Out()->Resize(out_dims);
DLOG << "feed_op output dims size" << out_dims.size();
// note : mobile infershape iscalled when executer is created. so do not
// pass lod here .
......@@ -49,7 +50,7 @@ class FeedOp : public framework::OperatorBase<DeviceType> {
}
void RunImpl() const {
Tensor *input = const_cast<Tensor *>(param_.InputX());
auto input = (Tensor *)const_cast<LoDTensor *>(param_.InputX());
auto input_ptr = input->data<float>();
fpga::format_image(input);
Tensor *output = param_.Out();
......
......@@ -22,8 +22,8 @@ template <>
bool ElementwiseAddReluKernel<FPGA, float>::Init(
ElementwiseAddReluParam<FPGA> *param) {
bool relu_enabled = true;
auto *input_x = const_cast<Tensor *>(param->InputX());
auto *input_y = const_cast<Tensor *>(param->InputY());
auto *input_x = const_cast<LoDTensor *>(param->InputX());
auto *input_y = const_cast<LoDTensor *>(param->InputY());
auto *out = param->Out();
auto input_x_ptr = input_x->data<float>();
auto input_y_ptr = input_y->data<float>();
......
......@@ -20,7 +20,7 @@ namespace operators {
template <>
bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam<FPGA> *param) {
bool relu_enabled = true;
auto *input_x = const_cast<Tensor *>(param->InputX());
auto *input_x = const_cast<LoDTensor *>(param->InputX());
auto input_x_ptr = input_x->data<float>();
auto *filter = const_cast<Tensor *>(param->InputY());
const Tensor *input_z = param->InputZ();
......
......@@ -21,7 +21,7 @@ namespace operators {
template <>
bool FusionFcKernel<FPGA, float>::Init(FusionFcParam<FPGA> *param) {
bool relu_enabled = false;
auto *input_x = const_cast<Tensor *>(param->InputX());
auto *input_x = const_cast<LoDTensor *>(param->InputX());
auto input_x_ptr = input_x->data<float>();
auto *filter = const_cast<Tensor *>(param->InputY());
const Tensor *input_z = param->InputZ();
......
......@@ -56,7 +56,7 @@ struct DtypeTensorTrait<CPU> {
template <>
struct DtypeTensorTrait<FPGA> {
// This is the type we obtained in variable.
typedef framework::Tensor gtype;
typedef framework::LoDTensor gtype;
// This type will be the parent class type
// or the same type.
typedef framework::Tensor rtype;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册