Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
a747df02
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
提交
a747df02
编写于
2月 18, 2019
作者:
H
hjchen2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix gru_unit bug
上级
b6993ba3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
8 deletion
+31
-8
src/framework/tensor_util.h
src/framework/tensor_util.h
+15
-2
src/operators/kernel/arm/beam_search_decode_kernel.cpp
src/operators/kernel/arm/beam_search_decode_kernel.cpp
+2
-2
src/operators/kernel/central-arm-func/gru_unit_arm_func.h
src/operators/kernel/central-arm-func/gru_unit_arm_func.h
+11
-2
test/test_helper.h
test/test_helper.h
+3
-2
未找到文件。
src/framework/tensor_util.h
浏览文件 @
a747df02
...
...
@@ -14,13 +14,26 @@ limitations under the License. */
#pragma once
#include <vector>
#include "framework/tensor.h"
#include "memory/t_malloc.h"
#include "tensor.h"
namespace
paddle_mobile
{
namespace
framework
{
void
TensorCopy
(
const
Tensor
&
src
,
Tensor
*
dst
);
void
TensorCopy
(
const
Tensor
&
src
,
Tensor
*
dst
);
template
<
typename
T
>
void
TensorFromVector
(
const
std
::
vector
<
T
>&
src
,
Tensor
*
dst
);
template
<
typename
T
>
void
TensorFromVector
(
const
std
::
vector
<
T
>&
src
,
Tensor
*
dst
)
{
auto
src_ptr
=
static_cast
<
const
void
*>
(
src
.
data
());
dst
->
Resize
({
static_cast
<
int64_t
>
(
src
.
size
())});
auto
dst_ptr
=
static_cast
<
void
*>
(
dst
->
mutable_data
<
T
>
());
auto
size
=
src
.
size
()
*
sizeof
(
T
);
memory
::
Copy
(
dst_ptr
,
src_ptr
,
size
);
}
}
// namespace framework
}
// namespace paddle_mobile
src/operators/kernel/arm/beam_search_decode_kernel.cpp
浏览文件 @
a747df02
...
...
@@ -124,12 +124,12 @@ void BeamSearchDecoder<T>::ConvertSentenceVectorToLodTensor(
id_tensor
->
set_lod
(
lod
);
id_tensor
->
Resize
({
static_cast
<
int64_t
>
(
id_data
.
size
())});
id_tensor
->
mutable_data
<
int64_t
>
();
// framework::TensorFromVector<int64_t>(id_data, cpu_ctx
, id_tensor);
framework
::
TensorFromVector
<
int64_t
>
(
id_data
,
id_tensor
);
score_tensor
->
set_lod
(
lod
);
score_tensor
->
Resize
({
static_cast
<
int64_t
>
(
score_data
.
size
())});
score_tensor
->
mutable_data
<
T
>
();
// framework::TensorFromVector<T>(score_data, cpu_ctx
, score_tensor);
framework
::
TensorFromVector
<
T
>
(
score_data
,
score_tensor
);
}
template
<
typename
T
>
...
...
src/operators/kernel/central-arm-func/gru_unit_arm_func.h
浏览文件 @
a747df02
...
...
@@ -27,30 +27,39 @@ namespace operators {
template
<
typename
P
>
void
GruUnitCompute
(
const
GruUnitParam
<
CPU
>&
param
)
{
// inputs
auto
*
input
=
param
.
InputInput
();
auto
*
hidden_prev
=
param
.
InputHiddenPrev
();
auto
*
weight
=
param
.
InputWeight
();
auto
*
bias
=
param
.
InputBias
();
// outputs
auto
*
gate
=
param
.
OutGate
();
gate
->
mutable_data
<
P
>
();
auto
*
reset_hidden_prev
=
param
.
OutResetHiddenPrev
();
reset_hidden_prev
->
mutable_data
<
P
>
();
auto
*
hidden
=
param
.
OutHidden
();
hidden
->
mutable_data
<
P
>
();
// add bias
if
(
bias
)
{
math
::
RowwiseAdd
<
CPU
,
float
>
add_bias
;
add_bias
(
*
gate
,
*
bias
,
gate
);
add_bias
(
*
input
,
*
bias
,
gate
);
}
int
batch_size
=
input
->
dims
()[
0
];
int
frame_size
=
hidden_prev
->
dims
()[
1
];
const
P
*
weight_data
=
weight
->
data
<
P
>
();
math
::
GRUMetaValue
<
P
>
gru_value
;
gru_value
.
gate_weight
=
const_cast
<
P
*>
(
weight_data
);
gru_value
.
state_weight
=
const_cast
<
P
*>
(
weight_data
+
2
*
frame_size
*
frame_size
);
gru_value
.
output_value
=
hidden
->
data
<
P
>
();
gru_value
.
prev_out_value
=
const_cast
<
P
*>
(
hidden_prev
->
data
<
P
>
());
gru_value
.
output_value
=
hidden
->
data
<
P
>
();
gru_value
.
gate_value
=
gate
->
data
<
P
>
();
gru_value
.
reset_output_value
=
reset_hidden_prev
->
data
<
P
>
();
auto
active_node
=
math
::
GetActivationType
(
param
.
Activation
());
auto
active_gate
=
math
::
GetActivationType
(
param
.
GateActivation
());
math
::
GRUUnitFunctor
<
CPU
,
float
>::
compute
(
gru_value
,
frame_size
,
batch_size
,
...
...
test/test_helper.h
浏览文件 @
a747df02
...
...
@@ -22,7 +22,7 @@ limitations under the License. */
#include "common/common.h"
#include "common/log.h"
#include "framework/ddim.h"
#include "framework/tensor.h"
#include "framework/
lod_
tensor.h"
static
const
char
*
g_ocr
=
"../models/ocr"
;
static
const
char
*
g_mobilenet_ssd
=
"../models/mobilenet+ssd"
;
...
...
@@ -66,9 +66,10 @@ static const char *g_yolo_img = "../images/in_put_1_3_416_416_2";
static
const
char
*
g_super_img
=
"../images/mingren_input_data"
;
static
const
char
*
g_mobilenet_img
=
"../images/image"
;
using
namespace
paddle_mobile
;
using
paddle_mobile
::
framework
::
DDim
;
using
paddle_mobile
::
framework
::
LoDTensor
;
using
paddle_mobile
::
framework
::
Tensor
;
using
namespace
paddle_mobile
;
template
<
typename
T
>
void
SetupTensor
(
paddle_mobile
::
framework
::
Tensor
*
input
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录