Commit 7aa8a94e authored by Paul's avatar Paul
Browse files

Fix tidy warnings

parent f1cf5cf0
add_executable(driver main.cpp verify.cpp perf.cpp)
rocm_clang_tidy_check(driver)
target_link_libraries(driver migraphx_cpu migraphx_onnx migraphx_tf)
if(MIGRAPHX_ENABLE_GPU)
target_link_libraries(driver migraphx_gpu)
......
......@@ -21,6 +21,13 @@ namespace migraphx {
namespace driver {
inline namespace MIGRAPHX_INLINE_NS {
#ifdef MIGRAPHX_USE_CLANG_TIDY
#define MIGRAPHX_DRIVER_STATIC
#else
#define MIGRAPHX_DRIVER_STATIC static
#endif
template <class T>
struct value_parser
{
......@@ -79,7 +86,7 @@ struct argument_parser
template <class... Fs>
void operator()(std::nullptr_t x, std::vector<std::string> flags, Fs... fs)
{
arguments.push_back({flags});
arguments.push_back({std::move(flags)});
argument& arg = arguments.back();
arg.type = "";
......@@ -87,13 +94,13 @@ struct argument_parser
migraphx::each_args([&](auto f) { f(x, arg); }, fs...);
}
static auto nargs(unsigned n = 1)
MIGRAPHX_DRIVER_STATIC auto nargs(unsigned n = 1)
{
return [=](auto&&, auto& arg) { arg.nargs = n; };
}
template <class F>
static auto write_action(F f)
MIGRAPHX_DRIVER_STATIC auto write_action(F f)
{
return [=](auto& x, auto& arg) {
arg.action = [&, f](auto& self, const std::vector<std::string>& params) {
......@@ -104,7 +111,7 @@ struct argument_parser
}
template <class F>
static auto do_action(F f)
MIGRAPHX_DRIVER_STATIC auto do_action(F f)
{
return [=](auto&, auto& arg) {
arg.nargs = 0;
......@@ -115,7 +122,7 @@ struct argument_parser
};
}
static auto append()
MIGRAPHX_DRIVER_STATIC auto append()
{
return write_action([](auto&, auto& x, auto& params) {
using type = typename decltype(params)::value_type;
......@@ -126,7 +133,7 @@ struct argument_parser
});
}
static auto show_help(std::string msg = "")
MIGRAPHX_DRIVER_STATIC auto show_help(const std::string& msg = "")
{
return do_action([=](auto& self) {
for(auto&& arg : self.arguments)
......@@ -155,18 +162,18 @@ struct argument_parser
});
}
static auto help(std::string help)
MIGRAPHX_DRIVER_STATIC auto help(std::string help)
{
return [=](auto&, auto& arg) { arg.help = help; };
}
static auto metavar(std::string metavar)
MIGRAPHX_DRIVER_STATIC auto metavar(std::string metavar)
{
return [=](auto&, auto& arg) { arg.metavar = metavar; };
}
template <class T>
static auto set_value(T value)
MIGRAPHX_DRIVER_STATIC auto set_value(T value)
{
return [=](auto& x, auto& arg) {
arg.nargs = 0;
......@@ -186,7 +193,7 @@ struct argument_parser
for(auto&& flag : arg.flags)
keywords[flag] = arg.nargs + 1;
}
auto arg_map = generic_parse(args, [&](std::string x) { return keywords[x]; });
auto arg_map = generic_parse(std::move(args), [&](std::string x) { return keywords[x]; });
for(auto&& arg : arguments)
{
auto flags = arg.flags;
......
......@@ -8,6 +8,7 @@
#include <migraphx/stringutils.hpp>
#include <unordered_map>
#include <utility>
#include <vector>
namespace migraphx {
......@@ -47,7 +48,7 @@ void run_command(std::vector<std::string> args, bool add_help = false)
if(add_help)
ap(nullptr, {"-h", "--help"}, ap.help("Show help"), ap.show_help());
x.parse(ap);
if(ap.parse(args))
if(ap.parse(std::move(args)))
return;
x.run();
}
......
......@@ -194,7 +194,7 @@ struct main_command
} // namespace driver
} // namespace migraphx
using namespace migraphx::driver;
using namespace migraphx::driver; // NOLINT
int main(int argc, const char* argv[])
{
std::vector<std::string> args(argv + 1, argv + argc);
......
......@@ -20,6 +20,8 @@ program::parameter_map create_param_map(const program& p, bool gpu)
if(gpu)
m[x.first] = gpu::to_gpu(generate_argument(x.second));
else
#else
(void)gpu;
#endif
m[x.first] = generate_argument(x.second);
}
......
......@@ -52,7 +52,7 @@ argument run_gpu(program p)
#endif
}
void verify_program(const std::string& name, program p, double tolerance)
void verify_program(const std::string& name, const program& p, double tolerance)
{
auto x = run_cpu(p);
auto y = run_gpu(p);
......@@ -106,7 +106,7 @@ void verify_reduced(program p, int n, double tolerance)
verify_program(std::to_string(n), p, tolerance);
}
void verify_reduced_program(program p, double tolerance)
void verify_reduced_program(const program& p, double tolerance)
{
auto n = std::distance(p.begin(), p.end());
for(std::size_t i = 0; i < n; i++)
......
......@@ -9,9 +9,9 @@ inline namespace MIGRAPHX_INLINE_NS {
argument run_cpu(program p);
argument run_gpu(program p);
void verify_program(const std::string& name, program p, double tolerance = 100);
void verify_program(const std::string& name, const program& p, double tolerance = 100);
void verify_instructions(const program& prog, double tolerance = 80);
void verify_reduced_program(program p, double tolerance = 80);
void verify_reduced_program(const program& p, double tolerance = 80);
} // namespace MIGRAPHX_INLINE_NS
} // namespace driver
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment