Esempio n. 1
0
    def run(self, config, args, use_feed_fetch=True, feeder_adapter=None):
        self.name = config.api_name
        feeder_adapter = self.generate_random_feeder(config, use_feed_fetch,
                                                     feeder_adapter)
        if self._backward != args.backward:
            print(
                "Backward is not surported for %s in Tensorflow. It is actually running the forward test."
                % self.name)
            assert not special_op_list.has_backward(
                config
            ), "If backward is not surported for %s, please add the Paddle's \'%s\' to NO_BACKWARD_OPS in api/common/special_op_list.py." % (
                self.name, self.name)

        feed_list = feeder_adapter.to_tensorflow(self.feed_list)
        assert len(feed_list) == len(self.feed_list)
        feed = {}
        for i in range(len(feed_list)):
            feed[self.feed_list[i]] = feed_list[i]

        fetch_list = []
        for item in self.fetch_list:
            if isinstance(item, list):
                for var in item:
                    fetch_list.append(var)
            else:
                fetch_list.append(item)
        self.fetch_list = fetch_list

        self.allow_growth = False if args.task == "speed" else True
        outputs, stats = self.run_impl(use_gpu=args.use_gpu,
                                       feed=feed,
                                       repeat=args.repeat,
                                       check_output=args.check_output,
                                       profiler=args.profiler)
        return outputs, stats
Esempio n. 2
0
    def run(self, config, args, use_feed_fetch=True, feeder_adapter=None):
        self.name = config.api_name
        feeder_adapter = self.generate_random_feeder(config, use_feed_fetch,
                                                     feeder_adapter)
        if self.__backward != args.backward:
            print(
                "Backward is not surported for %s in Paddle. It is actually running the forward test."
                % self.name)
            assert not special_op_list.has_backward(
                config
            ), "If backward is not surported for %s, please add the \'%s\' to NO_BACKWARD_OPS in api/common/special_op_list.py." % (
                self.name, self.name)

        feed_list = feeder_adapter.to_paddle(self.feed_vars)
        assert len(feed_list) == len(self.feed_vars)
        feed = {}
        for i in range(len(feed_list)):
            feed[self.feed_vars[i].name] = feed_list[i]

        self.scope = fluid.Scope()
        with fluid.scope_guard(self.scope):
            outputs, stats = self.run_impl(use_gpu=args.use_gpu,
                                           feed=feed,
                                           repeat=args.repeat,
                                           check_output=args.check_output,
                                           profiler=args.profiler)
        return outputs, stats
    def _run_static(self,
                    config,
                    args,
                    use_feed_fetch=True,
                    feeder_adapter=None):
        assert self._testing_mode == "static", "Function \"_run_static\" can only be called when self._testing_mode is static, but recieved {}.".format(
            self._testing_mode)

        self.name = config.api_name
        feeder_adapter = self.generate_random_feeder(config, use_feed_fetch,
                                                     feeder_adapter)
        if self._backward != args.backward:
            print(
                "Backward is not surported for %s in Paddle. It is actually running the forward test."
                % self.name)
            assert not special_op_list.has_backward(
                config
            ), "If backward is not surported for %s, please add the \'%s\' to NO_BACKWARD_OPS in api/common/special_op_list.py." % (
                self.name, self.name)

        feed_list = feeder_adapter.to_paddle(self.feed_list)
        assert len(feed_list) == len(self.feed_list)
        feed = {}
        for i in range(len(feed_list)):
            feed[self.feed_list[i].name] = feed_list[i]

        self.scope = paddle.static.Scope()
        with paddle.static.scope_guard(self.scope):
            outputs, stats = self._run_static_impl(use_gpu=args.use_gpu,
                                                   config=config,
                                                   feed=feed,
                                                   repeat=args.repeat,
                                                   profiler=args.profiler)
        return outputs, stats
Esempio n. 4
0
def _check_disabled(config, args):
    if config.disabled():
        status = collections.OrderedDict()
        status["name"] = config.api_name
        status["device"] = "GPU" if args.use_gpu else "CPU"
        status["backward"] = args.backward if special_op_list.has_backward(
            config) else False
        status["disabled"] = True
        status["parameters"] = config.to_string()
        print(json.dumps(status))
        return True
    return False