Unverified Commit d37a4df9 authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Enable cppcheck rule for 'not', 'or' keywords (#1361)

Using not and or improves readability. The cppcheck rule will help ensure we are doing it consistently.
parent 794a4335
...@@ -266,7 +266,7 @@ struct nonmaxsuppression ...@@ -266,7 +266,7 @@ struct nonmaxsuppression
auto boxes_heap = filter_boxes_by_score(scores_start, num_boxes, score_threshold); auto boxes_heap = filter_boxes_by_score(scores_start, num_boxes, score_threshold);
selected_boxes_inside_class.clear(); selected_boxes_inside_class.clear();
// Get the next box with top score, filter by iou_threshold // Get the next box with top score, filter by iou_threshold
while(!boxes_heap.empty() && while(not boxes_heap.empty() &&
selected_boxes_inside_class.size() < max_output_boxes_per_class) selected_boxes_inside_class.size() < max_output_boxes_per_class)
{ {
// Check with existing selected boxes for this class, remove box if it // Check with existing selected boxes for this class, remove box if it
......
...@@ -49,13 +49,14 @@ struct quant_dot ...@@ -49,13 +49,14 @@ struct quant_dot
MIGRAPHX_THROW("QUANT_DOT: only support data type int8_t"); MIGRAPHX_THROW("QUANT_DOT: only support data type int8_t");
} }
if(!std::all_of(inputs.begin(), inputs.end(), [](auto s) { return s.lens().size() >= 2; })) if(not std::all_of(
inputs.begin(), inputs.end(), [](auto s) { return s.lens().size() >= 2; }))
{ {
MIGRAPHX_THROW("QUANT_DOT: dot only accept 2 or more dims operands"); MIGRAPHX_THROW("QUANT_DOT: dot only accept 2 or more dims operands");
} }
// only handle the case that the batch size of a and b are the same // only handle the case that the batch size of a and b are the same
if(!std::equal( if(not std::equal(
a.lens().rbegin() + 2, a.lens().rend(), b.lens().rbegin() + 2, b.lens().rend())) a.lens().rbegin() + 2, a.lens().rend(), b.lens().rbegin() + 2, b.lens().rend()))
{ {
MIGRAPHX_THROW("QUANT_DOT: batch size of A and B mismatch: {" + MIGRAPHX_THROW("QUANT_DOT: batch size of A and B mismatch: {" +
......
...@@ -78,7 +78,7 @@ struct slice ...@@ -78,7 +78,7 @@ struct slice
const std::vector<std::size_t>& lens = s.lens(); const std::vector<std::size_t>& lens = s.lens();
const std::vector<std::size_t>& strides = s.strides(); const std::vector<std::size_t>& strides = s.strides();
auto offset = 0; auto offset = 0;
if(!axes.empty()) if(not axes.empty())
{ {
for(std::size_t i = 0; i < axes.size(); i++) for(std::size_t i = 0; i < axes.size(); i++)
{ {
...@@ -109,7 +109,7 @@ struct slice ...@@ -109,7 +109,7 @@ struct slice
MIGRAPHX_THROW("SLICE: input axis " + to_string_range(axes) + " out of range"); MIGRAPHX_THROW("SLICE: input axis " + to_string_range(axes) + " out of range");
} }
if(starts.size() != axes.size() || axes.size() != ends.size()) if(starts.size() != axes.size() or axes.size() != ends.size())
{ {
MIGRAPHX_THROW("SLICE: inconsistent sizes"); MIGRAPHX_THROW("SLICE: inconsistent sizes");
} }
......
...@@ -59,7 +59,7 @@ struct transpose ...@@ -59,7 +59,7 @@ struct transpose
} }
std::vector<int64_t> axes(dims.size()); std::vector<int64_t> axes(dims.size());
std::iota(axes.begin(), axes.end(), 0); std::iota(axes.begin(), axes.end(), 0);
if(!std::is_permutation(axes.begin(), axes.end(), dims.begin())) if(not std::is_permutation(axes.begin(), axes.end(), dims.begin()))
{ {
MIGRAPHX_THROW("TRANSPOSE: Invalid permutation"); MIGRAPHX_THROW("TRANSPOSE: Invalid permutation");
} }
......
...@@ -1066,7 +1066,7 @@ struct operation ...@@ -1066,7 +1066,7 @@ struct operation
template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT> template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT>
private_detail_te_handle_type( private_detail_te_handle_type(
PrivateDetailTypeErasedT value, PrivateDetailTypeErasedT value,
typename std::enable_if<!std::is_reference<PrivateDetailTypeErasedU>::value, typename std::enable_if<not std::is_reference<PrivateDetailTypeErasedU>::value,
int>::type* = nullptr) noexcept int>::type* = nullptr) noexcept
: private_detail_te_value(std::move(value)) : private_detail_te_value(std::move(value))
{ {
...@@ -1237,7 +1237,7 @@ struct operation ...@@ -1237,7 +1237,7 @@ struct operation
private_detail_te_handle_base_type& private_detail_te_get_handle() private_detail_te_handle_base_type& private_detail_te_get_handle()
{ {
assert(private_detail_te_handle_mem_var != nullptr); assert(private_detail_te_handle_mem_var != nullptr);
if(!private_detail_te_handle_mem_var.unique()) if(not private_detail_te_handle_mem_var.unique())
private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone(); private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone();
return *private_detail_te_handle_mem_var; return *private_detail_te_handle_mem_var;
} }
...@@ -1276,7 +1276,7 @@ inline const ValueType& any_cast(const operation& x) ...@@ -1276,7 +1276,7 @@ inline const ValueType& any_cast(const operation& x)
} }
#endif #endif
inline bool operator!=(const operation& x, const operation& y) { return !(x == y); } inline bool operator!=(const operation& x, const operation& y) { return not(x == y); }
inline value inline value
compile(operation& op, context& ctx, const shape& output_shape, const std::vector<shape>& input) compile(operation& op, context& ctx, const shape& output_shape, const std::vector<shape>& input)
......
...@@ -238,7 +238,7 @@ struct pass ...@@ -238,7 +238,7 @@ struct pass
template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT> template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT>
private_detail_te_handle_type( private_detail_te_handle_type(
PrivateDetailTypeErasedT value, PrivateDetailTypeErasedT value,
typename std::enable_if<!std::is_reference<PrivateDetailTypeErasedU>::value, typename std::enable_if<not std::is_reference<PrivateDetailTypeErasedU>::value,
int>::type* = nullptr) noexcept int>::type* = nullptr) noexcept
: private_detail_te_value(std::move(value)) : private_detail_te_value(std::move(value))
{ {
...@@ -292,7 +292,7 @@ struct pass ...@@ -292,7 +292,7 @@ struct pass
private_detail_te_handle_base_type& private_detail_te_get_handle() private_detail_te_handle_base_type& private_detail_te_get_handle()
{ {
assert(private_detail_te_handle_mem_var != nullptr); assert(private_detail_te_handle_mem_var != nullptr);
if(!private_detail_te_handle_mem_var.unique()) if(not private_detail_te_handle_mem_var.unique())
private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone(); private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone();
return *private_detail_te_handle_mem_var; return *private_detail_te_handle_mem_var;
} }
......
...@@ -124,7 +124,7 @@ struct program ...@@ -124,7 +124,7 @@ struct program
friend std::ostream& operator<<(std::ostream& os, const program& p); friend std::ostream& operator<<(std::ostream& os, const program& p);
friend bool operator==(const program& x, const program& y); friend bool operator==(const program& x, const program& y);
friend bool operator!=(const program& x, const program& y) { return !(x == y); } friend bool operator!=(const program& x, const program& y) { return not(x == y); }
// module related api // module related api
module* create_module(const std::string& name); module* create_module(const std::string& name);
......
...@@ -147,7 +147,7 @@ struct raw_data : raw_data_base ...@@ -147,7 +147,7 @@ struct raw_data : raw_data_base
template <class T> template <class T>
bool matches() const bool matches() const
{ {
return is_data_ptr<T>{} || return is_data_ptr<T>{} or
self->get_shape().type() == migraphx::shape::get_type<get_data_type<T>>{}; self->get_shape().type() == migraphx::shape::get_type<get_data_type<T>>{};
} }
...@@ -232,7 +232,7 @@ auto visit_all(T&& x, Ts&&... xs) ...@@ -232,7 +232,7 @@ auto visit_all(T&& x, Ts&&... xs)
{ {
auto&& s = x.get_shape(); auto&& s = x.get_shape();
std::initializer_list<shape::type_t> types = {xs.get_shape().type()...}; std::initializer_list<shape::type_t> types = {xs.get_shape().type()...};
if(!std::all_of(types.begin(), types.end(), [&](shape::type_t t) { return t == s.type(); })) if(not std::all_of(types.begin(), types.end(), [&](shape::type_t t) { return t == s.type(); }))
MIGRAPHX_THROW("Types must be the same"); MIGRAPHX_THROW("Types must be the same");
return [&](auto... vs) { detail::visit_all_pack(s, vs...)(x, xs...); }; return [&](auto... vs) { detail::visit_all_pack(s, vs...)(x, xs...); };
} }
...@@ -241,7 +241,7 @@ template <class T> ...@@ -241,7 +241,7 @@ template <class T>
auto visit_all(const std::vector<T>& x) auto visit_all(const std::vector<T>& x)
{ {
auto&& s = x.front().get_shape(); auto&& s = x.front().get_shape();
if(!std::all_of( if(not std::all_of(
x.begin(), x.end(), [&](const T& y) { return y.get_shape().type() == s.type(); })) x.begin(), x.end(), [&](const T& y) { return y.get_shape().type() == s.type(); }))
MIGRAPHX_THROW("Types must be the same"); MIGRAPHX_THROW("Types must be the same");
return [&](auto v) { return [&](auto v) {
...@@ -281,7 +281,7 @@ template <class T, ...@@ -281,7 +281,7 @@ template <class T,
std::is_base_of<raw_data_base, U>{})> std::is_base_of<raw_data_base, U>{})>
bool operator!=(const T& x, const U& y) bool operator!=(const T& x, const U& y)
{ {
return !(x == y); return not(x == y);
} }
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
......
...@@ -129,7 +129,7 @@ template <class T> ...@@ -129,7 +129,7 @@ template <class T>
struct reflect_equality struct reflect_equality
{ {
friend bool operator==(const T& x, const T& y) { return reflect_tie(x) == reflect_tie(y); } friend bool operator==(const T& x, const T& y) { return reflect_tie(x) == reflect_tie(y); }
friend bool operator!=(const T& x, const T& y) { return !(x == y); } friend bool operator!=(const T& x, const T& y) { return not(x == y); }
}; };
template <class T> template <class T>
......
...@@ -31,7 +31,7 @@ namespace migraphx { ...@@ -31,7 +31,7 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
template <bool... Bs> template <bool... Bs>
struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>> // NOLINT struct and_ : std::is_same<and_<Bs...>, and_<(Bs or true)...>> // NOLINT
{ {
}; };
......
...@@ -208,7 +208,7 @@ struct schedule_model ...@@ -208,7 +208,7 @@ struct schedule_model
template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT> template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT>
private_detail_te_handle_type( private_detail_te_handle_type(
PrivateDetailTypeErasedT value, PrivateDetailTypeErasedT value,
typename std::enable_if<!std::is_reference<PrivateDetailTypeErasedU>::value, typename std::enable_if<not std::is_reference<PrivateDetailTypeErasedU>::value,
int>::type* = nullptr) noexcept int>::type* = nullptr) noexcept
: private_detail_te_value(std::move(value)) : private_detail_te_value(std::move(value))
{ {
...@@ -274,7 +274,7 @@ struct schedule_model ...@@ -274,7 +274,7 @@ struct schedule_model
private_detail_te_handle_base_type& private_detail_te_get_handle() private_detail_te_handle_base_type& private_detail_te_get_handle()
{ {
assert(private_detail_te_handle_mem_var != nullptr); assert(private_detail_te_handle_mem_var != nullptr);
if(!private_detail_te_handle_mem_var.unique()) if(not private_detail_te_handle_mem_var.unique())
private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone(); private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone();
return *private_detail_te_handle_mem_var; return *private_detail_te_handle_mem_var;
} }
......
...@@ -216,7 +216,7 @@ struct stream_model ...@@ -216,7 +216,7 @@ struct stream_model
template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT> template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT>
private_detail_te_handle_type( private_detail_te_handle_type(
PrivateDetailTypeErasedT value, PrivateDetailTypeErasedT value,
typename std::enable_if<!std::is_reference<PrivateDetailTypeErasedU>::value, typename std::enable_if<not std::is_reference<PrivateDetailTypeErasedU>::value,
int>::type* = nullptr) noexcept int>::type* = nullptr) noexcept
: private_detail_te_value(std::move(value)) : private_detail_te_value(std::move(value))
{ {
...@@ -288,7 +288,7 @@ struct stream_model ...@@ -288,7 +288,7 @@ struct stream_model
private_detail_te_handle_base_type& private_detail_te_get_handle() private_detail_te_handle_base_type& private_detail_te_get_handle()
{ {
assert(private_detail_te_handle_mem_var != nullptr); assert(private_detail_te_handle_mem_var != nullptr);
if(!private_detail_te_handle_mem_var.unique()) if(not private_detail_te_handle_mem_var.unique())
private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone(); private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone();
return *private_detail_te_handle_mem_var; return *private_detail_te_handle_mem_var;
} }
......
...@@ -41,7 +41,7 @@ struct stream_range_container ...@@ -41,7 +41,7 @@ struct stream_range_container
friend std::ostream& operator<<(std::ostream& os, const stream_range_container& sr) friend std::ostream& operator<<(std::ostream& os, const stream_range_container& sr)
{ {
assert(sr.r != nullptr); assert(sr.r != nullptr);
if(!sr.r->empty()) if(not sr.r->empty())
{ {
os << sr.r->front(); os << sr.r->front();
std::for_each( std::for_each(
......
...@@ -351,7 +351,7 @@ struct target ...@@ -351,7 +351,7 @@ struct target
template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT> template <typename PrivateDetailTypeErasedU = PrivateDetailTypeErasedT>
private_detail_te_handle_type( private_detail_te_handle_type(
PrivateDetailTypeErasedT value, PrivateDetailTypeErasedT value,
typename std::enable_if<!std::is_reference<PrivateDetailTypeErasedU>::value, typename std::enable_if<not std::is_reference<PrivateDetailTypeErasedU>::value,
int>::type* = nullptr) noexcept int>::type* = nullptr) noexcept
: private_detail_te_value(std::move(value)) : private_detail_te_value(std::move(value))
{ {
...@@ -426,7 +426,7 @@ struct target ...@@ -426,7 +426,7 @@ struct target
private_detail_te_handle_base_type& private_detail_te_get_handle() private_detail_te_handle_base_type& private_detail_te_get_handle()
{ {
assert(private_detail_te_handle_mem_var != nullptr); assert(private_detail_te_handle_mem_var != nullptr);
if(!private_detail_te_handle_mem_var.unique()) if(not private_detail_te_handle_mem_var.unique())
private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone(); private_detail_te_handle_mem_var = private_detail_te_handle_mem_var->clone();
return *private_detail_te_handle_mem_var; return *private_detail_te_handle_mem_var;
} }
......
...@@ -67,7 +67,7 @@ struct tensor_view ...@@ -67,7 +67,7 @@ struct tensor_view
const shape& get_shape() const { return this->m_shape; } const shape& get_shape() const { return this->m_shape; }
bool empty() const { return m_data == nullptr || m_shape.lens().empty(); } bool empty() const { return m_data == nullptr or m_shape.lens().empty(); }
std::size_t size() const { return m_shape.elements(); } std::size_t size() const { return m_shape.elements(); }
...@@ -109,37 +109,37 @@ struct tensor_view ...@@ -109,37 +109,37 @@ struct tensor_view
T& operator[](std::size_t i) T& operator[](std::size_t i)
{ {
assert(!this->empty() && i < this->size()); assert(not this->empty() && i < this->size());
return m_data[m_shape.index(i)]; return m_data[m_shape.index(i)];
} }
const T& operator[](std::size_t i) const const T& operator[](std::size_t i) const
{ {
assert(!this->empty() && i < this->size()); assert(not this->empty() && i < this->size());
return m_data[m_shape.index(i)]; return m_data[m_shape.index(i)];
} }
T& front() T& front()
{ {
assert(!this->empty()); assert(not this->empty());
return m_data[0]; return m_data[0];
} }
const T& front() const const T& front() const
{ {
assert(!this->empty()); assert(not this->empty());
return m_data[0]; return m_data[0];
} }
T& back() T& back()
{ {
assert(!this->empty()); assert(not this->empty());
return m_data[m_shape.index(this->size() - 1)]; return m_data[m_shape.index(this->size() - 1)];
} }
const T& back() const const T& back() const
{ {
assert(!this->empty()); assert(not this->empty());
return m_data[m_shape.index(this->size() - 1)]; return m_data[m_shape.index(this->size() - 1)];
} }
...@@ -159,7 +159,7 @@ struct tensor_view ...@@ -159,7 +159,7 @@ struct tensor_view
friend std::ostream& operator<<(std::ostream& os, const tensor_view<T>& x) friend std::ostream& operator<<(std::ostream& os, const tensor_view<T>& x)
{ {
if(!x.empty()) if(not x.empty())
{ {
os << as_number(x.front()); os << as_number(x.front());
for(std::size_t i = 1; i < x.m_shape.elements(); i++) for(std::size_t i = 1; i < x.m_shape.elements(); i++)
...@@ -182,7 +182,7 @@ bool operator==(const tensor_view<T>& x, const tensor_view<U>& y) ...@@ -182,7 +182,7 @@ bool operator==(const tensor_view<T>& x, const tensor_view<U>& y)
{ {
for(std::size_t i = 0; i < x.get_shape().elements(); i++) for(std::size_t i = 0; i < x.get_shape().elements(); i++)
{ {
if(!float_equal(x[i], y[i])) if(not float_equal(x[i], y[i]))
return false; return false;
} }
return true; return true;
...@@ -193,7 +193,7 @@ bool operator==(const tensor_view<T>& x, const tensor_view<U>& y) ...@@ -193,7 +193,7 @@ bool operator==(const tensor_view<T>& x, const tensor_view<U>& y)
template <class T, class U> template <class T, class U>
bool operator!=(const tensor_view<T>& x, const tensor_view<U>& y) bool operator!=(const tensor_view<T>& x, const tensor_view<U>& y)
{ {
return !(x == y); return not(x == y);
} }
template <class T> template <class T>
......
...@@ -34,7 +34,7 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -34,7 +34,7 @@ inline namespace MIGRAPHX_INLINE_NS {
inline int tune_axis(const int n_dim, const int axis, const std::string& op_name = "OPERATOR") inline int tune_axis(const int n_dim, const int axis, const std::string& op_name = "OPERATOR")
{ {
if(axis >= n_dim || std::abs(axis) > n_dim) if(axis >= n_dim or std::abs(axis) > n_dim)
{ {
MIGRAPHX_THROW(to_upper(op_name) + ": axis is out of range."); MIGRAPHX_THROW(to_upper(op_name) + ": axis is out of range.");
} }
......
...@@ -176,13 +176,13 @@ bool operator==(const instruction& x, const instruction& y) ...@@ -176,13 +176,13 @@ bool operator==(const instruction& x, const instruction& y)
return true; return true;
} }
bool operator!=(const instruction& x, const instruction& y) { return !(x == y); } bool operator!=(const instruction& x, const instruction& y) { return not(x == y); }
bool operator==(instruction_ref ref, const instruction& i) { return i == ref; } bool operator==(instruction_ref ref, const instruction& i) { return i == ref; }
bool operator!=(const instruction& i, instruction_ref ref) { return !(i == ref); } bool operator!=(const instruction& i, instruction_ref ref) { return not(i == ref); }
bool operator!=(instruction_ref ref, const instruction& i) { return !(i == ref); } bool operator!=(instruction_ref ref, const instruction& i) { return not(i == ref); }
void instruction::add_output(instruction_ref ins) void instruction::add_output(instruction_ref ins)
{ {
...@@ -361,7 +361,7 @@ void instruction::print(std::ostream& os, ...@@ -361,7 +361,7 @@ void instruction::print(std::ostream& os,
os << "{" << ins->get_literal() << "}"; os << "{" << ins->get_literal() << "}";
} }
if(!ins->inputs().empty()) if(not ins->inputs().empty())
{ {
char delim = '('; char delim = '(';
for(auto&& arg : ins->inputs()) for(auto&& arg : ins->inputs())
...@@ -374,7 +374,7 @@ void instruction::print(std::ostream& os, ...@@ -374,7 +374,7 @@ void instruction::print(std::ostream& os,
} }
// print module inputs // print module inputs
if(!ins->module_inputs().empty()) if(not ins->module_inputs().empty())
{ {
std::string delim = ", ["; std::string delim = ", [";
for(auto&& mod_arg : ins->module_inputs()) for(auto&& mod_arg : ins->module_inputs())
...@@ -446,7 +446,7 @@ operation instruction::normalized_operator() const ...@@ -446,7 +446,7 @@ operation instruction::normalized_operator() const
if(this->need_normalization()) if(this->need_normalization())
{ {
auto s = this->inputs().front()->get_shape(); auto s = this->inputs().front()->get_shape();
if(!normalize_attributes(o, s.max_lens())) if(not normalize_attributes(o, s.max_lens()))
return this->get_operator(); return this->get_operator();
} }
return o; return o;
......
...@@ -141,12 +141,12 @@ void module::set_bypass(bool b) { impl->bypass = b; } ...@@ -141,12 +141,12 @@ void module::set_bypass(bool b) { impl->bypass = b; }
void module::assign(const module& m) void module::assign(const module& m)
{ {
// copy the impl // copy the impl
if(!impl) if(not impl)
impl = std::make_unique<module_impl>(); impl = std::make_unique<module_impl>();
*impl = *m.impl; *impl = *m.impl;
// clear instructions // clear instructions
if(!impl->instructions.empty()) if(not impl->instructions.empty())
{ {
impl->clear(); impl->clear();
} }
...@@ -346,7 +346,7 @@ instruction_ref module::replace_instruction(instruction_ref ins, instruction_ref ...@@ -346,7 +346,7 @@ instruction_ref module::replace_instruction(instruction_ref ins, instruction_ref
assert(out->valid(begin())); assert(out->valid(begin()));
} }
// Replacement should not be dead code unless its the last instruction // Replacement should not be dead code unless its the last instruction
assert(!rep->outputs().empty() or rep == std::prev(end())); assert(not rep->outputs().empty() or rep == std::prev(end()));
// Output of the original instruction should only be the replacement or empty // Output of the original instruction should only be the replacement or empty
assert(ins->outputs().empty() or std::all_of(ins->outputs().begin(), assert(ins->outputs().empty() or std::all_of(ins->outputs().begin(),
ins->outputs().end(), ins->outputs().end(),
...@@ -598,7 +598,7 @@ instruction_ref module::validate() const ...@@ -598,7 +598,7 @@ instruction_ref module::validate() const
auto inputs = i.inputs(); auto inputs = i.inputs();
bool check_order = std::all_of( bool check_order = std::all_of(
inputs.begin(), inputs.end(), [&](auto in) { return has_instruction(in); }); inputs.begin(), inputs.end(), [&](auto in) { return has_instruction(in); });
return !i.valid(impl->instructions.begin(), check_order); return not i.valid(impl->instructions.begin(), check_order);
}); });
} }
...@@ -754,7 +754,7 @@ void module::print_graph(std::ostream& os, bool brief) const ...@@ -754,7 +754,7 @@ void module::print_graph(std::ostream& os, bool brief) const
label = to_string(ins->get_operator()); label = to_string(ins->get_operator());
os << "\t" << enclose_name(ins_names.at(ins)) << "[label=" << enclose_name(label) << "]"; os << "\t" << enclose_name(ins_names.at(ins)) << "[label=" << enclose_name(label) << "]";
os << ";" << std::endl; os << ";" << std::endl;
if(!ins->inputs().empty()) if(not ins->inputs().empty())
{ {
for(auto&& arg : ins->inputs()) for(auto&& arg : ins->inputs())
{ {
...@@ -908,7 +908,7 @@ module& module::sort() ...@@ -908,7 +908,7 @@ module& module::sort()
this->move_instruction(ins, this->begin()); this->move_instruction(ins, this->begin());
for(auto child : ins->inputs()) for(auto child : ins->inputs())
{ {
if(!contains(this->impl->instructions, child)) if(not contains(this->impl->instructions, child))
{ {
continue; continue;
} }
......
...@@ -79,14 +79,14 @@ auto tune_attribute(const std::vector<int64_t>& vec, ...@@ -79,14 +79,14 @@ auto tune_attribute(const std::vector<int64_t>& vec,
{ {
if(contains(vec_attrs, op::normalize_attribute::include_max)) if(contains(vec_attrs, op::normalize_attribute::include_max))
{ {
if(!std::equal(result.begin(), result.end(), max_vals.begin(), std::less_equal<>{})) if(not std::equal(result.begin(), result.end(), max_vals.begin(), std::less_equal<>{}))
{ {
MIGRAPHX_THROW("TUNE_VECTOR: value out of range!"); MIGRAPHX_THROW("TUNE_VECTOR: value out of range!");
} }
} }
else else
{ {
if(!std::equal(result.begin(), result.end(), max_vals.begin(), std::less<>{})) if(not std::equal(result.begin(), result.end(), max_vals.begin(), std::less<>{}))
{ {
MIGRAPHX_THROW("TUNE_VECTOR: value out of range!"); MIGRAPHX_THROW("TUNE_VECTOR: value out of range!");
} }
...@@ -118,14 +118,15 @@ auto tune_attribute(const std::vector<int64_t>& vec, ...@@ -118,14 +118,15 @@ auto tune_attribute(const std::vector<int64_t>& vec,
{ {
if(contains(vec_attrs, op::normalize_attribute::include_min)) if(contains(vec_attrs, op::normalize_attribute::include_min))
{ {
if(!std::equal(min_vals.begin(), min_vals.end(), result.begin(), std::less_equal<>{})) if(not std::equal(
min_vals.begin(), min_vals.end(), result.begin(), std::less_equal<>{}))
{ {
MIGRAPHX_THROW("TUNE_VECTOR: attribute out of range!"); MIGRAPHX_THROW("TUNE_VECTOR: attribute out of range!");
} }
} }
else else
{ {
if(!std::equal(result.begin(), result.end(), min_vals.begin(), std::less<>{})) if(not std::equal(result.begin(), result.end(), min_vals.begin(), std::less<>{}))
{ {
MIGRAPHX_THROW("TUNE_VECTOR: attribute out of range!"); MIGRAPHX_THROW("TUNE_VECTOR: attribute out of range!");
} }
...@@ -174,7 +175,7 @@ bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens) ...@@ -174,7 +175,7 @@ bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens)
tuned = true; tuned = true;
} }
} }
if(!attrs.contains("normalize_axes")) if(not attrs.contains("normalize_axes"))
{ {
return tuned; return tuned;
} }
......
...@@ -187,7 +187,7 @@ operation onnx_parser::load(const std::string& name, const node_info& info) cons ...@@ -187,7 +187,7 @@ operation onnx_parser::load(const std::string& name, const node_info& info) cons
void onnx_parser::parse_undefined(module* mod, const std::string& name) void onnx_parser::parse_undefined(module* mod, const std::string& name)
{ {
if(!contains(instructions, name)) if(not contains(instructions, name))
{ {
auto ins = mod->add_instruction(make_op("undefined")); auto ins = mod->add_instruction(make_op("undefined"));
instructions[name] = ins; instructions[name] = ins;
...@@ -267,7 +267,7 @@ void onnx_parser::parse_graph(module* mod, const onnx::GraphProto& graph) ...@@ -267,7 +267,7 @@ void onnx_parser::parse_graph(module* mod, const onnx::GraphProto& graph)
{ {
const std::string& name = input.name(); const std::string& name = input.name();
// input not in initializer_data, so it is a real input // input not in initializer_data, so it is a real input
if(!contains(mod_insts, name)) if(not contains(mod_insts, name))
{ {
// ONNX specification does not specify how to deal with the // ONNX specification does not specify how to deal with the
// scenario that a nested subgraph contains a parameter with the // scenario that a nested subgraph contains a parameter with the
...@@ -354,7 +354,7 @@ void onnx_parser::parse_graph(module* mod, const onnx::GraphProto& graph) ...@@ -354,7 +354,7 @@ void onnx_parser::parse_graph(module* mod, const onnx::GraphProto& graph)
all_output_names.begin(), all_output_names.begin(),
all_output_names.end(), all_output_names.end(),
std::back_inserter(prog_output_names), std::back_inserter(prog_output_names),
[&](const auto& name) { return !(name.empty() or instructions.count(name) == 0); }); [&](const auto& name) { return not(name.empty() or instructions.count(name) == 0); });
std::vector<instruction_ref> output_ins; std::vector<instruction_ref> output_ins;
std::transform(prog_output_names.begin(), std::transform(prog_output_names.begin(),
...@@ -444,7 +444,7 @@ shape onnx_parser::parse_type(const onnx::TypeProto& t, ...@@ -444,7 +444,7 @@ shape onnx_parser::parse_type(const onnx::TypeProto& t,
const std::vector<std::size_t>& input_dims) const const std::vector<std::size_t>& input_dims) const
{ {
shape::type_t shape_type = get_type(t.tensor_type().elem_type()); shape::type_t shape_type = get_type(t.tensor_type().elem_type());
if(!input_dims.empty()) if(not input_dims.empty())
{ {
return {shape_type, input_dims}; return {shape_type, input_dims};
} }
...@@ -511,7 +511,7 @@ shape::type_t get_type(int dtype) ...@@ -511,7 +511,7 @@ shape::type_t get_type(int dtype)
bool is_type_float(shape::type_t dtype) bool is_type_float(shape::type_t dtype)
{ {
bool r = false; bool r = false;
if(dtype == shape::float_type || dtype == shape::double_type || dtype == shape::half_type) if(dtype == shape::float_type or dtype == shape::double_type or dtype == shape::half_type)
{ {
r = true; r = true;
} }
......
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