Make kGradientAccumulatorInitialValue a function.
The presence of absl::bit_cast in the static initializer caused an initialization-order-fiasco issue when I was working on an unrelated change. PiperOrigin-RevId: 252921770
This commit is contained in:
parent
9cf397a716
commit
41ab825f80
@ -252,7 +252,7 @@ Status GetOptimizationAlgorithmStateVariables(
|
|||||||
StateVariableSpecification gradient_acc;
|
StateVariableSpecification gradient_acc;
|
||||||
gradient_acc.set_name("gradient_accumulators");
|
gradient_acc.set_name("gradient_accumulators");
|
||||||
gradient_acc.mutable_fill_with_constant()->set_initial_value(
|
gradient_acc.mutable_fill_with_constant()->set_initial_value(
|
||||||
kGradientAccumulatorInitialValue);
|
GradientAccumulatorInitialValue());
|
||||||
state_variables->push_back(std::move(gradient_acc));
|
state_variables->push_back(std::move(gradient_acc));
|
||||||
}
|
}
|
||||||
if (state_variables->size() > kMaxAuxiliaryParameterCount + 1) {
|
if (state_variables->size() > kMaxAuxiliaryParameterCount + 1) {
|
||||||
|
@ -84,7 +84,9 @@ static constexpr int kMaxAuxiliaryParameterCount = 3;
|
|||||||
// not no-ops on zero gradients, so we need to distinguish an accumulated
|
// not no-ops on zero gradients, so we need to distinguish an accumulated
|
||||||
// gradient of zero from one that has been cleared after its gradients have
|
// gradient of zero from one that has been cleared after its gradients have
|
||||||
// already been applied to the parameters and accumulators.
|
// already been applied to the parameters and accumulators.
|
||||||
const float kGradientAccumulatorInitialValue = absl::bit_cast<float, uint32>(1);
|
inline float GradientAccumulatorInitialValue() {
|
||||||
|
return absl::bit_cast<float, uint32>(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Computes registration data for per table load Op. Each load Op transfers
|
// Computes registration data for per table load Op. Each load Op transfers
|
||||||
// the embedding parameters from the host memory to the TPU memory.
|
// the embedding parameters from the host memory to the TPU memory.
|
||||||
|
Loading…
Reference in New Issue
Block a user