test_gather_op.py 570 字节
Newer Older
Z
zchen0211 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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"
Z
zchen0211 已提交
15
        xnp = numpy.random.random((10, 20)).astype("float32")
Z
zchen0211 已提交
16
        self.inputs = {
Z
zchen0211 已提交
17 18
            'X': xnp,
            'Index': numpy.array([1, 3, 5]).astype("int32")
Z
zchen0211 已提交
19
        }
Z
zchen0211 已提交
20
        self.outputs = {'Y': self.inputs['X'][self.inputs['Index']]}
Z
zchen0211 已提交
21 22 23 24


if __name__ == "__main__":
    unittest.main()