Commit d159522a authored by Philipp Arras's avatar Philipp Arras
Browse files

Improve performance check

parent 5bbbcca6
Pipeline #70447 failed with stages
in 9 minutes and 3 seconds
...@@ -138,20 +138,27 @@ def _performance_check(op, pos, raise_on_fail): ...@@ -138,20 +138,27 @@ def _performance_check(op, pos, raise_on_fail):
@property @property
def count(self): def count(self):
return self._count return self._count
cop = CountingOp(op.domain) for wm in [False, True]:
op = op @ cop cop = CountingOp(op.domain)
lin = op(Linearization.make_var(pos)) op = op @ cop
cond = [cop.count != 1] op(pos)
lin.jac(pos) cond = [cop.count != 1]
cond.append(cop.count != 2) lin = op(Linearization.make_var(pos, wm))
lin.jac.adjoint(lin.val) cond.append(cop.count != 2)
cond.append(cop.count != 3) lin.jac(pos)
if any(cond): cond.append(cop.count != 3)
s = 'The operator has a performance problem.' lin.jac.adjoint(lin.val)
if raise_on_fail: cond.append(cop.count != 4)
raise RuntimeError(s) if wm and op.target is DomainTuple.scalar_domain():
from .logger import logger lin.metric(pos)
logger.warn(s) cond.append(cop.count != 6)
if any(cond):
s = 'The operator has a performance problem (want_metric={}).'.format(wm)
from .logger import logger
logger.error(s)
logger.info(cond)
if raise_on_fail:
raise RuntimeError(s)
def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64, def consistency_check(op, domain_dtype=np.float64, target_dtype=np.float64,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment