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

clang format

parent 94e3a2e4
...@@ -596,10 +596,7 @@ void program::mark(const parameter_map& params, marker&& m) ...@@ -596,10 +596,7 @@ void program::mark(const parameter_map& params, marker&& m)
m.mark_stop(*this); m.mark_stop(*this);
} }
void program::perf_report(std::ostream& os, void program::perf_report(std::ostream& os, int n, parameter_map params, int batch) const
int n,
parameter_map params,
int batch) const
{ {
auto& ctx = this->impl->ctx; auto& ctx = this->impl->ctx;
// Run once by itself // Run once by itself
......
...@@ -103,9 +103,7 @@ struct cpu_im2col ...@@ -103,9 +103,7 @@ struct cpu_im2col
// compute linear index for output // compute linear index for output
int ldx = ioutput * col_width + joutput; int ldx = ioutput * col_width + joutput;
int p = 0; int p = 0;
dfor(channels, dfor(channels, kernel_h, kernel_w)([&](int c, int koffset, int loffset) {
kernel_h,
kernel_w)([&](int c, int koffset, int loffset) {
auto idx = iinput + long(koffset) - kdiv2_h; auto idx = iinput + long(koffset) - kdiv2_h;
auto jdx = jinput + long(loffset) - kdiv2_w; auto jdx = jinput + long(loffset) - kdiv2_w;
col(ldx, p) = ((idx >= 0) && (idx < height) && (jdx >= 0) && (jdx < width)) col(ldx, p) = ((idx >= 0) && (idx < height) && (jdx >= 0) && (jdx < width))
......
...@@ -79,12 +79,8 @@ __device__ auto auto_block_reduce(index idx, Op op, T init, index_int n, F f) ...@@ -79,12 +79,8 @@ __device__ auto auto_block_reduce(index idx, Op op, T init, index_int n, F f)
} }
template <index_int MaxBlockSize, class Input, class Output> template <index_int MaxBlockSize, class Input, class Output>
__device__ void layernorm(index_int i, __device__ void layernorm(
index idx, index_int i, index idx, int block_size_div, index_int relements, Input input, Output output)
int block_size_div,
index_int relements,
Input input,
Output output)
{ {
using value_type = decltype(input(idx.local)); using value_type = decltype(input(idx.local));
const auto relements_v = relements / vector_size<value_type>{}; const auto relements_v = relements / vector_size<value_type>{};
......
...@@ -89,8 +89,8 @@ void gemm_impl(context& ctx, ...@@ -89,8 +89,8 @@ void gemm_impl(context& ctx,
MIGRAPHX_THROW("ROCBLAS_GEMM: k size of int8 type input must be mutlple of 4!"); MIGRAPHX_THROW("ROCBLAS_GEMM: k size of int8 type input must be mutlple of 4!");
} }
auto num_matrices = std::accumulate( auto num_matrices =
out_lens.rbegin() + 2, out_lens.rend(), int{1}, std::multiplies<int>()); std::accumulate(out_lens.rbegin() + 2, out_lens.rend(), int{1}, std::multiplies<int>());
if(num_matrices == 1) if(num_matrices == 1)
{ {
// the rocblas_gemm API handles inputs and output matrices as // the rocblas_gemm API handles inputs and output matrices as
......
...@@ -187,10 +187,7 @@ struct context ...@@ -187,10 +187,7 @@ struct context
hip_device::stream& get_stream(int n) { return get_current_device().get_stream(n); } hip_device::stream& get_stream(int n) { return get_current_device().get_stream(n); }
const hip_device::stream& get_stream() const { return get_current_device().get_stream(); } const hip_device::stream& get_stream() const { return get_current_device().get_stream(); }
const hip_device::stream& get_stream(int n) const const hip_device::stream& get_stream(int n) const { return get_current_device().get_stream(n); }
{
return get_current_device().get_stream(n);
}
void set_stream(int n) { get_current_device().set_stream(n); } void set_stream(int n) { get_current_device().set_stream(n); }
......
...@@ -29,10 +29,7 @@ struct kernel ...@@ -29,10 +29,7 @@ struct kernel
int local, int local,
const std::vector<kernel_argument>& args) const; const std::vector<kernel_argument>& args) const;
void launch(hipStream_t stream, void launch(hipStream_t stream, int global, int local, std::vector<void*> args) const;
int global,
int local,
std::vector<void*> args) const;
auto launch(hipStream_t stream, int global, int local) const auto launch(hipStream_t stream, int global, int local) const
{ {
......
...@@ -52,12 +52,8 @@ kernel::kernel(const char* image, const std::string& name) : impl(std::make_shar ...@@ -52,12 +52,8 @@ kernel::kernel(const char* image, const std::string& name) : impl(std::make_shar
MIGRAPHX_THROW("Failed to get function: " + name + ": " + hip_error(status)); MIGRAPHX_THROW("Failed to get function: " + name + ": " + hip_error(status));
} }
void launch_kernel(hipFunction_t fun, void launch_kernel(
hipStream_t stream, hipFunction_t fun, hipStream_t stream, int global, int local, void* kernargs, int size)
int global,
int local,
void* kernargs,
int size)
{ {
void* config[] = { void* config[] = {
// HIP_LAUNCH_PARAM_* are macros that do horrible things // HIP_LAUNCH_PARAM_* are macros that do horrible things
...@@ -78,10 +74,7 @@ void launch_kernel(hipFunction_t fun, ...@@ -78,10 +74,7 @@ void launch_kernel(hipFunction_t fun,
MIGRAPHX_THROW("Failed to launch kernel: " + hip_error(status)); MIGRAPHX_THROW("Failed to launch kernel: " + hip_error(status));
} }
void kernel::launch(hipStream_t stream, void kernel::launch(hipStream_t stream, int global, int local, std::vector<void*> args) const
int global,
int local,
std::vector<void*> args) const
{ {
assert(impl != nullptr); assert(impl != nullptr);
void* kernargs = args.data(); void* kernargs = args.data();
......
...@@ -43,10 +43,8 @@ struct avg_pool ...@@ -43,10 +43,8 @@ struct avg_pool
}; };
template <class T, class Op> template <class T, class Op>
MIGRAPHX_DEVICE_CONSTEXPR T bilinear_interpolate(const T* data, MIGRAPHX_DEVICE_CONSTEXPR T
const array<int, 2>& dims, bilinear_interpolate(const T* data, const array<int, 2>& dims, array<float, 2> xy, Op pooling)
array<float, 2> xy,
Op pooling)
{ {
array<int, 2> low{}; array<int, 2> low{};
array<int, 2> high{}; array<int, 2> high{};
......
...@@ -20,8 +20,14 @@ static auto make_mat(tensor_view<T> x) ...@@ -20,8 +20,14 @@ static auto make_mat(tensor_view<T> x)
int dim_0 = n_dims - 2; int dim_0 = n_dims - 2;
int dim_1 = n_dims - 1; int dim_1 = n_dims - 1;
if(s.transposed()) if(s.transposed())
return matrix<T>{x.data(), static_cast<std::size_t>(s.lens()[dim_1]), static_cast<std::size_t>(s.lens()[dim_0]), static_cast<std::size_t>(s.strides()[dim_1])}; return matrix<T>{x.data(),
return matrix<T>{x.data(), static_cast<std::size_t>(s.lens()[dim_0]), static_cast<std::size_t>(s.lens()[dim_1]), static_cast<std::size_t>(s.strides()[dim_0])}; static_cast<std::size_t>(s.lens()[dim_1]),
static_cast<std::size_t>(s.lens()[dim_0]),
static_cast<std::size_t>(s.strides()[dim_1])};
return matrix<T>{x.data(),
static_cast<std::size_t>(s.lens()[dim_0]),
static_cast<std::size_t>(s.lens()[dim_1]),
static_cast<std::size_t>(s.strides()[dim_0])};
} }
template <class T, class F> template <class T, class F>
......
...@@ -317,9 +317,7 @@ struct ref_im2col ...@@ -317,9 +317,7 @@ struct ref_im2col
// compute linear index for output // compute linear index for output
int ldx = ioutput * col_width + joutput; int ldx = ioutput * col_width + joutput;
int p = 0; int p = 0;
dfor(channels, dfor(channels, kernel_h, kernel_w)([&](int c, int koffset, int loffset) {
kernel_h,
kernel_w)([&](int c, int koffset, int loffset) {
auto idx = iinput + long(koffset) - kdiv2_h; auto idx = iinput + long(koffset) - kdiv2_h;
auto jdx = jinput + long(loffset) - kdiv2_w; auto jdx = jinput + long(loffset) - kdiv2_w;
col(ldx, p) = ((idx >= 0) && (idx < height) && (jdx >= 0) && (jdx < width)) col(ldx, p) = ((idx >= 0) && (idx < height) && (jdx >= 0) && (jdx < width))
......
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