Skip to content

Commit

Permalink
Changed all references and pointers to Handle to be const
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizztDoUrden committed Nov 22, 2024
1 parent d16aed9 commit c3f910d
Show file tree
Hide file tree
Showing 244 changed files with 720 additions and 704 deletions.
2 changes: 1 addition & 1 deletion src/adam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace miopen {

miopenStatus_t Adam(Handle& handle,
miopenStatus_t Adam(Handle const& handle,
const TensorDescriptor& paramInDesc,
ConstData_t paramIn,
const TensorDescriptor& paramOutDesc,
Expand Down
2 changes: 1 addition & 1 deletion src/addlayernorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace miopen {

miopenStatus_t AddLayerNormForward(Handle& handle,
miopenStatus_t AddLayerNormForward(Handle const& handle,
const TensorDescriptor& xDesc,
ConstData_t x,
const TensorDescriptor& x2Desc,
Expand Down
12 changes: 6 additions & 6 deletions src/batch_norm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ TensorDescriptor BuildReshaped4DTensorDescriptor(const miopen::TensorDescriptor&
return {dataType, layout, dims};
}

void profileSequence(const Handle& handle, unsigned char select, float* ctime)
void profileSequence(Handle const& handle, unsigned char select, float* ctime)
{

float ktime = 0.;
Expand Down Expand Up @@ -164,7 +164,7 @@ void profileSequence(const Handle& handle, unsigned char select, float* ctime)
}
}

void bnFwdTrainSelectMulti(const Handle& handle,
void bnFwdTrainSelectMulti(Handle const& handle,
miopenDataType_t dtype,
const std::string& program_name,
const std::string& algo_name,
Expand Down Expand Up @@ -280,7 +280,7 @@ void bnFwdTrainSelectMulti(const Handle& handle,
});
}

void bnFwdTrainSelectSingleEmpty(const Handle& handle,
void bnFwdTrainSelectSingleEmpty(Handle const& handle,
int variant,
miopenDataType_t dtype,
const std::string& program_name,
Expand Down Expand Up @@ -428,7 +428,7 @@ void bnFwdTrainSelectSingleEmpty(const Handle& handle,
});
}

void bnFwdTrainSelectSingleFull(const Handle& handle,
void bnFwdTrainSelectSingleFull(Handle const& handle,
int variant,
miopenDataType_t dtype,
const std::string& algo_name,
Expand Down Expand Up @@ -565,7 +565,7 @@ void bnFwdTrainSelectSingleFull(const Handle& handle,
}
}

void bnBwdTrainSelectSingle(const Handle& handle,
void bnBwdTrainSelectSingle(Handle const& handle,
miopenDataType_t dtype,
const std::string& program_name,
const std::string& algo_name,
Expand Down Expand Up @@ -601,7 +601,7 @@ void bnBwdTrainSelectSingle(const Handle& handle,
});
}

void bnBwdTrainSelectMulti(const Handle& handle,
void bnBwdTrainSelectMulti(Handle const& handle,
miopenDataType_t dtype,
const std::string& program_name,
const std::string& algo_name,
Expand Down
2 changes: 1 addition & 1 deletion src/cat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace miopen {

miopenStatus_t CatForward(Handle& handle,
miopenStatus_t CatForward(Handle const& handle,
int32_t xCount,
const TensorDescriptor* const* xDescs,
ConstData_t* xs,
Expand Down
6 changes: 3 additions & 3 deletions src/check_numerics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ std::string GetKernelName(miopenDataType_t data_type)
}

bool checkNumericsImpl(
const Handle& handle, int mode, const TensorDescriptor& dDesc, ConstData_t data, bool isInput)
Handle const& handle, int mode, const TensorDescriptor& dDesc, ConstData_t data, bool isInput)
{
int numElements = dDesc.GetElementSize();
CheckNumericsResult abnormal_h;
Expand Down Expand Up @@ -138,14 +138,14 @@ bool checkNumericsImpl(

// Checks data for input
// Returns: 1 if abnormal value (inf or nan) detected in specified data, 0 otherwise
bool checkNumericsInput(const Handle& handle, const TensorDescriptor& dDesc, ConstData_t data)
bool checkNumericsInput(Handle const& handle, const TensorDescriptor& dDesc, ConstData_t data)
{
return checkNumericsImpl(handle, env::value(MIOPEN_CHECK_NUMERICS), dDesc, data, true);
}

// Synchronizes to wait for kernel to finish, then checks data for output:
// Returns: 1 if abnormal value (inf or nan) detected in specified data, 0 otherwise
bool checkNumericsOutput(const Handle& handle, const TensorDescriptor& dDesc, ConstData_t data)
bool checkNumericsOutput(Handle const& handle, const TensorDescriptor& dDesc, ConstData_t data)
{
handle.Finish();
return checkNumericsImpl(handle, env::value(MIOPEN_CHECK_NUMERICS), dDesc, data, false);
Expand Down
2 changes: 1 addition & 1 deletion src/conv/invokers/gcn_asm_1x1u.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ InvokerFactory MakeGcnAsm1x1UInvokerFactory(int N, int C, int H, int W, int K, i

const auto kernel = kernels[0];

return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
const auto& params = primitive_parameters.CastTo<DataInvokeParams>();
const auto& tensors = params.tensors;
int unused = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/conv/invokers/gcn_asm_1x1u_ss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ InvokerFactory MakeGcnAsm1x1USSInvokerFactory(
const auto ss_kernel = kernels[0];
const auto kernel = kernels[1];

return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
const auto& params = primitive_parameters.CastTo<DataInvokeParams>();
const auto& tensors = params.tensors;
const auto& workSpace = params.workSpace;
Expand Down
2 changes: 1 addition & 1 deletion src/conv/invokers/gcn_asm_1x1u_us.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ InvokerFactory MakeGcnAsm1x1UUSInvokerFactory(
const auto kernel = kernels[0];
const auto us_kernel = kernels[1];

return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
const auto& params = primitive_parameters.CastTo<DataInvokeParams>();
const auto& tensors = params.tensors;
const auto& workSpace = params.workSpace;
Expand Down
2 changes: 1 addition & 1 deletion src/conv/invokers/gcn_asm_wino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ InvokerFactory MakeGcnAsmWinoV2InvokerFactory(const WinoShaderArgsV2& args,
}

return [=](const std::vector<Kernel>& kernels) {
return [=](const Handle& handle, const AnyInvokeParams& primitive_params) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_params) {
const auto k = handle.Run(kernels[0], coop_launch);

// pointers
Expand Down
2 changes: 1 addition & 1 deletion src/conv/invokers/gen_x_w_y_pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Invoker MakeGenericXWYPadInvoker(const std::vector<Kernel>& kernels)

const auto kernel = kernels[0];

return [kernel](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [kernel](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
const auto& params = primitive_parameters.CastTo<DataInvokeParams>();
const auto& tensors = params.tensors;
float padding_val = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/conv/invokers/impl_gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ InvokerFactory MakeImplGemmDataInvokerFactory(const ProblemDescription& problem)
if(problem.IsDirectionForward())
{
return [](const std::vector<Kernel>& kernels) {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
const auto& data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
handle.Run(kernels[0])(tensors.in, tensors.w, tensors.out);
Expand All @@ -31,7 +31,7 @@ InvokerFactory MakeImplGemmDataInvokerFactory(const ProblemDescription& problem)
const auto& lowp_quant = conv.lowp_quant;

return [conv, lowp_quant](const std::vector<Kernel>& kernels) {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
const auto& data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
const auto& workSpace = data_ctx.workSpace;
Expand Down
14 changes: 7 additions & 7 deletions src/conv/invokers/impl_gemm_dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static inline uint32_t igemm_find_tile_size_with_upper_bound(
return (out_size + n_tiles - 1) / n_tiles;
}

static float CallImplGemmDynamicForward1x1(const miopen::Handle& handle,
static float CallImplGemmDynamicForward1x1(miopen::Handle const& handle,
const ProblemDescription& problem,
ConstData_t src,
Data_t dst,
Expand Down Expand Up @@ -90,7 +90,7 @@ static float CallImplGemmDynamicForward1x1(const miopen::Handle& handle,
InvokerFactory MakeImplGemmDynamicForward1x1InvokerFactory(const ProblemDescription& problem)
{
return [problem](const std::vector<Kernel>& kernels) {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
decltype(auto) data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
auto kernel = handle.Run(kernels[0]);
Expand Down Expand Up @@ -184,7 +184,7 @@ InvokerFactory MakeImplGemmDynamicBackwardDataInvokerFactory(const ProblemDescri

return [=](const std::vector<Kernel>& kernels) {
const auto kernel = kernels[0];
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
decltype(auto) data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
float elapsed = 0;
Expand Down Expand Up @@ -362,7 +362,7 @@ MakeImplGemmDynamicBackwardDataInvokerFactory(const ProblemDescription& problem,

return [=](const std::vector<Kernel>& kernels) {
const auto kernel = kernels[0];
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) {
decltype(auto) data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
float elapsed = 0;
Expand Down Expand Up @@ -615,7 +615,7 @@ InvokerFactory MakeImplGemmDynamicForwardXdlopsNHWCInvokerFactory(
auto null_buf = shared<Data_t>{};

return [=](const std::vector<Kernel>& kernels) mutable {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) mutable {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) mutable {
decltype(auto) data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
const auto& workSpace = data_ctx.workSpace;
Expand Down Expand Up @@ -931,7 +931,7 @@ InvokerFactory MakeImplGemmDynamicBackwardDataXdlopsNHWCInvokerFactory(
auto null_buf = shared<Data_t>{};

return [=](const std::vector<Kernel>& kernels) mutable {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) mutable {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) mutable {
decltype(auto) data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
const auto& workSpace = data_ctx.workSpace;
Expand Down Expand Up @@ -1152,7 +1152,7 @@ InvokerFactory MakeImplGemmDynamicForwardDlopsNCHWCInvokerFactory(
opArgs.emplace_back(shift_pack_1);

return [=](const std::vector<Kernel>& kernels) mutable {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) mutable {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) mutable {
decltype(auto) data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
const auto ker = handle.Run(kernels[0]);
Expand Down
6 changes: 3 additions & 3 deletions src/conv/invokers/mlir_impl_gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ InvokerFactory MakeMlirFwdInvokerFactory(const ProblemDescription& problem)
}

return [=](const std::vector<Kernel>& kernels) mutable {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) mutable {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) mutable {
const auto& forward_invoke_params =
primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = forward_invoke_params.tensors;
Expand Down Expand Up @@ -370,7 +370,7 @@ InvokerFactory MakeMlirBwdInvokerFactory(const ProblemDescription& problem)
in_dims, in_strides, weights_dims, weights_strides, out_dims, out_strides, 0);

return [=](const std::vector<Kernel>& kernels) mutable {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) mutable {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) mutable {
float elapsed = 0.f;
const auto& data_ctx = primitive_parameters.CastTo<conv::DataInvokeParams>();
const auto& tensors = data_ctx.tensors;
Expand Down Expand Up @@ -425,7 +425,7 @@ InvokerFactory MakeMlirWrWInvokerFactory(const ProblemDescription& problem, size
in_dims, in_strides, weights_dims, weights_strides, out_dims, out_strides, workspace_req);

return [=](const std::vector<Kernel>& kernels) mutable {
return [=](const Handle& handle, const AnyInvokeParams& primitive_parameters) mutable {
return [=](Handle const& handle, const AnyInvokeParams& primitive_parameters) mutable {
float elapsed = 0.f;
const auto& wrw_invoke_params = primitive_parameters.CastTo<conv::WrWInvokeParams>();
const auto& tensors = wrw_invoke_params.tensors;
Expand Down
4 changes: 2 additions & 2 deletions src/conv/invokers/ocl_wrw_rdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ InvokerFactory MakeOclWrWRdcInvokerFactory(bool twoKernels, size_t workspaceSize
if(twoKernels)
{
return [workspaceSize](const std::vector<Kernel>& kernels) {
return [=](const Handle& handle, const AnyInvokeParams& primitive_params) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_params) {
const auto main_kernel = handle.Run(kernels[0]);
const auto& invoke_params = primitive_params.CastTo<WrWInvokeParams>();
const auto& tensors = invoke_params.tensors;
Expand Down Expand Up @@ -75,7 +75,7 @@ InvokerFactory MakeOclWrWRdcInvokerFactory(bool twoKernels, size_t workspaceSize
else
{
return [](const std::vector<Kernel>& kernels) {
return [=](const Handle& handle, const AnyInvokeParams& primitive_params) {
return [=](Handle const& handle, const AnyInvokeParams& primitive_params) {
const auto main_kernel = handle.Run(kernels[0]);
const auto& invoke_params = primitive_params.CastTo<conv::WrWInvokeParams>();
const auto& tensors = invoke_params.tensors;
Expand Down
2 changes: 1 addition & 1 deletion src/conv/solver_finders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const std::vector<std::unique_ptr<ISolversFinder>>& GetConvSolverFinders()
} // namespace conv

/// Register invoker only for the best solution within algorithm.
static std::vector<Solution> EvaluateInvokers(Handle& handle,
static std::vector<Solution> EvaluateInvokers(Handle const& handle,
const std::vector<solver::ConvSolution>& solutions,
const AlgorithmName& algorithm_name,
const NetworkConfig& network_config,
Expand Down
2 changes: 1 addition & 1 deletion src/ctc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CTCLossDescriptor::CTCLossDescriptor()
blank_label_id = 0;
}

size_t CTCLossDescriptor::GetCTCLossWorkspaceSize(Handle& handle,
size_t CTCLossDescriptor::GetCTCLossWorkspaceSize(Handle const& handle,
const TensorDescriptor& probsDesc,
const TensorDescriptor& gradientsDesc,
const int* labels,
Expand Down
12 changes: 7 additions & 5 deletions src/find_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ boost::optional<fs::path>& testing_find_db_path_override()

#if MIOPEN_EMBED_DB
template <class TDb>
fs::path FindDbRecord_t<TDb>::GetInstalledPathEmbed(Handle& handle, const std::string& path_suffix)
fs::path FindDbRecord_t<TDb>::GetInstalledPathEmbed(Handle const& handle,
const std::string& path_suffix)
{
static const auto embed_path = [&] {
const std::string ext = ".fdb.txt";
Expand Down Expand Up @@ -121,7 +122,8 @@ fs::path FindDbRecord_t<TDb>::GetInstalledPathEmbed(Handle& handle, const std::s
#else

template <class TDb>
fs::path FindDbRecord_t<TDb>::GetInstalledPathFile(Handle& handle, const std::string& path_suffix)
fs::path FindDbRecord_t<TDb>::GetInstalledPathFile(Handle const& handle,
const std::string& path_suffix)
{
static const auto installed_path = [&] {
const std::string ext = ".fdb.txt";
Expand Down Expand Up @@ -197,7 +199,7 @@ fs::path FindDbRecord_t<TDb>::GetInstalledPathFile(Handle& handle, const std::st
}
#endif
template <class TDb>
fs::path FindDbRecord_t<TDb>::GetInstalledPath(Handle& handle, const std::string& path_suffix)
fs::path FindDbRecord_t<TDb>::GetInstalledPath(Handle const& handle, const std::string& path_suffix)
{
#if !MIOPEN_DISABLE_SYSDB
#if MIOPEN_EMBED_DB
Expand All @@ -213,7 +215,7 @@ fs::path FindDbRecord_t<TDb>::GetInstalledPath(Handle& handle, const std::string
}

template <class TDb>
fs::path FindDbRecord_t<TDb>::GetUserPath(Handle& handle, const std::string& path_suffix)
fs::path FindDbRecord_t<TDb>::GetUserPath(Handle const& handle, const std::string& path_suffix)
{
#if !MIOPEN_DISABLE_USERDB
return GetUserDbPath() / (handle.GetDbBasename() + '.' + GetUserDbSuffix() +
Expand All @@ -226,7 +228,7 @@ fs::path FindDbRecord_t<TDb>::GetUserPath(Handle& handle, const std::string& pat
}

template <class TDb>
bool FindDbRecord_t<TDb>::Validate(Handle& handle, const NetworkConfig& config) const
bool FindDbRecord_t<TDb>::Validate(Handle const& handle, const NetworkConfig& config) const
{
auto unbuilt = false;
auto any = false;
Expand Down
Loading

0 comments on commit c3f910d

Please sign in to comment.