Store references instead of copying the results of intermediate autograd computations.

This commit is contained in:
Tomasz Sobczyk
2020-11-30 21:43:24 +01:00
committed by nodchip
parent 6cd0b03098
commit 4eb0e77a2a
+7 -7
View File
@@ -392,11 +392,11 @@ namespace Learner
{ {
using namespace Learner::Autograd::UnivariateStatic; using namespace Learner::Autograd::UnivariateStatic;
static thread_local auto q_ = expected_perf_(VariableParameter<double, 0>{}); static thread_local auto& q_ = expected_perf_(VariableParameter<double, 0>{});
static thread_local auto p_ = expected_perf_(scale_score_(ConstantParameter<double, 1>{})); static thread_local auto& p_ = expected_perf_(scale_score_(ConstantParameter<double, 1>{}));
static thread_local auto t_ = (ConstantParameter<double, 2>{} + 1.0) * 0.5; static thread_local auto t_ = (ConstantParameter<double, 2>{} + 1.0) * 0.5;
static thread_local auto lambda_ = ConstantParameter<double, 3>{}; static thread_local auto lambda_ = ConstantParameter<double, 3>{};
static thread_local auto loss_ = cross_entropy_(q_, p_, t_, lambda_); static thread_local auto& loss_ = cross_entropy_(q_, p_, t_, lambda_);
auto args = std::tuple( auto args = std::tuple(
(double)shallow, (double)shallow,
@@ -415,14 +415,14 @@ namespace Learner
static thread_local auto ply_ = ConstantParameter<double, 4>{}; static thread_local auto ply_ = ConstantParameter<double, 4>{};
static thread_local auto shallow_ = VariableParameter<double, 0>{}; static thread_local auto shallow_ = VariableParameter<double, 0>{};
static thread_local auto q_ = expected_perf_use_wdl_(shallow_, ply_); static thread_local auto& q_ = expected_perf_use_wdl_(shallow_, ply_);
// We could do just this but MSVC crashes with an internal compiler error :( // We could do just this but MSVC crashes with an internal compiler error :(
// static thread_local auto scaled_teacher_ = scale_score_(ConstantParameter<double, 1>{}); // static thread_local auto& scaled_teacher_ = scale_score_(ConstantParameter<double, 1>{});
// static thread_local auto p_ = expected_perf_use_wdl_(scaled_teacher_, ply_); // static thread_local auto& p_ = expected_perf_use_wdl_(scaled_teacher_, ply_);
static thread_local auto p_ = ConstantParameter<double, 1>{}; static thread_local auto p_ = ConstantParameter<double, 1>{};
static thread_local auto t_ = (ConstantParameter<double, 2>{} + 1.0) * 0.5; static thread_local auto t_ = (ConstantParameter<double, 2>{} + 1.0) * 0.5;
static thread_local auto lambda_ = ConstantParameter<double, 3>{}; static thread_local auto lambda_ = ConstantParameter<double, 3>{};
static thread_local auto loss_ = cross_entropy_(q_, p_, t_, lambda_); static thread_local auto& loss_ = cross_entropy_(q_, p_, t_, lambda_);
auto args = std::tuple( auto args = std::tuple(
(double)shallow, (double)shallow,