Skip to content

Commit 2213aa2

Browse files
committed
update nimble benchmark code
1 parent ae083dc commit 2213aa2

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

benchmark/nimble/examples/vol1/dogs/dogs.bug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ model {
55
p[i, 1] <- 0
66

77
for (j in 2 : Trials) {
8-
xa[i, j] <- sum(Y[i, 1 : j - 1])
8+
xa[i, j] <- sum(y[i, 1 : (j - 1)])
99
xs[i, j] <- j - 1 - xa[i, j]
1010
log(p[i, j]) <- alpha * xa[i, j] + beta * xs[i, j]
1111
y[i, j] ~ dbern(p[i, j])

benchmark/nimble/nimble.r

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ nimbleOptions(enableDerivs = TRUE)
44
nimbleOptions(buildModelDerivs = TRUE)
55
nimbleOptions(allowDynamicIndexing = TRUE)
66

7+
#! Last time this was run: nimble version 0.13.0
8+
79
# functions
810

911
logLikelihood_nf <- nimbleFunction(
@@ -49,7 +51,7 @@ logLikelihood_nf <- nimbleFunction(
4951
return(transformer$transform(p))
5052
returnType(double(1))
5153
},
52-
inverse = function(ptrans = double(1)) { # ... and its inverse.
54+
inverseTransform = function(ptrans = double(1)) { # ... and its inverse.
5355
return(transformer$inverseTransform(ptrans))
5456
returnType(double(1))
5557
}
@@ -73,7 +75,7 @@ log_joint_nf <- nimbleFunction(
7375
MODEL_VOL1_NIMBLE <- c(
7476
"rats",
7577
"pumps",
76-
# "dogs",
78+
"dogs",
7779
"seeds",
7880
"surgical",
7981
"magnesium",
@@ -114,9 +116,11 @@ MODEL_VOL2_NIMBLE <- c(
114116

115117
#
116118

117-
process_example("leukfr", current_dir, "vol1")
118-
119-
process_example("asia", current_dir, "vol2")
119+
# process_example("rats", current_dir, "vol1")
120+
# process_example("dogs", current_dir, "vol1")
121+
# process_example("equiv", current_dir, "vol1")
122+
# process_example("leukfr", current_dir, "vol1")
123+
# process_example("asia", current_dir, "vol2")
120124

121125
#
122126
current_dir <- getwd()
@@ -222,22 +226,22 @@ for (example in names(benchmark_results)) {
222226

223227
if (!is.null(result$non_compiled_log_joint)) {
224228
cat("Non-compiled log joint time (microseconds):\n")
225-
print(summary(result$non_compiled_log_joint)$table)
229+
print(summary(result$non_compiled_log_joint))
226230
}
227231

228232
if (!is.null(result$compiled_log_joint)) {
229233
cat("Compiled log joint time (microseconds):\n")
230-
print(summary(result$compiled_log_joint)$table)
234+
print(summary(result$compiled_log_joint))
231235
}
232236

233237
if (!is.null(result$nll)) {
234238
cat("Negative log likelihood time (microseconds):\n")
235-
print(summary(result$nll)$table)
239+
print(summary(result$nll))
236240
}
237241

238242
if (!is.null(result$gr)) {
239243
cat("Gradient time (microseconds):\n")
240-
print(summary(result$gr)$table)
244+
print(summary(result$gr))
241245
}
242246
}
243247

@@ -249,21 +253,21 @@ for (example in names(benchmark_results_vol2)) {
249253

250254
if (!is.null(result$non_compiled_log_joint)) {
251255
cat("Non-compiled log joint time (microseconds):\n")
252-
print(summary(result$non_compiled_log_joint)$table)
256+
print(summary(result$non_compiled_log_joint))
253257
}
254258

255259
if (!is.null(result$compiled_log_joint)) {
256260
cat("Compiled log joint time (microseconds):\n")
257-
print(summary(result$compiled_log_joint)$table)
261+
print(summary(result$compiled_log_joint))
258262
}
259263

260264
if (!is.null(result$nll)) {
261265
cat("Negative log likelihood time (microseconds):\n")
262-
print(summary(result$nll)$table)
266+
print(summary(result$nll))
263267
}
264268

265269
if (!is.null(result$gr)) {
266270
cat("Gradient time (microseconds):\n")
267-
print(summary(result$gr)$table)
271+
print(summary(result$gr))
268272
}
269273
}

0 commit comments

Comments
 (0)