Skip to content

Commit 77cf21e

Browse files
committed
Change input data type to int64_t
1 parent 3388e52 commit 77cf21e

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

paddle/operators/edit_distance_op.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class EditDistanceOpMaker : public framework::OpProtoAndCheckerMaker {
4949
EditDistanceOpMaker(OpProto *proto, OpAttrChecker *op_checker)
5050
: OpProtoAndCheckerMaker(proto, op_checker) {
5151
AddInput("Hyps",
52-
"(2-D LoDTensor<int>, 2nd dim. equal to 1) "
52+
"(2-D LoDTensor<int64_t>, 2nd dim. equal to 1) "
5353
"The indices for hypothesis strings.");
5454
AddInput("Refs",
55-
"(2-D LoDTensor<int>, 2nd dim. equal to 1) "
55+
"(2-D LoDTensor<int64_t>, 2nd dim. equal to 1) "
5656
"The indices for reference strings.");
5757
AddAttr<bool>("normalized",
5858
"(bool, default false) Indicated whether to normalize "
@@ -66,22 +66,22 @@ class EditDistanceOpMaker : public framework::OpProtoAndCheckerMaker {
6666
EditDistance operator computes the edit distances between a batch of hypothesis
6767
strings and their references.
6868
69-
Edit distance, also called Levenshtein distance, measures how dissimilar two strings
70-
are by counting the minimum number of operations to transform one string into anthor.
71-
Here the operations include insertion, deletion, and substitution. For example,
72-
given hypothesis string A = "kitten" and reference B = "sitting", the edit distance
73-
is 3 for A will be transformed into B at least after two substitutions and one
69+
Edit distance, also called Levenshtein distance, measures how dissimilar two strings
70+
are by counting the minimum number of operations to transform one string into anthor.
71+
Here the operations include insertion, deletion, and substitution. For example,
72+
given hypothesis string A = "kitten" and reference B = "sitting", the edit distance
73+
is 3 for A will be transformed into B at least after two substitutions and one
7474
insertion:
75-
75+
7676
"kitten" -> "sitten" -> "sittin" -> "sitting"
7777
78-
Input(Hyps) is a LoDTensor consisting of all the hypothesis strings with the total
79-
number denoted by `batch_size`, and the separation is specified by the LoD information.
80-
And the `batch_size` reference strings are arranged in order in the same way in the
78+
Input(Hyps) is a LoDTensor consisting of all the hypothesis strings with the total
79+
number denoted by `batch_size`, and the separation is specified by the LoD information.
80+
And the `batch_size` reference strings are arranged in order in the same way in the
8181
LoDTensor Input(Refs).
8282
83-
Output(Out) contains the `batch_size` results and each stands for the edit stance
84-
for a pair of strings respectively. If Attr(normalized) is true, the edit distance
83+
Output(Out) contains the `batch_size` results and each stands for the edit stance
84+
for a pair of strings respectively. If Attr(normalized) is true, the edit distance
8585
will be divided by the length of reference string.
8686
)DOC");
8787
}

paddle/operators/edit_distance_op.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class EditDistanceGPUKernel : public framework::OpKernel<T> {
113113
dist_t.Resize({m + 1, n + 1});
114114
dist_t.mutable_data<T>(ctx.GetPlace());
115115
auto dist = dist_t.data<T>();
116-
auto x1 = x1_t->data<int>() + hyp_lod[num];
117-
auto x2 = x2_t->data<int>() + ref_lod[num];
116+
auto x1 = x1_t->data<int64_t>() + hyp_lod[num];
117+
auto x2 = x2_t->data<int64_t>() + ref_lod[num];
118118

119119
FillFirstColumn<T><<<1 + m / PADDLE_CUDA_NUM_THREADS,
120120
PADDLE_CUDA_NUM_THREADS, 0, stream>>>(dist, m, n);

paddle/operators/edit_distance_op.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class EditDistanceKernel : public framework::OpKernel<T> {
6060
dist_t.Resize({m + 1, n + 1});
6161
dist_t.mutable_data<T>(ctx.GetPlace());
6262
auto dist = dist_t.data<T>();
63-
auto x1 = x1_t->data<int>() + hyp_lod[num];
64-
auto x2 = x2_t->data<int>() + ref_lod[num];
63+
auto x1 = x1_t->data<int64_t>() + hyp_lod[num];
64+
auto x2 = x2_t->data<int64_t>() + ref_lod[num];
6565
for (int64_t i = 0; i < m + 1; ++i) {
6666
dist[i * (n + 1)] = i;
6767
}

0 commit comments

Comments
 (0)