Skip to content

Commit 28d0208

Browse files
committed
Only set the gradient norm if we have set up the Riesz map elsewhere
1 parent 7f51b2a commit 28d0208

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pyadjoint/optimization/tao_solver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,6 @@ def objective_gradient(tao, x, g):
699699
hessian_mat.getPythonContext().update,
700700
H=hessian_mat, P=Pmat or hessian_mat)
701701

702-
Minv_mat = RieszMapMat(rf.controls, comm=comm)
703-
tao.setGradientNorm(Minv_mat)
704-
705702
if problem.bounds is not None:
706703
lbs = []
707704
ubs = []
@@ -727,6 +724,9 @@ def objective_gradient(tao, x, g):
727724
if tao.getType() in {PETSc.TAO.Type.LMVM, PETSc.TAO.Type.BLMVM}:
728725
n, N = vec_interface.n, vec_interface.N
729726

727+
Minv_mat = RieszMapMat(rf.controls, comm=comm)
728+
tao.setGradientNorm(Minv_mat)
729+
730730
class InitialHessian:
731731
""":class:`petsc4py.PETSc.Mat` context.
732732
"""

0 commit comments

Comments
 (0)