Add initialize check for the persistable variables created by optimizer to polish the error message of run(startup_porgram) position sensitive program !19432
Created by: chenwhql
This PR wants to solve the run(startup_program)
position sensitive program. When run(startup_program)
is executed before optimizer.minimize
, because the parameters added by optimizer
are not initialized, which will cause run failed. The error message is like:
this error occur to RunTimeInferShape
phase. the program doesn't check whether the tensor in LearningRate
variable is initialized, and get the dim of variable used to compare directly, which is the reason that this error messgae is not easy to understand. So this PR add the tensor->IsInitialized
for persistable Input variable check in optimize ops to provide a clear error messgae.
I add tensor->IsInitialized
check into GetInputDim
function, the result after change is like:
I think it's not very good to put the tensor->Initialized check
into infershape check
phase, and I try to add the similar check in op->RunImpl
or ctx->HasInput
, but it will introduce heavy time costs. Maybe there is a better way to solve this problem.