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