Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paddle/operators/top_k_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TopkKernel : public framework::OpKernel<T> {
const size_t k = static_cast<int>(ctx.Attr<int>("k"));

T* output_data = output->mutable_data<T>(ctx.GetPlace());
T* indices_data = indices->mutable_data<T>(ctx.GetPlace());
int64_t* indices_data = indices->mutable_data<int64_t>(ctx.GetPlace());

auto eg_input = EigenMatrix<T>::From(*input);

Expand All @@ -66,7 +66,7 @@ class TopkKernel : public framework::OpKernel<T> {
});
for (size_t j = 0; j < k; j++) {
output_data[i * k + j] = vec[j].first;
indices_data[i * k + j] = vec[j].second;
indices_data[i * k + j] = int64_t(vec[j].second);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/v2/framework/tests/test_top_k_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def setUp(self):
k = 1
input = np.random.random((32, 84)).astype("float32")
output = np.ndarray((32, k))
indices = np.ndarray((32, k))
indices = np.ndarray((32, k)).astype("int64")

self.inputs = {'X': input}
self.attrs = {'k': k}
Expand All @@ -32,7 +32,7 @@ def setUp(self):
input = np.random.random((32, 2, 84)).astype("float32")
input_flat_2d = input.reshape(64, 84)
output = np.ndarray((64, k))
indices = np.ndarray((64, k)).astype("int")
indices = np.ndarray((64, k)).astype("int64")

# FIXME: should use 'X': input for a 3d input
self.inputs = {'X': input_flat_2d}
Expand Down