Open atamazov opened 3 years ago
conv::ProblemDescription
This is an input for the Solver.
struct ProblemDescription
{
int n_inputs = 0;
int in_height = 0;
int in_width = 0;
int kernel_size1 = 0;
int kernel_size0 = 0;
int n_outputs = 0;
...
struct Direction direction; // has members like IsBackwardData() etc
...
}
struct ProblemDescription
{...
int GetBackwardPad0() const { return kernel_size0 - pad0 - 1; }
int GetBackwardPad1() const { return kernel_size1 - pad1 - 1; }
...}
ExecutionContext
TBD|
ConvolutionContext
Inherits from ProblemDescription
and ExecutionContext
, so for example an instance of ConvolutionContext
can be used as an instance of conv::ProblemDescription
. More info TBD.
Solver is an object which encapsulates the implementation of specific primitive.
bool IsApplicable(ConvolutionContext&);
If a Solver needs workspace:
size_t GetWorkspaceSize(const ConvolutionContext&) const
bool MayNeedWorkspace() const
Each Solver instance s
can be used as a parameter to GetSolverDbId(s)
template function which retrieves the string id of the Solver. There is default implementation of GetSolverDbId()
which returns the class name and can be overridden if necessary.
If a Solver is Dynamic:
bool IsDynamic() const { return true; }
If a Solver is NOT searchable (NOT tunable):
Solution GetSolution(ConvolutionContext&);
If a Solver is searchable (tunable), then also the accompanying PerformanceConfig type shall be defined plus some member functions:
PerformanceConfig GetPerformanceConfig(const ConvolutionContext&) const;
PerformanceConfig Search(const ConvolutionContext&) const;
Solution GetSolution(const ConvolutionContext&, const PerformanceConfig&);
bool IsValidPerformanceConfig(const ConvolutionContext&, const PerformanceConfig&);
PerformanceConfig
instance (e.g. read from the perf-db) is valid.GetSolution()
:Modern Solvers employ Generic search.
Search()
.Search()
in Solvers as simple calls to the GenericSearch()
template function. PerformanceConfig
type to provide some member functions. These functions are used by GenericSearch()
in order to build the ComputedContainer
object and iterate over it.RunAndMeasureSolution()
. This is to be removed as soon as Invoker object concept is implemented.~The PerformanceConfig
of a modern searchable Solver type shall provide some functions. These are necessary to build the ComputedContainer instances. The following member functions are required for that:
(ctor)()
(ctor)(bool)
SetNextValue(ConvolutionContext& c)
SetNextValue()
before #1033.PerformaneConfig
instance pc
is valid if and only if the IsValidPerformanceConfig(..., pc)
returns true. This ensures that all the perf-configs which reside in the ComputedContainer
are:IsValid(ConvolutionContext& c) const
operator==(const PerformanceConfig&)
⚠️ IMPORTANT:
GetPerformanceConfig(const ConvolutionContext&)
).All PerformanceConfig types shall implement the following member functions:
void Serialize(std::ostream&) const;
bool Deserialize(const std::string& str)
Information required to build and run a kernel (or a set of kernels), which is expected to perform computatons as per the ProblemConfig
.
struct ConvSolution
{
std::vector<KernelInfo> construction_params; // impl may consist of multiple kernels.
miopenStatus_t status;
std::string solver_id;
...
}
As you see, it contains a vector of KernelInfo objects.
struct KernelInfo
{
std::string comp_options;
std::vector<size_t> l_wk;
std::vector<size_t> g_wk;
std::string kernel_file;
std::string kernel_name;
friend std::ostream& operator<<(std::ostream& os, const KernelInfo& k);
};
Just curious, should this topic belong or eventually belong to Wiki or Contribution Guide page? It looks like a guideline which we should follow. The intention for the issue is to bring up discussion and key decision?
@junliume This is a copy of a presentation for MIOpen team I held a couple of years ago, when we've introduced and implemented the Solver/Solution architecture. It does not cover the recent additions like GetWti() and Invokers.
I would like to make it available for all MIOpen developers, including collaborators.
SolverDbId(solver)
PerformanceConfigs
Currently we are not going to include strides of non-packed tensors to the database keys. Only an optional flag (saying that at least one tensor is non-packed) should be included there. The above means that databases will share the same find-db records, same Invoker instances and same perf-db information for the non-packed convolutions that differ only in strides.
The above design should work correctly provided that:
InvokeParams
and pass it to the kernels as arguments. _Originated from https://github.com/ROCmSoftwarePlatform/MIOpen/pull/2334#discussion_r1348090910_
This is a copy of a presentation for MIOpen team I held a couple of years ago, when we've introduced and implemented the Solver/Solution architecture. It does not cover the recent additions like GetWti() and Invokers. I would like to make it available for all MIOpen developers, including collaborators.
Though a bit outdated, this should provide a good overview of how device code is abstracted away from the rest of the library.
1. Intent
Problem: Variety of convolution kernels
Experience shows that straightforward attempts to support such a set of kernels result in host code which is large, fragile, difficult to develop and maintain. You may see leftovers of this in convolutionocl.cpp.
Provide abstractions which able to represent in the single place all the information required to
Such abstractions allow working with all convolutions in unified manner. Currently, there are: