tapewasm 0.1.0
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/LICENSE +201 -0
- package/README.md +10 -0
- package/index.d.ts +11 -0
- package/index.js +15 -0
- package/package.json +27 -0
- package/pkg/LICENSE +201 -0
- package/pkg/README.md +10 -0
- package/pkg/package.json +28 -0
- package/pkg/snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js +41 -0
- package/pkg/tapewasm.d.ts +146 -0
- package/pkg/tapewasm.js +543 -0
- package/pkg/tapewasm_bg.wasm +0 -0
- package/pkg/tapewasm_bg.wasm.d.ts +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 habakan
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# tapewasm
|
|
2
|
+
|
|
3
|
+
The wasm-bindgen API: compile a tape to a WebAssembly module, then sample it
|
|
4
|
+
with [nuts-rs](https://github.com/pymc-devs/nuts-rs).
|
|
5
|
+
|
|
6
|
+
See the [repository](https://github.com/habakan/tapewasm) for what this is for
|
|
7
|
+
and how a front end uses it. The npm package of the same name is this crate
|
|
8
|
+
built with `wasm-pack`.
|
|
9
|
+
|
|
10
|
+
Licensed under Apache-2.0.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Types for `index.js`; the shapes come from `pkg/`, which `make wasm` writes.
|
|
2
|
+
export {
|
|
3
|
+
AotSampler,
|
|
4
|
+
CompiledTape,
|
|
5
|
+
compileTape,
|
|
6
|
+
tapewasmVersion,
|
|
7
|
+
setAotExports,
|
|
8
|
+
clearAotExports,
|
|
9
|
+
sharedMemory,
|
|
10
|
+
} from "./pkg/tapewasm.js";
|
|
11
|
+
export { default } from "./pkg/tapewasm.js";
|
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Public facade: re-exports the wasm-bindgen bindings so callers never reach
|
|
2
|
+
// into `pkg/`. Plain `.js` because a package entry point has to load without
|
|
3
|
+
// `--experimental-strip-types`, and there is no TypeScript syntax here to lose.
|
|
4
|
+
|
|
5
|
+
import init from "./pkg/tapewasm.js";
|
|
6
|
+
export {
|
|
7
|
+
AotSampler,
|
|
8
|
+
CompiledTape,
|
|
9
|
+
compileTape,
|
|
10
|
+
tapewasmVersion,
|
|
11
|
+
setAotExports,
|
|
12
|
+
clearAotExports,
|
|
13
|
+
sharedMemory,
|
|
14
|
+
} from "./pkg/tapewasm.js";
|
|
15
|
+
export default init;
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tapewasm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Compile an autodiff tape to a WebAssembly module and sample it with nuts-rs, in the browser.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"module": "./index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"default": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./pkg/*": "./pkg/*"
|
|
15
|
+
},
|
|
16
|
+
"files": ["index.js", "index.d.ts", "pkg/", "LICENSE", "README.md"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build:wasm": "make -C .. wasm"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/habakan/tapewasm.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/habakan/tapewasm#readme",
|
|
25
|
+
"keywords": ["autodiff", "gradient", "bayesian", "mcmc", "nuts", "webassembly", "wasm"],
|
|
26
|
+
"license": "Apache-2.0"
|
|
27
|
+
}
|
package/pkg/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 habakan
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/pkg/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# tapewasm
|
|
2
|
+
|
|
3
|
+
The wasm-bindgen API: compile a tape to a WebAssembly module, then sample it
|
|
4
|
+
with [nuts-rs](https://github.com/pymc-devs/nuts-rs).
|
|
5
|
+
|
|
6
|
+
See the [repository](https://github.com/habakan/tapewasm) for what this is for
|
|
7
|
+
and how a front end uses it. The npm package of the same name is this crate
|
|
8
|
+
built with `wasm-pack`.
|
|
9
|
+
|
|
10
|
+
Licensed under Apache-2.0.
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tapewasm",
|
|
3
|
+
"type": "module",
|
|
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.1.0",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/habakan/tapewasm"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"tapewasm_bg.wasm",
|
|
13
|
+
"tapewasm.js",
|
|
14
|
+
"tapewasm.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"main": "tapewasm.js",
|
|
17
|
+
"types": "tapewasm.d.ts",
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"./snippets/*"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"autodiff",
|
|
23
|
+
"wasm",
|
|
24
|
+
"bayesian",
|
|
25
|
+
"mcmc",
|
|
26
|
+
"nuts"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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` and
|
|
3
|
+
// `tapewasm_abi_version`.
|
|
4
|
+
//
|
|
5
|
+
// The binding is per page while the scratch buffer belongs to one model, so
|
|
6
|
+
// the sampler reads the id back to refuse a mismatched pair.
|
|
7
|
+
|
|
8
|
+
let aotLogProbGrad = null;
|
|
9
|
+
// NaN means nothing is bound, or no id is exported; no u32 id collides with it.
|
|
10
|
+
let aotLayoutId = NaN;
|
|
11
|
+
// Likewise: a module from before the global existed reads as unknown, not as 0.
|
|
12
|
+
let aotAbiVersion = NaN;
|
|
13
|
+
|
|
14
|
+
export function set_aot_exports(exports) {
|
|
15
|
+
aotLogProbGrad = exports.log_prob_grad;
|
|
16
|
+
const g = exports.tapewasm_layout_id;
|
|
17
|
+
aotLayoutId = g ? g.value >>> 0 : NaN;
|
|
18
|
+
const v = exports.tapewasm_abi_version;
|
|
19
|
+
aotAbiVersion = v ? v.value >>> 0 : NaN;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function clear_aot_exports() {
|
|
23
|
+
aotLogProbGrad = null;
|
|
24
|
+
aotLayoutId = NaN;
|
|
25
|
+
aotAbiVersion = NaN;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function aot_layout_id() {
|
|
29
|
+
return aotLayoutId;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function aot_abi_version() {
|
|
33
|
+
return aotAbiVersion;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function aot_logp(paramsPtr, gradsPtr, nParams, scratchPtr) {
|
|
37
|
+
if (!aotLogProbGrad) {
|
|
38
|
+
throw new Error("no module bound — call setAotExports() before sampling");
|
|
39
|
+
}
|
|
40
|
+
return aotLogProbGrad(paramsPtr, gradsPtr, nParams, scratchPtr);
|
|
41
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A sampler over one compiled module.
|
|
6
|
+
*
|
|
7
|
+
* It reaches the module alone: nothing that recorded or emitted the tape is
|
|
8
|
+
* on this path, so a page that loads a module built earlier needs no
|
|
9
|
+
* compiler in its bundle. Bind the module with `setAotExports` first.
|
|
10
|
+
*/
|
|
11
|
+
export class AotSampler {
|
|
12
|
+
free(): void;
|
|
13
|
+
[Symbol.dispose](): void;
|
|
14
|
+
/**
|
|
15
|
+
* `[log_prob, d/dparam...]`.
|
|
16
|
+
*/
|
|
17
|
+
logProbGrad(params: Float64Array): Float64Array;
|
|
18
|
+
/**
|
|
19
|
+
* `scratch_init` is the buffer the module works in — zeroed primals and
|
|
20
|
+
* adjoints followed by the re-rolled loops' constant table, which is what
|
|
21
|
+
* `aotScratchInit` returns and what a compiler should record beside the
|
|
22
|
+
* module. `layout_id` is the module's `tapewasm_layout_id` global, checked
|
|
23
|
+
* against the bound exports before each run so a module and a scratch
|
|
24
|
+
* buffer built for different models cannot be used together.
|
|
25
|
+
*
|
|
26
|
+
* `param_names` only names a parameter in a rejected starting point; pass
|
|
27
|
+
* an empty array to go without.
|
|
28
|
+
*/
|
|
29
|
+
constructor(n_params: number, scratch_init: Float64Array, layout_id: number, param_names: string[]);
|
|
30
|
+
/**
|
|
31
|
+
* `num_warmup + num_draws` draws, row-major, `n_params` wide.
|
|
32
|
+
*/
|
|
33
|
+
sample(init: Float64Array, num_warmup: number, num_draws: number, seed: bigint): Float64Array;
|
|
34
|
+
readonly nParams: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* What [`compile_tape`] produced, and everything [`AotSampler`] needs from it.
|
|
39
|
+
*/
|
|
40
|
+
export class CompiledTape {
|
|
41
|
+
private constructor();
|
|
42
|
+
free(): void;
|
|
43
|
+
[Symbol.dispose](): void;
|
|
44
|
+
readonly layoutId: number;
|
|
45
|
+
readonly nParams: number;
|
|
46
|
+
readonly scratchInit: Float64Array;
|
|
47
|
+
/**
|
|
48
|
+
* The module. Instantiate it against [`shared_memory`] and the `Math`
|
|
49
|
+
* imports, then bind it with `setAotExports`.
|
|
50
|
+
*/
|
|
51
|
+
readonly wasm: Uint8Array;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Release the bound module's exports. The next draw will throw.
|
|
56
|
+
*/
|
|
57
|
+
export function clearAotExports(): void;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Compile a tape written by another front end.
|
|
61
|
+
*
|
|
62
|
+
* `tape` is the text format `tapewasm_codegen::tape_text` documents: one
|
|
63
|
+
* instruction per line, operands naming instructions rather than nodes. A
|
|
64
|
+
* front end that can build a tape reaches the emitter this way — including
|
|
65
|
+
* one that is not Rust and not in this module.
|
|
66
|
+
*
|
|
67
|
+
* The format is not an artifact and carries no compatibility promise: a tape
|
|
68
|
+
* is written and consumed inside one call.
|
|
69
|
+
*/
|
|
70
|
+
export function compileTape(tape: string): CompiledTape;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Forwards Rust panics to `console.error` with a message and backtrace rather
|
|
74
|
+
* than an opaque `RuntimeError: unreachable`. Diagnostics: the instance still traps.
|
|
75
|
+
*/
|
|
76
|
+
export function init_panic_hook(): void;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Bind a freshly-instantiated model module's exports so sampling dispatches
|
|
80
|
+
* through it. Pass `instance.exports`.
|
|
81
|
+
*
|
|
82
|
+
* One binding serves the whole page, so a page holding several models has to
|
|
83
|
+
* re-bind before sampling a different one. The sampler compares the bound
|
|
84
|
+
* module's `tapewasm_layout_id` against the model it belongs to and refuses
|
|
85
|
+
* the pair rather than running it against the wrong scratch buffer.
|
|
86
|
+
*/
|
|
87
|
+
export function setAotExports(exports: any): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The linear memory backing this module. Pass as the `tapewasm.memory`
|
|
91
|
+
* import when instantiating a model module so the two share buffers.
|
|
92
|
+
*/
|
|
93
|
+
export function sharedMemory(): any;
|
|
94
|
+
|
|
95
|
+
export function tapewasmVersion(): string;
|
|
96
|
+
|
|
97
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
98
|
+
|
|
99
|
+
export interface InitOutput {
|
|
100
|
+
readonly memory: WebAssembly.Memory;
|
|
101
|
+
readonly __wbg_aotsampler_free: (a: number, b: number) => void;
|
|
102
|
+
readonly __wbg_compiledtape_free: (a: number, b: number) => void;
|
|
103
|
+
readonly aotsampler_logProbGrad: (a: number, b: number, c: number) => [number, number, number, number];
|
|
104
|
+
readonly aotsampler_nParams: (a: number) => number;
|
|
105
|
+
readonly aotsampler_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
106
|
+
readonly aotsampler_sample: (a: number, b: number, c: number, d: number, e: number, f: bigint) => [number, number, number, number];
|
|
107
|
+
readonly clearAotExports: () => void;
|
|
108
|
+
readonly compileTape: (a: number, b: number) => [number, number, number];
|
|
109
|
+
readonly compiledtape_layoutId: (a: number) => number;
|
|
110
|
+
readonly compiledtape_nParams: (a: number) => number;
|
|
111
|
+
readonly compiledtape_scratchInit: (a: number) => [number, number];
|
|
112
|
+
readonly compiledtape_wasm: (a: number) => [number, number];
|
|
113
|
+
readonly init_panic_hook: () => void;
|
|
114
|
+
readonly setAotExports: (a: any) => void;
|
|
115
|
+
readonly sharedMemory: () => any;
|
|
116
|
+
readonly tapewasmVersion: () => [number, number];
|
|
117
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
118
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
119
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
120
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
121
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
122
|
+
readonly __externref_table_alloc: () => number;
|
|
123
|
+
readonly __wbindgen_start: () => void;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
130
|
+
* a precompiled `WebAssembly.Module`.
|
|
131
|
+
*
|
|
132
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
133
|
+
*
|
|
134
|
+
* @returns {InitOutput}
|
|
135
|
+
*/
|
|
136
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
140
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
141
|
+
*
|
|
142
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
143
|
+
*
|
|
144
|
+
* @returns {Promise<InitOutput>}
|
|
145
|
+
*/
|
|
146
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/pkg/tapewasm.js
ADDED
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
/* @ts-self-types="./tapewasm.d.ts" */
|
|
2
|
+
import { aot_logp } from './snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js';
|
|
3
|
+
import * as import1 from "./snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js"
|
|
4
|
+
import * as import2 from "./snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js"
|
|
5
|
+
import * as import3 from "./snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js"
|
|
6
|
+
import * as import4 from "./snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A sampler over one compiled module.
|
|
11
|
+
*
|
|
12
|
+
* It reaches the module alone: nothing that recorded or emitted the tape is
|
|
13
|
+
* on this path, so a page that loads a module built earlier needs no
|
|
14
|
+
* compiler in its bundle. Bind the module with `setAotExports` first.
|
|
15
|
+
*/
|
|
16
|
+
export class AotSampler {
|
|
17
|
+
__destroy_into_raw() {
|
|
18
|
+
const ptr = this.__wbg_ptr;
|
|
19
|
+
this.__wbg_ptr = 0;
|
|
20
|
+
AotSamplerFinalization.unregister(this);
|
|
21
|
+
return ptr;
|
|
22
|
+
}
|
|
23
|
+
free() {
|
|
24
|
+
const ptr = this.__destroy_into_raw();
|
|
25
|
+
wasm.__wbg_aotsampler_free(ptr, 0);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* `[log_prob, d/dparam...]`.
|
|
29
|
+
* @param {Float64Array} params
|
|
30
|
+
* @returns {Float64Array}
|
|
31
|
+
*/
|
|
32
|
+
logProbGrad(params) {
|
|
33
|
+
const ptr0 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
34
|
+
const len0 = WASM_VECTOR_LEN;
|
|
35
|
+
const ret = wasm.aotsampler_logProbGrad(this.__wbg_ptr, ptr0, len0);
|
|
36
|
+
if (ret[3]) {
|
|
37
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
38
|
+
}
|
|
39
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
40
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
41
|
+
return v2;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @returns {number}
|
|
45
|
+
*/
|
|
46
|
+
get nParams() {
|
|
47
|
+
const ret = wasm.aotsampler_nParams(this.__wbg_ptr);
|
|
48
|
+
return ret >>> 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `scratch_init` is the buffer the module works in — zeroed primals and
|
|
52
|
+
* adjoints followed by the re-rolled loops' constant table, which is what
|
|
53
|
+
* `aotScratchInit` returns and what a compiler should record beside the
|
|
54
|
+
* module. `layout_id` is the module's `tapewasm_layout_id` global, checked
|
|
55
|
+
* against the bound exports before each run so a module and a scratch
|
|
56
|
+
* buffer built for different models cannot be used together.
|
|
57
|
+
*
|
|
58
|
+
* `param_names` only names a parameter in a rejected starting point; pass
|
|
59
|
+
* an empty array to go without.
|
|
60
|
+
* @param {number} n_params
|
|
61
|
+
* @param {Float64Array} scratch_init
|
|
62
|
+
* @param {number} layout_id
|
|
63
|
+
* @param {string[]} param_names
|
|
64
|
+
*/
|
|
65
|
+
constructor(n_params, scratch_init, layout_id, param_names) {
|
|
66
|
+
const ptr0 = passArrayF64ToWasm0(scratch_init, wasm.__wbindgen_malloc);
|
|
67
|
+
const len0 = WASM_VECTOR_LEN;
|
|
68
|
+
const ptr1 = passArrayJsValueToWasm0(param_names, wasm.__wbindgen_malloc);
|
|
69
|
+
const len1 = WASM_VECTOR_LEN;
|
|
70
|
+
const ret = wasm.aotsampler_new(n_params, ptr0, len0, layout_id, ptr1, len1);
|
|
71
|
+
if (ret[2]) {
|
|
72
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
73
|
+
}
|
|
74
|
+
this.__wbg_ptr = ret[0];
|
|
75
|
+
AotSamplerFinalization.register(this, this.__wbg_ptr, this);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* `num_warmup + num_draws` draws, row-major, `n_params` wide.
|
|
80
|
+
* @param {Float64Array} init
|
|
81
|
+
* @param {number} num_warmup
|
|
82
|
+
* @param {number} num_draws
|
|
83
|
+
* @param {bigint} seed
|
|
84
|
+
* @returns {Float64Array}
|
|
85
|
+
*/
|
|
86
|
+
sample(init, num_warmup, num_draws, seed) {
|
|
87
|
+
const ptr0 = passArrayF64ToWasm0(init, wasm.__wbindgen_malloc);
|
|
88
|
+
const len0 = WASM_VECTOR_LEN;
|
|
89
|
+
const ret = wasm.aotsampler_sample(this.__wbg_ptr, ptr0, len0, num_warmup, num_draws, seed);
|
|
90
|
+
if (ret[3]) {
|
|
91
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
92
|
+
}
|
|
93
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
94
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
95
|
+
return v2;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (Symbol.dispose) AotSampler.prototype[Symbol.dispose] = AotSampler.prototype.free;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* What [`compile_tape`] produced, and everything [`AotSampler`] needs from it.
|
|
102
|
+
*/
|
|
103
|
+
export class CompiledTape {
|
|
104
|
+
static __wrap(ptr) {
|
|
105
|
+
const obj = Object.create(CompiledTape.prototype);
|
|
106
|
+
obj.__wbg_ptr = ptr;
|
|
107
|
+
CompiledTapeFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
108
|
+
return obj;
|
|
109
|
+
}
|
|
110
|
+
__destroy_into_raw() {
|
|
111
|
+
const ptr = this.__wbg_ptr;
|
|
112
|
+
this.__wbg_ptr = 0;
|
|
113
|
+
CompiledTapeFinalization.unregister(this);
|
|
114
|
+
return ptr;
|
|
115
|
+
}
|
|
116
|
+
free() {
|
|
117
|
+
const ptr = this.__destroy_into_raw();
|
|
118
|
+
wasm.__wbg_compiledtape_free(ptr, 0);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @returns {number}
|
|
122
|
+
*/
|
|
123
|
+
get layoutId() {
|
|
124
|
+
const ret = wasm.compiledtape_layoutId(this.__wbg_ptr);
|
|
125
|
+
return ret >>> 0;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @returns {number}
|
|
129
|
+
*/
|
|
130
|
+
get nParams() {
|
|
131
|
+
const ret = wasm.compiledtape_nParams(this.__wbg_ptr);
|
|
132
|
+
return ret >>> 0;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @returns {Float64Array}
|
|
136
|
+
*/
|
|
137
|
+
get scratchInit() {
|
|
138
|
+
const ret = wasm.compiledtape_scratchInit(this.__wbg_ptr);
|
|
139
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
140
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
141
|
+
return v1;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The module. Instantiate it against [`shared_memory`] and the `Math`
|
|
145
|
+
* imports, then bind it with `setAotExports`.
|
|
146
|
+
* @returns {Uint8Array}
|
|
147
|
+
*/
|
|
148
|
+
get wasm() {
|
|
149
|
+
const ret = wasm.compiledtape_wasm(this.__wbg_ptr);
|
|
150
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
151
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
152
|
+
return v1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (Symbol.dispose) CompiledTape.prototype[Symbol.dispose] = CompiledTape.prototype.free;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Release the bound module's exports. The next draw will throw.
|
|
159
|
+
*/
|
|
160
|
+
export function clearAotExports() {
|
|
161
|
+
wasm.clearAotExports();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Compile a tape written by another front end.
|
|
166
|
+
*
|
|
167
|
+
* `tape` is the text format `tapewasm_codegen::tape_text` documents: one
|
|
168
|
+
* instruction per line, operands naming instructions rather than nodes. A
|
|
169
|
+
* front end that can build a tape reaches the emitter this way — including
|
|
170
|
+
* one that is not Rust and not in this module.
|
|
171
|
+
*
|
|
172
|
+
* The format is not an artifact and carries no compatibility promise: a tape
|
|
173
|
+
* is written and consumed inside one call.
|
|
174
|
+
* @param {string} tape
|
|
175
|
+
* @returns {CompiledTape}
|
|
176
|
+
*/
|
|
177
|
+
export function compileTape(tape) {
|
|
178
|
+
const ptr0 = passStringToWasm0(tape, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
179
|
+
const len0 = WASM_VECTOR_LEN;
|
|
180
|
+
const ret = wasm.compileTape(ptr0, len0);
|
|
181
|
+
if (ret[2]) {
|
|
182
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
183
|
+
}
|
|
184
|
+
return CompiledTape.__wrap(ret[0]);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Forwards Rust panics to `console.error` with a message and backtrace rather
|
|
189
|
+
* than an opaque `RuntimeError: unreachable`. Diagnostics: the instance still traps.
|
|
190
|
+
*/
|
|
191
|
+
export function init_panic_hook() {
|
|
192
|
+
wasm.init_panic_hook();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Bind a freshly-instantiated model module's exports so sampling dispatches
|
|
197
|
+
* through it. Pass `instance.exports`.
|
|
198
|
+
*
|
|
199
|
+
* One binding serves the whole page, so a page holding several models has to
|
|
200
|
+
* re-bind before sampling a different one. The sampler compares the bound
|
|
201
|
+
* module's `tapewasm_layout_id` against the model it belongs to and refuses
|
|
202
|
+
* the pair rather than running it against the wrong scratch buffer.
|
|
203
|
+
* @param {any} exports
|
|
204
|
+
*/
|
|
205
|
+
export function setAotExports(exports) {
|
|
206
|
+
wasm.setAotExports(exports);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The linear memory backing this module. Pass as the `tapewasm.memory`
|
|
211
|
+
* import when instantiating a model module so the two share buffers.
|
|
212
|
+
* @returns {any}
|
|
213
|
+
*/
|
|
214
|
+
export function sharedMemory() {
|
|
215
|
+
const ret = wasm.sharedMemory();
|
|
216
|
+
return ret;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @returns {string}
|
|
221
|
+
*/
|
|
222
|
+
export function tapewasmVersion() {
|
|
223
|
+
let deferred1_0;
|
|
224
|
+
let deferred1_1;
|
|
225
|
+
try {
|
|
226
|
+
const ret = wasm.tapewasmVersion();
|
|
227
|
+
deferred1_0 = ret[0];
|
|
228
|
+
deferred1_1 = ret[1];
|
|
229
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
230
|
+
} finally {
|
|
231
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function __wbg_get_imports() {
|
|
235
|
+
const import0 = {
|
|
236
|
+
__proto__: null,
|
|
237
|
+
__wbg_Error_67e7344beaa85059: function(arg0, arg1) {
|
|
238
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
239
|
+
return ret;
|
|
240
|
+
},
|
|
241
|
+
__wbg___wbindgen_memory_3f8442e22540244f: function() {
|
|
242
|
+
const ret = wasm.memory;
|
|
243
|
+
return ret;
|
|
244
|
+
},
|
|
245
|
+
__wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
|
|
246
|
+
const obj = arg1;
|
|
247
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
248
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
249
|
+
var len1 = WASM_VECTOR_LEN;
|
|
250
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
251
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
252
|
+
},
|
|
253
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
254
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
255
|
+
},
|
|
256
|
+
__wbg_aot_logp_50f9146d22ee7ef4: function(arg0, arg1, arg2, arg3) {
|
|
257
|
+
const ret = aot_logp(arg0 >>> 0, arg1 >>> 0, arg2 >>> 0, arg3 >>> 0);
|
|
258
|
+
return ret;
|
|
259
|
+
},
|
|
260
|
+
__wbg_error_757e9472f8410341: function(arg0, arg1) {
|
|
261
|
+
let deferred0_0;
|
|
262
|
+
let deferred0_1;
|
|
263
|
+
try {
|
|
264
|
+
deferred0_0 = arg0;
|
|
265
|
+
deferred0_1 = arg1;
|
|
266
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
267
|
+
} finally {
|
|
268
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
272
|
+
const ret = new Error();
|
|
273
|
+
return ret;
|
|
274
|
+
},
|
|
275
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
276
|
+
const ret = arg1.stack;
|
|
277
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
278
|
+
const len1 = WASM_VECTOR_LEN;
|
|
279
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
280
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
281
|
+
},
|
|
282
|
+
__wbindgen_init_externref_table: function() {
|
|
283
|
+
const table = wasm.__wbindgen_externrefs;
|
|
284
|
+
const offset = table.grow(4);
|
|
285
|
+
table.set(0, undefined);
|
|
286
|
+
table.set(offset + 0, undefined);
|
|
287
|
+
table.set(offset + 1, null);
|
|
288
|
+
table.set(offset + 2, true);
|
|
289
|
+
table.set(offset + 3, false);
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
return {
|
|
293
|
+
__proto__: null,
|
|
294
|
+
"./tapewasm_bg.js": import0,
|
|
295
|
+
"./snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js": import1,
|
|
296
|
+
"./snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js": import2,
|
|
297
|
+
"./snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js": import3,
|
|
298
|
+
"./snippets/tapewasm-86b4af57c39247cc/js/aot_bridge.js": import4,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const AotSamplerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
303
|
+
? { register: () => {}, unregister: () => {} }
|
|
304
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_aotsampler_free(ptr, 1));
|
|
305
|
+
const CompiledTapeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
306
|
+
? { register: () => {}, unregister: () => {} }
|
|
307
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_compiledtape_free(ptr, 1));
|
|
308
|
+
|
|
309
|
+
function addToExternrefTable0(obj) {
|
|
310
|
+
const idx = wasm.__externref_table_alloc();
|
|
311
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
312
|
+
return idx;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
316
|
+
ptr = ptr >>> 0;
|
|
317
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
321
|
+
ptr = ptr >>> 0;
|
|
322
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let cachedDataViewMemory0 = null;
|
|
326
|
+
function getDataViewMemory0() {
|
|
327
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
328
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
329
|
+
}
|
|
330
|
+
return cachedDataViewMemory0;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
334
|
+
function getFloat64ArrayMemory0() {
|
|
335
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
336
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
337
|
+
}
|
|
338
|
+
return cachedFloat64ArrayMemory0;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function getStringFromWasm0(ptr, len) {
|
|
342
|
+
return decodeText(ptr >>> 0, len);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
let cachedUint8ArrayMemory0 = null;
|
|
346
|
+
function getUint8ArrayMemory0() {
|
|
347
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
348
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
349
|
+
}
|
|
350
|
+
return cachedUint8ArrayMemory0;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function isLikeNone(x) {
|
|
354
|
+
return x === undefined || x === null;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
358
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
359
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
360
|
+
WASM_VECTOR_LEN = arg.length;
|
|
361
|
+
return ptr;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
365
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
366
|
+
for (let i = 0; i < array.length; i++) {
|
|
367
|
+
const add = addToExternrefTable0(array[i]);
|
|
368
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
369
|
+
}
|
|
370
|
+
WASM_VECTOR_LEN = array.length;
|
|
371
|
+
return ptr;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
375
|
+
if (realloc === undefined) {
|
|
376
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
377
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
378
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
379
|
+
WASM_VECTOR_LEN = buf.length;
|
|
380
|
+
return ptr;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
let len = arg.length;
|
|
384
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
385
|
+
|
|
386
|
+
const mem = getUint8ArrayMemory0();
|
|
387
|
+
|
|
388
|
+
let offset = 0;
|
|
389
|
+
|
|
390
|
+
for (; offset < len; offset++) {
|
|
391
|
+
const code = arg.charCodeAt(offset);
|
|
392
|
+
if (code > 0x7F) break;
|
|
393
|
+
mem[ptr + offset] = code;
|
|
394
|
+
}
|
|
395
|
+
if (offset !== len) {
|
|
396
|
+
if (offset !== 0) {
|
|
397
|
+
arg = arg.slice(offset);
|
|
398
|
+
}
|
|
399
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
400
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
401
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
402
|
+
|
|
403
|
+
offset += ret.written;
|
|
404
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
WASM_VECTOR_LEN = offset;
|
|
408
|
+
return ptr;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function takeFromExternrefTable0(idx) {
|
|
412
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
413
|
+
wasm.__externref_table_dealloc(idx);
|
|
414
|
+
return value;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
418
|
+
cachedTextDecoder.decode();
|
|
419
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
420
|
+
let numBytesDecoded = 0;
|
|
421
|
+
function decodeText(ptr, len) {
|
|
422
|
+
numBytesDecoded += len;
|
|
423
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
424
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
425
|
+
cachedTextDecoder.decode();
|
|
426
|
+
numBytesDecoded = len;
|
|
427
|
+
}
|
|
428
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const cachedTextEncoder = new TextEncoder();
|
|
432
|
+
|
|
433
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
434
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
435
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
436
|
+
view.set(buf);
|
|
437
|
+
return {
|
|
438
|
+
read: arg.length,
|
|
439
|
+
written: buf.length
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let WASM_VECTOR_LEN = 0;
|
|
445
|
+
|
|
446
|
+
let wasmModule, wasmInstance, wasm;
|
|
447
|
+
function __wbg_finalize_init(instance, module) {
|
|
448
|
+
wasmInstance = instance;
|
|
449
|
+
wasm = instance.exports;
|
|
450
|
+
wasmModule = module;
|
|
451
|
+
cachedDataViewMemory0 = null;
|
|
452
|
+
cachedFloat64ArrayMemory0 = null;
|
|
453
|
+
cachedUint8ArrayMemory0 = null;
|
|
454
|
+
wasm.__wbindgen_start();
|
|
455
|
+
return wasm;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
async function __wbg_load(module, imports) {
|
|
459
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
460
|
+
if (!module.ok) {
|
|
461
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
465
|
+
try {
|
|
466
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
467
|
+
} catch (e) {
|
|
468
|
+
const validResponse = expectedResponseType(module.type);
|
|
469
|
+
|
|
470
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
471
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
472
|
+
|
|
473
|
+
} else { throw e; }
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const bytes = await module.arrayBuffer();
|
|
478
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
479
|
+
} else {
|
|
480
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
481
|
+
|
|
482
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
483
|
+
return { instance, module };
|
|
484
|
+
} else {
|
|
485
|
+
return instance;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function expectedResponseType(type) {
|
|
490
|
+
switch (type) {
|
|
491
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
492
|
+
}
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function initSync(module) {
|
|
498
|
+
if (wasm !== undefined) return wasm;
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
if (module !== undefined) {
|
|
502
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
503
|
+
({module} = module)
|
|
504
|
+
} else {
|
|
505
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const imports = __wbg_get_imports();
|
|
510
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
511
|
+
module = new WebAssembly.Module(module);
|
|
512
|
+
}
|
|
513
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
514
|
+
return __wbg_finalize_init(instance, module);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
async function __wbg_init(module_or_path) {
|
|
518
|
+
if (wasm !== undefined) return wasm;
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
if (module_or_path !== undefined) {
|
|
522
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
523
|
+
({module_or_path} = module_or_path)
|
|
524
|
+
} else {
|
|
525
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (module_or_path === undefined) {
|
|
530
|
+
module_or_path = new URL('tapewasm_bg.wasm', import.meta.url);
|
|
531
|
+
}
|
|
532
|
+
const imports = __wbg_get_imports();
|
|
533
|
+
|
|
534
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
535
|
+
module_or_path = fetch(module_or_path);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
539
|
+
|
|
540
|
+
return __wbg_finalize_init(instance, module);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_aotsampler_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_compiledtape_free: (a: number, b: number) => void;
|
|
6
|
+
export const aotsampler_logProbGrad: (a: number, b: number, c: number) => [number, number, number, number];
|
|
7
|
+
export const aotsampler_nParams: (a: number) => number;
|
|
8
|
+
export const aotsampler_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
9
|
+
export const aotsampler_sample: (a: number, b: number, c: number, d: number, e: number, f: bigint) => [number, number, number, number];
|
|
10
|
+
export const clearAotExports: () => void;
|
|
11
|
+
export const compileTape: (a: number, b: number) => [number, number, number];
|
|
12
|
+
export const compiledtape_layoutId: (a: number) => number;
|
|
13
|
+
export const compiledtape_nParams: (a: number) => number;
|
|
14
|
+
export const compiledtape_scratchInit: (a: number) => [number, number];
|
|
15
|
+
export const compiledtape_wasm: (a: number) => [number, number];
|
|
16
|
+
export const init_panic_hook: () => void;
|
|
17
|
+
export const setAotExports: (a: any) => void;
|
|
18
|
+
export const sharedMemory: () => any;
|
|
19
|
+
export const tapewasmVersion: () => [number, number];
|
|
20
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
21
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
22
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
23
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
24
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
25
|
+
export const __externref_table_alloc: () => number;
|
|
26
|
+
export const __wbindgen_start: () => void;
|