Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
59d6e33f
提交
59d6e33f
authored
5月 24, 2017
作者:
João Victor Tozatti Risso
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace int variables with npy_int ones
Signed-off-by:
João Victor Tozatti Risso
<
joaovictor.risso@gmail.com
>
上级
df6afa22
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
19 行增加
和
20 行删除
+19
-20
ctc_wrapper.c
theano/tensor/nnet/ctc_wrapper.c
+19
-20
没有找到文件。
theano/tensor/nnet/ctc_wrapper.c
浏览文件 @
59d6e33f
...
...
@@ -3,9 +3,9 @@
typedef
struct
ctc_context
{
struct
ctcOptions
options
;
void
*
workspace
;
int
*
input_lengths
;
int
*
flat_labels
;
int
*
label_lengths
;
npy_
int
*
input_lengths
;
npy_
int
*
flat_labels
;
npy_
int
*
label_lengths
;
}
ctc_context_t
;
void
ctc_context_init
(
ctc_context_t
*
context
)
...
...
@@ -53,32 +53,32 @@ int ctc_check_result(ctcStatus_t retcode, const char * msg)
}
void
create_contiguous_input_lengths
(
PyArrayObject
*
input_lengths_arr
,
int
**
input_lengths
)
npy_
int
**
input_lengths
)
{
int
num_elements
=
PyArray_DIMS
(
input_lengths_arr
)[
0
];
npy_
int
num_elements
=
PyArray_DIMS
(
input_lengths_arr
)[
0
];
*
input_lengths
=
(
int
*
)
malloc
(
num_elements
*
sizeof
(
int
)
);
*
input_lengths
=
(
npy_int
*
)
malloc
(
num_elements
*
sizeof
(
npy_
int
)
);
if
(
NULL
==
(
*
input_lengths
)
)
return
;
for
(
int
elem_idx
=
0
;
elem_idx
<
num_elements
;
++
elem_idx
)
for
(
npy_
int
elem_idx
=
0
;
elem_idx
<
num_elements
;
++
elem_idx
)
{
(
*
input_lengths
)[
elem_idx
]
=
*
(
(
int
*
)
PyArray_GETPTR1
(
input_lengths_arr
,
elem_idx
)
);
(
*
input_lengths
)[
elem_idx
]
=
*
(
(
npy_
int
*
)
PyArray_GETPTR1
(
input_lengths_arr
,
elem_idx
)
);
}
}
void
create_flat_labels
(
PyArrayObject
*
label_matrix
,
int
**
flat_labels
,
int
**
label_lengths
)
void
create_flat_labels
(
PyArrayObject
*
label_matrix
,
npy_
int
**
flat_labels
,
npy_
int
**
label_lengths
)
{
int
rows
=
PyArray_DIMS
(
label_matrix
)[
0
];
int
cols
=
PyArray_DIMS
(
label_matrix
)[
1
];
npy_
int
rows
=
PyArray_DIMS
(
label_matrix
)[
0
];
npy_
int
cols
=
PyArray_DIMS
(
label_matrix
)[
1
];
*
flat_labels
=
(
int
*
)
malloc
(
rows
*
cols
*
sizeof
(
int
)
);
*
flat_labels
=
(
npy_int
*
)
malloc
(
rows
*
cols
*
sizeof
(
npy_
int
)
);
if
(
NULL
==
(
*
flat_labels
)
)
return
;
*
label_lengths
=
(
int
*
)
malloc
(
rows
*
sizeof
(
int
)
);
*
label_lengths
=
(
npy_int
*
)
malloc
(
rows
*
sizeof
(
npy_
int
)
);
if
(
NULL
==
(
*
label_lengths
)
)
{
free
(
*
flat_labels
);
...
...
@@ -86,13 +86,13 @@ void create_flat_labels( PyArrayObject * label_matrix, int ** flat_labels,
return
;
}
int
label_index
=
0
;
for
(
int
row_idx
=
0
;
row_idx
<
rows
;
++
row_idx
)
npy_
int
label_index
=
0
;
for
(
npy_
int
row_idx
=
0
;
row_idx
<
rows
;
++
row_idx
)
{
int
label_length
=
0
;
for
(
int
col_idx
=
0
;
col_idx
<
cols
;
++
col_idx
)
npy_
int
label_length
=
0
;
for
(
npy_
int
col_idx
=
0
;
col_idx
<
cols
;
++
col_idx
)
{
int
label
=
*
(
(
int
*
)
PyArray_GETPTR2
(
label_matrix
,
row_idx
,
col_idx
)
);
npy_int
label
=
*
(
(
npy_
int
*
)
PyArray_GETPTR2
(
label_matrix
,
row_idx
,
col_idx
)
);
if
(
label
>=
0
)
// negative values are assumed to be padding
{
(
*
flat_labels
)[
label_index
++
]
=
label
;
...
...
@@ -262,4 +262,3 @@ int APPLY_SPECIFIC(ctc_cost_cpu_no_grad)(PyArrayObject * in_activations,
out_costs
,
NULL
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论