Conversation
|
@alexandraBara Hey there, here is the PR draft. |
@DrizztDoUrden Sounds good, ill use your branch for my changes. |
| -> decltype(s.GetPerformanceConfig(context)) | ||
| { | ||
| static_assert( | ||
| !(is_detected<RunAndMeasure_t, Solver, ConstData_t, Data_t>::value || |
There was a problem hiding this comment.
Use {} instead of ::value.
| if(&other != this) | ||
| impl = other.impl ? other.impl->Copy() : nullptr; | ||
| return *this; | ||
| } |
There was a problem hiding this comment.
The assignment operator should use copy-swap:
AnyInvokeParams& operator=(AnyInvokeParams other)
{
impl.swap(other.impl);
return *this;
}This provides the strong exception guarantee.
| { | ||
| } | ||
|
|
||
| AnyInvokeParams(AnyInvokeParams&& other) noexcept : impl(std::move(other.impl)) {} |
There was a problem hiding this comment.
This can be AnyInvokeParams(AnyInvokeParams&& other) noexcept = default.
| } | ||
|
|
||
| template <class Actual, | ||
| class = std::enable_if_t<!std::is_same<Actual, AnyInvokeParams>::value, void>> |
There was a problem hiding this comment.
Use {} instead of ::value here as well.
| } | ||
|
|
||
| template <class Actual> | ||
| Actual& CastTo() |
There was a problem hiding this comment.
This should be a static or free function so you dont have to create multiple overloads for const and non-const.
There was a problem hiding this comment.
To be honest, I don't understand how being static/free would help with multiple overloads. I could make it copying like boost::any_cast, which would reduce it to a single const overload, or make it templated (regarding receiving AnyInvokeParams) with auto, which would be a strange solution to eliminate a single five-lined overload. Could you please clarify?
There was a problem hiding this comment.
I was suggesting writing something like this:
template<class Actual, class T>
static Actual& AnyCast(T&& x)
{
if(!x.impl)
MIOPEN_THROW("Attempt to use empty AnyInvokeParams.");
if(!x.impl->CanCastTo(typeid(Actual)))
MIOPEN_THROW("Attempt to cast AnyInvokeParams to invalid type.");
return *reinterpret_cast<Actual*>(x.impl->GetRawPtr());
}But this will require the const to match. It might be better to have two seperate overloads and remove const on the const overload.
| return *reinterpret_cast<Actual*>(impl->GetRawPtr()); | ||
| } | ||
|
|
||
| operator bool() const { return !!impl; } |
There was a problem hiding this comment.
Couldn't you write impl != nullptr instead of using !!?
| } | ||
|
|
||
| template <class Actual> | ||
| const Actual& CastTo() const |
There was a problem hiding this comment.
If we have seperate overloads then this should be const std::remove_cv_t<Actual>& CastTo() const, and the reinterpret_cast will need to remove the const as well(ie return *reinterpret_cast<const std::remove_cv_t<Actual>*>(impl->GetRawPtr()).
| return *this; | ||
| } | ||
|
|
||
| AnyInvokeParams& operator=(AnyInvokeParams&& other) noexcept |
There was a problem hiding this comment.
This can be removed because the by value assignment will handle move-assignment.
| } | ||
|
|
||
| template <class Actual> | ||
| std::remove_cv_t<Actual>& CastTo() const |
There was a problem hiding this comment.
This needs to be const std::remove_cv_t<Actual>& otherwise this will always drop the const
| MIOPEN_THROW("Attempt to use empty AnyInvokeParams."); | ||
| if(!impl->CanCastTo(typeid(Actual))) | ||
| MIOPEN_THROW("Attempt to cast AnyInvokeParams to invalid type."); | ||
| return *reinterpret_cast<std::remove_cv_t<Actual>*>(impl->GetRawPtr()); |
There was a problem hiding this comment.
Same here, this needs to be const std::remove_cv_t<Actual>*.
|
@pfultz2 @DrizztDoUrden I am not fully aware of what you are discussing here, but perhaps it is worth to merge PR #212 here. It adds a lot of |
|
We are discussing new code from this PR. |
|
Obviously ;) |
|
More testing is in progress, but mostly the PR is ready. |
| struct AnyInvokeParams; | ||
|
|
||
| namespace solver { | ||
| struct ConvSolution; |
There was a problem hiding this comment.
@DrizztDoUrden any change we can make Algorithm name available in the Convolution Context? its needed to call handle.AddKernel() (which requires algorithm and network as first 2 params) in generic_search.
I think NetworkConfig is available through context.BuildConfKey() but I dont see a way to access algorithm
There was a problem hiding this comment.
You may use solver::Id{SolverDbId(s)}.GetAlgo() for that, I suppose.
FYI, invokers don't use that layer of KernelDb, so you may also have to alter Handle::PrepareInvoker in some way.
| MIOPEN_THROW("Attempt to use empty AnyInvokeParams."); | ||
| if(!impl->CanCastTo(typeid(Actual))) | ||
| MIOPEN_THROW("Attempt to cast AnyInvokeParams to invalid type."); | ||
| return *reinterpret_cast<const std::remove_cv_t<Actual>*>(impl->GetRawPtr()); |
There was a problem hiding this comment.
It shouldn't be const here because you returning without const.
| } | ||
|
|
||
| template <class Actual> | ||
| std::remove_cv_t<Actual>& CastTo() |
There was a problem hiding this comment.
This overload shouldn't use std::remove_cv_t<Actual>, because it should be expected that doing x.CastTo<const T>() returns a const reference even if x is non-const.
There was a problem hiding this comment.
Oh, it looks like, I misunderstood some of your advice. I will fix. Thanks for tips.
| } | ||
|
|
||
| template <class Actual> | ||
| const std::remove_cv_t<Actual>& CastTo() const |
There was a problem hiding this comment.
This overload uses std::remove_cv_t<Actual> correctly.
|
During the time we developed Invokers, changes have occurred: some iGemm WrW solvers that use tuning appeared. Therefore, we need to pause this PR until Invokers support for iGemm WrW implemented. @DrizztDoUrden is switching to implementation of Invokers for iGemm WrW right now. |
|
All please review. |
|
I don't see any failures on my tests, including Winograd wrw, which was the last one to fail due to being not implemented. |
|
@alexandraBara If you have any questions about the changes, please ask me anywhere you would feel comfortable. I know that this PR directly affects your branch, and I would probably be the person with answers to the questions related to it. |
|
@atamazov does this have your seal of approval? |
|
@daniellowell Let me make a quick check tomorrow morning. |
|
The check is not that quick... but almost done |
|
This now blocks Tuna and iGEMM development. |
atamazov
left a comment
There was a problem hiding this comment.
All tests passed, including some auto-tuning sessions. Code changes looks Ok.
|
@daniellowell Let's merge this? |
* [Squashed] Generic search with invokers
| namespace miopen { | ||
| namespace conv { | ||
|
|
||
| struct FusedDataInvokeParams : InvokeParams |
This PR updates the generic search to use invokers instead of run and measure.
All relevant solvers are updated to support the new way of things, which has led to significant removal of duplicated code.
Things not done yet: