device_options.h 1.2 KB
Newer Older
1 2 3 4 5 6
#pragma once
#include <gflags/gflags.h>
#include "models/model.h"
#include "option_base.h"

DECLARE_bool(cpu);
7
#if LITE_WITH_CUDA
8 9 10 11 12 13 14 15 16 17 18 19
DECLARE_bool(cuda);
#endif
DECLARE_bool(cpu_default);
DECLARE_int32(multithread);
DECLARE_int32(multithread_default);
DECLARE_string(multi_thread_core_ids);
namespace lar {

class XPUDeviceOption final : public OptionBase {
public:
    static bool is_valid();
    static std::shared_ptr<OptionBase> create_option();
20
    void config_model(RuntimeParam&, std::shared_ptr<ModelBase>) override;
21 22
    std::string option_name() const override { return m_option_name; };

23 24 25 26
    static void set_valid(bool val) { m_valid = val; }

    OptionValMap* get_option() override { return &m_option; }

27 28 29 30 31
private:
    XPUDeviceOption();
    template <typename ModelImpl>
    void config_model_internel(RuntimeParam&, std::shared_ptr<ModelImpl>){};
    bool enable_cpu;
32
#if LITE_WITH_CUDA
33 34 35 36 37 38 39 40 41
    bool enable_cuda;
#endif
    bool enable_cpu_default;
    bool enable_multithread;
    bool enable_multithread_default;
    bool enable_set_core_ids;
    size_t thread_num;
    std::vector<int> core_ids;
    std::string m_option_name;
42 43 44

    static bool m_valid;
    OptionValMap m_option;
45
};
46
}  // namespace lar