Skip to content

Commit

Permalink
update clang-format version
Browse files Browse the repository at this point in the history
  • Loading branch information
vtavana committed Jun 21, 2024
1 parent edcaaa5 commit b814641
Show file tree
Hide file tree
Showing 26 changed files with 69 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
steps:
- name: Set up clang-format
run: |
sudo apt-get install -y clang-format-12
sudo apt-get install -y clang-format-15
sudo unlink /usr/bin/clang-format
sudo ln -s /usr/bin/clang-format-12 /usr/bin/clang-format
sudo ln -s /usr/bin/clang-format-15 /usr/bin/clang-format
clang-format --version
- name: Set up pip packages
Expand Down
3 changes: 2 additions & 1 deletion dpnp/backend/extensions/blas/gemm_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ struct GemmBatchContigFactory
fnT get()
{
if constexpr (types::GemmBatchTypePairSupportFactory<Tab,
Tc>::is_defined) {
Tc>::is_defined)
{
return gemm_batch_impl<Tab, Tc>;
}
else {
Expand Down
3 changes: 2 additions & 1 deletion dpnp/backend/extensions/blas/gemv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ std::pair<sycl::event, sycl::event>
const int vectorY_typenum = vectorY.get_typenum();

if (matrixA_typenum != vectorX_typenum ||
matrixA_typenum != vectorY_typenum) {
matrixA_typenum != vectorY_typenum)
{
throw py::value_error("Given arrays must be of the same type.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ std::pair<sycl::event, sycl::event>
simplified_dst_strides, src_offset, dst_offset);

if (nd == 1 && simplified_src_strides[0] == 1 &&
simplified_dst_strides[0] == 1) {
simplified_dst_strides[0] == 1)
{
// Special case of contiguous data
auto contig_fn = contig_dispatch_vector[src_typeid];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ void simplify_iteration_space_3(
simplified_dst_strides.reserve(nd);

if ((src1_strides[0] < 0) && (src2_strides[0] < 0) &&
(dst_strides[0] < 0)) {
(dst_strides[0] < 0))
{
simplified_src1_strides.push_back(-src1_strides[0]);
simplified_src2_strides.push_back(-src2_strides[0]);
simplified_dst_strides.push_back(-dst_strides[0]);
Expand Down
5 changes: 1 addition & 4 deletions dpnp/backend/extensions/lapack/linalg_exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ class LinAlgError : public std::exception
public:
explicit LinAlgError(const char *message) : msg_(message) {}

const char *what() const noexcept override
{
return msg_.c_str();
}
const char *what() const noexcept override { return msg_.c_str(); }

private:
std::string msg_;
Expand Down
10 changes: 2 additions & 8 deletions dpnp/backend/extensions/sycl_ext/dispatcher_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,7 @@ struct elements_count
template <typename T>
struct elements_count<std::tuple<T>>
{
static constexpr int count()
{
return std::tuple_size_v<T>;
}
static constexpr int count() { return std::tuple_size_v<T>; }
};

template <typename T, typename... Axis>
Expand All @@ -354,10 +351,7 @@ struct get_linear_id
template <typename T>
struct get_linear_id<std::tuple<T>>
{
static int get(const int *data)
{
return data[0];
}
static int get(const int *data) { return data[0]; }
};

template <typename T, typename... Axis>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@ namespace dpnp::extensions::ufunc
/**
* @brief Add elementwise functions to Python module
*/
void init_elementwise_functions(py::module_ m)
{
init_fabs(m);
}
void init_elementwise_functions(py::module_ m) { init_fabs(m); }
} // namespace dpnp::extensions::ufunc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
fnT get() \
{ \
if constexpr (std::is_same_v<typename OutputType<T>::value_type, \
void>) { \
void>) \
{ \
fnT fn = nullptr; \
return fn; \
} \
Expand Down Expand Up @@ -93,7 +94,8 @@
fnT get() \
{ \
if constexpr (std::is_same_v<typename OutputType<T>::value_type, \
void>) { \
void>) \
{ \
fnT fn = nullptr; \
return fn; \
} \
Expand Down
5 changes: 1 addition & 4 deletions dpnp/backend/extensions/ufunc/ufunc_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,4 @@
namespace py = pybind11;
namespace ufunc_ns = dpnp::extensions::ufunc;

PYBIND11_MODULE(_ufunc_impl, m)
{
ufunc_ns::init_elementwise_functions(m);
}
PYBIND11_MODULE(_ufunc_impl, m) { ufunc_ns::init_elementwise_functions(m); }
3 changes: 2 additions & 1 deletion dpnp/backend/extensions/vm/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ bool need_to_call_binary_ufunc(sycl::queue &exec_q,
fnT get() \
{ \
if constexpr (std::is_same_v<typename OutputType<T>::value_type, \
void>) { \
void>) \
{ \
return nullptr; \
} \
else { \
Expand Down
3 changes: 2 additions & 1 deletion dpnp/backend/kernels/dpnp_krnl_bitwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ DPCTLSyclEventRef dpnp_invert_c(DPCTLSyclQueueRef q_ref,
}
else {
for (size_t k = start + sg.get_local_id()[0]; k < size;
k += max_sg_size) {
k += max_sg_size)
{
if constexpr (std::is_same_v<_DataType, bool>) {
result[k] = !(input_data[k]);
}
Expand Down
3 changes: 2 additions & 1 deletion dpnp/backend/kernels/dpnp_krnl_elemwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,8 @@ static void func_map_init_elemwise_1arg_1type(func_map_t &fmap)
} \
else { \
for (size_t k = start + sg.get_local_id()[0]; \
k < result_size; k += max_sg_size) { \
k < result_size; k += max_sg_size) \
{ \
const _DataType_output input1_elem = \
input1_data[k]; \
const _DataType_output input2_elem = \
Expand Down
6 changes: 4 additions & 2 deletions dpnp/backend/kernels/dpnp_krnl_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,17 @@ static void dpnp_fft_fft_sycl_c(DPCTLSyclQueueRef q_ref,

if (it < input_shape[axis]) {
if constexpr (std::is_same<_DataType_input,
std::complex<double>>::value) {
std::complex<double>>::value)
{
const _DataType_input *cmplx_ptr = array_1 + input_it;
const double *dbl_ptr =
reinterpret_cast<const double *>(cmplx_ptr);
in_real = *dbl_ptr;
in_imag = *(dbl_ptr + 1);
}
else if constexpr (std::is_same<_DataType_input,
std::complex<float>>::value) {
std::complex<float>>::value)
{
const _DataType_input *cmplx_ptr = array_1 + input_it;
const float *dbl_ptr =
reinterpret_cast<const float *>(cmplx_ptr);
Expand Down
9 changes: 6 additions & 3 deletions dpnp/backend/kernels/dpnp_krnl_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,20 @@ static sycl::event dpnp_allclose(sycl::queue &q,
continue;
}
else if (array1[i] ==
-std::numeric_limits<_DataType1>::infinity()) {
-std::numeric_limits<_DataType1>::infinity())
{
partial &= (array1[i] == array2[i]);
continue;
}
else if (array2[i] ==
std::numeric_limits<_DataType2>::infinity()) {
std::numeric_limits<_DataType2>::infinity())
{
partial &= (array1[i] == array2[i]);
continue;
}
else if (array2[i] ==
-std::numeric_limits<_DataType2>::infinity()) {
-std::numeric_limits<_DataType2>::infinity())
{
partial &= (array1[i] == array2[i]);
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion dpnp/backend/kernels/dpnp_krnl_mathematical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ DPCTLSyclEventRef
}
else {
for (size_t k = start + sg.get_local_id()[0]; k < size;
k += max_sg_size) {
k += max_sg_size)
{
result[k] = std::abs(array1[k]);
}
}
Expand Down
8 changes: 3 additions & 5 deletions dpnp/backend/kernels/dpnp_krnl_sorting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
template <typename _DataType, typename _idx_DataType>
struct _argsort_less
{
_argsort_less(_DataType *data_ptr)
{
_data_ptr = data_ptr;
}
_argsort_less(_DataType *data_ptr) { _data_ptr = data_ptr; }

inline bool operator()(const _idx_DataType &idx1, const _idx_DataType &idx2)
{
Expand Down Expand Up @@ -136,7 +133,8 @@ DPCTLSyclEventRef dpnp_partition_c(DPCTLSyclQueueRef q_ref,
DPCTLSyclEventRef event_ref = nullptr;

if ((array1_in == nullptr) || (array2_in == nullptr) ||
(result1 == nullptr)) {
(result1 == nullptr))
{
return event_ref;
}

Expand Down
3 changes: 2 additions & 1 deletion dpnp/backend/kernels/dpnp_krnl_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,8 @@ DPCTLSyclEventRef dpnp_nanvar_c(DPCTLSyclQueueRef q_ref,
DPCTLSyclEventRef event_ref = nullptr;

if ((array1_in == nullptr) || (mask_arr1 == nullptr) ||
(result1 == nullptr)) {
(result1 == nullptr))
{
return event_ref;
}

Expand Down
5 changes: 1 addition & 4 deletions dpnp/backend/kernels/elementwise_functions/fabs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ struct FabsFunctor
// do both argT and resT support sugroup store/load operation
using supports_sg_loadstore = typename std::true_type;

resT operator()(const argT &x) const
{
return sycl::fabs(x);
}
resT operator()(const argT &x) const { return sycl::fabs(x); }
};
} // namespace dpnp::kernels::fabs
3 changes: 2 additions & 1 deletion dpnp/backend/src/dpnp_fptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ class dpnp_less_comp
ret = (b.imag() != b.imag() && a.imag() == a.imag());
}
else if (a.real() == b.real() ||
(a.real() != a.real() && b.real() != b.real())) {
(a.real() != a.real() && b.real() != b.real()))
{
ret = (a.imag() < b.imag() ||
(b.imag() != b.imag() && a.imag() == a.imag()));
}
Expand Down
3 changes: 2 additions & 1 deletion dpnp/backend/src/dpnp_iface_fptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ void *get_backend_function_name(const char *func_name, const char *type_name)
/** of coerce it will be converted into std::map later */
if (!strncmp(func_name, supported_func_name, strlen(supported_func_name))) {
if (!strncmp(type_name, supported_type1_name,
strlen(supported_type1_name))) {
strlen(supported_type1_name)))
{
return reinterpret_cast<void *>(
dpnp_dot_default_c<double, double, double>);
}
Expand Down
49 changes: 14 additions & 35 deletions dpnp/backend/src/dpnp_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,9 @@ class DPNP_USM_iterator final

DPNP_USM_iterator() = delete;

inline reference operator*() const
{
return *ptr();
}
inline reference operator*() const { return *ptr(); }

inline pointer operator->() const
{
return ptr();
}
inline pointer operator->() const { return ptr(); }

/// prefix increment
inline DPNP_USM_iterator &operator++()
Expand Down Expand Up @@ -116,10 +110,7 @@ class DPNP_USM_iterator final
// TODO need more operators

// Random access iterator requirements
inline reference operator[](size_type __n) const
{
return *ptr(__n);
}
inline reference operator[](size_type __n) const { return *ptr(__n); }

inline difference_type operator-(const DPNP_USM_iterator &__rhs) const
{
Expand Down Expand Up @@ -151,10 +142,7 @@ class DPNP_USM_iterator final
}

private:
inline pointer ptr() const
{
return ptr(iter_id);
}
inline pointer ptr() const { return ptr(iter_id); }

inline pointer ptr(size_type iteration_id) const
{
Expand All @@ -163,7 +151,8 @@ class DPNP_USM_iterator final
if (iteration_shape_size > 0) {
long reminder = iteration_id;
for (size_t it = 0; it < static_cast<size_t>(iteration_shape_size);
++it) {
++it)
{
const size_type axis_val = iteration_shape_strides[it];
size_type xyz_id = reminder / axis_val;
offset += (xyz_id * axes_shape_strides[it]);
Expand Down Expand Up @@ -275,16 +264,10 @@ class DPNPC_id final

DPNPC_id() = delete;

~DPNPC_id()
{
free_memory();
}
~DPNPC_id() { free_memory(); }

/// this function return number of elements in output
inline size_type get_output_size() const
{
return output_size;
}
inline size_type get_output_size() const { return output_size; }

inline void broadcast_to_shape(const size_type *__shape,
const size_type __shape_size)
Expand Down Expand Up @@ -371,10 +354,7 @@ class DPNPC_id final
*
* @param [in] __axis Axis in a shape of input array.
*/
inline void set_axis(shape_elem_type __axis)
{
set_axes({__axis});
}
inline void set_axis(shape_elem_type __axis) { set_axes({__axis}); }

inline void set_axes(const shape_elem_type *__axes, const size_t axes_ndim)
{
Expand Down Expand Up @@ -458,7 +438,8 @@ class DPNPC_id final
axes_shape_strides = reinterpret_cast<size_type *>(
dpnp_memory_alloc_c(queue_ref, iteration_shape_size_in_bytes));
for (size_t i = 0; i < static_cast<size_t>(iteration_shape_size);
++i) {
++i)
{
axes_shape_strides[i] = input_shape_strides[axes[i]];
}
}
Expand Down Expand Up @@ -603,7 +584,8 @@ class DPNPC_id final
size_type *broadcast_axes_end =
broadcast_axes + broadcast_axes_size;
if (std::find(broadcast_axes, broadcast_axes_end, orit) ==
broadcast_axes_end) {
broadcast_axes_end)
{
const size_type output_xyz_id = get_xyz_id_by_id_inkernel(
output_global_id, output_shape_strides,
output_shape_size, orit);
Expand All @@ -617,10 +599,7 @@ class DPNPC_id final
}

/// this function is designed for SYCL environment execution
size_type get_iteration_size() const
{
return iteration_size;
}
size_type get_iteration_size() const { return iteration_size; }

void free_axes_memory()
{
Expand Down
3 changes: 2 additions & 1 deletion dpnp/backend/src/dpnp_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ static inline std::vector<shape_elem_type>

if (!__allow_duplicate) {
if (std::find(result.begin(), result.end(), positive_axis) !=
result.end()) { // find axis duplication
result.end())
{ // find axis duplication
goto err;
}
}
Expand Down
Loading

0 comments on commit b814641

Please sign in to comment.