Skip to content

Commit

Permalink
Assign OpKernelArg() to opArgs vector, set proper ctest flag
Browse files Browse the repository at this point in the history
  • Loading branch information
carlushuang committed Jun 16, 2021
1 parent 66db338 commit a6ffe3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 38 deletions.
48 changes: 12 additions & 36 deletions src/conv/invokers/impl_gemm_dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ InvokerFactory MakeImplGemmDynamicForwardXdlopsNHWCInvokerFactory(
bool need_set_zero = config.gemm_k_global_split > 0;

std::vector<OpKernelArg> opArgs;
opArgs.emplace_back(static_cast<const void*>(nullptr)); // placeholder for input ptr
opArgs.emplace_back(static_cast<const void*>(nullptr)); // placeholder for weight ptr
opArgs.emplace_back(static_cast<void*>(nullptr)); // placeholder for output ptr
opArgs.emplace_back(0); // placeholder
opArgs.emplace_back(0); // placeholder
opArgs.emplace_back(0); // placeholder
opArgs.emplace_back(hi);
opArgs.emplace_back(wi);
opArgs.emplace_back(n);
Expand Down Expand Up @@ -511,21 +511,9 @@ InvokerFactory MakeImplGemmDynamicForwardXdlopsNHWCInvokerFactory(
const auto ker = handle.Run(kernels[0]);
float elapsed = 0;

#if MIOPEN_BACKEND_OPENCL
void* ptr_inp;
void* ptr_wei;
void* ptr_out;
clGetMemObjectInfo(tensors.in, CL_MEM_HOST_PTR, sizeof(ptr_inp), &ptr_inp, nullptr);
clGetMemObjectInfo(tensors.w, CL_MEM_HOST_PTR, sizeof(ptr_wei), &ptr_wei, nullptr);
clGetMemObjectInfo(tensors.out, CL_MEM_HOST_PTR, sizeof(ptr_out), &ptr_out, nullptr);
opArgs[0] = ptr_inp;
opArgs[1] = ptr_wei;
opArgs[2] = ptr_out;
#elif MIOPEN_BACKEND_HIP
opArgs[0] = static_cast<const void*>(tensors.in);
opArgs[1] = static_cast<const void*>(tensors.w);
opArgs[2] = static_cast<void*>(tensors.out);
#endif
opArgs[0] = OpKernelArg(tensors.in);
opArgs[1] = OpKernelArg(tensors.w);
opArgs[2] = OpKernelArg(tensors.out);

if(need_set_zero)
{
Expand Down Expand Up @@ -620,9 +608,9 @@ InvokerFactory MakeImplGemmDynamicBackwardDataXdlopsNHWCInvokerFactory(
need_set_zero |= config.gemm_k_global_split > 0;

std::vector<OpKernelArg> opArgs;
opArgs.emplace_back(static_cast<void*>(nullptr)); // placeholder for input ptr
opArgs.emplace_back(static_cast<const void*>(nullptr)); // placeholder for weight ptr
opArgs.emplace_back(static_cast<const void*>(nullptr)); // placeholder for output ptr
opArgs.emplace_back(0); // placeholder
opArgs.emplace_back(0); // placeholder
opArgs.emplace_back(0); // placeholder
opArgs.emplace_back(hi);
opArgs.emplace_back(wi);
opArgs.emplace_back(n);
Expand Down Expand Up @@ -670,21 +658,9 @@ InvokerFactory MakeImplGemmDynamicBackwardDataXdlopsNHWCInvokerFactory(
const auto ker = handle.Run(kernels[0]);
float elapsed = 0;

#if MIOPEN_BACKEND_OPENCL
void* ptr_inp;
void* ptr_wei;
void* ptr_out;
clGetMemObjectInfo(tensors.out, CL_MEM_HOST_PTR, sizeof(ptr_inp), &ptr_inp, nullptr);
clGetMemObjectInfo(tensors.w, CL_MEM_HOST_PTR, sizeof(ptr_wei), &ptr_wei, nullptr);
clGetMemObjectInfo(tensors.in, CL_MEM_HOST_PTR, sizeof(ptr_out), &ptr_out, nullptr);
opArgs[0] = ptr_inp;
opArgs[1] = ptr_wei;
opArgs[2] = ptr_out;
#elif MIOPEN_BACKEND_HIP
opArgs[0] = static_cast<void*>(tensors.out);
opArgs[1] = static_cast<const void*>(tensors.w);
opArgs[2] = static_cast<const void*>(tensors.in);
#endif
opArgs[0] = OpKernelArg(tensors.out);
opArgs[1] = OpKernelArg(tensors.w);
opArgs[2] = OpKernelArg(tensors.in);

if(need_set_zero)
{
Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ COMMAND ${DYNAMIC_IMPLICITGEMM_WRW_ENVS_XDLOPS} $<TARGET_FILE:test_conv2d> --ver
COMMAND ${DYNAMIC_IMPLICITGEMM_WRW_ENVS_XDLOPS} $<TARGET_FILE:test_conv2d> --verbose --half --input 1 1 8 8 --weights 1 1 2 2 --pads_strides_dilations 0 0 1 1 2 2 --disable-forward --disable-backward-data
COMMAND ${DYNAMIC_IMPLICITGEMM_WRW_ENVS_XDLOPS} $<TARGET_FILE:test_conv2d> --verbose --half --input 1 128 56 56 --weights 1 128 5 5 --pads_strides_dilations 0 0 2 2 1 1 --disable-forward --disable-backward-data
)
add_custom_test(test_conv_igemm_dynamic_xdlops_nhwc_fwd SKIP_UNLESS_ALL ALLOW_HALF
add_custom_test(test_conv_igemm_dynamic_xdlops_nhwc_fwd SKIP_UNLESS_ALL HALF_ENABLED GFX908_ENABLED VEGA_DISABLED
COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_FWD_ENVS} $<TARGET_FILE:test_conv2d> --verbose --input 64 256 7 7 --weights 128 256 1 1 --pads_strides_dilations 0 0 1 1 1 1 --disable-backward-data --disable-backward-weights --in_layout NHWC --fil_layout NHWC --out_layout NHWC
COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_FWD_ENVS} $<TARGET_FILE:test_conv2d> --verbose --input 32 160 73 73 --weights 64 160 1 1 --pads_strides_dilations 0 0 1 1 1 1 --disable-backward-data --disable-backward-weights --in_layout NHWC --fil_layout NHWC --out_layout NHWC
COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_FWD_ENVS} $<TARGET_FILE:test_conv2d> --verbose --input 16 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1 --disable-backward-data --disable-backward-weights --in_layout NHWC --fil_layout NHWC --out_layout NHWC
Expand All @@ -990,7 +990,7 @@ COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_FWD_ENVS} $<TARGET_FILE:test_conv2d>
COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_FWD_ENVS} $<TARGET_FILE:test_conv2d> --verbose --input 16 64 56 56 --weights 64 64 3 3 --pads_strides_dilations 1 1 1 1 1 1 --disable-backward-data --disable-backward-weights --in_layout NHWC --fil_layout NHWC --out_layout NHWC
COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_FWD_ENVS} $<TARGET_FILE:test_conv2d> --verbose --input 64 3 78 78 --weights 64 3 7 7 --pads_strides_dilations 0 0 2 2 1 1 --disable-backward-data --disable-backward-weights --in_layout NHWC --fil_layout NHWC --out_layout NHWC
)
add_custom_test(test_conv_igemm_dynamic_xdlops_nhwc_bwd SKIP_UNLESS_ALL ALLOW_HALF
add_custom_test(test_conv_igemm_dynamic_xdlops_nhwc_bwd SKIP_UNLESS_ALL HALF_ENABLED GFX908_ENABLED VEGA_DISABLED
COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_BWD_ENVS} $<TARGET_FILE:test_conv2d> --verbose --input 64 256 7 7 --weights 128 256 1 1 --pads_strides_dilations 0 0 1 1 1 1 --disable-forward --disable-backward-weights --in_layout NHWC --fil_layout NHWC --out_layout NHWC
COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_BWD_ENVS} $<TARGET_FILE:test_conv2d> --verbose --input 32 160 73 73 --weights 64 160 1 1 --pads_strides_dilations 0 0 1 1 1 1 --disable-forward --disable-backward-weights --in_layout NHWC --fil_layout NHWC --out_layout NHWC
COMMAND ${DYNAMIC_IMPLICITGEMM_XDLOPS_NHWC_BWD_ENVS} $<TARGET_FILE:test_conv2d> --verbose --input 16 64 56 56 --weights 64 64 1 1 --pads_strides_dilations 0 0 1 1 1 1 --disable-forward --disable-backward-weights --in_layout NHWC --fil_layout NHWC --out_layout NHWC
Expand Down

0 comments on commit a6ffe3b

Please sign in to comment.