Commit 3272b22e authored by Shucai Xiao's avatar Shucai Xiao
Browse files

clang format

parent 94e3a2e4
...@@ -94,9 +94,7 @@ void set_nhwc(tf_options& options, bool is_nhwc) { options.is_nhwc = is_nhwc; } ...@@ -94,9 +94,7 @@ void set_nhwc(tf_options& options, bool is_nhwc) { options.is_nhwc = is_nhwc; }
void set_default_dim_value(tf_options& options, size_t value) { options.batch_size = value; } void set_default_dim_value(tf_options& options, size_t value) { options.batch_size = value; }
void set_input_parameter_shape(onnx_options& options, void set_input_parameter_shape(onnx_options& options, const char* name, std::vector<int> dims)
const char* name,
std::vector<int> dims)
{ {
options.map_input_dims[std::string(name)] = std::move(dims); options.map_input_dims[std::string(name)] = std::move(dims);
} }
...@@ -855,7 +853,8 @@ migraphx_operation_name(char* out, int out_size, migraphx_operation_t operation) ...@@ -855,7 +853,8 @@ migraphx_operation_name(char* out, int out_size, migraphx_operation_t operation)
if(operation == nullptr) if(operation == nullptr)
MIGRAPHX_THROW(migraphx_status_bad_param, "Bad parameter operation: Null pointer"); MIGRAPHX_THROW(migraphx_status_bad_param, "Bad parameter operation: Null pointer");
auto&& api_result = (operation->object).name(); auto&& api_result = (operation->object).name();
auto* it = std::copy_n(api_result.begin(), std::min(static_cast<int>(api_result.size()), out_size - 1), out); auto* it = std::copy_n(
api_result.begin(), std::min(static_cast<int>(api_result.size()), out_size - 1), out);
*it = '\0'; *it = '\0';
}); });
return api_error_result; return api_error_result;
......
...@@ -235,9 +235,7 @@ struct shape : MIGRAPHX_CONST_HANDLE_BASE(shape) ...@@ -235,9 +235,7 @@ struct shape : MIGRAPHX_CONST_HANDLE_BASE(shape)
this->make_handle(&migraphx_shape_create, type, plengths.data(), plengths.size()); this->make_handle(&migraphx_shape_create, type, plengths.data(), plengths.size());
} }
shape(migraphx_shape_datatype_t type, shape(migraphx_shape_datatype_t type, std::vector<int> plengths, std::vector<int> pstrides)
std::vector<int> plengths,
std::vector<int> pstrides)
{ {
this->make_handle(&migraphx_shape_create_with_strides, this->make_handle(&migraphx_shape_create_with_strides,
type, type,
...@@ -699,8 +697,7 @@ inline program parse_onnx(const char* filename) ...@@ -699,8 +697,7 @@ inline program parse_onnx(const char* filename)
} }
/// Parse a buffer of memory as an onnx file /// Parse a buffer of memory as an onnx file
inline program inline program parse_onnx_buffer(const void* data, int size, const migraphx::onnx_options& options)
parse_onnx_buffer(const void* data, int size, const migraphx::onnx_options& options)
{ {
return program( return program(
make<migraphx_program>(&migraphx_parse_onnx_buffer, data, size, options.get_handle_ptr()), make<migraphx_program>(&migraphx_parse_onnx_buffer, data, size, options.get_handle_ptr()),
......
...@@ -15,8 +15,7 @@ struct file_options ...@@ -15,8 +15,7 @@ struct file_options
program load(const std::string& filename, const file_options& options = file_options{}); program load(const std::string& filename, const file_options& options = file_options{});
program load_buffer(const std::vector<char>& buffer, const file_options& options = file_options{}); program load_buffer(const std::vector<char>& buffer, const file_options& options = file_options{});
program program load_buffer(const char* buffer, int size, const file_options& options = file_options{});
load_buffer(const char* buffer, int size, const file_options& options = file_options{});
void save(const program& p, void save(const program& p,
const std::string& filename, const std::string& filename,
......
...@@ -21,12 +21,9 @@ auto par_dfor(Ts... xs) ...@@ -21,12 +21,9 @@ auto par_dfor(Ts... xs)
{ {
array_type strides; array_type strides;
strides.fill(1); strides.fill(1);
std::partial_sum(lens.rbegin(), std::partial_sum(
lens.rend() - 1, lens.rbegin(), lens.rend() - 1, strides.rbegin() + 1, std::multiplies<int>());
strides.rbegin() + 1, auto size = std::accumulate(lens.begin(), lens.end(), 1, std::multiplies<int>());
std::multiplies<int>());
auto size =
std::accumulate(lens.begin(), lens.end(), 1, std::multiplies<int>());
par_for(size, min_grain, [&](int i) { par_for(size, min_grain, [&](int i) {
array_type indices; array_type indices;
std::transform(strides.begin(), std::transform(strides.begin(),
......
...@@ -67,8 +67,7 @@ struct program ...@@ -67,8 +67,7 @@ struct program
void finalize(); void finalize();
void void perf_report(std::ostream& os, int n, parameter_map params, int batch = 1) const;
perf_report(std::ostream& os, int n, parameter_map params, int batch = 1) const;
void mark(const parameter_map& params, marker&& m); void mark(const parameter_map& params, marker&& m);
......
...@@ -24,8 +24,7 @@ struct parse_gru : op_parser<parse_gru> ...@@ -24,8 +24,7 @@ struct parse_gru : op_parser<parse_gru>
if(contains(info.attributes, "hidden_size")) if(contains(info.attributes, "hidden_size"))
{ {
int hidden_size_att = int hidden_size_att = parser.parse_value(info.attributes.at("hidden_size")).at<int>();
parser.parse_value(info.attributes.at("hidden_size")).at<int>();
if(hidden_size != hidden_size_att) if(hidden_size != hidden_size_att)
{ {
MIGRAPHX_THROW("GRU: hidden size mismatch in input and attribute"); MIGRAPHX_THROW("GRU: hidden size mismatch in input and attribute");
......
...@@ -107,8 +107,7 @@ struct parse_lstm : op_parser<parse_lstm> ...@@ -107,8 +107,7 @@ struct parse_lstm : op_parser<parse_lstm>
if(contains(info.attributes, "hidden_size")) if(contains(info.attributes, "hidden_size"))
{ {
int hidden_size_att = int hidden_size_att = parser.parse_value(info.attributes.at("hidden_size")).at<int>();
parser.parse_value(info.attributes.at("hidden_size")).at<int>();
if(hidden_size != hidden_size_att) if(hidden_size != hidden_size_att)
{ {
MIGRAPHX_THROW("LSTM: hidden size mismatch in input and attribute"); MIGRAPHX_THROW("LSTM: hidden size mismatch in input and attribute");
......
...@@ -45,10 +45,7 @@ const auto& get_original_idx_op(const std::string& mode) ...@@ -45,10 +45,7 @@ const auto& get_original_idx_op(const std::string& mode)
{ {
using original_idx_op = std::function<double(int, int, int, double)>; using original_idx_op = std::function<double(int, int, int, double)>;
static std::unordered_map<std::string, original_idx_op> const idx_ops = { static std::unordered_map<std::string, original_idx_op> const idx_ops = {
{"half_pixel", {"half_pixel", [=](int, int, int idx, double scale) { return (idx + 0.5) / scale - 0.5; }},
[=](int, int, int idx, double scale) {
return (idx + 0.5) / scale - 0.5;
}},
{"pytorch_half_pixel", {"pytorch_half_pixel",
[=](int, int l_out, int idx, double scale) { [=](int, int l_out, int idx, double scale) {
return l_out > 1 ? (idx + 0.5) / scale - 0.5 : 0.0; return l_out > 1 ? (idx + 0.5) / scale - 0.5 : 0.0;
...@@ -57,11 +54,9 @@ const auto& get_original_idx_op(const std::string& mode) ...@@ -57,11 +54,9 @@ const auto& get_original_idx_op(const std::string& mode)
[=](int l_in, int l_out, int idx, double) { [=](int l_in, int l_out, int idx, double) {
return (l_out == 1) ? 0.0 : (1.0 * idx * (l_in - 1.0) / (l_out - 1.0)); return (l_out == 1) ? 0.0 : (1.0 * idx * (l_in - 1.0) / (l_out - 1.0));
}}, }},
{"asymmetric", {"asymmetric", [=](int, int, int idx, double scale) { return idx / scale; }},
[=](int, int, int idx, double scale) { return idx / scale; }}, {"tf_half_pixel_for_nn",
{"tf_half_pixel_for_nn", [=](int, int, int idx, double scale) { [=](int, int, int idx, double scale) { return (idx + 0.5) / scale; }}};
return (idx + 0.5) / scale;
}}};
if(!contains(idx_ops, mode)) if(!contains(idx_ops, mode))
{ {
...@@ -251,13 +246,12 @@ struct parse_resize : op_parser<parse_resize> ...@@ -251,13 +246,12 @@ struct parse_resize : op_parser<parse_resize>
": ranks of input and scale are different!"); ": ranks of input and scale are different!");
} }
std::transform(in_lens.begin(), std::transform(
in_lens.begin(),
in_lens.end(), in_lens.end(),
vec_scale.begin(), vec_scale.begin(),
out_lens.begin(), out_lens.begin(),
[&](auto idx, auto scale) { [&](auto idx, auto scale) { return static_cast<int>(idx * scale); });
return static_cast<int>(idx * scale);
});
} }
} }
} }
......
...@@ -24,8 +24,7 @@ struct parse_rnn : op_parser<parse_rnn> ...@@ -24,8 +24,7 @@ struct parse_rnn : op_parser<parse_rnn>
if(contains(info.attributes, "hidden_size")) if(contains(info.attributes, "hidden_size"))
{ {
int hidden_size_att = int hidden_size_att = parser.parse_value(info.attributes.at("hidden_size")).at<int>();
parser.parse_value(info.attributes.at("hidden_size")).at<int>();
if(hidden_size != hidden_size_att) if(hidden_size != hidden_size_att)
{ {
MIGRAPHX_THROW("RNN: hidden size mismatch in input and attribute"); MIGRAPHX_THROW("RNN: hidden size mismatch in input and attribute");
......
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