tapewasm 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calibrate.js +141 -0
- package/index.js +7 -1
- package/package.json +2 -2
- package/pkg/package.json +1 -1
- package/pkg/snippets/{tapewasm-cbf82a3d7bc31b1b → tapewasm-a5eaf252e13afb7a}/js/aot_bridge.js +26 -2
- package/pkg/tapewasm.d.ts +25 -1
- package/pkg/tapewasm.js +55 -11
- package/pkg/tapewasm_bg.wasm +0 -0
- package/pkg/tapewasm_bg.wasm.d.ts +3 -1
package/calibrate.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Which shape this engine prefers, measured once.
|
|
2
|
+
//
|
|
3
|
+
// `compileTape`'s `"auto"` threshold cannot be right for every engine:
|
|
4
|
+
// straight-line and re-rolled cross over between 8,026 and 24,564 nodes in V8
|
|
5
|
+
// and around 2,000 in SpiderMonkey and JavaScriptCore. The built-in value serves the
|
|
6
|
+
// latter two and costs V8 up to 7.6x on a trace between them. This measures
|
|
7
|
+
// which side the engine is on and returns a threshold to pass to `compileTape`.
|
|
8
|
+
//
|
|
9
|
+
// await init(...);
|
|
10
|
+
// const above = await calibrateReroll();
|
|
11
|
+
// const built = compileTape(text, String(above));
|
|
12
|
+
//
|
|
13
|
+
// The answer is cached: it is a property of the engine, not of the model.
|
|
14
|
+
|
|
15
|
+
import { compileTape } from "./pkg/tapewasm.js";
|
|
16
|
+
|
|
17
|
+
/// What `"auto"` uses. Right for SpiderMonkey and JavaScriptCore.
|
|
18
|
+
export const RE_ROLL_ABOVE = 2_000;
|
|
19
|
+
|
|
20
|
+
/// For an engine that prefers straight-line, as V8 does.
|
|
21
|
+
///
|
|
22
|
+
/// Bracketed by measurement rather than picked: on eleven posteriordb models,
|
|
23
|
+
/// straight-line still wins at 8,026 nodes and has lost by 24,564. A threshold
|
|
24
|
+
/// of 24,000 already costs `low_dim_gauss_mix` 1.21x, so this sits clear of
|
|
25
|
+
/// that edge. At 20,000 the five models whose shape changes get 2.54x in the
|
|
26
|
+
/// geometric mean and none is slower.
|
|
27
|
+
export const V8_RE_ROLL_ABOVE = 20_000;
|
|
28
|
+
|
|
29
|
+
/// Where the two engine families disagree most clearly. At this size V8 prefers
|
|
30
|
+
/// straight-line on every model measured, and the other two prefer loops on all
|
|
31
|
+
/// but one.
|
|
32
|
+
const PROBE_NODES = 4_000;
|
|
33
|
+
|
|
34
|
+
let cached = null;
|
|
35
|
+
|
|
36
|
+
/// A tape of the commonest shape — one accumulated term per observation —
|
|
37
|
+
/// using nothing but arithmetic, so the module it compiles to imports only
|
|
38
|
+
/// memory and the probe needs no maths from the caller.
|
|
39
|
+
function probeTape(terms) {
|
|
40
|
+
// Instruction 0, 1, 2 are the parameters; `at` is the index the next line takes.
|
|
41
|
+
const out = ["n_params 3", "new_var 0.4", "new_var 1.1", "new_var 0.3"];
|
|
42
|
+
let at = 3;
|
|
43
|
+
const push = (line) => {
|
|
44
|
+
out.push(line);
|
|
45
|
+
return at++;
|
|
46
|
+
};
|
|
47
|
+
let acc = null;
|
|
48
|
+
for (let i = 0; i < terms; i++) {
|
|
49
|
+
const x = (0.001 * (i % 997)).toFixed(6);
|
|
50
|
+
const y = (0.5 + 0.001 * (i % 991)).toFixed(6);
|
|
51
|
+
const bx = push(`mul_c 1 ${x}`); // beta * x
|
|
52
|
+
const mu = push(`add ${bx} 0`); // + alpha
|
|
53
|
+
const r = push(`rsub_c ${mu} ${y}`); // y - mu
|
|
54
|
+
const z = push(`div ${r} 2`); // / sigma
|
|
55
|
+
const sq = push(`mul ${z} ${z}`);
|
|
56
|
+
acc = acc === null ? sq : push(`add ${acc} ${sq}`);
|
|
57
|
+
}
|
|
58
|
+
const half = push(`mul_c ${acc} -0.5`);
|
|
59
|
+
out.push(`root ${half}`);
|
|
60
|
+
return out.join("\n") + "\n";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function timeOne(wasm, nParams, scratchInit, rounds) {
|
|
64
|
+
const need = nParams * 16 + scratchInit.length * 8;
|
|
65
|
+
const memory = new WebAssembly.Memory({ initial: Math.ceil(need / 65536) + 2 });
|
|
66
|
+
const { instance } = await WebAssembly.instantiate(wasm, { tapewasm: { memory } });
|
|
67
|
+
const view = new Float64Array(memory.buffer);
|
|
68
|
+
view.set(scratchInit, nParams * 2);
|
|
69
|
+
for (let i = 0; i < nParams; i++) view[i] = 0.1 * (i + 1);
|
|
70
|
+
const lpg = instance.exports.log_prob_grad;
|
|
71
|
+
const call = () => lpg(0, nParams * 8, nParams, nParams * 16);
|
|
72
|
+
|
|
73
|
+
for (let i = 0; i < 50; i++) call(); // past the first tier
|
|
74
|
+
const t0 = performance.now();
|
|
75
|
+
let n = 0;
|
|
76
|
+
while (performance.now() - t0 < 4) { call(); n++; }
|
|
77
|
+
const iters = Math.max(1, n);
|
|
78
|
+
let best = Infinity;
|
|
79
|
+
for (let r = 0; r < rounds; r++) {
|
|
80
|
+
const t = performance.now();
|
|
81
|
+
for (let j = 0; j < iters; j++) call();
|
|
82
|
+
best = Math.min(best, (performance.now() - t) / iters);
|
|
83
|
+
}
|
|
84
|
+
return best;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Measure which shape this engine prefers and return a threshold for
|
|
89
|
+
* `compileTape`'s `reroll` argument. Call after `init()`.
|
|
90
|
+
*
|
|
91
|
+
* Cached after the first call — pass `{ force: true }` to measure again.
|
|
92
|
+
* On any failure it returns the built-in threshold, so a caller can use the
|
|
93
|
+
* result without guarding it.
|
|
94
|
+
*/
|
|
95
|
+
export async function calibrateReroll({ force = false, rounds = 7 } = {}) {
|
|
96
|
+
if (cached !== null && !force) return cached.above;
|
|
97
|
+
let result;
|
|
98
|
+
try {
|
|
99
|
+
const text = probeTape(Math.max(1, Math.round(PROBE_NODES / 5)));
|
|
100
|
+
const straight = compileTape(text, "never");
|
|
101
|
+
const looped = compileTape(text, "always");
|
|
102
|
+
// Interleaved, so a drift in machine state lands on both.
|
|
103
|
+
let sBest = Infinity, lBest = Infinity;
|
|
104
|
+
for (let r = 0; r < 2; r++) {
|
|
105
|
+
sBest = Math.min(sBest, await timeOne(straight.wasm, straight.nParams, straight.scratchInit, rounds));
|
|
106
|
+
lBest = Math.min(lBest, await timeOne(looped.wasm, looped.nParams, looped.scratchInit, rounds));
|
|
107
|
+
}
|
|
108
|
+
const prefersStraight = sBest < lBest;
|
|
109
|
+
result = {
|
|
110
|
+
above: prefersStraight ? V8_RE_ROLL_ABOVE : RE_ROLL_ABOVE,
|
|
111
|
+
prefersStraight,
|
|
112
|
+
straightMs: sBest,
|
|
113
|
+
loopedMs: lBest,
|
|
114
|
+
measured: true,
|
|
115
|
+
};
|
|
116
|
+
} catch (e) {
|
|
117
|
+
// A threshold is an optimisation; failing to measure one is not an error.
|
|
118
|
+
result = { above: RE_ROLL_ABOVE, measured: false, error: String(e?.message ?? e) };
|
|
119
|
+
}
|
|
120
|
+
cached = result;
|
|
121
|
+
return result.above;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** What the last `calibrateReroll` measured, or `null` before the first call. */
|
|
125
|
+
export function lastCalibration() {
|
|
126
|
+
return cached;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* `compileTape` at the threshold this engine prefers, measured once.
|
|
131
|
+
*
|
|
132
|
+
* The plain `compileTape` is synchronous and cannot wait for a measurement, so
|
|
133
|
+
* its `"auto"` is the built-in 2,000 — right for SpiderMonkey and
|
|
134
|
+
* JavaScriptCore, and low for V8. On posteriordb's 23 models in Node, that
|
|
135
|
+
* default loses on thirteen of them, by up to 12x. This is the same call with
|
|
136
|
+
* the measured number, and the measurement happens once per process.
|
|
137
|
+
*/
|
|
138
|
+
export async function compileTapeCalibrated(text, opts) {
|
|
139
|
+
const above = await calibrateReroll(opts);
|
|
140
|
+
return compileTape(text, String(above));
|
|
141
|
+
}
|
package/index.js
CHANGED
|
@@ -14,5 +14,11 @@ export {
|
|
|
14
14
|
clearAotExports,
|
|
15
15
|
sharedMemory,
|
|
16
16
|
} from "./pkg/tapewasm.js";
|
|
17
|
-
export {
|
|
17
|
+
export {
|
|
18
|
+
calibrateReroll,
|
|
19
|
+
compileTapeCalibrated,
|
|
20
|
+
lastCalibration,
|
|
21
|
+
RE_ROLL_ABOVE,
|
|
22
|
+
V8_RE_ROLL_ABOVE,
|
|
23
|
+
} from "./calibrate.js";
|
|
18
24
|
export default init;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tapewasm",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Compile an autodiff tape to a WebAssembly module and sample it with nuts-rs, in the browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"./pkg/*": "./pkg/*"
|
|
15
15
|
},
|
|
16
|
-
"files": ["index.js", "index.d.ts", "pkg/", "LICENSE-APACHE", "LICENSE-MIT", "README.md"],
|
|
16
|
+
"files": ["index.js", "index.d.ts", "calibrate.js", "pkg/", "LICENSE-APACHE", "LICENSE-MIT", "README.md"],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build:wasm": "make -C .. wasm"
|
|
19
19
|
},
|
package/pkg/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "tapewasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Compile an autodiff tape to a wasm module and sample it with nuts-rs, in the browser. The wasm-bindgen API over tapewasm-codegen.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.3",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/pkg/snippets/{tapewasm-cbf82a3d7bc31b1b → tapewasm-a5eaf252e13afb7a}/js/aot_bridge.js
RENAMED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
// Bridge between tapewasm.wasm and a per-model compiled wasm, which imports
|
|
2
|
-
// tapewasm's memory and exports `log_prob_grad`, `tapewasm_layout_id
|
|
3
|
-
// `tapewasm_abi_version
|
|
2
|
+
// tapewasm's memory and exports `log_prob_grad`, `tapewasm_layout_id`,
|
|
3
|
+
// `tapewasm_abi_version` and `tapewasm_n_outputs` — plus `evaluate` when the
|
|
4
|
+
// tape named any outputs.
|
|
4
5
|
//
|
|
5
6
|
// The binding is per page while the scratch buffer belongs to one model, so
|
|
6
7
|
// the sampler reads the id back to refuse a mismatched pair.
|
|
7
8
|
|
|
8
9
|
let aotLogProbGrad = null;
|
|
10
|
+
let aotEvaluate = null;
|
|
11
|
+
// How many values `evaluate` writes. 0 when the tape named none, and for a
|
|
12
|
+
// module built before outputs existed, which exports neither.
|
|
13
|
+
let aotNOutputs = 0;
|
|
9
14
|
// NaN means nothing is bound, or no id is exported; no u32 id collides with it.
|
|
10
15
|
let aotLayoutId = NaN;
|
|
11
16
|
// Likewise: a module from before the global existed reads as unknown, not as 0.
|
|
@@ -13,6 +18,9 @@ let aotAbiVersion = NaN;
|
|
|
13
18
|
|
|
14
19
|
export function set_aot_exports(exports) {
|
|
15
20
|
aotLogProbGrad = exports.log_prob_grad;
|
|
21
|
+
aotEvaluate = exports.evaluate ?? null;
|
|
22
|
+
const n = exports.tapewasm_n_outputs;
|
|
23
|
+
aotNOutputs = n ? n.value >>> 0 : 0;
|
|
16
24
|
const g = exports.tapewasm_layout_id;
|
|
17
25
|
aotLayoutId = g ? g.value >>> 0 : NaN;
|
|
18
26
|
const v = exports.tapewasm_abi_version;
|
|
@@ -21,6 +29,8 @@ export function set_aot_exports(exports) {
|
|
|
21
29
|
|
|
22
30
|
export function clear_aot_exports() {
|
|
23
31
|
aotLogProbGrad = null;
|
|
32
|
+
aotEvaluate = null;
|
|
33
|
+
aotNOutputs = 0;
|
|
24
34
|
aotLayoutId = NaN;
|
|
25
35
|
aotAbiVersion = NaN;
|
|
26
36
|
}
|
|
@@ -39,3 +49,17 @@ export function aot_logp(paramsPtr, gradsPtr, nParams, scratchPtr) {
|
|
|
39
49
|
}
|
|
40
50
|
return aotLogProbGrad(paramsPtr, gradsPtr, nParams, scratchPtr);
|
|
41
51
|
}
|
|
52
|
+
|
|
53
|
+
export function aot_n_outputs() {
|
|
54
|
+
return aotNOutputs;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function aot_evaluate(paramsPtr, outPtr, nParams, scratchPtr) {
|
|
58
|
+
if (!aotEvaluate) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
"the bound module exports no evaluate — compile the tape with an " +
|
|
61
|
+
"`outputs` line naming what it should report",
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return aotEvaluate(paramsPtr, outPtr, nParams, scratchPtr);
|
|
65
|
+
}
|
package/pkg/tapewasm.d.ts
CHANGED
|
@@ -67,6 +67,19 @@ export class AotSampler {
|
|
|
67
67
|
* once it returns.
|
|
68
68
|
*/
|
|
69
69
|
advi(init: Float64Array, num_iters: number, mc_samples: number, learning_rate: number, seed: bigint, snapshot_every: number, on_snapshot?: ((iter: number, mu: Float64Array, elbo: Float64Array) => void) | null): AdviResult;
|
|
70
|
+
/**
|
|
71
|
+
* What the module's `outputs` named, at one point in the parameter space.
|
|
72
|
+
*
|
|
73
|
+
* The forward pass alone, so this is the way to a pointwise
|
|
74
|
+
* log-likelihood — one call per draw, a term per observation — or to a
|
|
75
|
+
* deterministic quantity the density does not return. It shares the
|
|
76
|
+
* scratch buffer with `logProbGrad`, whose own call recomputes what it
|
|
77
|
+
* needs, so the two interleave freely.
|
|
78
|
+
*
|
|
79
|
+
* Throws when the bound module was compiled from a tape that named no
|
|
80
|
+
* outputs.
|
|
81
|
+
*/
|
|
82
|
+
evaluate(params: Float64Array): Float64Array;
|
|
70
83
|
/**
|
|
71
84
|
* `[log_prob, d/dparam...]`.
|
|
72
85
|
*
|
|
@@ -120,6 +133,11 @@ export class CompiledTape {
|
|
|
120
133
|
free(): void;
|
|
121
134
|
[Symbol.dispose](): void;
|
|
122
135
|
readonly layoutId: number;
|
|
136
|
+
/**
|
|
137
|
+
* How many values `AotSampler.evaluate` returns — what the tape's
|
|
138
|
+
* `outputs` line named, and 0 when it had none.
|
|
139
|
+
*/
|
|
140
|
+
readonly nOutputs: number;
|
|
123
141
|
readonly nParams: number;
|
|
124
142
|
readonly scratchInit: Float64Array;
|
|
125
143
|
/**
|
|
@@ -176,6 +194,10 @@ export function clearAotExports(): void;
|
|
|
176
194
|
* The format is not an artifact and carries no compatibility promise: a tape
|
|
177
195
|
* is written and consumed inside one call.
|
|
178
196
|
*
|
|
197
|
+
* An `outputs` line names nodes the module reports through
|
|
198
|
+
* `AotSampler.evaluate` — a pointwise log-likelihood's per-observation terms,
|
|
199
|
+
* or a deterministic quantity. Without one the module is what it always was.
|
|
200
|
+
*
|
|
179
201
|
* `reroll` says when a vectorised statement becomes a wasm loop: `"auto"`
|
|
180
202
|
* (the default, straight-line below a size threshold), `"always"`, `"never"`,
|
|
181
203
|
* or a node count to re-roll past, written as a number.
|
|
@@ -230,6 +252,7 @@ export interface InitOutput {
|
|
|
230
252
|
readonly adviresult_sigma: (a: number) => [number, number];
|
|
231
253
|
readonly adviresult_snapshotIters: (a: number) => [number, number];
|
|
232
254
|
readonly aotsampler_advi: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number) => [number, number, number];
|
|
255
|
+
readonly aotsampler_evaluate: (a: number, b: number, c: number) => [number, number, number, number];
|
|
233
256
|
readonly aotsampler_logProbGrad: (a: number, b: number, c: number) => [number, number, number, number];
|
|
234
257
|
readonly aotsampler_nParams: (a: number) => number;
|
|
235
258
|
readonly aotsampler_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
@@ -240,6 +263,7 @@ export interface InitOutput {
|
|
|
240
263
|
readonly clearAotExports: () => void;
|
|
241
264
|
readonly compileTape: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
242
265
|
readonly compiledtape_layoutId: (a: number) => number;
|
|
266
|
+
readonly compiledtape_nOutputs: (a: number) => number;
|
|
243
267
|
readonly compiledtape_nParams: (a: number) => number;
|
|
244
268
|
readonly compiledtape_scratchInit: (a: number) => [number, number];
|
|
245
269
|
readonly compiledtape_wasm: (a: number) => [number, number];
|
|
@@ -255,10 +279,10 @@ export interface InitOutput {
|
|
|
255
279
|
readonly tapewasmVersion: () => [number, number];
|
|
256
280
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
257
281
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
258
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
259
282
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
260
283
|
readonly __externref_table_alloc: () => number;
|
|
261
284
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
285
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
262
286
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
263
287
|
readonly __wbindgen_start: () => void;
|
|
264
288
|
}
|
package/pkg/tapewasm.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* @ts-self-types="./tapewasm.d.ts" */
|
|
2
|
-
import { aot_logp } from './snippets/tapewasm-
|
|
3
|
-
import * as import1 from "./snippets/tapewasm-
|
|
4
|
-
import * as import2 from "./snippets/tapewasm-
|
|
5
|
-
import * as import3 from "./snippets/tapewasm-
|
|
6
|
-
import * as import4 from "./snippets/tapewasm-
|
|
2
|
+
import { aot_evaluate, aot_logp } from './snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js';
|
|
3
|
+
import * as import1 from "./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js"
|
|
4
|
+
import * as import2 from "./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js"
|
|
5
|
+
import * as import3 from "./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js"
|
|
6
|
+
import * as import4 from "./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js"
|
|
7
|
+
import * as import5 from "./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js"
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -144,6 +145,31 @@ export class AotSampler {
|
|
|
144
145
|
}
|
|
145
146
|
return AdviResult.__wrap(ret[0]);
|
|
146
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* What the module's `outputs` named, at one point in the parameter space.
|
|
150
|
+
*
|
|
151
|
+
* The forward pass alone, so this is the way to a pointwise
|
|
152
|
+
* log-likelihood — one call per draw, a term per observation — or to a
|
|
153
|
+
* deterministic quantity the density does not return. It shares the
|
|
154
|
+
* scratch buffer with `logProbGrad`, whose own call recomputes what it
|
|
155
|
+
* needs, so the two interleave freely.
|
|
156
|
+
*
|
|
157
|
+
* Throws when the bound module was compiled from a tape that named no
|
|
158
|
+
* outputs.
|
|
159
|
+
* @param {Float64Array} params
|
|
160
|
+
* @returns {Float64Array}
|
|
161
|
+
*/
|
|
162
|
+
evaluate(params) {
|
|
163
|
+
const ptr0 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
164
|
+
const len0 = WASM_VECTOR_LEN;
|
|
165
|
+
const ret = wasm.aotsampler_evaluate(this.__wbg_ptr, ptr0, len0);
|
|
166
|
+
if (ret[3]) {
|
|
167
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
168
|
+
}
|
|
169
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
170
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
171
|
+
return v2;
|
|
172
|
+
}
|
|
147
173
|
/**
|
|
148
174
|
* `[log_prob, d/dparam...]`.
|
|
149
175
|
*
|
|
@@ -289,6 +315,15 @@ export class CompiledTape {
|
|
|
289
315
|
const ret = wasm.compiledtape_layoutId(this.__wbg_ptr);
|
|
290
316
|
return ret >>> 0;
|
|
291
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* How many values `AotSampler.evaluate` returns — what the tape's
|
|
320
|
+
* `outputs` line named, and 0 when it had none.
|
|
321
|
+
* @returns {number}
|
|
322
|
+
*/
|
|
323
|
+
get nOutputs() {
|
|
324
|
+
const ret = wasm.compiledtape_nOutputs(this.__wbg_ptr);
|
|
325
|
+
return ret >>> 0;
|
|
326
|
+
}
|
|
292
327
|
/**
|
|
293
328
|
* @returns {number}
|
|
294
329
|
*/
|
|
@@ -420,6 +455,10 @@ export function clearAotExports() {
|
|
|
420
455
|
* The format is not an artifact and carries no compatibility promise: a tape
|
|
421
456
|
* is written and consumed inside one call.
|
|
422
457
|
*
|
|
458
|
+
* An `outputs` line names nodes the module reports through
|
|
459
|
+
* `AotSampler.evaluate` — a pointwise log-likelihood's per-observation terms,
|
|
460
|
+
* or a deterministic quantity. Without one the module is what it always was.
|
|
461
|
+
*
|
|
423
462
|
* `reroll` says when a vectorised statement becomes a wasm loop: `"auto"`
|
|
424
463
|
* (the default, straight-line below a size threshold), `"always"`, `"never"`,
|
|
425
464
|
* or a node count to re-roll past, written as a number.
|
|
@@ -524,11 +563,15 @@ function __wbg_get_imports() {
|
|
|
524
563
|
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
525
564
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
526
565
|
},
|
|
527
|
-
|
|
566
|
+
__wbg_aot_evaluate_90ed2a4aec33a889: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
567
|
+
const ret = aot_evaluate(arg0 >>> 0, arg1 >>> 0, arg2 >>> 0, arg3 >>> 0);
|
|
568
|
+
return ret;
|
|
569
|
+
}, arguments); },
|
|
570
|
+
__wbg_aot_logp_212144b205cad1c9: function(arg0, arg1, arg2, arg3) {
|
|
528
571
|
const ret = aot_logp(arg0 >>> 0, arg1 >>> 0, arg2 >>> 0, arg3 >>> 0);
|
|
529
572
|
return ret;
|
|
530
573
|
},
|
|
531
|
-
|
|
574
|
+
__wbg_call_ae8ca521a7cc221c: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
532
575
|
var v0 = getArrayF64FromWasm0(arg3, arg4).slice();
|
|
533
576
|
wasm.__wbindgen_free(arg3, arg4 * 8, 8);
|
|
534
577
|
var v1 = getArrayF64FromWasm0(arg5, arg6).slice();
|
|
@@ -571,10 +614,11 @@ function __wbg_get_imports() {
|
|
|
571
614
|
return {
|
|
572
615
|
__proto__: null,
|
|
573
616
|
"./tapewasm_bg.js": import0,
|
|
574
|
-
"./snippets/tapewasm-
|
|
575
|
-
"./snippets/tapewasm-
|
|
576
|
-
"./snippets/tapewasm-
|
|
577
|
-
"./snippets/tapewasm-
|
|
617
|
+
"./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js": import1,
|
|
618
|
+
"./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js": import2,
|
|
619
|
+
"./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js": import3,
|
|
620
|
+
"./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js": import4,
|
|
621
|
+
"./snippets/tapewasm-a5eaf252e13afb7a/js/aot_bridge.js": import5,
|
|
578
622
|
};
|
|
579
623
|
}
|
|
580
624
|
|
package/pkg/tapewasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -11,6 +11,7 @@ export const adviresult_muSnapshots: (a: number) => [number, number];
|
|
|
11
11
|
export const adviresult_sigma: (a: number) => [number, number];
|
|
12
12
|
export const adviresult_snapshotIters: (a: number) => [number, number];
|
|
13
13
|
export const aotsampler_advi: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number) => [number, number, number];
|
|
14
|
+
export const aotsampler_evaluate: (a: number, b: number, c: number) => [number, number, number, number];
|
|
14
15
|
export const aotsampler_logProbGrad: (a: number, b: number, c: number) => [number, number, number, number];
|
|
15
16
|
export const aotsampler_nParams: (a: number) => number;
|
|
16
17
|
export const aotsampler_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
@@ -21,6 +22,7 @@ export const aotsampler_setTargetAccept: (a: number, b: number) => [number, numb
|
|
|
21
22
|
export const clearAotExports: () => void;
|
|
22
23
|
export const compileTape: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
23
24
|
export const compiledtape_layoutId: (a: number) => number;
|
|
25
|
+
export const compiledtape_nOutputs: (a: number) => number;
|
|
24
26
|
export const compiledtape_nParams: (a: number) => number;
|
|
25
27
|
export const compiledtape_scratchInit: (a: number) => [number, number];
|
|
26
28
|
export const compiledtape_wasm: (a: number) => [number, number];
|
|
@@ -36,9 +38,9 @@ export const sharedMemory: () => any;
|
|
|
36
38
|
export const tapewasmVersion: () => [number, number];
|
|
37
39
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
38
40
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
39
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
40
41
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
41
42
|
export const __externref_table_alloc: () => number;
|
|
42
43
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
44
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
43
45
|
export const __externref_table_dealloc: (a: number) => void;
|
|
44
46
|
export const __wbindgen_start: () => void;
|