Access Number of Operation Calls

Hi all,

For my project I do Bayes inference of the parameters of an ODE with NUTS, quite similar to this example https://docs.pymc.io/notebooks/ODE_parameter_estimation.html

I have a theano operation that is the evaluation of the ODE and one that is the evaluation of the gradient of that.

Now I want to know exactly how many times each of these two operations are called, but I could not find any method in pymc3, which would tell me. I did set a global counting variable , but as soon as I use more than one cpu processor this does not work anymore. I guess pymc3 creates copies of the operation objects and I would somehow have to access these, but that seems too much effort for such a small request.

I looked through all documentation and the only thing I came across was trace[‘tree_size’] which for every draw shows “the number of leafs of the sampling tree, when the sample was accepted”.
However, when running with one core and tune=0 it does not match my global counter variables, so obviously it is not the number of times the operation is evaluated. So what is it?

Cheers,
Michael

The only thing I can think of right now is putting tt.printing.Print in your ODE evaluation and gradient evaluation