"vscode:/vscode.git/clone" did not exist on "c5e52baa632878e2989d62d5888179f900b01c8b"
Commit 0aeeb4bb authored by wsttiger's avatar wsttiger
Browse files

Fixed up for clang-tidy and cppcheck and formatting

parent 7b55afee
...@@ -6,7 +6,7 @@ namespace migraph { ...@@ -6,7 +6,7 @@ namespace migraph {
namespace miopen { namespace miopen {
template <int NDIM> template <int NDIM>
struct HIPTensorDescriptor struct hip_tensor_descriptor
{ {
size_t lens[NDIM]; size_t lens[NDIM];
size_t strides[NDIM]; size_t strides[NDIM];
...@@ -24,21 +24,21 @@ __host__ __device__ void multiindex(size_t (&strides)[NDIM], size_t idx, size_t* ...@@ -24,21 +24,21 @@ __host__ __device__ void multiindex(size_t (&strides)[NDIM], size_t idx, size_t*
} }
template <typename T, int NDIM> template <typename T, int NDIM>
__global__ void contiguous_gpu(const T* A, __global__ void contiguous_gpu(const T* a,
HIPTensorDescriptor<NDIM> td_a, hip_tensor_descriptor<NDIM> a_desc,
T* At, T* at,
HIPTensorDescriptor<NDIM> td_at, hip_tensor_descriptor<NDIM> at_desc,
size_t nelements) size_t nelements)
{ {
for(size_t i = blockIdx.x * blockDim.x + threadIdx.x; i < nelements; for(size_t i = blockIdx.x * blockDim.x + threadIdx.x; i < nelements;
i += blockDim.x * gridDim.x) i += blockDim.x * gridDim.x)
{ {
size_t s[NDIM]; size_t s[NDIM];
multiindex<NDIM>(td_at.strides, i, s); multiindex<NDIM>(at_desc.strides, i, s);
size_t lidx = 0; size_t lidx = 0;
for(size_t j = 0; j < NDIM; j++) for(size_t j = 0; j < NDIM; j++)
lidx += s[j] * td_a.strides[j]; lidx += s[j] * a_desc.strides[j];
At[i] = A[lidx]; at[i] = a[lidx];
} }
} }
...@@ -48,12 +48,13 @@ void hip_contiguous(migraph::shape output_shape, migraph::argument arg, migraph: ...@@ -48,12 +48,13 @@ void hip_contiguous(migraph::shape output_shape, migraph::argument arg, migraph:
visit_all(result, arg)([&](auto output, auto input) { visit_all(result, arg)([&](auto output, auto input) {
if(ndim == 4) if(ndim == 4)
{ {
HIPTensorDescriptor<4> td_a, td_at; hip_tensor_descriptor<4> a_desc{};
auto s = arg.get_shape(); hip_tensor_descriptor<4> at_desc{};
const auto& s = arg.get_shape();
for(int i = 0; i < ndim; i++) for(int i = 0; i < ndim; i++)
{ {
td_a.strides[i] = s.strides().at(i); a_desc.strides[i] = s.strides().at(i);
td_at.strides[i] = output_shape.strides().at(i); at_desc.strides[i] = output_shape.strides().at(i);
} }
dim3 nblocks(512); dim3 nblocks(512);
dim3 nthreads(512); dim3 nthreads(512);
...@@ -61,11 +62,11 @@ void hip_contiguous(migraph::shape output_shape, migraph::argument arg, migraph: ...@@ -61,11 +62,11 @@ void hip_contiguous(migraph::shape output_shape, migraph::argument arg, migraph:
nblocks, nblocks,
nthreads, nthreads,
0, 0,
0, nullptr,
input.data(), input.data(),
td_a, a_desc,
output.data(), output.data(),
td_at, at_desc,
s.elements()); s.elements());
} }
else else
......
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