"test/old-api/spectests.cpp" did not exist on "a4b8521efe2d7e200ead2cc5539d3573732e2e3a"
Commit 67e84aed authored by Po-Yen, Chen's avatar Po-Yen, Chen
Browse files

Remove cmd arg parsing logics

parent 234c0580
......@@ -27,12 +27,6 @@ using F16 = ck::half_t;
using F32 = float;
using F64 = double;
struct ExecutionConfig final
{
bool do_verification = true;
bool time_kernel = true;
};
struct Problem final
{
static constexpr std::size_t NumDim = 3;
......@@ -273,65 +267,6 @@ is_valid_axes(const Axes& axes)
(*std::prev(last) == size(axes) - 1);
}
inline bool parse_cmd_args(int argc, char* argv[], ExecutionConfig& config, Problem& problem)
{
constexpr int num_execution_config_args = 2;
constexpr int num_problem_args = 2 * Problem::NumDim;
if(!(num_problem_args == size(problem.shape) + size(problem.axes)))
{
return false;
}
if(argc == 1)
{
// use default case
}
else if(argc == 1 + num_execution_config_args)
{
config.do_verification = std::stoi(argv[1]);
config.time_kernel = std::stoi(argv[2]);
}
else if(argc == 1 + num_execution_config_args + num_problem_args)
{
config.do_verification = std::stoi(argv[1]);
config.time_kernel = std::stoi(argv[2]);
// read shape
for(std::size_t idx = 0; idx < size(problem.shape); ++idx)
{
problem.shape[idx] = std::stoi(argv[idx + (1 + num_execution_config_args)]);
}
// read axes
for(std::size_t idx = 0; idx < size(problem.axes); ++idx)
{
problem.axes[idx] =
std::stoi(argv[idx + (1 + num_execution_config_args + size(problem.shape))]);
}
if(!is_valid_axes(problem.axes))
{
std::cerr << "invalid axes: ";
std::copy(begin(problem.axes),
end(problem.axes),
std::ostream_iterator<std::size_t>(std::cerr, " "));
std::cerr << std::endl;
return false;
}
}
else
{
std::cerr << "arg1: verification (0=no, 1=yes)" << std::endl
<< "arg2: time kernel (0=no, 1=yes)" << std::endl
<< "arg3 ~ arg5: shape for 3D tensor" << std::endl
<< "arg6 ~ arg8: axes to permute" << std::endl;
return false;
}
return true;
}
template <typename Shape>
inline std::enable_if_t<detail::is_range_v<Shape>, bool> is_valid_shape(const Shape& shape)
{
......
......@@ -17,7 +17,4 @@ using DevicePermuteInstance = ck::tensor_operation::device::DevicePermute
#include "run_permute_example.inc"
int main(int argc, char* argv[])
{
return !run_permute_example(argc, argv, {1, 16000, 80}, {0, 2, 1});
}
int main() { return !run_permute_example({1, 16000, 80}, {0, 2, 1}); }
......@@ -20,7 +20,4 @@ static_assert(std::is_same_v<detail::get_bundled_t<F64, NUM_ELEMS_IN_BUNDLE>, F1
#include "run_permute_example.inc"
int main(int argc, char* argv[])
{
return !run_permute_example(argc, argv, {1, 80, 16000}, {0, 2, 1});
}
int main() { return !run_permute_example({1, 80, 16000}, {0, 2, 1}); }
......@@ -17,7 +17,4 @@ using DevicePermuteInstance = ck::tensor_operation::device::DevicePermute
#include "run_permute_example.inc"
int main(int argc, char* argv[])
{
return !run_permute_example(argc, argv, {121, 768, 80}, {0, 2, 1});
}
int main() { return !run_permute_example({121, 768, 80}, {0, 2, 1}); }
......@@ -7,7 +7,7 @@
#define NUM_ELEMS_IN_BUNDLE 1
#endif
bool run_permute(const ExecutionConfig& config, const Problem& problem)
bool run_permute(const Problem& problem)
{
#if 1 < NUM_ELEMS_IN_BUNDLE
static_assert(std::is_same_v<ADataType, BDataType> &&
......@@ -61,12 +61,10 @@ bool run_permute(const ExecutionConfig& config, const Problem& problem)
};
auto invoker = permute.MakeInvoker();
float ave_time = invoker.Run(argument, StreamConfig{nullptr, config.time_kernel});
float ave_time = invoker.Run(argument, StreamConfig{nullptr, true});
std::cout << "Perf: " << ave_time << " ms" << std::endl;
if(config.do_verification)
{
b_device_buf.FromDevice(data(b.mData));
#if NUM_ELEMS_IN_BUNDLE == 1
......@@ -89,9 +87,8 @@ bool run_permute(const ExecutionConfig& config, const Problem& problem)
transpose_shape(extended_shape, extended_axes, begin(transposed_extended_shape));
Tensor<DataType> extended_a(extended_shape);
std::memcpy(data(extended_a.mData),
data(a.mData),
sizeof(ADataType) * a.mDesc.GetElementSpaceSize());
std::memcpy(
data(extended_a.mData), data(a.mData), sizeof(ADataType) * a.mDesc.GetElementSpaceSize());
Tensor<DataType> extended_host_b(transposed_extended_shape);
if(!host_permute(extended_a, extended_axes, PassThrough{}, extended_host_b))
......@@ -107,18 +104,9 @@ bool run_permute(const ExecutionConfig& config, const Problem& problem)
1e-6,
1e-6);
#endif
}
return true;
}
bool run_permute_example(int argc,
char* argv[],
const Problem::Shape& default_shape,
const Problem::Axes& default_axes)
bool run_permute_example(const Problem::Shape& default_shape, const Problem::Axes& default_axes)
{
ExecutionConfig config;
Problem problem(default_shape, default_axes);
return parse_cmd_args(argc, argv, config, problem) && run_permute(config, problem);
return run_permute(Problem{default_shape, default_axes});
}
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