Skip to content

Commit b7d4d82

Browse files
committed
format bucketize_cpu.cc
1 parent 6b1d1b1 commit b7d4d82

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/infinicore/ops/bucketize/bucketize_cpu.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
#include "infinicore/ops/bucketize.hpp"
44
#include <algorithm>
55
#include <cmath>
6+
#include <cstring>
67
#include <omp.h>
78
#include <vector>
8-
#include <cstring>
99

1010
namespace infinicore::op::bucketize_impl::cpu {
1111

1212
template <typename T>
1313
void bucketize_contiguous_kernel(const T *in_ptr, const T *bound_ptr, int64_t *out_ptr,
1414
size_t numel, size_t bound_len, bool right) {
15-
const T* bound_end = bound_ptr + bound_len;
15+
const T *bound_end = bound_ptr + bound_len;
1616

1717
#pragma omp parallel for
1818
for (size_t i = 0; i < numel; ++i) {
1919
T val = in_ptr[i];
20-
const T* result_ptr;
21-
20+
const T *result_ptr;
21+
2222
if (right) {
2323
result_ptr = std::upper_bound(bound_ptr, bound_end, val);
2424
} else {
2525
result_ptr = std::lower_bound(bound_ptr, bound_end, val);
2626
}
27-
27+
2828
out_ptr[i] = static_cast<int64_t>(result_ptr - bound_ptr);
2929
}
3030
}
@@ -35,7 +35,7 @@ void bucketize_strided_kernel(const T *in_ptr, const T *bound_ptr, int64_t *out_
3535
const Shape &out_shape, const Strides &out_strides,
3636
size_t numel, size_t bound_len, bool right) {
3737
int ndim = out_shape.size();
38-
const T* bound_end = bound_ptr + bound_len;
38+
const T *bound_end = bound_ptr + bound_len;
3939

4040
#pragma omp parallel for
4141
for (size_t i = 0; i < numel; ++i) {
@@ -52,7 +52,7 @@ void bucketize_strided_kernel(const T *in_ptr, const T *bound_ptr, int64_t *out_
5252
}
5353

5454
T val = in_ptr[in_offset];
55-
const T* result_ptr;
55+
const T *result_ptr;
5656

5757
if (right) {
5858
result_ptr = std::upper_bound(bound_ptr, bound_end, val);
@@ -79,21 +79,21 @@ void calculate_bucketize(Tensor input, Tensor boundaries, Tensor output, bool ri
7979
auto dtype = input->dtype();
8080

8181
std::vector<float> sorted_boundaries(bound_len);
82-
const float* raw_bound_ptr = reinterpret_cast<const float*>(boundaries_contig->data());
82+
const float *raw_bound_ptr = reinterpret_cast<const float *>(boundaries_contig->data());
8383

8484
std::memcpy(sorted_boundaries.data(), raw_bound_ptr, bound_len * sizeof(float));
8585

8686
std::sort(sorted_boundaries.begin(), sorted_boundaries.end());
8787

88-
const float* bound_ptr = sorted_boundaries.data();
88+
const float *bound_ptr = sorted_boundaries.data();
8989

9090
bool in_out_contiguous = input->is_contiguous() && output->is_contiguous();
9191

9292
if (in_out_contiguous) {
9393
int64_t *out_ptr = reinterpret_cast<int64_t *>(output->data());
9494
if (dtype == DataType::F32) {
9595
bucketize_contiguous_kernel<float>(
96-
(float *)input->data(),
96+
(float *)input->data(),
9797
bound_ptr,
9898
out_ptr, numel, bound_len, right);
9999
} else if (dtype == DataType::F16) {
@@ -105,7 +105,7 @@ void calculate_bucketize(Tensor input, Tensor boundaries, Tensor output, bool ri
105105
int64_t *out_ptr = reinterpret_cast<int64_t *>(output->data());
106106
if (dtype == DataType::F32) {
107107
bucketize_strided_kernel<float>(
108-
(float *)input->data(),
108+
(float *)input->data(),
109109
bound_ptr,
110110
out_ptr,
111111
input->shape(), input->strides(), output->shape(), output->strides(),

0 commit comments

Comments
 (0)