Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use and keyword consistently #3676

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,7 @@ CheckOptions:
value: MIGRAPHX_
- key: readability-identifier-naming.ConstexprMethodIgnoredRegexp
value: 'quiet_NaN|signaling_NaN'
- key: readability-operators-representation.BinaryOperators
value: 'and;or;not'
- key: readability-operators-representation.OverloadedOperators
value: 'and;or;not'
4 changes: 2 additions & 2 deletions src/apply_alpha_beta.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -51,7 +51,7 @@ instruction_ref insert_apply_alpha_beta(module& m,
auto op_res = m.insert_instruction(pos, op, a, b);
if(args.size() == 3)
{
if(not float_equal(beta.at<float>(0), 0.0) && args[2]->get_shape().elements() > 0)
if(not float_equal(beta.at<float>(0), 0.0) and args[2]->get_shape().elements() > 0)
{
auto out_lens = op_res->get_shape().lens();
auto c = args[2];
Expand Down
4 changes: 2 additions & 2 deletions src/driver/argument_parser.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -433,7 +433,7 @@ struct argument_parser
argument* input_argument =
self.find_argument([](const auto& arg) { return arg.flags.empty(); });
auto required_usages = get_argument_usages(get_required_arguments());
if(required_usages.empty() && input_argument)
if(required_usages.empty() and input_argument)
required_usages.push_back(input_argument->metavar);
required_usages.insert(required_usages.begin(), "<options>");
print_usage(required_usages);
Expand Down
2 changes: 1 addition & 1 deletion src/driver/perf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool is_offload_copy_set(const program& p)
for(const auto& j : return_args)
{
auto alias_ins = instruction::get_output_alias(j, true);
if((alias_ins->name() == "@param" && param_ins.erase(alias_ins) == 0) or
if((alias_ins->name() == "@param" and param_ins.erase(alias_ins) == 0) or
(alias_ins->name() != "hip::copy_from_gpu"))
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/include/migraphx/op/nonmaxsuppression.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -335,7 +335,7 @@ struct nonmaxsuppression
auto batch_boxes_start = boxes.begin() + batch_idx * num_boxes * 4;
auto boxes_heap = filter_boxes_by_score(scores_start, num_boxes, score_threshold);
int64_t selected_boxes_inside_class = 0;
while(not boxes_heap.empty() &&
while(not boxes_heap.empty() and
selected_boxes_inside_class < max_output_boxes_per_class)
{
// select next top scorer box and remove any boxes from boxes_heap that exceeds IOU
Expand Down
4 changes: 2 additions & 2 deletions src/include/migraphx/raw_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ auto visit_all(const std::vector<T>& x)

template <class T,
class U,
MIGRAPHX_REQUIRES(std::is_base_of<raw_data_base, T>{} &&
MIGRAPHX_REQUIRES(std::is_base_of<raw_data_base, T>{} and
std::is_base_of<raw_data_base, U>{})>
bool operator==(const T& x, const U& y)
{
Expand All @@ -294,7 +294,7 @@ bool operator==(const T& x, const U& y)

template <class T,
class U,
MIGRAPHX_REQUIRES(std::is_base_of<raw_data_base, T>{} &&
MIGRAPHX_REQUIRES(std::is_base_of<raw_data_base, T>{} and
std::is_base_of<raw_data_base, U>{})>
bool operator!=(const T& x, const U& y)
{
Expand Down
10 changes: 5 additions & 5 deletions src/include/migraphx/requires.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -47,10 +47,10 @@ using bool_c = std::integral_constant<bool, B>;
#define MIGRAPHX_REQUIRES(...) class = void
#define MIGRAPHX_CLASS_REQUIRES(...) void
#else
#define MIGRAPHX_REQUIRES(...) \
long MIGRAPHX_REQUIRES_VAR() = __LINE__, \
typename std::enable_if<(MIGRAPHX_REQUIRES_VAR() == __LINE__ && \
(migraphx::and_<__VA_ARGS__>{})), \
#define MIGRAPHX_REQUIRES(...) \
long MIGRAPHX_REQUIRES_VAR() = __LINE__, \
typename std::enable_if<(MIGRAPHX_REQUIRES_VAR() == __LINE__ and \
(migraphx::and_<__VA_ARGS__>{})), \
int>::type = 0
#define MIGRAPHX_CLASS_REQUIRES(...) typename std::enable_if<(migraphx::and_<__VA_ARGS__>{})>::type
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/include/migraphx/tensor_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ struct tensor_view

T& operator[](std::size_t i)
{
assert(not this->empty() && i < this->size());
assert(not this->empty() and i < this->size());
return m_data[m_shape.index(i)];
}

const T& operator[](std::size_t i) const
{
assert(not this->empty() && i < this->size());
assert(not this->empty() and i < this->size());
return m_data[m_shape.index(i)];
}

Expand Down
4 changes: 2 additions & 2 deletions src/instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool operator==(const instruction& i, instruction_ref ref)

bool instruction::valid(instruction_ref start, bool check_order) const
{
return valid() && std::all_of(arguments.begin(), arguments.end(), [&](instruction_ref i) {
return valid() and std::all_of(arguments.begin(), arguments.end(), [&](instruction_ref i) {
auto self = std::find(i->outputs().begin(), i->outputs().end(), *this);
bool ret = self != i->outputs().end();
if(check_order)
Expand Down Expand Up @@ -162,7 +162,7 @@ bool instruction::valid() const
}
}

return (result == computed) &&
return (result == computed) and
std::all_of(output.begin(), output.end(), [&](instruction_ref i) {
return std::find(i->inputs().begin(), i->inputs().end(), *this) != i->inputs().end();
});
Expand Down
4 changes: 2 additions & 2 deletions src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,12 +1204,12 @@ bool references_instruction(Map& m, const instruction& ins, const std::string& n
void program::remove_module(const std::string& name)
{
// cppcheck-suppress assertWithSideEffect
assert(is_unused_module(impl->modules, generic_get_modules(this->get_main_module()), name) &&
assert(is_unused_module(impl->modules, generic_get_modules(this->get_main_module()), name) and
"Module used in program");
assert(std::none_of(
impl->modules.at(name).begin(),
impl->modules.at(name).end(),
[&](auto&& ins) { return references_instruction(impl->modules, ins, name); }) &&
[&](auto&& ins) { return references_instruction(impl->modules, ins, name); }) and
"Instruction referenced in another module");

// if an instruction has an input out side of the current module, need to remove
Expand Down
2 changes: 1 addition & 1 deletion src/simplify_algebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ struct find_splits
{
assert(not std::none_of(start->inputs().begin(), start->inputs().end(), [](auto i) {
return i->name() == "slice";
}) && "one argument must be a split");
}) and "one argument must be a split");

split_idx = get_binary_op_split_idx(group, splits);
assert(split_idx < 2);
Expand Down
2 changes: 1 addition & 1 deletion src/targets/gpu/kernels/include/migraphx/kernels/dpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace migraphx {

constexpr bool is_power_of_2(unsigned int x) { return x > 0 && (x & (x - 1)) == 0u; }
constexpr bool is_power_of_2(unsigned int x) { return x > 0 and (x & (x - 1)) == 0u; }

#ifndef MIGRAPHX_HAS_DPP
#define MIGRAPHX_HAS_DPP 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ struct float8
}
else
{
return (data == 0x00) || (data == 0x80);
return (data == 0x00) or (data == 0x80);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ constexpr T as_float(T x)
template <class... Ts> \
auto __device__ name(migraphx::vec<migraphx::half, 2> x, Ts... xs) \
MIGRAPHX_RETURNS(migraphx::vec<migraphx::half, 2>{fname(x, xs...)}); \
template <class... Ts, index_int N, MIGRAPHX_REQUIRES(N % 2 == 0 && (N > 2))> \
template <class... Ts, index_int N, MIGRAPHX_REQUIRES(N % 2 == 0 and (N > 2))> \
auto __device__ name(migraphx::vec<migraphx::half, N> x, Ts... xs) \
{ \
return vec_packed_transform<2>(x, xs...)( \
Expand Down
9 changes: 5 additions & 4 deletions src/targets/ref/lowering.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -184,9 +184,10 @@ struct ref_im2col
kernel_w)([&](std::size_t c, std::size_t koffset, std::size_t loffset) {
auto idx = iinput + long(koffset) - kdiv2_h;
auto jdx = jinput + long(loffset) - kdiv2_w;
col(ldx, p) = ((idx >= 0) && (idx < height) && (jdx >= 0) && (jdx < width))
? input(0, c, idx, jdx)
: 0;
col(ldx, p) =
((idx >= 0) and (idx < height) and (jdx >= 0) and (jdx < width))
? input(0, c, idx, jdx)
: 0;
p++;
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/gpu/fuse_mlir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ migraphx::instruction_ref add_mlir(migraphx::program& p,
std::vector<std::string> arg_names,
F f)
{
assert(inputs.size() == arg_names.size() && "One interior parameter name given per input.");
assert(inputs.size() == arg_names.size() and "One interior parameter name given per input.");
auto* mm = p.get_main_module();
auto* pm = p.create_module(name);
pm->set_bypass();
Expand Down
2 changes: 1 addition & 1 deletion test/simplify_algebra_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ TEST_CASE(simplify_zero_add_constant)
}
run_pass(m3);

EXPECT((m1 == m2) && (m2 == m3));
EXPECT((m1 == m2) and (m2 == m3));
}

TEST_CASE(simplify_add_broadcast1)
Expand Down
Loading