From 5d8038b1de8647651d12cbe4199779398eae2f88 Mon Sep 17 00:00:00 2001 From: Vasilii Filippov Date: Fri, 22 Nov 2024 15:50:22 +0100 Subject: [PATCH 1/7] Changed all references and pointers to Handle to be const --- src/adam.cpp | 2 +- src/addlayernorm.cpp | 2 +- src/cat.cpp | 2 +- src/conv/solver_finders.cpp | 2 +- src/ctc.cpp | 2 +- src/find_db.cpp | 12 ++-- src/fusion.cpp | 10 ++-- src/getitem.cpp | 4 +- src/glu.cpp | 4 +- src/groupnorm.cpp | 2 +- src/hip/handlehip.cpp | 2 +- src/include/miopen/activ.hpp | 4 +- src/include/miopen/adam.hpp | 4 +- src/include/miopen/addlayernorm.hpp | 2 +- src/include/miopen/batch_norm.hpp | 6 +- src/include/miopen/cat.hpp | 2 +- src/include/miopen/convolution.hpp | 22 +++---- src/include/miopen/ctc.hpp | 4 +- src/include/miopen/dropout.hpp | 2 +- src/include/miopen/execution_context.hpp | 8 +-- src/include/miopen/find_db.hpp | 16 ++--- src/include/miopen/find_solution.hpp | 2 +- src/include/miopen/fusion.hpp | 8 +-- src/include/miopen/fusion/context.hpp | 2 +- src/include/miopen/fusion_plan.hpp | 9 +-- src/include/miopen/getitem.hpp | 4 +- src/include/miopen/glu.hpp | 4 +- src/include/miopen/groupnorm.hpp | 2 +- src/include/miopen/handle.hpp | 21 +++---- src/include/miopen/kthvalue.hpp | 2 +- src/include/miopen/layernorm.hpp | 2 +- src/include/miopen/lrn.hpp | 4 +- src/include/miopen/mlo_internal.hpp | 2 +- src/include/miopen/multimarginloss.hpp | 4 +- src/include/miopen/pooling.hpp | 4 +- src/include/miopen/prelu.hpp | 4 +- src/include/miopen/problem.hpp | 16 ++--- src/include/miopen/reducecalculation.hpp | 4 +- src/include/miopen/reduceextreme.hpp | 4 +- src/include/miopen/rnn.hpp | 71 ++++++++++++----------- src/include/miopen/rnn/solvers.hpp | 6 +- src/include/miopen/rnn_util.hpp | 8 +-- src/include/miopen/rope.hpp | 4 +- src/include/miopen/softmarginloss.hpp | 6 +- src/include/miopen/softmax.hpp | 4 +- src/include/miopen/solution.hpp | 10 ++-- src/include/miopen/solver/gemm_common.hpp | 2 +- src/include/miopen/t5layernorm.hpp | 6 +- src/kthvalue.cpp | 2 +- src/layernorm.cpp | 2 +- src/multimarginloss.cpp | 4 +- src/nogpu/handle.cpp | 2 +- src/ocl/activ_ocl.cpp | 4 +- src/ocl/batchnormocl.cpp | 6 +- src/ocl/convolutionocl.cpp | 24 ++++---- src/ocl/ctcocl.cpp | 2 +- src/ocl/dropoutocl.cpp | 2 +- src/ocl/fusionopbiasbnactivocl.cpp | 4 +- src/ocl/handleocl.cpp | 2 +- src/ocl/lrn_ocl.cpp | 4 +- src/ocl/pooling_ocl.cpp | 4 +- src/ocl/rnnocl.cpp | 20 +++---- src/prelu.cpp | 4 +- src/problem.cpp | 15 ++--- src/reducecalculation.cpp | 4 +- src/reduceextreme.cpp | 4 +- src/rnn.cpp | 34 +++++------ src/rnn/Solutions/bwd_multi_stream.cpp | 2 +- src/rnn/Solutions/bwd_s_stream.cpp | 2 +- src/rnn/Solutions/fwd_s_stream.cpp | 3 +- src/rnn/Solutions/rnn_transformer.cpp | 6 +- src/rnn/selector.cpp | 6 +- src/rope.cpp | 4 +- src/softmarginloss.cpp | 6 +- src/softmax.cpp | 4 +- src/solution.cpp | 10 ++-- src/solver/conv/gemm_common.cpp | 2 +- src/t5layernorm.cpp | 6 +- src/transformers_adam_w.cpp | 2 +- test/conv_common.hpp | 4 +- test/cpu_rnn.hpp | 8 +-- test/dropout_util.hpp | 2 +- test/gru_common.hpp | 2 +- test/gtest/bad_fusion_plan.cpp | 2 +- test/gtest/bn_infer_fused_ocl_hip.cpp | 2 +- test/gtest/db_sync.cpp | 2 +- test/gtest/gpu_mha_backward.cpp | 4 +- test/gtest/gpu_mha_forward.cpp | 8 +-- test/gtest/graphapi_capi_mha_backward.cpp | 4 +- test/gtest/graphapi_capi_mha_common.hpp | 18 +++--- test/gtest/graphapi_capi_mha_forward.cpp | 8 +-- test/gtest/gtest_activation.cpp | 4 +- test/gtest/gtest_common.cpp | 5 +- test/gtest/hipblaslt_gemm.cpp | 4 +- test/gtest/mha_find20.cpp | 18 +++--- test/gtest/perf_helper.hpp | 2 +- test/gtest/softmax_find20.cpp | 12 ++-- test/gtest/test_operations.hpp | 2 +- test/handle_test.cpp | 2 +- test/rnn_seq_api.hpp | 10 ++-- test/rnn_vanilla_common.hpp | 2 +- test/workspace.hpp | 2 +- 102 files changed, 334 insertions(+), 318 deletions(-) diff --git a/src/adam.cpp b/src/adam.cpp index fedc32791d..032ba4628a 100644 --- a/src/adam.cpp +++ b/src/adam.cpp @@ -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, diff --git a/src/addlayernorm.cpp b/src/addlayernorm.cpp index 271c81ca60..4ee6787a39 100644 --- a/src/addlayernorm.cpp +++ b/src/addlayernorm.cpp @@ -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, diff --git a/src/cat.cpp b/src/cat.cpp index 85e8e89ea7..3bf736a593 100644 --- a/src/cat.cpp +++ b/src/cat.cpp @@ -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, diff --git a/src/conv/solver_finders.cpp b/src/conv/solver_finders.cpp index 43d5e72031..bf65aaae4f 100644 --- a/src/conv/solver_finders.cpp +++ b/src/conv/solver_finders.cpp @@ -214,7 +214,7 @@ const std::vector>& GetConvSolverFinders() } // namespace conv /// Register invoker only for the best solution within algorithm. -static std::vector EvaluateInvokers(Handle& handle, +static std::vector EvaluateInvokers(Handle const& handle, const std::vector& solutions, const AlgorithmName& algorithm_name, const NetworkConfig& network_config, diff --git a/src/ctc.cpp b/src/ctc.cpp index 4cc3ffe1b0..05e6d72688 100644 --- a/src/ctc.cpp +++ b/src/ctc.cpp @@ -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, diff --git a/src/find_db.cpp b/src/find_db.cpp index 6c493a5b62..e13814380a 100644 --- a/src/find_db.cpp +++ b/src/find_db.cpp @@ -55,7 +55,8 @@ boost::optional& testing_find_db_path_override() #if MIOPEN_EMBED_DB template -fs::path FindDbRecord_t::GetInstalledPathEmbed(Handle& handle, const std::string& path_suffix) +fs::path FindDbRecord_t::GetInstalledPathEmbed(Handle const& handle, + const std::string& path_suffix) { static const auto embed_path = [&] { const std::string ext = ".fdb.txt"; @@ -121,7 +122,8 @@ fs::path FindDbRecord_t::GetInstalledPathEmbed(Handle& handle, const std::s #else template -fs::path FindDbRecord_t::GetInstalledPathFile(Handle& handle, const std::string& path_suffix) +fs::path FindDbRecord_t::GetInstalledPathFile(Handle const& handle, + const std::string& path_suffix) { static const auto installed_path = [&] { const std::string ext = ".fdb.txt"; @@ -197,7 +199,7 @@ fs::path FindDbRecord_t::GetInstalledPathFile(Handle& handle, const std::st } #endif template -fs::path FindDbRecord_t::GetInstalledPath(Handle& handle, const std::string& path_suffix) +fs::path FindDbRecord_t::GetInstalledPath(Handle const& handle, const std::string& path_suffix) { #if !MIOPEN_DISABLE_SYSDB #if MIOPEN_EMBED_DB @@ -213,7 +215,7 @@ fs::path FindDbRecord_t::GetInstalledPath(Handle& handle, const std::string } template -fs::path FindDbRecord_t::GetUserPath(Handle& handle, const std::string& path_suffix) +fs::path FindDbRecord_t::GetUserPath(Handle const& handle, const std::string& path_suffix) { #if !MIOPEN_DISABLE_USERDB return GetUserDbPath() / (handle.GetDbBasename() + '.' + GetUserDbSuffix() + @@ -226,7 +228,7 @@ fs::path FindDbRecord_t::GetUserPath(Handle& handle, const std::string& pat } template -bool FindDbRecord_t::Validate(Handle& handle, const NetworkConfig& config) const +bool FindDbRecord_t::Validate(Handle const& handle, const NetworkConfig& config) const { auto unbuilt = false; auto any = false; diff --git a/src/fusion.cpp b/src/fusion.cpp index 5541409a67..fc5db7ca56 100644 --- a/src/fusion.cpp +++ b/src/fusion.cpp @@ -54,7 +54,7 @@ namespace miopen { -miopenStatus_t ConvBiasActivFusion(Handle& handle, +miopenStatus_t ConvBiasActivFusion(Handle const& handle, const void* alpha1, const TensorDescriptor& xDesc, ConstData_t x, @@ -137,7 +137,7 @@ miopenStatus_t ConvBiasActivFusion(Handle& handle, } static auto -AllocateBuffersAndMakeFusionInvokeParams(Handle& handle, +AllocateBuffersAndMakeFusionInvokeParams(Handle const& handle, const FusionDescription& problem, std::vector& invoke_bufs, miopen::OperatorArgs& params, @@ -490,7 +490,7 @@ TensorDescriptor FusionPlanDescriptor::FusionPlanDescriptor::DeriveOutputDescrip return o_desc; } -miopenStatus_t FusionPlanDescriptor::GetWorkspaceSizeImmed(Handle& handle, +miopenStatus_t FusionPlanDescriptor::GetWorkspaceSizeImmed(Handle const& handle, size_t& workSpaceSize, miopenConvFwdAlgorithm_t /*algo*/) { @@ -969,7 +969,7 @@ std::vector GetSolutions(const FusionContext& ctx, } // namespace -miopenStatus_t FusionPlanDescriptor::Compile(Handle& handle) +miopenStatus_t FusionPlanDescriptor::Compile(Handle const& handle) { std::vector invoke_bufs; miopen::OperatorArgs params; @@ -1097,7 +1097,7 @@ miopenStatus_t FusionPlanDescriptor::Compile(Handle& handle) } std::vector -FusionPlanDescriptor::Find(Handle& handle, +FusionPlanDescriptor::Find(Handle const& handle, const std::function& invoke_params, const std::optional& options) const { diff --git a/src/getitem.cpp b/src/getitem.cpp index c3b1b0c3bc..434e6c6023 100644 --- a/src/getitem.cpp +++ b/src/getitem.cpp @@ -35,7 +35,7 @@ namespace miopen { -std::size_t GetGetitemWorkspaceSize(Handle& handle, +std::size_t GetGetitemWorkspaceSize(Handle const& handle, uint32_t indexCount, const TensorDescriptor* const* indexDescs) { @@ -50,7 +50,7 @@ std::size_t GetGetitemWorkspaceSize(Handle& handle, return pair_size_vector.empty() ? static_cast(0) : pair_size_vector.front().second; } -miopenStatus_t GetitemBackward(Handle& handle, +miopenStatus_t GetitemBackward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& dyDesc, diff --git a/src/glu.cpp b/src/glu.cpp index 9d1181d32e..24a2930006 100644 --- a/src/glu.cpp +++ b/src/glu.cpp @@ -37,7 +37,7 @@ namespace miopen { namespace glu { -miopenStatus_t GLUForward(Handle& handle, +miopenStatus_t GLUForward(Handle const& handle, const TensorDescriptor& inputDesc, ConstData_t input, const TensorDescriptor& outputDesc, @@ -65,7 +65,7 @@ miopenStatus_t GLUForward(Handle& handle, return miopenStatusSuccess; } -miopenStatus_t GLUBackward(Handle& handle, +miopenStatus_t GLUBackward(Handle const& handle, const TensorDescriptor& inputDesc, ConstData_t input, const TensorDescriptor& outputGradDesc, diff --git a/src/groupnorm.cpp b/src/groupnorm.cpp index 2cf21102af..48f320f0f7 100644 --- a/src/groupnorm.cpp +++ b/src/groupnorm.cpp @@ -33,7 +33,7 @@ namespace miopen { -miopenStatus_t GroupNormForward(Handle& handle, +miopenStatus_t GroupNormForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& weightDesc, diff --git a/src/hip/handlehip.cpp b/src/hip/handlehip.cpp index 5b1852c7cd..d65e5fd8e7 100644 --- a/src/hip/handlehip.cpp +++ b/src/hip/handlehip.cpp @@ -755,7 +755,7 @@ std::size_t Handle::GetWavefrontWidth() const // No HIP API that could return maximum memory allocation size // for a single object. -std::size_t Handle::GetMaxMemoryAllocSize() +std::size_t Handle::GetMaxMemoryAllocSize() const { if(m_MaxMemoryAllocSizeCached == 0) { diff --git a/src/include/miopen/activ.hpp b/src/include/miopen/activ.hpp index 26ce91112f..a98b691f3e 100644 --- a/src/include/miopen/activ.hpp +++ b/src/include/miopen/activ.hpp @@ -50,7 +50,7 @@ struct MIOPEN_INTERNALS_EXPORT ActivationDescriptor : miopenActivationDescriptor double GetBeta() const; double GetGamma() const; - miopenStatus_t Forward(Handle& handle, + miopenStatus_t Forward(Handle const& handle, const void* alpha, const TensorDescriptor& xDesc, ConstData_t x, @@ -60,7 +60,7 @@ struct MIOPEN_INTERNALS_EXPORT ActivationDescriptor : miopenActivationDescriptor size_t xOffset = 0, size_t yOffset = 0) const; - miopenStatus_t Backward(Handle& handle, + miopenStatus_t Backward(Handle const& handle, const void* alpha, const TensorDescriptor& yDesc, ConstData_t y, diff --git a/src/include/miopen/adam.hpp b/src/include/miopen/adam.hpp index 05e22aa5be..d5596b4d59 100644 --- a/src/include/miopen/adam.hpp +++ b/src/include/miopen/adam.hpp @@ -33,7 +33,7 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT miopenStatus_t Adam(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t Adam(Handle const& handle, const TensorDescriptor& paramInDesc, ConstData_t paramIn, const TensorDescriptor& paramOutDesc, @@ -74,7 +74,7 @@ MIOPEN_INTERNALS_EXPORT miopenStatus_t Adam(Handle& handle, bool is_amp); MIOPEN_INTERNALS_EXPORT miopenStatus_t -TransformersAdamW(Handle& handle, +TransformersAdamW(Handle const& handle, const TensorDescriptor& paramInDesc, ConstData_t paramIn, const TensorDescriptor& paramOutDesc, diff --git a/src/include/miopen/addlayernorm.hpp b/src/include/miopen/addlayernorm.hpp index d70587193c..53f3429c6a 100644 --- a/src/include/miopen/addlayernorm.hpp +++ b/src/include/miopen/addlayernorm.hpp @@ -33,7 +33,7 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT miopenStatus_t AddLayerNormForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t AddLayerNormForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& x2Desc, diff --git a/src/include/miopen/batch_norm.hpp b/src/include/miopen/batch_norm.hpp index 92444f039b..d61546614f 100644 --- a/src/include/miopen/batch_norm.hpp +++ b/src/include/miopen/batch_norm.hpp @@ -163,7 +163,7 @@ void bnFwdTrainSelectMulti(const Handle& handle, void profileSequence(const Handle& handle, unsigned char select, float* ctime); -MIOPEN_INTERNALS_EXPORT void BatchNormForwardInference(Handle& handle, +MIOPEN_INTERNALS_EXPORT void BatchNormForwardInference(Handle const& handle, miopenBatchNormMode_t bn_mode, const void* alpha, const void* beta, @@ -181,7 +181,7 @@ MIOPEN_INTERNALS_EXPORT void BatchNormForwardInference(Handle& handle, ConstData_t estimatedVariance, double epsilon); -MIOPEN_INTERNALS_EXPORT void BatchNormForwardTraining(Handle& handle, +MIOPEN_INTERNALS_EXPORT void BatchNormForwardTraining(Handle const& handle, miopenBatchNormMode_t bn_mode, const void* alpha, const void* beta, @@ -202,7 +202,7 @@ MIOPEN_INTERNALS_EXPORT void BatchNormForwardTraining(Handle& handle, Data_t resultSaveMean, Data_t resultSaveInvVariance); -MIOPEN_INTERNALS_EXPORT void BatchNormBackward(Handle& handle, +MIOPEN_INTERNALS_EXPORT void BatchNormBackward(Handle const& handle, miopenBatchNormMode_t bn_mode, const void* alphaDataDiff, const void* betaDataDiff, diff --git a/src/include/miopen/cat.hpp b/src/include/miopen/cat.hpp index 70e4f7361a..dcc15f6ce1 100644 --- a/src/include/miopen/cat.hpp +++ b/src/include/miopen/cat.hpp @@ -33,7 +33,7 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT miopenStatus_t CatForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t CatForward(Handle const& handle, int32_t xCount, const TensorDescriptor* const* xDescs, ConstData_t* xs, diff --git a/src/include/miopen/convolution.hpp b/src/include/miopen/convolution.hpp index 88368ac95e..d8dc95f40b 100644 --- a/src/include/miopen/convolution.hpp +++ b/src/include/miopen/convolution.hpp @@ -197,7 +197,7 @@ struct MIOPEN_INTERNALS_EXPORT ConvolutionDescriptor : miopenConvolutionDescript std::size_t GetWorkSpaceSize(ExecutionContext ctx, const conv::ProblemDescription& problem) const; - void FindConvFwdAlgorithm(Handle& handle, + void FindConvFwdAlgorithm(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& wDesc, @@ -211,7 +211,7 @@ struct MIOPEN_INTERNALS_EXPORT ConvolutionDescriptor : miopenConvolutionDescript std::size_t workSpaceSize, bool exhaustiveSearch) const; - void ConvolutionForward(Handle& handle, + void ConvolutionForward(Handle const& handle, const void* alpha, const TensorDescriptor& xDesc, ConstData_t x, @@ -238,13 +238,13 @@ struct MIOPEN_INTERNALS_EXPORT ConvolutionDescriptor : miopenConvolutionDescript const conv::ProblemDescription& problem, solver::Id solver_id) const; - std::size_t GetForwardSolutionWorkspaceSize(Handle& handle, + std::size_t GetForwardSolutionWorkspaceSize(Handle const& handle, const TensorDescriptor& wDesc, const TensorDescriptor& xDesc, const TensorDescriptor& yDesc, solver::Id solver_id) const; - void ConvolutionForwardImmediate(Handle& handle, + void ConvolutionForwardImmediate(Handle const& handle, const TensorDescriptor& wDesc, ConstData_t w, const TensorDescriptor& xDesc, @@ -255,7 +255,7 @@ struct MIOPEN_INTERNALS_EXPORT ConvolutionDescriptor : miopenConvolutionDescript std::size_t workSpaceSize, solver::Id solver_id) const; - void FindConvBwdDataAlgorithm(Handle& handle, + void FindConvBwdDataAlgorithm(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& wDesc, @@ -269,7 +269,7 @@ struct MIOPEN_INTERNALS_EXPORT ConvolutionDescriptor : miopenConvolutionDescript std::size_t workSpaceSize, bool exhaustiveSearch) const; - void ConvolutionBackwardData(Handle& handle, + void ConvolutionBackwardData(Handle const& handle, const void* alpha, const TensorDescriptor& dyDesc, ConstData_t dy, @@ -282,13 +282,13 @@ struct MIOPEN_INTERNALS_EXPORT ConvolutionDescriptor : miopenConvolutionDescript Data_t workSpace, std::size_t workSpaceSize) const; - std::size_t GetBackwardSolutionWorkspaceSize(Handle& handle, + std::size_t GetBackwardSolutionWorkspaceSize(Handle const& handle, const TensorDescriptor& dyDesc, const TensorDescriptor& wDesc, const TensorDescriptor& dxDesc, solver::Id solver_id) const; - void ConvolutionBackwardImmediate(Handle& handle, + void ConvolutionBackwardImmediate(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& wDesc, @@ -299,13 +299,13 @@ struct MIOPEN_INTERNALS_EXPORT ConvolutionDescriptor : miopenConvolutionDescript std::size_t workSpaceSize, solver::Id solver_id) const; - std::size_t GetWrwSolutionWorkspaceSize(Handle& handle, + std::size_t GetWrwSolutionWorkspaceSize(Handle const& handle, const TensorDescriptor& dyDesc, const TensorDescriptor& xDesc, const TensorDescriptor& dwDesc, solver::Id solver_id) const; - void ConvolutionWrwImmediate(Handle& handle, + void ConvolutionWrwImmediate(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& xDesc, @@ -316,7 +316,7 @@ struct MIOPEN_INTERNALS_EXPORT ConvolutionDescriptor : miopenConvolutionDescript std::size_t workSpaceSize, solver::Id solver_id) const; - void FindConvBwdWeightsAlgorithm(Handle& handle, + void FindConvBwdWeightsAlgorithm(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& xDesc, diff --git a/src/include/miopen/ctc.hpp b/src/include/miopen/ctc.hpp index f57db4b609..eb763a9ded 100644 --- a/src/include/miopen/ctc.hpp +++ b/src/include/miopen/ctc.hpp @@ -48,7 +48,7 @@ struct MIOPEN_INTERNALS_EXPORT CTCLossDescriptor : miopenCTCLossDescriptor bool apply_softmax_layer; int blank_label_id; - size_t GetCTCLossWorkspaceSize(Handle& handle, + size_t GetCTCLossWorkspaceSize(Handle const& handle, const TensorDescriptor& probsDesc, const TensorDescriptor& gradientsDesc, const int* labels, @@ -56,7 +56,7 @@ struct MIOPEN_INTERNALS_EXPORT CTCLossDescriptor : miopenCTCLossDescriptor const int* inputLengths, miopenCTCLossAlgo_t algo) const; - void CTCLoss(Handle& handle, + void CTCLoss(Handle const& handle, const TensorDescriptor& probsDesc, ConstData_t probs, const int* labels, diff --git a/src/include/miopen/dropout.hpp b/src/include/miopen/dropout.hpp index b332f87690..353cdd687b 100644 --- a/src/include/miopen/dropout.hpp +++ b/src/include/miopen/dropout.hpp @@ -68,7 +68,7 @@ struct MIOPEN_INTERNALS_EXPORT DropoutDescriptor : miopenDropoutDescriptor miopenDataType_t dataType_; - void InitPRNGState(Handle& handle, + void InitPRNGState(Handle const& handle, Data_t prng_states, size_t prng_stateSizeInBytes, unsigned long long prng_seed) const; diff --git a/src/include/miopen/execution_context.hpp b/src/include/miopen/execution_context.hpp index 32660006ae..444fd3ef54 100644 --- a/src/include/miopen/execution_context.hpp +++ b/src/include/miopen/execution_context.hpp @@ -98,11 +98,11 @@ struct MIOPEN_INTERNALS_EXPORT ExecutionContext bool use_dynamic_solutions_only = false; bool is_for_generic_search = false; - inline Handle& GetStream() const { return *stream; } - inline void SetStream(Handle* stream_) { stream = stream_; } + inline Handle const& GetStream() const { return *stream; } + inline void SetStream(Handle const* stream_) { stream = stream_; } ExecutionContext() { DetectRocm(); } - ExecutionContext(Handle* stream_) : stream(stream_) { DetectRocm(); } + ExecutionContext(Handle const* stream_) : stream(stream_) { DetectRocm(); } virtual ~ExecutionContext() = default; ExecutionContext(const ExecutionContext&) = default; @@ -293,7 +293,7 @@ struct MIOPEN_INTERNALS_EXPORT ExecutionContext } private: - Handle* stream = nullptr; + Handle const* stream = nullptr; void DetectRocm(); }; diff --git a/src/include/miopen/find_db.hpp b/src/include/miopen/find_db.hpp index a5c1b806bd..ead0746665 100644 --- a/src/include/miopen/find_db.hpp +++ b/src/include/miopen/find_db.hpp @@ -90,7 +90,7 @@ class FindDbRecord_t FindDbRecord_t& operator=(const FindDbRecord_t&) = delete; template - FindDbRecord_t(Handle& handle, + FindDbRecord_t(Handle const& handle, const TProblemDescription& problem, const std::string& path_suffix = "", is_immediate_t = 0) @@ -111,7 +111,7 @@ class FindDbRecord_t } template - FindDbRecord_t(Handle& handle, + FindDbRecord_t(Handle const& handle, const TProblemDescription& problem, const std::string& path_suffix = "", is_find_t = 0) @@ -147,7 +147,7 @@ class FindDbRecord_t bool empty() const { return !content.is_initialized(); } template - static std::vector TryLoad(Handle& handle, + static std::vector TryLoad(Handle const& handle, const TProblemDescription& problem, const std::function& regenerator, const std::string& path_suffix = "") @@ -192,13 +192,13 @@ class FindDbRecord_t bool in_sync = false; bool dont_store = false; // E.g. to skip writing sub-optimal find-db records to disk. - static fs::path GetInstalledPath(Handle& handle, const std::string& path_suffix); - static fs::path GetInstalledPathEmbed(Handle& handle, const std::string& path_suffix); - static fs::path GetInstalledPathFile(Handle& handle, const std::string& path_suffix); - static fs::path GetUserPath(Handle& handle, const std::string& path_suffix); + static fs::path GetInstalledPath(Handle const& handle, const std::string& path_suffix); + static fs::path GetInstalledPathEmbed(Handle const& handle, const std::string& path_suffix); + static fs::path GetInstalledPathFile(Handle const& handle, const std::string& path_suffix); + static fs::path GetUserPath(Handle const& handle, const std::string& path_suffix); // Returns true if rebuild is required - bool Validate(Handle& handle, const NetworkConfig& config) const; + bool Validate(Handle const& handle, const NetworkConfig& config) const; void CopyTo(std::vector& to) const; void LogFindDbItem(const std::pair& item) const; diff --git a/src/include/miopen/find_solution.hpp b/src/include/miopen/find_solution.hpp index 30735cd38a..ab412faf34 100644 --- a/src/include/miopen/find_solution.hpp +++ b/src/include/miopen/find_solution.hpp @@ -503,7 +503,7 @@ struct SolverContainer } template - void ExecutePrimitive(Handle& handle, + void ExecutePrimitive(Handle const& handle, const Problem& problem, const AlgorithmName& algo, const AnyInvokeParams& invoke_params) const diff --git a/src/include/miopen/fusion.hpp b/src/include/miopen/fusion.hpp index babf192b74..b260c7230c 100644 --- a/src/include/miopen/fusion.hpp +++ b/src/include/miopen/fusion.hpp @@ -142,8 +142,8 @@ struct MIOPEN_INTERNALS_EXPORT BatchNormInferenceFusionOpDescriptor : FusionOpDe ConstData_t estimatedVariance, double epsilon) const; miopenFusionOp_t kind() const override { return miopenFusionOpBatchNormInference; }; - std::vector GetLocalWGSz(Handle& handle, std::string algorithm_name); - std::vector GetGlobalWGSz(Handle& handle, std::string algorithm_name); + std::vector GetLocalWGSz(Handle const& handle, std::string algorithm_name); + std::vector GetGlobalWGSz(Handle const& handle, std::string algorithm_name); miopenBatchNormMode_t mode; TensorDescriptor base_desc; @@ -228,7 +228,7 @@ struct MIOPEN_INTERNALS_EXPORT ConvForwardOpDescriptor : FusionOpDescriptor miopenStatus_t SetArgs(OperatorArgs& args, const void* alpha, const void* beta, ConstData_t w); // miopenStatus_t SetArgs(OperatorArgs& args, float alpha, float beta, ConstData_t w); miopenStatus_t GetNetworkConfig(std::ostringstream& network_config) override; - bool isASMApplicable(Handle& handle); + bool isASMApplicable(Handle const& handle); miopenFusionOp_t kind() const override { return miopenFusionOpConvForward; }; ConvolutionDescriptor base_desc; @@ -242,7 +242,7 @@ struct MIOPEN_INTERNALS_EXPORT ConvForwardOpDescriptor : FusionOpDescriptor }; MIOPEN_INTERNALS_EXPORT -miopenStatus_t ConvBiasActivFusion(Handle& handle, +miopenStatus_t ConvBiasActivFusion(Handle const& handle, const void* alpha1, const TensorDescriptor& xDesc, ConstData_t x, diff --git a/src/include/miopen/fusion/context.hpp b/src/include/miopen/fusion/context.hpp index 6f5ea25b2d..c28cb181f3 100644 --- a/src/include/miopen/fusion/context.hpp +++ b/src/include/miopen/fusion/context.hpp @@ -35,7 +35,7 @@ struct Handle; struct FusionContext : ExecutionContext { - explicit FusionContext(Handle& handle) : ExecutionContext(&handle) {} + explicit FusionContext(Handle const& handle) : ExecutionContext(&handle) {} explicit FusionContext(const ExecutionContext& ctx) : ExecutionContext(ctx) {} ExecutionContext GetConvContext(const conv::ProblemDescription& conv_problem) const diff --git a/src/include/miopen/fusion_plan.hpp b/src/include/miopen/fusion_plan.hpp index 439e58a80d..9b7a262db3 100644 --- a/src/include/miopen/fusion_plan.hpp +++ b/src/include/miopen/fusion_plan.hpp @@ -50,16 +50,17 @@ struct MIOPEN_INTERNALS_EXPORT FusionPlanDescriptor : miopenFusionPlanDescriptor bool isValid() const { return is_valid; }; miopenStatus_t AddOp(std::shared_ptr desc); TensorDescriptor DeriveOutputDescriptor(); - miopenStatus_t - GetWorkspaceSizeImmed(Handle& handle, size_t& workSpaceSize, miopenConvFwdAlgorithm_t algo); + miopenStatus_t GetWorkspaceSizeImmed(Handle const& handle, + size_t& workSpaceSize, + miopenConvFwdAlgorithm_t algo); miopenStatus_t Execute(const Handle& handle, const TensorDescriptor& inputDesc, ConstData_t input, const TensorDescriptor& outputDesc, Data_t output, const OperatorArgs& op_args); - miopenStatus_t Compile(Handle& handle); - std::vector Find(Handle& handle, + miopenStatus_t Compile(Handle const& handle); + std::vector Find(Handle const& handle, const std::function& invoke_params, const std::optional& options = std::nullopt) const; friend std::ostream& operator<<(std::ostream& stream, const FusionPlanDescriptor& fpd); diff --git a/src/include/miopen/getitem.hpp b/src/include/miopen/getitem.hpp index 191b1dba97..cce74246c4 100644 --- a/src/include/miopen/getitem.hpp +++ b/src/include/miopen/getitem.hpp @@ -34,9 +34,9 @@ struct Handle; struct TensorDescriptor; MIOPEN_INTERNALS_EXPORT std::size_t GetGetitemWorkspaceSize( - Handle& handle, uint32_t indexCount, const TensorDescriptor* const* indexDescs); + Handle const& handle, uint32_t indexCount, const TensorDescriptor* const* indexDescs); -MIOPEN_INTERNALS_EXPORT miopenStatus_t GetitemBackward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t GetitemBackward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& dyDesc, diff --git a/src/include/miopen/glu.hpp b/src/include/miopen/glu.hpp index 448929ef94..59162debe5 100644 --- a/src/include/miopen/glu.hpp +++ b/src/include/miopen/glu.hpp @@ -34,14 +34,14 @@ struct TensorDescriptor; namespace glu { -MIOPEN_INTERNALS_EXPORT miopenStatus_t GLUForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t GLUForward(Handle const& handle, const TensorDescriptor& inputDesc, ConstData_t input, const TensorDescriptor& outputDesc, Data_t output, uint32_t dim); -MIOPEN_INTERNALS_EXPORT miopenStatus_t GLUBackward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t GLUBackward(Handle const& handle, const TensorDescriptor& inputDesc, ConstData_t input, const TensorDescriptor& outputGradDesc, diff --git a/src/include/miopen/groupnorm.hpp b/src/include/miopen/groupnorm.hpp index 68ed8a866c..5202525b44 100644 --- a/src/include/miopen/groupnorm.hpp +++ b/src/include/miopen/groupnorm.hpp @@ -34,7 +34,7 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT miopenStatus_t GroupNormForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t GroupNormForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& weightDesc, diff --git a/src/include/miopen/handle.hpp b/src/include/miopen/handle.hpp index 5e6dc5f793..99f412910d 100644 --- a/src/include/miopen/handle.hpp +++ b/src/include/miopen/handle.hpp @@ -164,8 +164,8 @@ struct MIOPEN_EXPORT Handle : miopenHandle return StartsWith(name, "gfx1") ? num_cu * 2 /* CUs per WGP */ : num_cu; } - std::size_t m_MaxMemoryAllocSizeCached = 0; - virtual std::size_t GetMaxMemoryAllocSize(); + mutable std::size_t m_MaxMemoryAllocSizeCached = 0; + virtual std::size_t GetMaxMemoryAllocSize() const; virtual bool CooperativeLaunchSupported() const; virtual std::string GetDeviceName() const; @@ -190,13 +190,13 @@ struct MIOPEN_EXPORT Handle : miopenHandle #endif template - Allocator::ManageDataPtr Create(std::size_t sz) + Allocator::ManageDataPtr Create(std::size_t sz) const { return this->Create(sz * sizeof(T)); } template - Allocator::ManageDataPtr Write(const Container& c) + Allocator::ManageDataPtr Write(const Container& c) const { assert(!c.empty()); using type = typename Container::value_type; @@ -206,7 +206,7 @@ struct MIOPEN_EXPORT Handle : miopenHandle } template - std::vector Read(const Allocator::ManageDataPtr& ddata, std::size_t sz) + std::vector Read(const Allocator::ManageDataPtr& ddata, std::size_t sz) const { std::vector result(sz); this->ReadTo(result.data(), ddata, sz * sizeof(T)); @@ -214,7 +214,7 @@ struct MIOPEN_EXPORT Handle : miopenHandle } template - void ReadToVec(const Allocator::ManageDataPtr& ddata, V& output_vec) + void ReadToVec(const Allocator::ManageDataPtr& ddata, V& output_vec) const { using T = typename V::value_type; assert(ddata); @@ -250,15 +250,16 @@ struct MIOPEN_EXPORT Handle : miopenHandle void RegisterInvoker(const Invoker& invoker, const NetworkConfig& config, const std::string& solver, - const std::optional& algo = std::nullopt) + const std::optional& algo = std::nullopt) const { invokers.Register({config, solver}, invoker); if(algo.has_value()) SetAsFound1_0(config, *algo, solver); } - void - SetAsFound1_0(const NetworkConfig& config, const AlgorithmName& algo, const std::string& solver) + void SetAsFound1_0(const NetworkConfig& config, + const AlgorithmName& algo, + const std::string& solver) const { invokers.SetAsFound1_0(config, algo, solver); } @@ -305,7 +306,7 @@ struct MIOPEN_EXPORT Handle : miopenHandle hipblasLt_handle_ptr CreateHipblasLtHandle() const; #endif - InvokerCache invokers; + mutable InvokerCache invokers; }; inline std::ostream& operator<<(std::ostream& os, const Handle& handle) { return handle.Print(os); } diff --git a/src/include/miopen/kthvalue.hpp b/src/include/miopen/kthvalue.hpp index 32cb008e0b..04cd215317 100644 --- a/src/include/miopen/kthvalue.hpp +++ b/src/include/miopen/kthvalue.hpp @@ -33,7 +33,7 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT miopenStatus_t KthvalueForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t KthvalueForward(Handle const& handle, const TensorDescriptor& inputDesc, ConstData_t input, const TensorDescriptor& outputDesc, diff --git a/src/include/miopen/layernorm.hpp b/src/include/miopen/layernorm.hpp index dc695140fc..4e2a4568b9 100644 --- a/src/include/miopen/layernorm.hpp +++ b/src/include/miopen/layernorm.hpp @@ -33,7 +33,7 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT miopenStatus_t LayerNormForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t LayerNormForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& weightDesc, diff --git a/src/include/miopen/lrn.hpp b/src/include/miopen/lrn.hpp index 5238495cd1..2c23ff1d43 100644 --- a/src/include/miopen/lrn.hpp +++ b/src/include/miopen/lrn.hpp @@ -47,7 +47,7 @@ struct MIOPEN_INTERNALS_EXPORT LRNDescriptor : miopenLRNDescriptor double GetBeta() const; double GetK() const; - miopenStatus_t Forward(Handle& handle, + miopenStatus_t Forward(Handle const& handle, const void* alpha, const TensorDescriptor& xDesc, ConstData_t x, @@ -57,7 +57,7 @@ struct MIOPEN_INTERNALS_EXPORT LRNDescriptor : miopenLRNDescriptor bool do_backward, Data_t workSpace) const; - miopenStatus_t Backward(Handle& handle, + miopenStatus_t Backward(Handle const& handle, const void* alpha, const TensorDescriptor& yDesc, ConstData_t y, diff --git a/src/include/miopen/mlo_internal.hpp b/src/include/miopen/mlo_internal.hpp index 6252df3087..e7c4ff35aa 100644 --- a/src/include/miopen/mlo_internal.hpp +++ b/src/include/miopen/mlo_internal.hpp @@ -274,7 +274,7 @@ struct mlo_construct_base /* * set library stream */ - inline void setStream(miopen::Handle* stream) { _ctx.SetStream(stream); } + inline void setStream(miopen::Handle const* stream) { _ctx.SetStream(stream); } protected: miopen::ProblemDescriptionCompatTemporary _problem; diff --git a/src/include/miopen/multimarginloss.hpp b/src/include/miopen/multimarginloss.hpp index fa718923a2..1e61df345d 100644 --- a/src/include/miopen/multimarginloss.hpp +++ b/src/include/miopen/multimarginloss.hpp @@ -35,7 +35,7 @@ struct Handle; struct TensorDescriptor; MIOPEN_INTERNALS_EXPORT std::size_t -GetMultiMarginLossForwardWorkspaceSize(Handle& handle, +GetMultiMarginLossForwardWorkspaceSize(Handle const& handle, const TensorDescriptor& iDesc, const TensorDescriptor& tDesc, const TensorDescriptor& wDesc, @@ -44,7 +44,7 @@ GetMultiMarginLossForwardWorkspaceSize(Handle& handle, float margin, miopenLossReductionMode_t reduction); -MIOPEN_INTERNALS_EXPORT miopenStatus_t MultiMarginLossForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t MultiMarginLossForward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& iDesc, diff --git a/src/include/miopen/pooling.hpp b/src/include/miopen/pooling.hpp index 0ab5ffa1c7..9bf8836723 100644 --- a/src/include/miopen/pooling.hpp +++ b/src/include/miopen/pooling.hpp @@ -137,7 +137,7 @@ struct MIOPEN_EXPORT PoolingDescriptor : miopenPoolingDescriptor std::size_t GetWorkSpaceSize(const TensorDescriptor& yDesc) const; - miopenStatus_t Forward(Handle& handle, + miopenStatus_t Forward(Handle const& handle, const void* alpha, const TensorDescriptor& xDesc, ConstData_t x, @@ -148,7 +148,7 @@ struct MIOPEN_EXPORT PoolingDescriptor : miopenPoolingDescriptor Data_t workSpace, size_t workSpaceSize) const; - miopenStatus_t Backward(Handle& handle, + miopenStatus_t Backward(Handle const& handle, const void* alpha, const TensorDescriptor& yDesc, ConstData_t y, diff --git a/src/include/miopen/prelu.hpp b/src/include/miopen/prelu.hpp index 35e5e7f611..4a46c2a9f9 100644 --- a/src/include/miopen/prelu.hpp +++ b/src/include/miopen/prelu.hpp @@ -32,11 +32,11 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT size_t GetPReLUBackwardWorkspaceSize(Handle& handle, +MIOPEN_INTERNALS_EXPORT size_t GetPReLUBackwardWorkspaceSize(Handle const& handle, const TensorDescriptor& inputDesc, const TensorDescriptor& weightDesc); -MIOPEN_INTERNALS_EXPORT miopenStatus_t PReLUBackward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t PReLUBackward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& inputDesc, diff --git a/src/include/miopen/problem.hpp b/src/include/miopen/problem.hpp index 110e69299d..af561ad14f 100644 --- a/src/include/miopen/problem.hpp +++ b/src/include/miopen/problem.hpp @@ -114,8 +114,9 @@ struct Problem const OperatorDescriptor& GetOperatorDescriptor() const { return operator_descriptor; } - std::vector - FindSolutions(Handle& handle, const FindOptions& options, std::size_t max_solutions) const; + std::vector FindSolutions(Handle const& handle, + const FindOptions& options, + std::size_t max_solutions) const; conv::ProblemDescription AsConvolution() const; activ::ProblemDescription AsActivation() const; @@ -182,19 +183,19 @@ struct Problem std::unordered_map tensor_descriptors; OperatorDescriptor operator_descriptor; - std::vector FindSolutionsImpl(Handle& handle, + std::vector FindSolutionsImpl(Handle const& handle, const FindOptions& options, std::size_t max_solutions, const Buffers& buffers, const ConvolutionDescriptor& conv_desc) const; - std::vector FindSolutionsImpl(Handle& handle, + std::vector FindSolutionsImpl(Handle const& handle, const FindOptions& options, std::size_t max_solutions, const Buffers& buffers, const MhaDescriptor& mha_desc) const; - std::vector FindSolutionsImpl(Handle& handle, + std::vector FindSolutionsImpl(Handle const& handle, const FindOptions& options, std::size_t max_solutions, const Buffers& buffers, @@ -217,8 +218,9 @@ struct MIOPEN_INTERNALS_EXPORT FusedProblem // Not implemented, but silently } - [[nodiscard]] std::vector - FindSolutions(Handle& handle, const FindOptions& options, std::size_t max_solutions) const; + [[nodiscard]] std::vector FindSolutions(Handle const& handle, + const FindOptions& options, + std::size_t max_solutions) const; void PropagateDescriptors(); diff --git a/src/include/miopen/reducecalculation.hpp b/src/include/miopen/reducecalculation.hpp index c21e1863be..bb76f49116 100644 --- a/src/include/miopen/reducecalculation.hpp +++ b/src/include/miopen/reducecalculation.hpp @@ -34,14 +34,14 @@ struct Handle; struct TensorDescriptor; MIOPEN_INTERNALS_EXPORT std::size_t -GetReduceCalculationWorkspaceSize(Handle& handle, +GetReduceCalculationWorkspaceSize(Handle const& handle, const TensorDescriptor& xDesc, const TensorDescriptor& yDesc, int32_t dim, miopenReduceCalculationOp_t reduceCalculationOp); MIOPEN_INTERNALS_EXPORT miopenStatus_t -ReduceCalculationForward(Handle& handle, +ReduceCalculationForward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& xDesc, diff --git a/src/include/miopen/reduceextreme.hpp b/src/include/miopen/reduceextreme.hpp index 5976aa7707..95b08e0e7c 100644 --- a/src/include/miopen/reduceextreme.hpp +++ b/src/include/miopen/reduceextreme.hpp @@ -34,7 +34,7 @@ struct Handle; struct TensorDescriptor; MIOPEN_INTERNALS_EXPORT miopenStatus_t -ReduceExtremeForward(Handle& handle, +ReduceExtremeForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& indiceDesc, @@ -43,7 +43,7 @@ ReduceExtremeForward(Handle& handle, miopenReduceExtremeOp_t reduceExtremeOp); MIOPEN_INTERNALS_EXPORT miopenStatus_t -ReduceExtremeForward(Handle& handle, +ReduceExtremeForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& yDesc, diff --git a/src/include/miopen/rnn.hpp b/src/include/miopen/rnn.hpp index eba00e2a29..b9db51afaf 100644 --- a/src/include/miopen/rnn.hpp +++ b/src/include/miopen/rnn.hpp @@ -138,36 +138,39 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor miopenRNNFWDMode_t fwdMode, miopenRNNBaseLayout_t ioLayout) const; - size_t GetWorkspaceSize(Handle& handle, + size_t GetWorkspaceSize(Handle const& handle, int seqLength, c_array_view xDesc) const; - size_t GetWorkspaceSize(Handle& handle, + size_t GetWorkspaceSize(Handle const& handle, const SeqTensorDescriptor& xDesc, miopenRNNFWDMode_t fwdMode) const; size_t GetReserveSize(size_t batchLenSum) const; - size_t GetReserveSize(Handle& handle, + size_t GetReserveSize(Handle const& handle, int seqLength, c_array_view xDesc) const; - size_t GetMaxWorkspaceSize(Handle& handle, + size_t GetMaxWorkspaceSize(Handle const& handle, const SeqTensorDescriptor& xDesc, miopenRNNFWDMode_t fwdMode) const; - size_t GetMaxReserveSize(Handle& handle, const SeqTensorDescriptor& xDesc) const; + size_t GetMaxReserveSize(Handle const& handle, const SeqTensorDescriptor& xDesc) const; - size_t - GetParamsSize(Handle& handle, const TensorDescriptor& xDesc, miopenDataType_t dtype) const; + size_t GetParamsSize(Handle const& handle, + const TensorDescriptor& xDesc, + miopenDataType_t dtype) const; size_t GetParamsSize(size_t inputVector) const; - void GetParamsDescriptor(Handle& handle, + void GetParamsDescriptor(Handle const& handle, const TensorDescriptor& xDesc, TensorDescriptor& wDesc, miopenDataType_t dtype) const; - std::size_t - GetLayerParamSize(Handle& handle, int layer, const TensorDescriptor& xDesc, int paramID) const; + std::size_t GetLayerParamSize(Handle const& handle, + int layer, + const TensorDescriptor& xDesc, + int paramID) const; - std::size_t GetLayerBiasSize(Handle& handle, int layer, int biasID) const; + std::size_t GetLayerBiasSize(Handle const& handle, int layer, int biasID) const; void GetLayerParam(const Handle& handle, int layer, @@ -219,14 +222,14 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor TensorDescriptor& biasDesc, size_t* biasOffset) const; - size_t GetRNNInputSuperTensorSize(Handle& handle, + size_t GetRNNInputSuperTensorSize(Handle const& handle, int seqLength, c_array_view xDesc) const; - size_t GetRNNHiddenSuperTensorSize(Handle& handle, + size_t GetRNNHiddenSuperTensorSize(Handle const& handle, c_array_view xDesc) const; - void RNNForward(Handle& handle, + void RNNForward(Handle const& handle, miopenRNNFWDMode_t fwdMode, const SeqTensorDescriptor& xDesc, ConstData_t x, @@ -245,7 +248,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNForwardTraining(Handle& handle, + void RNNForwardTraining(Handle const& handle, int seqLen, c_array_view xDesc, ConstData_t x, @@ -266,7 +269,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNForwardInference(Handle& handle, + void RNNForwardInference(Handle const& handle, int seqLen, c_array_view xDesc, ConstData_t x, @@ -285,7 +288,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t workSpace, size_t workSpaceSize) const; - void RNNBackwardData(Handle& handle, + void RNNBackwardData(Handle const& handle, const SeqTensorDescriptor& yDesc, ConstData_t y, ConstData_t dy, @@ -306,7 +309,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNBackwardData(Handle& handle, + void RNNBackwardData(Handle const& handle, int seqLen, c_array_view yDesc, ConstData_t y, @@ -333,7 +336,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNBackwardWeights(Handle& handle, + void RNNBackwardWeights(Handle const& handle, const SeqTensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& hDesc, @@ -347,7 +350,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor ConstData_t reserveSpace, size_t reserveSpaceSize) const; - void RNNBackwardWeights(Handle& handle, + void RNNBackwardWeights(Handle const& handle, int seqLen, c_array_view xDesc, ConstData_t x, @@ -371,7 +374,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor // TODO rename - void ModularForward(Handle& handle, + void ModularForward(Handle const& handle, miopenRNNFWDMode_t fwdMode, ConstData_t w, const SeqTensorDescriptor& xDesc, @@ -389,7 +392,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void ModularBackward(Handle& handle, + void ModularBackward(Handle const& handle, const SeqTensorDescriptor& yDesc, ConstData_t dy, const TensorDescriptor& hDesc, @@ -408,7 +411,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void ModularBackwardWeights(Handle& handle, + void ModularBackwardWeights(Handle const& handle, const SeqTensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& hDesc, @@ -420,7 +423,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor ConstData_t reserveSpace, size_t /*reserveSpaceSize*/) const; - void RNNTransformerForward(Handle& handle, + void RNNTransformerForward(Handle const& handle, miopenRNNFWDMode_t fwdMode, ConstData_t w, const SeqTensorDescriptor& xDesc, @@ -438,7 +441,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNTransformerBackwardData(Handle& handle, + void RNNTransformerBackwardData(Handle const& handle, const SeqTensorDescriptor& yDesc, ConstData_t dy, const TensorDescriptor& hDesc, @@ -457,7 +460,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNTransformerBackwardWeights(Handle& handle, + void RNNTransformerBackwardWeights(Handle const& handle, const SeqTensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& hDesc, @@ -469,7 +472,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor ConstData_t reserveSpace, size_t reserveSpaceSize) const; - void RNNVanillaForward(Handle& handle, + void RNNVanillaForward(Handle const& handle, miopenRNNFWDMode_t fwdMode, ConstData_t w, const SeqTensorDescriptor& xDesc, @@ -487,7 +490,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNVanillaBackwardData(Handle& handle, + void RNNVanillaBackwardData(Handle const& handle, const SeqTensorDescriptor& yDesc, ConstData_t dy, const TensorDescriptor& hDesc, @@ -506,7 +509,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNVanillaBackwardWeights(Handle& handle, + void RNNVanillaBackwardWeights(Handle const& handle, const SeqTensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& hDesc, @@ -518,7 +521,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor ConstData_t reserveSpace, size_t reserveSpaceSize) const; - void RNNForwardTrainingPackedTensors(Handle& handle, + void RNNForwardTrainingPackedTensors(Handle const& handle, int seqLen, c_array_view xDesc, ConstData_t x, @@ -537,7 +540,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNForwardMS(Handle& handle, + void RNNForwardMS(Handle const& handle, std::vector& seq_array, const TensorDescriptor& xDesc, ConstData_t x, @@ -554,7 +557,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor size_t extra_space_size, miopenRNNFWDMode_t fwd_mode) const; - void RNNForwardInferencePacked(Handle& handle, + void RNNForwardInferencePacked(Handle const& handle, int seqLen, c_array_view xDesc, ConstData_t x, @@ -573,7 +576,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t workSpace, size_t workSpaceSize) const; - void RNNBackwardDataPackedTensors(Handle& handle, + void RNNBackwardDataPackedTensors(Handle const& handle, int seqLen, c_array_view dyDesc, ConstData_t dy, @@ -593,7 +596,7 @@ struct MIOPEN_INTERNALS_EXPORT RNNDescriptor : miopenRNNDescriptor Data_t reserveSpace, size_t reserveSpaceSize) const; - void RNNBackwardWeightsPackedTensors(Handle& handle, + void RNNBackwardWeightsPackedTensors(Handle const& handle, int seqLen, c_array_view xDesc, ConstData_t x, diff --git a/src/include/miopen/rnn/solvers.hpp b/src/include/miopen/rnn/solvers.hpp index 429bcee752..8ccc65cf17 100644 --- a/src/include/miopen/rnn/solvers.hpp +++ b/src/include/miopen/rnn/solvers.hpp @@ -546,7 +546,7 @@ class RNNModularSingleStreamFWD // TODO static size_t GetWsSize() { return 0; }; - void ComputeFWD(Handle& handle, const runtimeArgsFwd& runtimeArgs) const; + void ComputeFWD(Handle const& handle, const runtimeArgsFwd& runtimeArgs) const; const rnn_base::RNNForwardDataModularAlgo rnnAlgoModules; @@ -580,7 +580,7 @@ class RNNModularSingleStreamBWD // TODO static size_t GetWsSize() { return 0; }; - void ComputeBWD(Handle& handle, + void ComputeBWD(Handle const& handle, ConstData_t dy, ConstData_t dhy, Data_t dhx, @@ -638,7 +638,7 @@ class RNNModularMultiStreamBWD Data_t reserveSpace; }; - void ComputeBWD(Handle& handle, + void ComputeBWD(Handle const& handle, ConstData_t dy, ConstData_t dhy, Data_t dhx, diff --git a/src/include/miopen/rnn_util.hpp b/src/include/miopen/rnn_util.hpp index 92876b8a9a..e0e8ff741f 100644 --- a/src/include/miopen/rnn_util.hpp +++ b/src/include/miopen/rnn_util.hpp @@ -38,7 +38,7 @@ namespace miopen { struct RnnHipAutoProfiler { - RnnHipAutoProfiler(Handle& handle) : is_profiling_active(handle.IsProfilingEnabled()) + RnnHipAutoProfiler(Handle const& handle) : is_profiling_active(handle.IsProfilingEnabled()) { if(is_profiling_active) { @@ -93,9 +93,9 @@ struct RnnHipAutoProfiler } #if MIOPEN_BACKEND_HIP - Handle* attached_handle = nullptr; - HipEventPtr start = nullptr; - HipEventPtr stop = nullptr; + Handle const* attached_handle = nullptr; + HipEventPtr start = nullptr; + HipEventPtr stop = nullptr; #endif bool is_profiling_active = false; }; diff --git a/src/include/miopen/rope.hpp b/src/include/miopen/rope.hpp index 5995354c1a..78e65a5318 100644 --- a/src/include/miopen/rope.hpp +++ b/src/include/miopen/rope.hpp @@ -33,7 +33,7 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT miopenStatus_t RoPEForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t RoPEForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& cosDesc, @@ -43,7 +43,7 @@ MIOPEN_INTERNALS_EXPORT miopenStatus_t RoPEForward(Handle& handle, const TensorDescriptor& yDesc, Data_t y); -MIOPEN_INTERNALS_EXPORT miopenStatus_t RoPEBackward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t RoPEBackward(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& cosDesc, diff --git a/src/include/miopen/softmarginloss.hpp b/src/include/miopen/softmarginloss.hpp index 58d1b2c0ce..6444e5a049 100644 --- a/src/include/miopen/softmarginloss.hpp +++ b/src/include/miopen/softmarginloss.hpp @@ -35,13 +35,13 @@ struct Handle; struct TensorDescriptor; MIOPEN_INTERNALS_EXPORT std::size_t -GetSoftMarginLossForwardWorkspaceSize(Handle& handle, +GetSoftMarginLossForwardWorkspaceSize(Handle const& handle, const TensorDescriptor& iDesc, const TensorDescriptor& tDesc, const TensorDescriptor& oDesc, miopenLossReductionMode_t reduction); -MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftMarginLossForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftMarginLossForward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& iDesc, @@ -52,7 +52,7 @@ MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftMarginLossForward(Handle& handle, Data_t o, miopenLossReductionMode_t reduction); -MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftMarginLossBackward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftMarginLossBackward(Handle const& handle, const TensorDescriptor& iDesc, ConstData_t i, const TensorDescriptor& tDesc, diff --git a/src/include/miopen/softmax.hpp b/src/include/miopen/softmax.hpp index f9c5ac9596..a7ae17cb63 100644 --- a/src/include/miopen/softmax.hpp +++ b/src/include/miopen/softmax.hpp @@ -70,7 +70,7 @@ struct MIOPEN_INTERNALS_EXPORT SoftmaxDescriptor : miopenSoftmaxDescriptor miopenSoftmaxMode_t mode; }; -MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftmaxForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftmaxForward(Handle const& handle, const void* alpha, const void* beta, const TensorDescriptor& xDesc, @@ -82,7 +82,7 @@ MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftmaxForward(Handle& handle, int x_offset = 0, int y_offset = 0); -MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftmaxBackward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t SoftmaxBackward(Handle const& handle, const void* alpha, const TensorDescriptor& yDesc, ConstData_t y, diff --git a/src/include/miopen/solution.hpp b/src/include/miopen/solution.hpp index 78daacc2d1..4767147387 100644 --- a/src/include/miopen/solution.hpp +++ b/src/include/miopen/solution.hpp @@ -109,7 +109,7 @@ struct MIOPEN_INTERNALS_EXPORT Solution : miopenSolution const ProblemContainer& GetProblem() const { return problem; } void SetProblem(ProblemContainer value) { problem = std::move(value); } - void Run(Handle& handle, + void Run(Handle const& handle, const std::unordered_map& inputs, Data_t workspace, size_t workspace_size); @@ -157,25 +157,25 @@ struct MIOPEN_INTERNALS_EXPORT Solution : miopenSolution std::optional invoker; std::vector kernels; - void RunImpl(Handle& handle, + void RunImpl(Handle const& handle, const std::unordered_map& inputs, Data_t workspace, std::size_t workspace_size, const ConvolutionDescriptor& conv_desc); - void RunImpl(Handle& handle, + void RunImpl(Handle const& handle, const std::unordered_map& inputs, Data_t /*workspace*/, std::size_t /*workspace_size*/, const SoftmaxDescriptor& softmax_desc); - void RunImpl(Handle& handle, + void RunImpl(Handle const& handle, const std::unordered_map& inputs, Data_t workspace, std::size_t workspace_size, const MhaDescriptor& mha_desc); - void RunImpl(Handle& handle, + void RunImpl(Handle const& handle, const std::unordered_map& inputs, Data_t workspace, std::size_t workspace_size, diff --git a/src/include/miopen/solver/gemm_common.hpp b/src/include/miopen/solver/gemm_common.hpp index d4b4568da9..16dc20516c 100644 --- a/src/include/miopen/solver/gemm_common.hpp +++ b/src/include/miopen/solver/gemm_common.hpp @@ -39,7 +39,7 @@ namespace solver { namespace conv { namespace gemm { -std::size_t MaxMemAllocSz(Handle& h, +std::size_t MaxMemAllocSz(Handle const& h, const miopen::conv::ProblemDescription& problem, bool double_limit_for_fp32 = false); diff --git a/src/include/miopen/t5layernorm.hpp b/src/include/miopen/t5layernorm.hpp index e9aa7abbb6..cc11598f06 100644 --- a/src/include/miopen/t5layernorm.hpp +++ b/src/include/miopen/t5layernorm.hpp @@ -33,7 +33,7 @@ namespace miopen { struct Handle; struct TensorDescriptor; -MIOPEN_INTERNALS_EXPORT miopenStatus_t T5LayerNormForward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t T5LayerNormForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& weightDesc, @@ -46,7 +46,7 @@ MIOPEN_INTERNALS_EXPORT miopenStatus_t T5LayerNormForward(Handle& handle, float epsilon); MIOPEN_INTERNALS_EXPORT std::size_t -GetT5LayerNormBackwardWorkspaceSize(Handle& handle, +GetT5LayerNormBackwardWorkspaceSize(Handle const& handle, const TensorDescriptor& dyDesc, const TensorDescriptor& xDesc, const TensorDescriptor& weightDesc, @@ -55,7 +55,7 @@ GetT5LayerNormBackwardWorkspaceSize(Handle& handle, const TensorDescriptor& dwDesc, miopenNormMode_t mode); -MIOPEN_INTERNALS_EXPORT miopenStatus_t T5LayerNormBackward(Handle& handle, +MIOPEN_INTERNALS_EXPORT miopenStatus_t T5LayerNormBackward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& dyDesc, diff --git a/src/kthvalue.cpp b/src/kthvalue.cpp index a9f4e73067..b96f7d8b2c 100644 --- a/src/kthvalue.cpp +++ b/src/kthvalue.cpp @@ -34,7 +34,7 @@ namespace miopen { -miopenStatus_t KthvalueForward(Handle& handle, +miopenStatus_t KthvalueForward(Handle const& handle, const TensorDescriptor& inputDesc, ConstData_t input, const TensorDescriptor& outputDesc, diff --git a/src/layernorm.cpp b/src/layernorm.cpp index 7d2789973f..20461f7196 100644 --- a/src/layernorm.cpp +++ b/src/layernorm.cpp @@ -34,7 +34,7 @@ namespace miopen { -miopenStatus_t LayerNormForward(Handle& handle, +miopenStatus_t LayerNormForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& weightDesc, diff --git a/src/multimarginloss.cpp b/src/multimarginloss.cpp index 53b28ce78b..08ca00dff2 100644 --- a/src/multimarginloss.cpp +++ b/src/multimarginloss.cpp @@ -36,7 +36,7 @@ namespace miopen { -std::size_t GetMultiMarginLossForwardWorkspaceSize(Handle& handle, +std::size_t GetMultiMarginLossForwardWorkspaceSize(Handle const& handle, const TensorDescriptor& iDesc, const TensorDescriptor& tDesc, const TensorDescriptor& wDesc, @@ -55,7 +55,7 @@ std::size_t GetMultiMarginLossForwardWorkspaceSize(Handle& handle, return pair_size_vector.empty() ? static_cast(-1) : pair_size_vector.front().second; } -miopenStatus_t MultiMarginLossForward(Handle& handle, +miopenStatus_t MultiMarginLossForward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& iDesc, diff --git a/src/nogpu/handle.cpp b/src/nogpu/handle.cpp index 6d3af3a9f2..d1b6e2dedf 100644 --- a/src/nogpu/handle.cpp +++ b/src/nogpu/handle.cpp @@ -258,7 +258,7 @@ std::size_t Handle::GetWavefrontWidth() const { return this->impl->warp_size; } // No HIP API that could return maximum memory allocation size // for a single object. -std::size_t Handle::GetMaxMemoryAllocSize() +std::size_t Handle::GetMaxMemoryAllocSize() const { if(this->impl->max_mem_alloc_size == 0) return floor(0.85 * this->impl->global_mem_size); diff --git a/src/ocl/activ_ocl.cpp b/src/ocl/activ_ocl.cpp index fc301acadd..4d7bd5e8e2 100644 --- a/src/ocl/activ_ocl.cpp +++ b/src/ocl/activ_ocl.cpp @@ -34,7 +34,7 @@ namespace miopen { -miopenStatus_t ActivationDescriptor::Forward(Handle& handle, +miopenStatus_t ActivationDescriptor::Forward(Handle const& handle, const void* alpha, const TensorDescriptor& xDesc, ConstData_t x, @@ -74,7 +74,7 @@ miopenStatus_t ActivationDescriptor::Forward(Handle& handle, return miopenStatusSuccess; } -miopenStatus_t ActivationDescriptor::Backward(Handle& handle, +miopenStatus_t ActivationDescriptor::Backward(Handle const& handle, const void* alpha, const TensorDescriptor& yDesc, ConstData_t y, diff --git a/src/ocl/batchnormocl.cpp b/src/ocl/batchnormocl.cpp index 6232759b0b..73fb373d48 100644 --- a/src/ocl/batchnormocl.cpp +++ b/src/ocl/batchnormocl.cpp @@ -57,7 +57,7 @@ miopen::PerformanceDb GetDb(const miopen::ExecutionContext& ctx, //============ BEGIN FORWARD TRAINING =============== -void BatchNormForwardTraining(Handle& handle, +void BatchNormForwardTraining(Handle const& handle, miopenBatchNormMode_t bn_mode, const void* alpha, const void* beta, @@ -175,7 +175,7 @@ void BatchNormForwardTraining(Handle& handle, //================== END FWD TRAIN =================== //============ BEGIN FORWARD INFERENCE =============== -void BatchNormForwardInference(Handle& handle, +void BatchNormForwardInference(Handle const& handle, miopenBatchNormMode_t bn_mode, const void* alpha, const void* beta, @@ -290,7 +290,7 @@ void BatchNormForwardInference(Handle& handle, //=============== BEGIN BACKWARDS PROPAGATION ================ -void BatchNormBackward(Handle& handle, +void BatchNormBackward(Handle const& handle, miopenBatchNormMode_t bn_mode, const void* alphaDataDiff, const void* betaDataDiff, diff --git a/src/ocl/convolutionocl.cpp b/src/ocl/convolutionocl.cpp index ee4c2839c7..b6e3d3e374 100644 --- a/src/ocl/convolutionocl.cpp +++ b/src/ocl/convolutionocl.cpp @@ -226,7 +226,7 @@ static inline void FillFindReturnParameters(const std::vector& results << results[0].GetWorkspaceSize() << ", " << results[0].GetTime()); } -void ConvolutionDescriptor::FindConvFwdAlgorithm(Handle& handle, +void ConvolutionDescriptor::FindConvFwdAlgorithm(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& wDesc, @@ -453,7 +453,7 @@ miopenDataType_t GetScalarDataType(const TensorDescriptor& xDesc) } } -void ConvolutionDescriptor::ConvolutionForward(Handle& handle, +void ConvolutionDescriptor::ConvolutionForward(Handle const& handle, const void* alpha, const TensorDescriptor& xDesc, ConstData_t x, @@ -501,7 +501,7 @@ void ConvolutionDescriptor::ConvolutionForward(Handle& handle, }); } -static std::size_t GetSolutionCount(Handle& handle, const conv::ProblemDescription& problem) +static std::size_t GetSolutionCount(Handle const& handle, const conv::ProblemDescription& problem) { const FindDbRecord fdb_record{handle, problem}; if(fdb_record.empty()) @@ -786,7 +786,7 @@ ConvolutionDescriptor::GetSolutions(const ExecutionContext& ctx, return GetSolutionsFallback(ctx, problem, maxSolutionCount, invokeParams); } -std::size_t ConvolutionDescriptor::GetForwardSolutionWorkspaceSize(Handle& handle, +std::size_t ConvolutionDescriptor::GetForwardSolutionWorkspaceSize(Handle const& handle, const TensorDescriptor& wDesc, const TensorDescriptor& xDesc, const TensorDescriptor& yDesc, @@ -817,7 +817,7 @@ void ConvolutionDescriptor::CompileSolution(const ExecutionContext& ctx, miopen::CompileSolution(solver_id, ctx, problem); } -void ConvolutionDescriptor::ConvolutionForwardImmediate(Handle& handle, +void ConvolutionDescriptor::ConvolutionForwardImmediate(Handle const& handle, const TensorDescriptor& wDesc, ConstData_t w, const TensorDescriptor& xDesc, @@ -849,7 +849,7 @@ void ConvolutionDescriptor::ConvolutionForwardImmediate(Handle& handle, // FindBackwardDataAlgorithm() // -void ConvolutionDescriptor::FindConvBwdDataAlgorithm(Handle& handle, +void ConvolutionDescriptor::FindConvBwdDataAlgorithm(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& wDesc, @@ -939,7 +939,7 @@ static void ConvBwdCheckNumerics(const Handle& handle, } // BackwardDataAlgorithm() -void ConvolutionDescriptor::ConvolutionBackwardData(Handle& handle, +void ConvolutionDescriptor::ConvolutionBackwardData(Handle const& handle, const void* alpha, const TensorDescriptor& dyDesc, ConstData_t dy, @@ -990,7 +990,7 @@ void ConvolutionDescriptor::ConvolutionBackwardData(Handle& handle, }); } -std::size_t ConvolutionDescriptor::GetBackwardSolutionWorkspaceSize(Handle& handle, +std::size_t ConvolutionDescriptor::GetBackwardSolutionWorkspaceSize(Handle const& handle, const TensorDescriptor& dyDesc, const TensorDescriptor& wDesc, const TensorDescriptor& dxDesc, @@ -1019,7 +1019,7 @@ std::size_t ConvolutionDescriptor::GetBackwardSolutionWorkspaceSize(Handle& hand } } -void ConvolutionDescriptor::ConvolutionBackwardImmediate(Handle& handle, +void ConvolutionDescriptor::ConvolutionBackwardImmediate(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& wDesc, @@ -1057,7 +1057,7 @@ void ConvolutionDescriptor::ConvolutionBackwardImmediate(Handle& handle, // ConvolutionBackwardWeightsGetWorkSpaceSize // FindBackwardWeightsAlgorithm() // -void ConvolutionDescriptor::FindConvBwdWeightsAlgorithm(Handle& handle, +void ConvolutionDescriptor::FindConvBwdWeightsAlgorithm(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& xDesc, @@ -1194,7 +1194,7 @@ void ConvolutionDescriptor::ConvolutionBackwardWeights(const Handle& handle, }); } -std::size_t ConvolutionDescriptor::GetWrwSolutionWorkspaceSize(Handle& handle, +std::size_t ConvolutionDescriptor::GetWrwSolutionWorkspaceSize(Handle const& handle, const TensorDescriptor& dyDesc, const TensorDescriptor& xDesc, const TensorDescriptor& dwDesc, @@ -1223,7 +1223,7 @@ std::size_t ConvolutionDescriptor::GetWrwSolutionWorkspaceSize(Handle& handle, } } -void ConvolutionDescriptor::ConvolutionWrwImmediate(Handle& handle, +void ConvolutionDescriptor::ConvolutionWrwImmediate(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& xDesc, diff --git a/src/ocl/ctcocl.cpp b/src/ocl/ctcocl.cpp index 35001e2855..09c1bf921d 100644 --- a/src/ocl/ctcocl.cpp +++ b/src/ocl/ctcocl.cpp @@ -43,7 +43,7 @@ namespace miopen { -void CTCLossDescriptor::CTCLoss(Handle& handle, +void CTCLossDescriptor::CTCLoss(Handle const& handle, const TensorDescriptor& probsDesc, ConstData_t probs, const int* labels, diff --git a/src/ocl/dropoutocl.cpp b/src/ocl/dropoutocl.cpp index 1f43da080f..ca656bc0d8 100644 --- a/src/ocl/dropoutocl.cpp +++ b/src/ocl/dropoutocl.cpp @@ -119,7 +119,7 @@ inline void SquashPairedTensor(const std::vector x_len, } } -void DropoutDescriptor::InitPRNGState(Handle& handle, +void DropoutDescriptor::InitPRNGState(Handle const& handle, Data_t prng_states, size_t prng_stateSizeInBytes, unsigned long long prng_seed) const diff --git a/src/ocl/fusionopbiasbnactivocl.cpp b/src/ocl/fusionopbiasbnactivocl.cpp index 60ba1dcd92..fb7f1149e3 100644 --- a/src/ocl/fusionopbiasbnactivocl.cpp +++ b/src/ocl/fusionopbiasbnactivocl.cpp @@ -72,7 +72,7 @@ BatchNormInferenceFusionOpDescriptor::GetNetworkConfig(std::ostringstream& netwo } std::vector -BatchNormInferenceFusionOpDescriptor::GetLocalWGSz(Handle& /*handle*/, +BatchNormInferenceFusionOpDescriptor::GetLocalWGSz(Handle const& /*handle*/, std::string /*algorithm_name*/) { std::vector vld{256, 1, 1}; @@ -80,7 +80,7 @@ BatchNormInferenceFusionOpDescriptor::GetLocalWGSz(Handle& /*handle*/, } std::vector -BatchNormInferenceFusionOpDescriptor::GetGlobalWGSz(Handle& /*handle*/, +BatchNormInferenceFusionOpDescriptor::GetGlobalWGSz(Handle const& /*handle*/, std::string /*algorithm_name*/) { if(input_desc.GetLengths().empty()) diff --git a/src/ocl/handleocl.cpp b/src/ocl/handleocl.cpp index e4f314a1a9..b55ce3ce89 100644 --- a/src/ocl/handleocl.cpp +++ b/src/ocl/handleocl.cpp @@ -482,7 +482,7 @@ std::ostream& Handle::Print(std::ostream& os) const return os; } -std::size_t Handle::GetMaxMemoryAllocSize() +std::size_t Handle::GetMaxMemoryAllocSize() const { if(m_MaxMemoryAllocSizeCached == 0) m_MaxMemoryAllocSizeCached = miopen::GetDeviceInfo( diff --git a/src/ocl/lrn_ocl.cpp b/src/ocl/lrn_ocl.cpp index 6bbb06c017..9ce922e6bb 100644 --- a/src/ocl/lrn_ocl.cpp +++ b/src/ocl/lrn_ocl.cpp @@ -30,7 +30,7 @@ namespace miopen { -miopenStatus_t LRNDescriptor::Forward(Handle& handle, +miopenStatus_t LRNDescriptor::Forward(Handle const& handle, const void* /*alpha*/, const TensorDescriptor& xDesc, ConstData_t x, @@ -177,7 +177,7 @@ miopenStatus_t LRNDescriptor::Forward(Handle& handle, return (status); } -miopenStatus_t LRNDescriptor::Backward(Handle& handle, +miopenStatus_t LRNDescriptor::Backward(Handle const& handle, const void* /*alpha*/, const TensorDescriptor& yDesc, ConstData_t y, diff --git a/src/ocl/pooling_ocl.cpp b/src/ocl/pooling_ocl.cpp index 9881c1596f..e4eb424137 100644 --- a/src/ocl/pooling_ocl.cpp +++ b/src/ocl/pooling_ocl.cpp @@ -54,7 +54,7 @@ static auto PoolingBackwardSolvers() solver::pooling::TransposedPoolingBwdNd>{}; } -miopenStatus_t PoolingDescriptor::Forward(Handle& handle, +miopenStatus_t PoolingDescriptor::Forward(Handle const& handle, const void* alpha, const TensorDescriptor& xDesc, ConstData_t x, @@ -139,7 +139,7 @@ miopenStatus_t PoolingDescriptor::Forward(Handle& handle, return miopenStatusSuccess; } -miopenStatus_t PoolingDescriptor::Backward(Handle& handle, +miopenStatus_t PoolingDescriptor::Backward(Handle const& handle, const void* alpha, const TensorDescriptor& yDesc, ConstData_t /*y*/, diff --git a/src/ocl/rnnocl.cpp b/src/ocl/rnnocl.cpp index 2700034f93..e10ee52393 100644 --- a/src/ocl/rnnocl.cpp +++ b/src/ocl/rnnocl.cpp @@ -87,7 +87,7 @@ void checkGemmStatusAndLog(miopenStatus_t gemm_status) } } -miopenStatus_t ReducAddBias(miopen::Handle& handle, +miopenStatus_t ReducAddBias(miopen::Handle const& handle, Data_t dw, const Data_t workSpace, const miopen::TensorDescriptor& dw_desc, @@ -253,7 +253,7 @@ miopenStatus_t ReducAddBias(miopen::Handle& handle, } // namespace -void RNNDescriptor::RNNForwardMS(Handle& handle, +void RNNDescriptor::RNNForwardMS(Handle const& handle, std::vector& seq_array, const TensorDescriptor& xDesc, ConstData_t x, @@ -1165,7 +1165,7 @@ void RNNDescriptor::RNNForwardMS(Handle& handle, } // Assuming sequence length is set to > 0 otherwise throw exception. -void RNNDescriptor::RNNForwardInference(Handle& handle, +void RNNDescriptor::RNNForwardInference(Handle const& handle, const int seqLen, c_array_view xDesc, ConstData_t x, @@ -1298,7 +1298,7 @@ void RNNDescriptor::RNNForwardInference(Handle& handle, } #endif } -void RNNDescriptor::RNNForwardInferencePacked(Handle& handle, +void RNNDescriptor::RNNForwardInferencePacked(Handle const& handle, const int seqLen, c_array_view xDesc, ConstData_t x, @@ -2551,7 +2551,7 @@ void RNNDescriptor::RNNForwardInferencePacked(Handle& handle, #endif } -void RNNDescriptor::RNNForwardTraining(Handle& handle, +void RNNDescriptor::RNNForwardTraining(Handle const& handle, const int seqLen, c_array_view xDesc, ConstData_t x, @@ -2692,7 +2692,7 @@ void RNNDescriptor::RNNForwardTraining(Handle& handle, }; void RNNDescriptor::RNNForwardTrainingPackedTensors( - Handle& handle, + Handle const& handle, const int seqLen, c_array_view xDesc, ConstData_t x, @@ -4053,7 +4053,7 @@ void RNNDescriptor::RNNForwardTrainingPackedTensors( #endif }; -void RNNDescriptor::RNNBackwardData(Handle& handle, +void RNNDescriptor::RNNBackwardData(Handle const& handle, const int seqLen, c_array_view yDesc, ConstData_t y, @@ -4196,7 +4196,7 @@ void RNNDescriptor::RNNBackwardData(Handle& handle, } void RNNDescriptor::RNNBackwardDataPackedTensors( - Handle& handle, + Handle const& handle, const int seqLen, c_array_view dyDesc, ConstData_t dy, @@ -5776,7 +5776,7 @@ void RNNDescriptor::RNNBackwardDataPackedTensors( #endif }; -void RNNDescriptor::RNNBackwardWeights(Handle& handle, +void RNNDescriptor::RNNBackwardWeights(Handle const& handle, const int seqLen, c_array_view xDesc, ConstData_t x, @@ -5876,7 +5876,7 @@ void RNNDescriptor::RNNBackwardWeights(Handle& handle, } void RNNDescriptor::RNNBackwardWeightsPackedTensors( - Handle& handle, + Handle const& handle, const int seqLen, c_array_view xDesc, ConstData_t x, diff --git a/src/prelu.cpp b/src/prelu.cpp index 3966c1f45f..74c70004d4 100644 --- a/src/prelu.cpp +++ b/src/prelu.cpp @@ -32,7 +32,7 @@ namespace miopen { -size_t GetPReLUBackwardWorkspaceSize(Handle& handle, +size_t GetPReLUBackwardWorkspaceSize(Handle const& handle, const TensorDescriptor& inputDesc, const TensorDescriptor& weightDesc) { @@ -48,7 +48,7 @@ size_t GetPReLUBackwardWorkspaceSize(Handle& handle, return pair_size_vector.empty() ? static_cast(-1) : pair_size_vector.front().second; } -miopenStatus_t PReLUBackward(Handle& handle, +miopenStatus_t PReLUBackward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& inputDesc, diff --git a/src/problem.cpp b/src/problem.cpp index ba84856850..4cbde073fc 100644 --- a/src/problem.cpp +++ b/src/problem.cpp @@ -119,7 +119,7 @@ void VisitType(int id, Args... args) detail::VisitType{}(id, args...); } -static Data_t AllocateTensor(Handle& handle, +static Data_t AllocateTensor(Handle const& handle, const FindOptions& options, std::vector& owned, std::vector& owned_scalars, @@ -160,8 +160,9 @@ static void SortFindResults(const FindOptions& options, std::vector& r }()); } -std::vector -Problem::FindSolutions(Handle& handle, const FindOptions& options, std::size_t max_solutions) const +std::vector Problem::FindSolutions(Handle const& handle, + const FindOptions& options, + std::size_t max_solutions) const { auto owned_buffers = std::vector{}; auto owned_scalars = std::vector{}; @@ -460,7 +461,7 @@ softmax::ProblemDescription Problem::AsSoftmax() const return problem_description; } -std::vector Problem::FindSolutionsImpl(Handle& handle, +std::vector Problem::FindSolutionsImpl(Handle const& handle, const FindOptions& options, std::size_t max_solutions, const Buffers& buffers, @@ -541,7 +542,7 @@ std::vector Problem::FindSolutionsImpl(Handle& handle, } std::vector -Problem::FindSolutionsImpl(Handle& handle, +Problem::FindSolutionsImpl(Handle const& handle, [[maybe_unused]] const FindOptions& options, std::size_t max_solutions, [[maybe_unused]] const Buffers& buffers, @@ -596,7 +597,7 @@ Problem::FindSolutionsImpl(Handle& handle, } std::vector -Problem::FindSolutionsImpl(Handle& handle, +Problem::FindSolutionsImpl(Handle const& handle, [[maybe_unused]] const FindOptions& options, std::size_t max_solutions, [[maybe_unused]] const Buffers& buffers, @@ -958,7 +959,7 @@ void FusedProblem::PropagateDescriptors() } } -std::vector FusedProblem::FindSolutions(Handle& handle, +std::vector FusedProblem::FindSolutions(Handle const& handle, const FindOptions& options, std::size_t max_solutions) const { diff --git a/src/reducecalculation.cpp b/src/reducecalculation.cpp index 58c9d45252..c06aa7a654 100644 --- a/src/reducecalculation.cpp +++ b/src/reducecalculation.cpp @@ -35,7 +35,7 @@ namespace miopen { -std::size_t GetReduceCalculationWorkspaceSize(Handle& handle, +std::size_t GetReduceCalculationWorkspaceSize(Handle const& handle, const TensorDescriptor& xDesc, const TensorDescriptor& yDesc, int32_t dim, @@ -71,7 +71,7 @@ std::size_t GetReduceCalculationWorkspaceSize(Handle& handle, return static_cast(-1); } -miopenStatus_t ReduceCalculationForward(Handle& handle, +miopenStatus_t ReduceCalculationForward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& xDesc, diff --git a/src/reduceextreme.cpp b/src/reduceextreme.cpp index d2a7d69f9b..11cf860b8e 100644 --- a/src/reduceextreme.cpp +++ b/src/reduceextreme.cpp @@ -35,7 +35,7 @@ namespace miopen { -miopenStatus_t ReduceExtremeForward(Handle& handle, +miopenStatus_t ReduceExtremeForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& indiceDesc, @@ -93,7 +93,7 @@ miopenStatus_t ReduceExtremeForward(Handle& handle, return miopenStatusUnsupportedOp; } -miopenStatus_t ReduceExtremeForward(Handle& handle, +miopenStatus_t ReduceExtremeForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& yDesc, diff --git a/src/rnn.cpp b/src/rnn.cpp index 5d23c79018..ca1607119a 100644 --- a/src/rnn.cpp +++ b/src/rnn.cpp @@ -455,7 +455,7 @@ size_t RNNDescriptor::GetMainSolWorkspaceSize(size_t batchLenSum, return (workspaceScale * nLayers * batchLenSum * hsize * typeSize) * (is_bidirect ? 2 : 1); } -size_t RNNDescriptor::GetWorkspaceSize(Handle& handle, +size_t RNNDescriptor::GetWorkspaceSize(Handle const& handle, const SeqTensorDescriptor& xDesc, miopenRNNFWDMode_t fwdMode) const { @@ -487,7 +487,7 @@ size_t RNNDescriptor::GetWorkspaceSize(Handle& handle, GetMainSolWorkspaceSize(total_sequence_len, fwdMode, miopenRNNDataSeqMajorNotPadded); } -size_t RNNDescriptor::GetMaxWorkspaceSize(Handle& handle, +size_t RNNDescriptor::GetMaxWorkspaceSize(Handle const& handle, const SeqTensorDescriptor& xDesc, miopenRNNFWDMode_t fwdMode) const { @@ -504,7 +504,7 @@ size_t RNNDescriptor::GetMaxWorkspaceSize(Handle& handle, } // legacy -size_t RNNDescriptor::GetWorkspaceSize(Handle& handle, +size_t RNNDescriptor::GetWorkspaceSize(Handle const& handle, const int seqLength, c_array_view xDesc) const { @@ -564,7 +564,7 @@ size_t RNNDescriptor::GetReserveSize(size_t batchLenSum) const // with tensor with maximum sequence length and maximum count of non empty sequences. // The previous version of this function returned a size sufficient only for the current tensor // size. -size_t RNNDescriptor::GetMaxReserveSize(Handle& /* handle */, +size_t RNNDescriptor::GetMaxReserveSize(Handle const& /* handle */, const SeqTensorDescriptor& xDesc) const { if(xDesc.GetType() != dataType) @@ -575,7 +575,7 @@ size_t RNNDescriptor::GetMaxReserveSize(Handle& /* handle */, } // Legacy. -size_t RNNDescriptor::GetReserveSize(Handle& /* handle */, +size_t RNNDescriptor::GetReserveSize(Handle const& /* handle */, const int seqLength, c_array_view xDesc) const { @@ -617,7 +617,7 @@ size_t RNNDescriptor::GetParamsSize(size_t inputVector) const return size_t(typeSize * sz); } -size_t RNNDescriptor::GetParamsSize(Handle& /* handle */, +size_t RNNDescriptor::GetParamsSize(Handle const& /* handle */, const TensorDescriptor& xDesc, miopenDataType_t dtype) const { @@ -631,7 +631,7 @@ size_t RNNDescriptor::GetParamsSize(Handle& /* handle */, return GetParamsSize(input_vector_len); } -size_t RNNDescriptor::GetRNNInputSuperTensorSize(Handle& /* handle */, +size_t RNNDescriptor::GetRNNInputSuperTensorSize(Handle const& /* handle */, const int seqLength, c_array_view xDesc) const { @@ -658,7 +658,7 @@ size_t RNNDescriptor::GetRNNInputSuperTensorSize(Handle& /* handle */, } size_t -RNNDescriptor::GetRNNHiddenSuperTensorSize(Handle& /* handle */, +RNNDescriptor::GetRNNHiddenSuperTensorSize(Handle const& /* handle */, c_array_view xDesc) const { if(xDesc[0].GetType() != dataType) @@ -669,7 +669,7 @@ RNNDescriptor::GetRNNHiddenSuperTensorSize(Handle& /* handle */, return size_t(dirMode == miopenRNNbidirection ? 2 * x : x); } -void RNNDescriptor::GetParamsDescriptor(Handle& /* handle */, +void RNNDescriptor::GetParamsDescriptor(Handle const& /* handle */, const TensorDescriptor& xDesc, TensorDescriptor& wDesc, miopenDataType_t dtype) const @@ -697,7 +697,7 @@ void RNNDescriptor::GetParamsDescriptor(Handle& /* handle */, wDesc = miopen::TensorDescriptor(dtype, weight_lens); } -std::size_t RNNDescriptor::GetLayerParamSize(Handle& /*handle*/, +std::size_t RNNDescriptor::GetLayerParamSize(Handle const& /*handle*/, int layer, const TensorDescriptor& xDesc, int paramID) const @@ -730,7 +730,7 @@ std::size_t RNNDescriptor::GetLayerParamSize(Handle& /*handle*/, } std::size_t -RNNDescriptor::GetLayerBiasSize(Handle& /* handle */, int /*layer*/, int /*biasID*/) const +RNNDescriptor::GetLayerBiasSize(Handle const& /* handle */, int /*layer*/, int /*biasID*/) const { return size_t(typeSize * hsize); // is ther more needed here? } @@ -1163,7 +1163,7 @@ void RNNDescriptor::SeqTensorToTensorDescArray(const SeqTensorDescriptor& desc, }); } -void RNNDescriptor::RNNVanillaForward(Handle& handle, +void RNNDescriptor::RNNVanillaForward(Handle const& handle, miopenRNNFWDMode_t fwdMode, ConstData_t w, const SeqTensorDescriptor& xDesc, @@ -1238,7 +1238,7 @@ void RNNDescriptor::RNNVanillaForward(Handle& handle, } } -void RNNDescriptor::RNNVanillaBackwardData(Handle& handle, +void RNNDescriptor::RNNVanillaBackwardData(Handle const& handle, const SeqTensorDescriptor& yDesc, ConstData_t dy, const TensorDescriptor& hDesc, @@ -1289,7 +1289,7 @@ void RNNDescriptor::RNNVanillaBackwardData(Handle& handle, reserveSpaceSize); } -void RNNDescriptor::RNNVanillaBackwardWeights(Handle& handle, +void RNNDescriptor::RNNVanillaBackwardWeights(Handle const& handle, const SeqTensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& hDesc, @@ -1328,7 +1328,7 @@ void RNNDescriptor::RNNVanillaBackwardWeights(Handle& handle, reserveSpaceSize); } -void RNNDescriptor::RNNForward(Handle& handle, +void RNNDescriptor::RNNForward(Handle const& handle, miopenRNNFWDMode_t fwdMode, const SeqTensorDescriptor& xDesc, ConstData_t x, @@ -1430,7 +1430,7 @@ void RNNDescriptor::RNNForward(Handle& handle, #endif } -void RNNDescriptor::RNNBackwardData(Handle& handle, +void RNNDescriptor::RNNBackwardData(Handle const& handle, const SeqTensorDescriptor& yDesc, ConstData_t, ConstData_t dy, @@ -1538,7 +1538,7 @@ void RNNDescriptor::RNNBackwardData(Handle& handle, #endif } -void RNNDescriptor::RNNBackwardWeights(Handle& handle, +void RNNDescriptor::RNNBackwardWeights(Handle const& handle, const SeqTensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& hDesc, diff --git a/src/rnn/Solutions/bwd_multi_stream.cpp b/src/rnn/Solutions/bwd_multi_stream.cpp index 964c8d50fa..97048012d0 100644 --- a/src/rnn/Solutions/bwd_multi_stream.cpp +++ b/src/rnn/Solutions/bwd_multi_stream.cpp @@ -254,7 +254,7 @@ void RNNModularMultiStreamBWD::PrologueDispatch(const runtimeArgsBwd& args) cons rnnAlgoModules.PropDy(*args.handle, args.dy, args.workSpace); } -void RNNModularMultiStreamBWD::ComputeBWD(Handle& handle, +void RNNModularMultiStreamBWD::ComputeBWD(Handle const& handle, ConstData_t dy, ConstData_t dhy, Data_t dhx, diff --git a/src/rnn/Solutions/bwd_s_stream.cpp b/src/rnn/Solutions/bwd_s_stream.cpp index 5244aff4bd..ab929e3a5c 100644 --- a/src/rnn/Solutions/bwd_s_stream.cpp +++ b/src/rnn/Solutions/bwd_s_stream.cpp @@ -29,7 +29,7 @@ namespace miopen { namespace rnn_base { -void RNNModularSingleStreamBWD::ComputeBWD(Handle& handle, +void RNNModularSingleStreamBWD::ComputeBWD(Handle const& handle, ConstData_t dy, ConstData_t dhy, Data_t dhx, diff --git a/src/rnn/Solutions/fwd_s_stream.cpp b/src/rnn/Solutions/fwd_s_stream.cpp index a9c1ed9751..3d9d1f9721 100644 --- a/src/rnn/Solutions/fwd_s_stream.cpp +++ b/src/rnn/Solutions/fwd_s_stream.cpp @@ -29,7 +29,8 @@ namespace miopen { namespace rnn_base { -void RNNModularSingleStreamFWD::ComputeFWD(Handle& handle, const runtimeArgsFwd& runtimeArgs) const +void RNNModularSingleStreamFWD::ComputeFWD(Handle const& handle, + const runtimeArgsFwd& runtimeArgs) const { if(rnnDesc.nLayers == 0 || max_seq_len == 0) diff --git a/src/rnn/Solutions/rnn_transformer.cpp b/src/rnn/Solutions/rnn_transformer.cpp index 72ebb560ee..db1124433e 100644 --- a/src/rnn/Solutions/rnn_transformer.cpp +++ b/src/rnn/Solutions/rnn_transformer.cpp @@ -120,7 +120,7 @@ size_t RNNDescriptor::RNNTransformerWorkspaceSize(const SeqTensorDescriptor& xDe typeSize; } -void RNNDescriptor::RNNTransformerForward(Handle& handle, +void RNNDescriptor::RNNTransformerForward(Handle const& handle, miopenRNNFWDMode_t fwdMode, ConstData_t w, const SeqTensorDescriptor& xDesc, @@ -278,7 +278,7 @@ void RNNDescriptor::RNNTransformerForward(Handle& handle, } } -void RNNDescriptor::RNNTransformerBackwardData(Handle& handle, +void RNNDescriptor::RNNTransformerBackwardData(Handle const& handle, const SeqTensorDescriptor& yDesc, ConstData_t dy, const TensorDescriptor& hDesc, @@ -446,7 +446,7 @@ void RNNDescriptor::RNNTransformerBackwardData(Handle& handle, } } -void RNNDescriptor::RNNTransformerBackwardWeights(Handle& handle, +void RNNDescriptor::RNNTransformerBackwardWeights(Handle const& handle, const SeqTensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& hDesc, diff --git a/src/rnn/selector.cpp b/src/rnn/selector.cpp index e7966eaffa..ef12f6f025 100644 --- a/src/rnn/selector.cpp +++ b/src/rnn/selector.cpp @@ -65,7 +65,7 @@ bool RNNBwWeightMSIsFast(const int seqLen) return false; } -void RNNDescriptor::ModularForward(Handle& handle, +void RNNDescriptor::ModularForward(Handle const& handle, miopenRNNFWDMode_t fwdMode, ConstData_t w, const SeqTensorDescriptor& xDesc, @@ -88,7 +88,7 @@ void RNNDescriptor::ModularForward(Handle& handle, handle, rnn_base::runtimeArgsFwd{x, hx, cx, y, hy, cy, w, workSpace, reserveSpace}); } -void RNNDescriptor::ModularBackward(Handle& handle, +void RNNDescriptor::ModularBackward(Handle const& handle, const SeqTensorDescriptor& yDesc, ConstData_t dy, const TensorDescriptor& hDesc, @@ -122,7 +122,7 @@ void RNNDescriptor::ModularBackward(Handle& handle, } } -void RNNDescriptor::ModularBackwardWeights(Handle& handle, +void RNNDescriptor::ModularBackwardWeights(Handle const& handle, const SeqTensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& hDesc, diff --git a/src/rope.cpp b/src/rope.cpp index 9dca9b145e..b8fcb153e9 100644 --- a/src/rope.cpp +++ b/src/rope.cpp @@ -35,7 +35,7 @@ namespace miopen { -miopenStatus_t RoPEForward(Handle& handle, +miopenStatus_t RoPEForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& cosDesc, @@ -69,7 +69,7 @@ miopenStatus_t RoPEForward(Handle& handle, return miopenStatusSuccess; } -miopenStatus_t RoPEBackward(Handle& handle, +miopenStatus_t RoPEBackward(Handle const& handle, const TensorDescriptor& dyDesc, ConstData_t dy, const TensorDescriptor& cosDesc, diff --git a/src/softmarginloss.cpp b/src/softmarginloss.cpp index 5bb98050a0..cabe87fc0e 100644 --- a/src/softmarginloss.cpp +++ b/src/softmarginloss.cpp @@ -35,7 +35,7 @@ namespace miopen { -std::size_t GetSoftMarginLossForwardWorkspaceSize(Handle& handle, +std::size_t GetSoftMarginLossForwardWorkspaceSize(Handle const& handle, const TensorDescriptor& iDesc, const TensorDescriptor& tDesc, const TensorDescriptor& oDesc, @@ -50,7 +50,7 @@ std::size_t GetSoftMarginLossForwardWorkspaceSize(Handle& handle, return pair_size_vector.empty() ? static_cast(-1) : pair_size_vector.front().second; } -miopenStatus_t SoftMarginLossForward(Handle& handle, +miopenStatus_t SoftMarginLossForward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& iDesc, @@ -84,7 +84,7 @@ miopenStatus_t SoftMarginLossForward(Handle& handle, return miopenStatusSuccess; } -miopenStatus_t SoftMarginLossBackward(Handle& handle, +miopenStatus_t SoftMarginLossBackward(Handle const& handle, const TensorDescriptor& iDesc, ConstData_t i, const TensorDescriptor& tDesc, diff --git a/src/softmax.cpp b/src/softmax.cpp index 38b233e2e6..8d34af5218 100644 --- a/src/softmax.cpp +++ b/src/softmax.cpp @@ -100,7 +100,7 @@ void from_json(const nlohmann::json& json, SoftmaxDescriptor& descriptor) json.at("mode").get_to(descriptor.mode); } -miopenStatus_t SoftmaxForward(Handle& handle, +miopenStatus_t SoftmaxForward(Handle const& handle, const void* alpha, const void* beta, const TensorDescriptor& xDesc, @@ -128,7 +128,7 @@ miopenStatus_t SoftmaxForward(Handle& handle, return miopenStatusSuccess; } -miopenStatus_t SoftmaxBackward(Handle& handle, +miopenStatus_t SoftmaxBackward(Handle const& handle, const void* alpha, const TensorDescriptor& yDesc, ConstData_t y, diff --git a/src/solution.cpp b/src/solution.cpp index 3df767c90b..c14132f8c7 100644 --- a/src/solution.cpp +++ b/src/solution.cpp @@ -57,7 +57,7 @@ void LogCmdConvolution(const miopen::TensorDescriptor& x, namespace miopen { -void Solution::Run(Handle& handle, +void Solution::Run(Handle const& handle, const std::unordered_map& inputs, Data_t workspace, std::size_t workspace_size) @@ -148,7 +148,7 @@ void Solution::LogDriverCommand(const FusedProblem& problem_) const /// \todo: add logging of some command to reproduce current solution or at least problem } -void Solution::RunImpl(Handle& handle, +void Solution::RunImpl(Handle const& handle, const std::unordered_map& inputs, Data_t workspace, std::size_t workspace_size, @@ -257,7 +257,7 @@ void Solution::RunImpl(Handle& handle, checkNumericsOutput_(); } -void Solution::RunImpl(Handle& handle, +void Solution::RunImpl(Handle const& handle, const std::unordered_map& inputs, Data_t workspace, std::size_t workspace_size, @@ -451,7 +451,7 @@ void Solution::RunImpl(Handle& handle, (*invoker)(handle, invoke_ctx); } -void Solution::RunImpl(Handle& handle, +void Solution::RunImpl(Handle const& handle, const std::unordered_map& inputs, Data_t /*workspace*/, std::size_t /*workspace_size*/, @@ -554,7 +554,7 @@ void Solution::RunImpl(Handle& handle, (*invoker)(handle, invoke_ctx); } -void Solution::RunImpl(Handle& handle, +void Solution::RunImpl(Handle const& handle, const std::unordered_map& inputs, Data_t /*workspace*/, std::size_t /*workspace_size*/, diff --git a/src/solver/conv/gemm_common.cpp b/src/solver/conv/gemm_common.cpp index a32d769338..32d4d0cbaa 100644 --- a/src/solver/conv/gemm_common.cpp +++ b/src/solver/conv/gemm_common.cpp @@ -52,7 +52,7 @@ namespace solver { namespace conv { namespace gemm { -std::size_t MaxMemAllocSz(Handle& h, +std::size_t MaxMemAllocSz(Handle const& h, const miopen::conv::ProblemDescription& problem, bool double_limit_for_fp32) { diff --git a/src/t5layernorm.cpp b/src/t5layernorm.cpp index 5978fdd677..51f298b237 100644 --- a/src/t5layernorm.cpp +++ b/src/t5layernorm.cpp @@ -34,7 +34,7 @@ namespace miopen { -miopenStatus_t T5LayerNormForward(Handle& handle, +miopenStatus_t T5LayerNormForward(Handle const& handle, const TensorDescriptor& xDesc, ConstData_t x, const TensorDescriptor& weightDesc, @@ -70,7 +70,7 @@ miopenStatus_t T5LayerNormForward(Handle& handle, return miopenStatusSuccess; } -std::size_t GetT5LayerNormBackwardWorkspaceSize(Handle& handle, +std::size_t GetT5LayerNormBackwardWorkspaceSize(Handle const& handle, const TensorDescriptor& dyDesc, const TensorDescriptor& xDesc, const TensorDescriptor& weightDesc, @@ -91,7 +91,7 @@ std::size_t GetT5LayerNormBackwardWorkspaceSize(Handle& handle, return pair_size_vector.empty() ? static_cast(0) : pair_size_vector.front().second; } -miopenStatus_t T5LayerNormBackward(Handle& handle, +miopenStatus_t T5LayerNormBackward(Handle const& handle, Data_t workspace, size_t workspaceSizeInBytes, const TensorDescriptor& dyDesc, diff --git a/src/transformers_adam_w.cpp b/src/transformers_adam_w.cpp index 0e644d8344..2518a4bbbb 100644 --- a/src/transformers_adam_w.cpp +++ b/src/transformers_adam_w.cpp @@ -35,7 +35,7 @@ namespace miopen { -miopenStatus_t TransformersAdamW(Handle& handle, +miopenStatus_t TransformersAdamW(Handle const& handle, const TensorDescriptor& paramInDesc, ConstData_t paramIn, const TensorDescriptor& paramOutDesc, diff --git a/test/conv_common.hpp b/test/conv_common.hpp index 81cc20eee1..5dc93ba22b 100644 --- a/test/conv_common.hpp +++ b/test/conv_common.hpp @@ -68,7 +68,7 @@ using Direction = miopen::conv::Direction; bool get_handle_xnack(); #if TEST_DIRECT_SUPPORTED_CONFIG_ONLY -static inline bool is_direct_fwd_bwd_data_supported(miopen::Handle& handle, +static inline bool is_direct_fwd_bwd_data_supported(miopen::Handle const& handle, const miopen::ConvolutionDescriptor convDesc, const miopen::TensorDescriptor& xDesc, const miopen::TensorDescriptor& wDesc, @@ -97,7 +97,7 @@ static inline bool is_direct_fwd_bwd_data_supported(miopen::Handle& handle, return true; } -static inline bool is_direct_bwd_wrw_supported(miopen::Handle& handle, +static inline bool is_direct_bwd_wrw_supported(miopen::Handle const& handle, const miopen::ConvolutionDescriptor convDesc, const miopen::TensorDescriptor& xDesc, const miopen::TensorDescriptor& wDesc, diff --git a/test/cpu_rnn.hpp b/test/cpu_rnn.hpp index 98ea98cc10..b97abc03d2 100644 --- a/test/cpu_rnn.hpp +++ b/test/cpu_rnn.hpp @@ -31,7 +31,7 @@ **********************************************/ template -void LSTMFwdCPUVerify(miopen::Handle& handle, +void LSTMFwdCPUVerify(miopen::Handle const& handle, bool use_dropout, const miopen::DropoutDescriptor& dropoutDesc, const std::vector& in, @@ -1563,7 +1563,7 @@ void LSTMBwdWeightCPUVerify(bool use_dropout_cpu, * rnn_vanilla_common.hpp **********************************************/ template -void RNNFwdTrainCPUVerify(miopen::Handle& handle, +void RNNFwdTrainCPUVerify(miopen::Handle const& handle, bool use_dropout, const miopen::DropoutDescriptor& dropoutDesc, const std::vector& in, @@ -2728,7 +2728,7 @@ void RNNBwdWeightCPUVerify(bool use_dropout, **********************************************/ template -void GRUFwdCPUVerify(miopen::Handle& handle, +void GRUFwdCPUVerify(miopen::Handle const& handle, bool use_dropout, const miopen::DropoutDescriptor& dropoutDesc, const std::vector& in, @@ -4488,7 +4488,7 @@ void GRUBwdWeightCPUVerify(bool use_dropout, **********************************************/ template void UniformRNNFwdTrainCPUVerify( - miopen::Handle& handle, + miopen::Handle const& handle, bool use_dropout, const miopen::DropoutDescriptor& dropoutDesc, const std::vector& in, diff --git a/test/dropout_util.hpp b/test/dropout_util.hpp index 5234d92f7b..ed6700d022 100644 --- a/test/dropout_util.hpp +++ b/test/dropout_util.hpp @@ -106,7 +106,7 @@ inline void ExpandTensorDim(std::vector x_len, } template -void DropoutForwardVerify(miopen::Handle& handle, +void DropoutForwardVerify(miopen::Handle const& handle, const miopen::DropoutDescriptor& DropoutDesc, const miopen::TensorDescriptor& inputTensor, const std::vector& input, diff --git a/test/gru_common.hpp b/test/gru_common.hpp index bf5ab07ead..26dd8cb516 100644 --- a/test/gru_common.hpp +++ b/test/gru_common.hpp @@ -58,7 +58,7 @@ * **********************************************/ template -void GRUFwdCPUVerify(miopen::Handle& handle, +void GRUFwdCPUVerify(miopen::Handle const& handle, bool use_dropout, miopen::DropoutDescriptor& dropoutDesc, std::vector& in, diff --git a/test/gtest/bad_fusion_plan.cpp b/test/gtest/bad_fusion_plan.cpp index 34d704a836..f21f7eb9e7 100644 --- a/test/gtest/bad_fusion_plan.cpp +++ b/test/gtest/bad_fusion_plan.cpp @@ -139,7 +139,7 @@ class GPU_FusionPlan_FP16 miopen::TensorDescriptor bias_des; miopen::TensorDescriptor weights_des; - miopen::Handle& handle; + miopen::Handle const& handle; miopen::ConvolutionDescriptor conv_desc; miopen::ActivationDescriptor activ_desc; diff --git a/test/gtest/bn_infer_fused_ocl_hip.cpp b/test/gtest/bn_infer_fused_ocl_hip.cpp index 955cbba8a9..ef39c31960 100644 --- a/test/gtest/bn_infer_fused_ocl_hip.cpp +++ b/test/gtest/bn_infer_fused_ocl_hip.cpp @@ -42,7 +42,7 @@ #define warpSize 32 #endif -void BatchNormFusedInferencGPU(miopen::Handle& handle, +void BatchNormFusedInferencGPU(miopen::Handle const& handle, miopenBatchNormMode_t bn_mode, miopenActivationMode_t activ_mode, const float activ_alpha, diff --git a/test/gtest/db_sync.cpp b/test/gtest/db_sync.cpp index 682b38b652..c2da259310 100644 --- a/test/gtest/db_sync.cpp +++ b/test/gtest/db_sync.cpp @@ -546,7 +546,7 @@ bool LogBuildMessage() void BuildKernel(const fs::path& program_file, const std::string& program_args, - [[maybe_unused]] miopen::Handle& handle) + [[maybe_unused]] miopen::Handle const& handle) { // Build the code object entry // This will write the code object in the user kdb which Jenkins can archive diff --git a/test/gtest/gpu_mha_backward.cpp b/test/gtest/gpu_mha_backward.cpp index 86a28d4e43..5c317507cc 100644 --- a/test/gtest/gpu_mha_backward.cpp +++ b/test/gtest/gpu_mha_backward.cpp @@ -121,7 +121,7 @@ class Test_Bwd_Mha : public testing::TestWithParam { prng::reset_seed(); auto [n, h, s, d, drop] = GetParam(); - Handle& handle = get_handle(); + Handle const& handle = get_handle(); if((drop > 0.0f)) { @@ -303,7 +303,7 @@ class Test_Bwd_Mha : public testing::TestWithParam void TestBody() override { - Handle& handle = get_handle(); + Handle const& handle = get_handle(); auto FindSolutions = [&handle](miopenProblem_t problem_) { std::size_t found; diff --git a/test/gtest/gpu_mha_forward.cpp b/test/gtest/gpu_mha_forward.cpp index 638c050bad..4db5b565b9 100644 --- a/test/gtest/gpu_mha_forward.cpp +++ b/test/gtest/gpu_mha_forward.cpp @@ -156,7 +156,7 @@ class Test_Fwd_Mha : public testing::TestWithParam { prng::reset_seed(); auto [n, h, s, d, drop] = GetParam(); - Handle& handle = get_handle(); + Handle const& handle = get_handle(); if((drop > 0.0f) && (s % handle.GetWavefrontWidth() != 0)) { @@ -304,7 +304,7 @@ class Test_Fwd_Mha : public testing::TestWithParam void TestBody() override { - Handle& handle = get_handle(); + Handle const& handle = get_handle(); std::vector solutions(16); std::size_t found; @@ -332,7 +332,7 @@ class Test_Fwd_Mha : public testing::TestWithParam } } - virtual void VerifyResults(Handle& handle) + virtual void VerifyResults(Handle const& handle) { auto GetResult = [this, &handle](miopenTensorArgumentId_t id, auto type) { using ResultT = std::decay_t; @@ -438,7 +438,7 @@ class GPU_Fwd_Mha_FP16 : public Test_Fwd_Mha q_val, k_val, v_val, softmax, attn_max, Z_sum, output); } - void VerifyResults(Handle& handle) override + void VerifyResults(Handle const& handle) override { auto GetResult = [this, &handle](miopenTensorArgumentId_t id) { auto& tensorStructPtr = tensors[id]; diff --git a/test/gtest/graphapi_capi_mha_backward.cpp b/test/gtest/graphapi_capi_mha_backward.cpp index 814b09a051..0b3b47cdc9 100644 --- a/test/gtest/graphapi_capi_mha_backward.cpp +++ b/test/gtest/graphapi_capi_mha_backward.cpp @@ -45,7 +45,7 @@ class MhaBackwardTest : public MhaCommonTest } } - virtual void MakeRealTensorsAndFillData(miopen::Handle& handle) override + virtual void MakeRealTensorsAndFillData(miopen::Handle const& handle) override { auto q = test::cpu::GenScaledTensorBackward(m_testN, m_testH, m_testS, m_testD); auto k = test::cpu::GenScaledTensorBackward(m_testN, m_testH, m_testS, m_testD); @@ -374,7 +374,7 @@ class MhaBackwardTest : public MhaCommonTest m_realTensorMap[miopenTensorMhaDK]->m_gapiDesc); } - virtual void RunCPUverify(miopen::Handle& handle) override + virtual void RunCPUverify(miopen::Handle const& handle) override { const double errorThreshold = 5e-5; const double fp8ErrorThreshold = (std::is_same_v) ? 3e-3 : errorThreshold; diff --git a/test/gtest/graphapi_capi_mha_common.hpp b/test/gtest/graphapi_capi_mha_common.hpp index c30e0401a2..30ab8c11c4 100644 --- a/test/gtest/graphapi_capi_mha_common.hpp +++ b/test/gtest/graphapi_capi_mha_common.hpp @@ -184,14 +184,14 @@ struct TensorData miopen::Allocator::ManageDataPtr m_gpuBuffer; template - void InitAndWriteToGPU(miopen::Handle& handle, tensor&& tensor) + void InitAndWriteToGPU(miopen::Handle const& handle, tensor&& tensor) { m_tensorVariant = std::move(tensor); m_gpuBuffer = handle.Write(GetTensor(m_tensorVariant).data); } template - void InitAndWriteToGPU(miopen::Handle& handle, T val) + void InitAndWriteToGPU(miopen::Handle const& handle, T val) { GetTensor(m_tensorVariant).generate([=](auto...) { return val; }); m_gpuBuffer = handle.Write(GetTensor(m_tensorVariant).data); @@ -238,7 +238,7 @@ class MhaCommonTest : public testing::TestWithParam 0.0f) && (s % handle.GetWavefrontWidth() != 0)) { @@ -249,7 +249,7 @@ class MhaCommonTest : public testing::TestWithParamAddRef(engineConfig); } - virtual void MakeVariantPackAndRun(miopen::Handle& handle) + virtual void MakeVariantPackAndRun(miopen::Handle const& handle) { miopenHandle_t rawHandle = &handle; @@ -388,7 +388,7 @@ class MhaCommonTest : public testing::TestWithParam - tensor& GetResult(const int64_t& id, miopen::Handle& handle) + tensor& GetResult(const int64_t& id, miopen::Handle const& handle) { auto it = m_realTensorMap.find(id); assert(it != m_realTensorMap.cend()); @@ -400,7 +400,7 @@ class MhaCommonTest : public testing::TestWithParam class MhaForwardTest : public MhaCommonTest { protected: - virtual void MakeRealTensorsAndFillData(miopen::Handle& handle) override + virtual void MakeRealTensorsAndFillData(miopen::Handle const& handle) override { // We use identifiers from Find 2.0 enum to have sopmething unique for the test purposes MakeAndAddRealTensorDescriptor( @@ -73,7 +73,7 @@ class MhaForwardTest : public MhaCommonTest m_nextTensorId++; } - void InitTensorValues(miopen::Handle& handle) + void InitTensorValues(miopen::Handle const& handle) { using namespace test::cpu; @@ -215,7 +215,7 @@ class MhaForwardTest : public MhaCommonTest m_realTensorMap[miopenTensorMhaO]->m_gapiDesc); } - virtual void RunCPUverify(miopen::Handle& handle) override + virtual void RunCPUverify(miopen::Handle const& handle) override { auto softmaxRef = tensor{m_testN, m_testH, m_testS, m_testS}; auto oDescRef = tensor{m_testN, m_testH, m_testS, m_testD}; @@ -313,7 +313,7 @@ class GPU_MhaForward_FP16 : public MhaForwardTest } } - void RunCPUverify(miopen::Handle& handle) override + void RunCPUverify(miopen::Handle const& handle) override { auto softmaxRef = tensor{m_testN, m_testH, m_testS, m_testS}; auto oDescRef = tensor{m_testN, m_testH, m_testS, m_testD}; diff --git a/test/gtest/gtest_activation.cpp b/test/gtest/gtest_activation.cpp index 2ac591b36b..cc4a4259d6 100644 --- a/test/gtest/gtest_activation.cpp +++ b/test/gtest/gtest_activation.cpp @@ -202,7 +202,7 @@ struct GPU_TestActivation_FP32 miopen::Allocator::ManageDataPtr dout_dev; // dy }; -miopenStatus_t RunFwdActivation(miopen::Handle& handle, +miopenStatus_t RunFwdActivation(miopen::Handle const& handle, miopenActivationDescriptor_t activationDesc, const void* alpha, const miopen::TensorDescriptor& xDesc, @@ -226,7 +226,7 @@ miopenStatus_t RunFwdActivation(miopen::Handle& handle, return status; } -miopenStatus_t RunFwdBwdActivation(miopen::Handle& handle, +miopenStatus_t RunFwdBwdActivation(miopen::Handle const& handle, miopenActivationDescriptor_t activationDesc, const void* alpha, const miopen::TensorDescriptor& xDesc, diff --git a/test/gtest/gtest_common.cpp b/test/gtest/gtest_common.cpp index 1c6dd83047..b058c7a165 100644 --- a/test/gtest/gtest_common.cpp +++ b/test/gtest/gtest_common.cpp @@ -37,7 +37,10 @@ std::string MockHandle::GetDeviceName() const { return std::string{dev_descr.nam std::size_t MockHandle::GetMaxComputeUnits() const { return dev_descr.cu_cnt; } -std::size_t MockHandle::GetMaxMemoryAllocSize() { return std::numeric_limits::max(); } +std::size_t MockHandle::GetMaxMemoryAllocSize() const +{ + return std::numeric_limits::max(); +} bool MockHandle::CooperativeLaunchSupported() const { return false; } diff --git a/test/gtest/hipblaslt_gemm.cpp b/test/gtest/hipblaslt_gemm.cpp index ec79290b7d..618b5422c0 100644 --- a/test/gtest/hipblaslt_gemm.cpp +++ b/test/gtest/hipblaslt_gemm.cpp @@ -196,7 +196,7 @@ static void RunGemmDescriptors(const TestCase& testCase, miopenDataType_t dataTy workspaceB_device.Write(workspaceB_host); workspaceC_device.Write(workspaceC_host); - Handle& handle = get_handle(); + Handle const& handle = get_handle(); if(desc.batch_count == 1) { @@ -255,7 +255,7 @@ static void CheckExceptions(miopenDataType_t dataType) Workspace workspaceB_device(bSize * sizeof(T)); Workspace workspaceC_device(cSize * sizeof(T)); - Handle& handle = get_handle(); + Handle const& handle = get_handle(); EXPECT_THROW(CallGemm(handle, desc, diff --git a/test/gtest/mha_find20.cpp b/test/gtest/mha_find20.cpp index af3d0b8862..9a7dc03ce8 100644 --- a/test/gtest/mha_find20.cpp +++ b/test/gtest/mha_find20.cpp @@ -70,7 +70,7 @@ struct TensorStruct TensorStruct(const TensorVariant& var) { tensorVariant = var; } - void GpuRead(Handle& handle) + void GpuRead(Handle const& handle) { if(std::holds_alternative>(tensorVariant)) { @@ -88,7 +88,7 @@ struct TensorStruct } } - void GpuWrite(Handle& handle) + void GpuWrite(Handle const& handle) { if(std::holds_alternative>(tensorVariant)) { @@ -165,7 +165,7 @@ class MhaFind20Test public: MhaFind20Test(bool forward) : problem(nullptr), isForward(forward) { Initialize(); } - std::vector TestFindSolutions(Handle& handle) + std::vector TestFindSolutions(Handle const& handle) { std::cerr << "Testing miopenFindSolutions..." << std::endl; @@ -204,7 +204,7 @@ class MhaFind20Test std::cerr << "Finished testing miopenGetSolution." << std::endl; } - void TestRunSolutions(Handle& handle, const std::vector& solutions) + void TestRunSolutions(Handle const& handle, const std::vector& solutions) { std::cerr << "Testing a solution..." << std::endl; @@ -410,7 +410,7 @@ class MhaFind20Test } } - void GetForwardResultsWithoutFind20(Handle& handle, + void GetForwardResultsWithoutFind20(Handle const& handle, TensorStructMap& outputResultsMap, Workspace& workspace, uint64_t solver_id) @@ -505,7 +505,7 @@ class MhaFind20Test ReadData(handle, outputResultsMap); } - void GetBackwardResultsWithoutFind20(Handle& handle, + void GetBackwardResultsWithoutFind20(Handle const& handle, TensorStructMap& outputResultsMap, Workspace& workspace, uint64_t solver_id) @@ -630,7 +630,7 @@ class MhaFind20Test ReadData(handle, outputResultsMap); } - void ReadData(Handle& handle, TensorStructMap& outputResultsMap) + void ReadData(Handle const& handle, TensorStructMap& outputResultsMap) { for(const auto& it : outputResultsMap) { @@ -658,7 +658,7 @@ class MhaFind20Test TEST(GPU_TestMhaFind20_FP32, MhaForward) { - Handle& handle = get_handle(); + Handle const& handle = get_handle(); MhaFind20Test test(true); @@ -671,7 +671,7 @@ TEST(GPU_TestMhaFind20_FP32, MhaForward) TEST(GPU_TestMhaFind20_FP32, MhaBackward) { - Handle& handle = get_handle(); + Handle const& handle = get_handle(); MhaFind20Test test(false); diff --git a/test/gtest/perf_helper.hpp b/test/gtest/perf_helper.hpp index de8bcb6ef8..c9b7346191 100644 --- a/test/gtest/perf_helper.hpp +++ b/test/gtest/perf_helper.hpp @@ -151,7 +151,7 @@ struct PerfHelper } template - void perfTest(miopen::Handle& handle, + void perfTest(miopen::Handle const& handle, const std::string& kernel_name, const std::string& network_config, bool append, diff --git a/test/gtest/softmax_find20.cpp b/test/gtest/softmax_find20.cpp index 1727699213..e70f3a1f38 100644 --- a/test/gtest/softmax_find20.cpp +++ b/test/gtest/softmax_find20.cpp @@ -71,7 +71,7 @@ class SoftmaxFind20Test std::cerr << "Created softmax tensor descriptors." << std::endl; } - std::vector TestFindSolutions(Handle& handle) + std::vector TestFindSolutions(Handle const& handle) { std::cerr << "Testing miopenFindSolutions..." << std::endl; @@ -112,7 +112,8 @@ class SoftmaxFind20Test std::cerr << "Finished testing miopenGetSolution." << std::endl; } - void TestRunSolutionsForward(Handle& handle, const std::vector& solutions) + void TestRunSolutionsForward(Handle const& handle, + const std::vector& solutions) { std::cerr << "Testing solution functions..." << std::endl; @@ -177,7 +178,8 @@ class SoftmaxFind20Test std::cerr << "Finished testing solution functions." << std::endl; } - void TestRunSolutionsBackward(Handle& handle, const std::vector& solutions) + void TestRunSolutionsBackward(Handle const& handle, + const std::vector& solutions) { std::cerr << "Testing solution functions..." << std::endl; @@ -302,7 +304,7 @@ class SoftmaxFind20Test TEST(GPU_SoftmaxFind20_FP32, softmaxForward) { - Handle& handle = get_handle(); + Handle const& handle = get_handle(); SoftmaxFind20Test test(true); @@ -315,7 +317,7 @@ TEST(GPU_SoftmaxFind20_FP32, softmaxForward) TEST(GPU_SoftmaxFind20_FP32, softmaxBackward) { - Handle& handle = get_handle(); + Handle const& handle = get_handle(); SoftmaxFind20Test test(false); diff --git a/test/gtest/test_operations.hpp b/test/gtest/test_operations.hpp index 2e07e4f02a..10bfb37347 100644 --- a/test/gtest/test_operations.hpp +++ b/test/gtest/test_operations.hpp @@ -127,7 +127,7 @@ void AddActiv(miopen::FusionPlanDescriptor& fusePlanDesc, miopenStatusSuccess); } -inline bool Skip(miopen::Handle& handle) +inline bool Skip(miopen::Handle const& handle) { const std::string arch = handle.GetDeviceName(); bool skip_test = (arch != "gfx908" && arch != "gfx90a"); diff --git a/test/handle_test.cpp b/test/handle_test.cpp index 743e9f7e7a..f608e513b3 100644 --- a/test/handle_test.cpp +++ b/test/handle_test.cpp @@ -95,7 +95,7 @@ std::string Write2s(kernel_type_t kern_type) } } -void run2s(miopen::Handle& h, std::size_t n, kernel_type_t kern_type) +void run2s(miopen::Handle const& h, std::size_t n, kernel_type_t kern_type) { std::vector data_in(n, 1); auto data_dev = h.Write(data_in); diff --git a/test/rnn_seq_api.hpp b/test/rnn_seq_api.hpp index 58cf9170d6..46025a9c39 100644 --- a/test/rnn_seq_api.hpp +++ b/test/rnn_seq_api.hpp @@ -50,7 +50,7 @@ template miopen::Allocator::ManageDataPtr -createTensorAtGPUOrNullptr(miopen::Handle& handle, TensorT& tensor, bool is_nullptr) +createTensorAtGPUOrNullptr(miopen::Handle const& handle, TensorT& tensor, bool is_nullptr) { if(!is_nullptr) return handle.Create(tensor.GetDataByteSize()); @@ -60,7 +60,7 @@ createTensorAtGPUOrNullptr(miopen::Handle& handle, TensorT& tensor, bool is_null template miopen::Allocator::ManageDataPtr -transferTensorToGPUOrNullptr(miopen::Handle& handle, TensorT& tensor, bool is_nullptr) +transferTensorToGPUOrNullptr(miopen::Handle const& handle, TensorT& tensor, bool is_nullptr) { if(!is_nullptr) return handle.Write(tensor.data); @@ -70,7 +70,7 @@ transferTensorToGPUOrNullptr(miopen::Handle& handle, TensorT& tensor, bool is_nu // read from GPU cnt elements of type T template