Exemplo n.º 1
0
 def test_dygraph(self):
     for place in self.places:
         with fluid.dygraph.guard(place):
             input_x = np.random.randint(20, size=100).astype("float64")
             x = paddle.to_tensor(input_x)
             result, inverse, counts = paddle.unique_consecutive(
                 x, return_inverse=True, return_counts=True)
    def build_program(self):
        main_program = paddle.static.Program()
        with paddle.static.program_guard(main_program):
            x = paddle.static.data(name='x', shape=[4, 1], dtype='float32')
            output = paddle.unique_consecutive(x,
                                               return_inverse=True,
                                               return_counts=True,
                                               axis=0)

        self.main_program = main_program
        self.fetch_list = output
Exemplo n.º 3
0
 def check_static_result(self, place):
     with fluid.program_guard(fluid.Program(), fluid.Program()):
         paddle.enable_static()
         input_x = fluid.data(name="input_x",
                              shape=[
                                  100,
                              ],
                              dtype="float32")
         result = paddle.unique_consecutive(input_x)
         x_np = np.random.randint(20, size=100).astype("float32")
         exe = fluid.Executor(place)
         fetches = exe.run(fluid.default_main_program(),
                           feed={"input_x": x_np},
                           fetch_list=[result])