-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up NNUE template parameters #5584
Conversation
3215928
to
132d421
Compare
Having multiple template parameters might lead to confusion that unallowed combinations are possible to use, such as: FeatureTransformer<TransformedFeatureDimensionsSmall, &StateInfo::accumulatorBig> By grouping the parameters into a single struct, the code becomes more clear, comprehensible, and easier to maintain. No functional change
132d421
to
ac58ebd
Compare
I think that's the right direction, I would still suggest to run a non-regression test for these kind of cleanups. |
I don't like how the FeatureTransformer is getting information about the whole rest of the network architecture. The code always looked like it's something special but it's just a normal layer in the network, it just happens to be doing some more caching. Other than that looks good. |
I agree but that also suggests that the current code leads to some confusion. The accumluator arrays are tied to the Let me know if this looks right to you: template<IndexType _L1, int _L2, int _L3, Accumulator<_L1> StateInfo::*_accPtr>
struct NetworkType {
static constexpr IndexType L1 = _L1;
static constexpr int L2 = _L2;
static constexpr int L3 = _L3;
struct FeatureTransformerType {
static constexpr IndexType TransformedFeatureDimensions = L1;
static constexpr Accumulator<TransformedFeatureDimensions> StateInfo::*accPtr = _accPtr;
};
}; and using Transformer = FeatureTransformer<typename Type::FeatureTransformerType>; |
I was thinking simply
|
As I mentioned in the commit message, two template parameters are grouped because they are not independent. It's never allowed to have |
You can't exclude all buggy code at compile time. Still nothing would prevent creating two networks that point to the same accumulator. I don't think this one case of keeping the parameters inseparable warrants closely coupling FeatureTransformer with the whole network. You should be able to create the FeatureTransformer as a standalone layer without having to specify anything about other layers. And I think the PR has a lot of merit outside of this small change. |
Ok, now I understand that. Although revamping FT template parameters was the main purpose of this PR, there seems to be other kinds of benefit this PR brings out. |
The revised code failed to pass the regression test. The initial version test is likely going to pass the test: I believe this is false negative, but let me know how to proceed on this. |
I'd say give the revised one a rerun |
Both tests have failed, so closing this for now. Something affects the compiler optimization. |
Having multiple template parameters might lead to confusion that unallowed combinations are possible to use, such as:
FeatureTransformer<TransformedFeatureDimensionsSmall, &StateInfo::accumulatorBig>
By grouping the parameters into a single struct, the code becomes more clear, comprehensible, and easier to maintain.
No functional change