parent
f6bffd4e1f
commit
323d4233f3
@ -0,0 +1,20 @@
|
|||||||
|
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
|
||||||
|
|
||||||
|
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. */
|
||||||
|
|
||||||
|
#define EIGEN_USE_GPU
|
||||||
|
#include "paddle/operators/gather_op.h"
|
||||||
|
|
||||||
|
namespace ops = paddle::operators;
|
||||||
|
REGISTER_OP_GPU_KERNEL(gather,
|
||||||
|
ops::GatherOpKernel<paddle::platform::GPUPlace, float>);
|
@ -0,0 +1,23 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
import numpy
|
||||||
|
import paddle.v2.framework.core as core
|
||||||
|
from paddle.v2.framework.op import Operator
|
||||||
|
|
||||||
|
from op_test_util import OpTestMeta
|
||||||
|
|
||||||
|
|
||||||
|
class TestGatherOp(unittest.TestCase):
|
||||||
|
__metaclass__ = OpTestMeta
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.type = "gather"
|
||||||
|
self.inputs = {
|
||||||
|
'X': numpy.random.random((10, 20)).astype("float32"),
|
||||||
|
'Index': numpy.array([1, 3, 5]).astype("int")
|
||||||
|
}
|
||||||
|
self.outputs = {'Y': self.input['X'][self.input['Index']]}
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
Loading…
Reference in new issue