Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
ff16962d
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ff16962d
编写于
7月 30, 2018
作者:
Z
zhangyang0701
提交者:
GitHub
7月 30, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #648 from chonwhite/develop
created fpga concat op:
#647
上级
7d140dca
c9286e93
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
83 addition
and
12 deletion
+83
-12
src/common/types.h
src/common/types.h
+7
-1
src/framework/program/program-optimize/fusion_op_register.h
src/framework/program/program-optimize/fusion_op_register.h
+3
-1
src/framework/tensor.h
src/framework/tensor.h
+5
-3
src/io/executor.cpp
src/io/executor.cpp
+2
-2
src/operators/concat_op.cpp
src/operators/concat_op.cpp
+4
-1
src/operators/concat_op.h
src/operators/concat_op.h
+1
-0
src/operators/kernel/fpga/concat_kernel.cpp
src/operators/kernel/fpga/concat_kernel.cpp
+55
-0
tools/android-cmake/android.toolchain.cmake
tools/android-cmake/android.toolchain.cmake
+2
-0
tools/build.sh
tools/build.sh
+4
-4
未找到文件。
src/common/types.h
浏览文件 @
ff16962d
...
@@ -20,7 +20,9 @@ limitations under the License. */
...
@@ -20,7 +20,9 @@ limitations under the License. */
#include <vector>
#include <vector>
namespace
paddle_mobile
{
namespace
paddle_mobile
{
enum
class
Precision
:
int
{
FP32
=
0
};
enum
class
Precision
:
int
{
FP32
=
0
,
FP16
=
1
};
typedef
int16_t
half
;
template
<
Precision
p
>
template
<
Precision
p
>
struct
PrecisionTrait
{
struct
PrecisionTrait
{
...
@@ -31,6 +33,10 @@ template <>
...
@@ -31,6 +33,10 @@ template <>
struct
PrecisionTrait
<
Precision
::
FP32
>
{
struct
PrecisionTrait
<
Precision
::
FP32
>
{
typedef
float
ptype
;
typedef
float
ptype
;
};
};
template
<
>
struct
PrecisionTrait
<
Precision
::
FP16
>
{
typedef
half
ptype
;
};
//! device type
//! device type
enum
DeviceTypeEnum
{
kINVALID
=
-
1
,
kCPU
=
0
,
kFPGA
=
1
,
kGPU_MALI
=
2
};
enum
DeviceTypeEnum
{
kINVALID
=
-
1
,
kCPU
=
0
,
kFPGA
=
1
,
kGPU_MALI
=
2
};
...
...
src/framework/program/program-optimize/fusion_op_register.h
浏览文件 @
ff16962d
...
@@ -14,11 +14,13 @@ limitations under the License. */
...
@@ -14,11 +14,13 @@ limitations under the License. */
#pragma once
#pragma once
#include <algorithm>
#include <map>
#include <map>
#include <string>
#include <string>
#include <vector>
#include "framework/operator.h"
#include "framework/operator.h"
#include "node.h"
#include "
framework/program/program-optimize/
node.h"
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
...
...
src/framework/tensor.h
浏览文件 @
ff16962d
...
@@ -16,14 +16,15 @@ limitations under the License. */
...
@@ -16,14 +16,15 @@ limitations under the License. */
#include <cstdint>
#include <cstdint>
#include <cstring>
#include <cstring>
#include <fstream>
#include <memory>
#include <memory>
#include <string>
#include <type_traits>
#include <type_traits>
#include <typeindex>
#include <typeindex>
#include <vector>
#include <vector>
#include "common/enforce.h"
#include <fstream>
#include "common/enforce.h"
#include "common/enforce.h"
#include "common/types.h"
#include "framework/data_layout.h"
#include "framework/data_layout.h"
#include "framework/ddim.h"
#include "framework/ddim.h"
#include "memory/t_malloc.h"
#include "memory/t_malloc.h"
...
@@ -63,7 +64,8 @@ struct SizeOfTypeFunctor<HEAD, TAIL...> {
...
@@ -63,7 +64,8 @@ struct SizeOfTypeFunctor<HEAD, TAIL...> {
};
};
static
inline
size_t
SizeOfType
(
std
::
type_index
type
)
{
static
inline
size_t
SizeOfType
(
std
::
type_index
type
)
{
SizeOfTypeFunctor
<
int
,
float
,
double
,
int16_t
,
int64_t
,
bool
,
size_t
>
functor
;
SizeOfTypeFunctor
<
int
,
half
,
float
,
double
,
int16_t
,
int64_t
,
bool
,
size_t
>
functor
;
size_t
size
=
functor
(
type
);
size_t
size
=
functor
(
type
);
PADDLE_MOBILE_ENFORCE
(
size
!=
0UL
,
"Cannot get size of type %s"
,
type
.
name
());
PADDLE_MOBILE_ENFORCE
(
size
!=
0UL
,
"Cannot get size of type %s"
,
type
.
name
());
...
...
src/io/executor.cpp
浏览文件 @
ff16962d
...
@@ -187,7 +187,7 @@ void Executor<Dtype, P>::LoadMemory(const framework::VarDesc var_desc,
...
@@ -187,7 +187,7 @@ void Executor<Dtype, P>::LoadMemory(const framework::VarDesc var_desc,
memcpy
(
&
max_value
,
*
data
+
sizeof
(
float
),
sizeof
(
float
));
memcpy
(
&
max_value
,
*
data
+
sizeof
(
float
),
sizeof
(
float
));
*
data
+=
2
*
sizeof
(
float
);
*
data
+=
2
*
sizeof
(
float
);
const
float
factor
=
(
max_value
-
min_value
)
/
255.0
;
const
float
factor
=
(
max_value
-
min_value
)
/
255.0
;
uint8_t
*
uint8_data
=
(
uint8_t
*
)
(
*
data
);
uint8_t
*
uint8_data
=
reinterpret_cast
<
uint8_t
*>
(
*
data
);
for
(
int
k
=
0
;
k
<
memory_size
;
++
k
)
{
for
(
int
k
=
0
;
k
<
memory_size
;
++
k
)
{
static_cast
<
float
*>
(
memory
)[
k
]
=
uint8_data
[
k
]
*
factor
+
min_value
;
static_cast
<
float
*>
(
memory
)[
k
]
=
uint8_data
[
k
]
*
factor
+
min_value
;
}
}
...
@@ -420,6 +420,6 @@ std::vector<typename Executor<Dtype, P>::Ptype> Executor<Dtype, P>::Predict(
...
@@ -420,6 +420,6 @@ std::vector<typename Executor<Dtype, P>::Ptype> Executor<Dtype, P>::Predict(
template
class
Executor
<
CPU
,
Precision
::
FP32
>;
template
class
Executor
<
CPU
,
Precision
::
FP32
>;
template
class
Executor
<
FPGA
,
Precision
::
FP32
>;
template
class
Executor
<
FPGA
,
Precision
::
FP32
>;
template
class
Executor
<
GPU_MALI
,
Precision
::
FP
32
>;
template
class
Executor
<
GPU_MALI
,
Precision
::
FP
16
>;
}
// namespace paddle_mobile
}
// namespace paddle_mobile
src/operators/concat_op.cpp
浏览文件 @
ff16962d
...
@@ -14,7 +14,9 @@ limitations under the License. */
...
@@ -14,7 +14,9 @@ limitations under the License. */
#ifdef CONCAT_OP
#ifdef CONCAT_OP
#include "concat_op.h"
#include <vector>
#include "operators/concat_op.h"
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
operators
{
namespace
operators
{
...
@@ -68,6 +70,7 @@ REGISTER_OPERATOR_CPU(concat, ops::ConcatOp);
...
@@ -68,6 +70,7 @@ REGISTER_OPERATOR_CPU(concat, ops::ConcatOp);
REGISTER_OPERATOR_MALI_GPU
(
concat
,
ops
::
ConcatOp
);
REGISTER_OPERATOR_MALI_GPU
(
concat
,
ops
::
ConcatOp
);
#endif
#endif
#ifdef PADDLE_MOBILE_FPGA
#ifdef PADDLE_MOBILE_FPGA
REGISTER_OPERATOR_FPGA
(
concat
,
ops
::
ConcatOp
);
#endif
#endif
#endif
#endif
src/operators/concat_op.h
浏览文件 @
ff16962d
...
@@ -53,6 +53,7 @@ USE_OP_CPU(concat);
...
@@ -53,6 +53,7 @@ USE_OP_CPU(concat);
USE_OP_MALI_GPU
(
concat
);
USE_OP_MALI_GPU
(
concat
);
#endif
#endif
#ifdef PADDLE_MOBILE_FPGA
#ifdef PADDLE_MOBILE_FPGA
USE_OP_FPGA
(
concat
);
#endif
#endif
#endif
#endif
src/operators/kernel/fpga/concat_kernel.cpp
0 → 100644
浏览文件 @
ff16962d
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
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. */
#ifdef CONCAT_OP
#include "operators/kernel/concat_kernel.h"
namespace
paddle_mobile
{
namespace
operators
{
template
<
>
bool
ConcatKernel
<
FPGA
,
half
>::
Init
(
ConcatParam
*
param
)
{
return
true
;
}
template
<
>
void
ConcatKernel
<
FPGA
,
half
>::
Compute
(
const
ConcatParam
&
param
)
const
{
auto
inputs
=
param
.
Inputs
();
auto
*
out
=
param
.
Out
();
int64_t
axis
=
param
.
Axis
();
out
->
mutable_data
<
half
>
();
DDim
out_dim
=
out
->
dims
();
int
pixels
=
out_dim
[
1
]
*
out_dim
[
2
];
auto
out_channel
=
out_dim
[
3
];
auto
out_offset
=
0
;
for
(
int
i
=
0
;
i
<
inputs
.
size
();
++
i
)
{
auto
input
=
inputs
[
i
];
auto
channels
=
input
[
3
];
out_offset
+=
channels
;
auto
src
=
input
->
data
<
half
>
();
for
(
int
j
=
0
;
j
<
pixels
;
++
j
)
{
auto
dst
=
out
->
data
<
half
>
()
+
out_offset
;
memory
::
Copy
(
dst
,
src
,
sizeof
(
half
));
}
}
}
}
// namespace operators
}
// namespace paddle_mobile
#endif
tools/android-cmake/android.toolchain.cmake
浏览文件 @
ff16962d
...
@@ -65,6 +65,8 @@ endif()
...
@@ -65,6 +65,8 @@ endif()
file
(
TO_CMAKE_PATH
"
${
ANDROID_NDK
}
"
ANDROID_NDK
)
file
(
TO_CMAKE_PATH
"
${
ANDROID_NDK
}
"
ANDROID_NDK
)
# Android NDK revision
# Android NDK revision
message
(
"
${
ANDROID_NDK
}
"
)
file
(
READ
"
${
ANDROID_NDK
}
/source.properties"
ANDROID_NDK_SOURCE_PROPERTIES
)
file
(
READ
"
${
ANDROID_NDK
}
/source.properties"
ANDROID_NDK_SOURCE_PROPERTIES
)
set
(
ANDROID_NDK_SOURCE_PROPERTIES_REGEX
set
(
ANDROID_NDK_SOURCE_PROPERTIES_REGEX
"^Pkg
\\
.Desc = Android NDK
\n
Pkg
\\
.Revision = ([0-9]+)
\\
."
)
"^Pkg
\\
.Desc = Android NDK
\n
Pkg
\\
.Revision = ([0-9]+)
\\
."
)
...
...
tools/build.sh
浏览文件 @
ff16962d
...
@@ -40,8 +40,8 @@ build_for_android() {
...
@@ -40,8 +40,8 @@ build_for_android() {
fi
fi
if
[
-z
"
$PLATFORM
"
]
;
then
if
[
-z
"
$PLATFORM
"
]
;
then
PLATFORM
=
"arm-v7a"
# Users could choose "arm-v8a" platform.
#
PLATFORM="arm-v7a" # Users could choose "arm-v8a" platform.
#
PLATFORM="arm-v8a"
PLATFORM
=
"arm-v8a"
fi
fi
if
[
"
${
PLATFORM
}
"
=
"arm-v7a"
]
;
then
if
[
"
${
PLATFORM
}
"
=
"arm-v7a"
]
;
then
...
@@ -63,7 +63,7 @@ build_for_android() {
...
@@ -63,7 +63,7 @@ build_for_android() {
TOOLCHAIN_FILE
=
"./tools/android-cmake/android.toolchain.cmake"
TOOLCHAIN_FILE
=
"./tools/android-cmake/android.toolchain.cmake"
ANDROID_ARM_MODE
=
"arm"
ANDROID_ARM_MODE
=
"arm"
if
[
"
${#
NETS
}
"
>
1
]
;
then
if
[
"
${#
NETS
}
"
-gt
1
]
;
then
cmake ..
\
cmake ..
\
-B
"../build/release/
${
PLATFORM
}
"
\
-B
"../build/release/
${
PLATFORM
}
"
\
-DANDROID_ABI
=
"
${
ABI
}
"
\
-DANDROID_ABI
=
"
${
ABI
}
"
\
...
@@ -99,7 +99,7 @@ build_for_ios() {
...
@@ -99,7 +99,7 @@ build_for_ios() {
BUILD_DIR
=
../build/release/
"
${
PLATFORM
}
"
/
BUILD_DIR
=
../build/release/
"
${
PLATFORM
}
"
/
TOOLCHAIN_FILE
=
"./tools/ios-cmake/ios.toolchain.cmake"
TOOLCHAIN_FILE
=
"./tools/ios-cmake/ios.toolchain.cmake"
mkdir
-p
"
${
BUILD_DIR
}
"
mkdir
-p
"
${
BUILD_DIR
}
"
if
[
"
${#
NETS
}
"
>
1
]
;
then
if
[
"
${#
NETS
}
"
-gt
1
]
;
then
cmake ..
\
cmake ..
\
-B
"
${
BUILD_DIR
}
"
\
-B
"
${
BUILD_DIR
}
"
\
-DCMAKE_BUILD_TYPE
=
"
${
MODE
}
"
\
-DCMAKE_BUILD_TYPE
=
"
${
MODE
}
"
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录