tensorgrad 0.0.15 → 0.0.16
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/dist/index.d.ts +154 -193
- package/dist/index.js +2208 -39
- package/dist/index.js.map +7 -1
- package/dist/worker.debug.js +553 -0
- package/package.json +60 -58
- package/src/adam.ts +69 -15
- package/src/compile.ts +334 -156
- package/src/index.ts +8 -4
- package/src/module.ts +72 -34
- package/src/worker-protocol.ts +183 -0
- package/src/worker-proxy.ts +76 -0
- package/src/worker.ts +281 -0
- package/dist/adam.js +0 -111
- package/dist/adam.js.map +0 -1
- package/dist/buffers.js +0 -120
- package/dist/buffers.js.map +0 -1
- package/dist/capture.js +0 -33
- package/dist/capture.js.map +0 -1
- package/dist/codegen.js +0 -724
- package/dist/codegen.js.map +0 -1
- package/dist/compile.js +0 -184
- package/dist/compile.js.map +0 -1
- package/dist/grad.js +0 -380
- package/dist/grad.js.map +0 -1
- package/dist/ir.js +0 -60
- package/dist/ir.js.map +0 -1
- package/dist/module.js +0 -155
- package/dist/module.js.map +0 -1
- package/dist/nn.js +0 -135
- package/dist/nn.js.map +0 -1
- package/dist/ops.js +0 -326
- package/dist/ops.js.map +0 -1
- package/dist/runtime.js +0 -402
- package/dist/runtime.js.map +0 -1
- package/dist/shape.js +0 -259
- package/dist/shape.js.map +0 -1
- package/dist/trace.js +0 -100
- package/dist/trace.js.map +0 -1
package/dist/shape.js
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
// Shape inference and validation for each op kind.
|
|
2
|
-
//
|
|
3
|
-
// Every op in src/ops.ts validates its inputs and computes its output shape
|
|
4
|
-
// through helpers here. Errors throw with the captured call-site so the
|
|
5
|
-
// stack trace points at the user's line, not into the library.
|
|
6
|
-
//
|
|
7
|
-
// Broadcasting rules (deliberately limited):
|
|
8
|
-
// * For element-wise binops (add/sub/mul/div), we support trailing-axis
|
|
9
|
-
// broadcasting: the smaller operand's shape must be a suffix of the
|
|
10
|
-
// larger's, with axes of size 1 broadcasting to any size. Examples
|
|
11
|
-
// ALLOWED: [B, T, D] op [D] → [B, T, D]
|
|
12
|
-
// [B, T, D] op [1, D] → [B, T, D]
|
|
13
|
-
// [B, T, D] op [B, T, D] → [B, T, D]
|
|
14
|
-
// Examples REJECTED: [B, T, D] op [B] (suffix mismatch)
|
|
15
|
-
// [B, T, D] op [T, D] when T != B (legal numpy, banned here)
|
|
16
|
-
// The restriction makes codegen and autograd much simpler and covers every
|
|
17
|
-
// broadcast pattern in our transformer (biases, layernorm gain/bias, masks).
|
|
18
|
-
import { formatSite } from './ir.js';
|
|
19
|
-
// ============================================================================
|
|
20
|
-
// Errors
|
|
21
|
-
// ============================================================================
|
|
22
|
-
export class ShapeError extends Error {
|
|
23
|
-
constructor(message, site) {
|
|
24
|
-
const formatted = site ? `${message}\n at ${formatSite(site)}` : message;
|
|
25
|
-
super(formatted);
|
|
26
|
-
this.name = 'ShapeError';
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function fail(message, site) {
|
|
30
|
-
throw new ShapeError(message, site);
|
|
31
|
-
}
|
|
32
|
-
// ============================================================================
|
|
33
|
-
// Shape utilities
|
|
34
|
-
// ============================================================================
|
|
35
|
-
export function shapesEqual(a, b) {
|
|
36
|
-
if (a.length !== b.length)
|
|
37
|
-
return false;
|
|
38
|
-
for (let i = 0; i < a.length; i++)
|
|
39
|
-
if (a[i] !== b[i])
|
|
40
|
-
return false;
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
export function shapeSize(shape) {
|
|
44
|
-
let n = 1;
|
|
45
|
-
for (const d of shape)
|
|
46
|
-
n *= d;
|
|
47
|
-
return n;
|
|
48
|
-
}
|
|
49
|
-
export function showShape(shape) {
|
|
50
|
-
return `[${shape.join(', ')}]`;
|
|
51
|
-
}
|
|
52
|
-
// Standard right-aligned NumPy-style broadcasting. Pad the shorter shape with
|
|
53
|
-
// leading 1s, then per-axis: equal dims unify, size-1 dims broadcast on either
|
|
54
|
-
// side, otherwise incompatible. Returns the resulting shape or null.
|
|
55
|
-
export function broadcastTrailing(a, b) {
|
|
56
|
-
const rank = Math.max(a.length, b.length);
|
|
57
|
-
const out = new Array(rank);
|
|
58
|
-
for (let i = 0; i < rank; i++) {
|
|
59
|
-
const ai = i - (rank - a.length);
|
|
60
|
-
const bi = i - (rank - b.length);
|
|
61
|
-
const av = ai < 0 ? 1 : a[ai];
|
|
62
|
-
const bv = bi < 0 ? 1 : b[bi];
|
|
63
|
-
if (av === bv)
|
|
64
|
-
out[i] = av;
|
|
65
|
-
else if (av === 1)
|
|
66
|
-
out[i] = bv;
|
|
67
|
-
else if (bv === 1)
|
|
68
|
-
out[i] = av;
|
|
69
|
-
else
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
|
-
// ============================================================================
|
|
75
|
-
// Per-op shape rules
|
|
76
|
-
// ============================================================================
|
|
77
|
-
//
|
|
78
|
-
// Each rule takes the input shapes and returns the output shape, or throws.
|
|
79
|
-
// All rules accept a `site` for error attribution.
|
|
80
|
-
export function inferElementwiseBinop(opName, aShape, bShape, site) {
|
|
81
|
-
const result = broadcastTrailing(aShape, bShape);
|
|
82
|
-
if (!result) {
|
|
83
|
-
fail(`${opName}: incompatible shapes ${showShape(aShape)} and ${showShape(bShape)}. ` +
|
|
84
|
-
`Trailing-suffix broadcasting only — the smaller shape must be a suffix of the larger, ` +
|
|
85
|
-
`with size-1 axes broadcasting to any size.`, site);
|
|
86
|
-
}
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
export function inferUnary(_opName, aShape, _site) {
|
|
90
|
-
return aShape;
|
|
91
|
-
}
|
|
92
|
-
export function inferMeanLast(opName, aShape, site) {
|
|
93
|
-
if (aShape.length === 0)
|
|
94
|
-
fail(`${opName}: cannot reduce a 0-d tensor`, site);
|
|
95
|
-
// keepdims=true: replace last axis with 1.
|
|
96
|
-
return [...aShape.slice(0, -1), 1];
|
|
97
|
-
}
|
|
98
|
-
export function inferSumLast(opName, aShape, site) {
|
|
99
|
-
if (aShape.length === 0)
|
|
100
|
-
fail(`${opName}: cannot reduce a 0-d tensor`, site);
|
|
101
|
-
// keepdims=false: drop the last axis.
|
|
102
|
-
return aShape.slice(0, -1);
|
|
103
|
-
}
|
|
104
|
-
export function inferReshape(opName, aShape, newShape, site) {
|
|
105
|
-
// Validate -1 placeholder (at most one allowed) and total size match.
|
|
106
|
-
let inferIdx = -1;
|
|
107
|
-
let knownSize = 1;
|
|
108
|
-
for (let i = 0; i < newShape.length; i++) {
|
|
109
|
-
const d = newShape[i];
|
|
110
|
-
if (d === -1) {
|
|
111
|
-
if (inferIdx !== -1)
|
|
112
|
-
fail(`${opName}: at most one -1 dim allowed in newShape ${showShape(newShape)}`, site);
|
|
113
|
-
inferIdx = i;
|
|
114
|
-
}
|
|
115
|
-
else if (d <= 0) {
|
|
116
|
-
fail(`${opName}: invalid dim ${d} in newShape ${showShape(newShape)}`, site);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
knownSize *= d;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const totalIn = shapeSize(aShape);
|
|
123
|
-
const out = [...newShape];
|
|
124
|
-
if (inferIdx !== -1) {
|
|
125
|
-
if (totalIn % knownSize !== 0) {
|
|
126
|
-
fail(`${opName}: cannot reshape ${showShape(aShape)} (size ${totalIn}) to ${showShape(newShape)} — known dims multiply to ${knownSize}`, site);
|
|
127
|
-
}
|
|
128
|
-
out[inferIdx] = totalIn / knownSize;
|
|
129
|
-
}
|
|
130
|
-
else if (knownSize !== totalIn) {
|
|
131
|
-
fail(`${opName}: size mismatch — input ${showShape(aShape)} has ${totalIn} elements but newShape ${showShape(newShape)} has ${knownSize}`, site);
|
|
132
|
-
}
|
|
133
|
-
return out;
|
|
134
|
-
}
|
|
135
|
-
export function inferTranspose(opName, aShape, perm, site) {
|
|
136
|
-
if (perm.length !== aShape.length) {
|
|
137
|
-
fail(`${opName}: perm length ${perm.length} must equal input rank ${aShape.length}`, site);
|
|
138
|
-
}
|
|
139
|
-
const seen = new Set();
|
|
140
|
-
for (const p of perm) {
|
|
141
|
-
if (p < 0 || p >= aShape.length)
|
|
142
|
-
fail(`${opName}: perm index ${p} out of range for rank ${aShape.length}`, site);
|
|
143
|
-
if (seen.has(p))
|
|
144
|
-
fail(`${opName}: perm has duplicate index ${p}`, site);
|
|
145
|
-
seen.add(p);
|
|
146
|
-
}
|
|
147
|
-
return perm.map(p => aShape[p]);
|
|
148
|
-
}
|
|
149
|
-
// matmul: a [..., M, K] · b [K, N] → [..., M, N]. b is unbatched.
|
|
150
|
-
export function inferMatmul(opName, aShape, bShape, site) {
|
|
151
|
-
if (aShape.length < 2)
|
|
152
|
-
fail(`${opName}: lhs must have rank >= 2, got ${showShape(aShape)}`, site);
|
|
153
|
-
if (bShape.length !== 2)
|
|
154
|
-
fail(`${opName}: rhs must have rank 2, got ${showShape(bShape)} — use matmulBatched for batched rhs`, site);
|
|
155
|
-
const M = aShape[aShape.length - 2];
|
|
156
|
-
const Ka = aShape[aShape.length - 1];
|
|
157
|
-
const Kb = bShape[0];
|
|
158
|
-
const N = bShape[1];
|
|
159
|
-
if (Ka !== Kb)
|
|
160
|
-
fail(`${opName}: inner dims don't match — ${showShape(aShape)} · ${showShape(bShape)} (last axis of lhs = ${Ka}, first axis of rhs = ${Kb})`, site);
|
|
161
|
-
return [...aShape.slice(0, -2), M, N];
|
|
162
|
-
}
|
|
163
|
-
// matmul_batched: a [..., M, K] · b [..., K, N] → [..., M, N]. Both have leading batch dims.
|
|
164
|
-
export function inferMatmulBatched(opName, aShape, bShape, site) {
|
|
165
|
-
if (aShape.length < 2 || bShape.length < 2) {
|
|
166
|
-
fail(`${opName}: both inputs must have rank >= 2, got ${showShape(aShape)} and ${showShape(bShape)}`, site);
|
|
167
|
-
}
|
|
168
|
-
if (aShape.length !== bShape.length) {
|
|
169
|
-
fail(`${opName}: ranks must match (got ${aShape.length} vs ${bShape.length}). Reshape if you need different batch dims.`, site);
|
|
170
|
-
}
|
|
171
|
-
const aBatch = aShape.slice(0, -2);
|
|
172
|
-
const bBatch = bShape.slice(0, -2);
|
|
173
|
-
for (let i = 0; i < aBatch.length; i++) {
|
|
174
|
-
if (aBatch[i] !== bBatch[i]) {
|
|
175
|
-
fail(`${opName}: batch dims must match — ${showShape(aShape)} vs ${showShape(bShape)}`, site);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
const M = aShape[aShape.length - 2];
|
|
179
|
-
const Ka = aShape[aShape.length - 1];
|
|
180
|
-
const Kb = bShape[bShape.length - 2];
|
|
181
|
-
const N = bShape[bShape.length - 1];
|
|
182
|
-
if (Ka !== Kb)
|
|
183
|
-
fail(`${opName}: inner dims don't match — last axis of lhs = ${Ka}, second-to-last of rhs = ${Kb}`, site);
|
|
184
|
-
return [...aBatch, M, N];
|
|
185
|
-
}
|
|
186
|
-
export function inferOneHot(opName, indicesShape, depth, site) {
|
|
187
|
-
if (depth <= 0)
|
|
188
|
-
fail(`${opName}: depth must be positive, got ${depth}`, site);
|
|
189
|
-
return [...indicesShape, depth];
|
|
190
|
-
}
|
|
191
|
-
// where_causal preserves shape but requires the last two axes to be square.
|
|
192
|
-
export function inferWhereCausal(opName, aShape, site) {
|
|
193
|
-
if (aShape.length < 2)
|
|
194
|
-
fail(`${opName}: requires rank >= 2, got ${showShape(aShape)}`, site);
|
|
195
|
-
const m = aShape[aShape.length - 2];
|
|
196
|
-
const n = aShape[aShape.length - 1];
|
|
197
|
-
if (m !== n)
|
|
198
|
-
fail(`${opName}: last two axes must be equal (square mask), got ${showShape(aShape)}`, site);
|
|
199
|
-
return aShape;
|
|
200
|
-
}
|
|
201
|
-
export function inferSliceLastRange(opName, aShape, start, end, site) {
|
|
202
|
-
if (aShape.length === 0)
|
|
203
|
-
fail(`${opName}: cannot slice 0-d tensor`, site);
|
|
204
|
-
const last = aShape[aShape.length - 1];
|
|
205
|
-
if (start < 0 || end > last || start >= end) {
|
|
206
|
-
fail(`${opName}: invalid range [${start}, ${end}) for last axis of size ${last}`, site);
|
|
207
|
-
}
|
|
208
|
-
return [...aShape.slice(0, -1), end - start];
|
|
209
|
-
}
|
|
210
|
-
// broadcast_to: validate that `aShape` can broadcast to `targetShape` under
|
|
211
|
-
// right-aligned NumPy rules. Returns targetShape on success.
|
|
212
|
-
export function inferBroadcastTo(opName, aShape, targetShape, site) {
|
|
213
|
-
if (aShape.length > targetShape.length) {
|
|
214
|
-
fail(`${opName}: source rank ${aShape.length} > target rank ${targetShape.length}`, site);
|
|
215
|
-
}
|
|
216
|
-
const offset = targetShape.length - aShape.length;
|
|
217
|
-
for (let i = 0; i < aShape.length; i++) {
|
|
218
|
-
const av = aShape[i];
|
|
219
|
-
const tv = targetShape[offset + i];
|
|
220
|
-
if (av !== tv && av !== 1) {
|
|
221
|
-
fail(`${opName}: cannot broadcast ${showShape(aShape)} to ${showShape(targetShape)} — axis ${i} (size ${av}) doesn't match target axis ${offset + i} (size ${tv}) and isn't 1`, site);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return targetShape;
|
|
225
|
-
}
|
|
226
|
-
// sum_to_shape: validate that `targetShape` is a valid right-aligned reduction
|
|
227
|
-
// of `aShape` (i.e., aShape can have been produced by broadcasting targetShape).
|
|
228
|
-
export function inferSumToShape(opName, aShape, targetShape, site) {
|
|
229
|
-
if (targetShape.length > aShape.length) {
|
|
230
|
-
fail(`${opName}: target rank ${targetShape.length} > source rank ${aShape.length}`, site);
|
|
231
|
-
}
|
|
232
|
-
const offset = aShape.length - targetShape.length;
|
|
233
|
-
for (let i = 0; i < targetShape.length; i++) {
|
|
234
|
-
const av = aShape[offset + i];
|
|
235
|
-
const tv = targetShape[i];
|
|
236
|
-
if (av !== tv && tv !== 1) {
|
|
237
|
-
fail(`${opName}: cannot sum-reduce ${showShape(aShape)} to ${showShape(targetShape)} — target axis ${i} (size ${tv}) must be 1 or match source`, site);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return targetShape;
|
|
241
|
-
}
|
|
242
|
-
// Three-way broadcast for `where(cond, a, b)`. All three shapes must broadcast
|
|
243
|
-
// to a common shape under standard NumPy rules.
|
|
244
|
-
export function inferWhere(opName, condShape, aShape, bShape, site) {
|
|
245
|
-
const ab = broadcastTrailing(aShape, bShape);
|
|
246
|
-
if (!ab)
|
|
247
|
-
fail(`${opName}: a/b incompatible: ${showShape(aShape)} vs ${showShape(bShape)}`, site);
|
|
248
|
-
const result = broadcastTrailing(condShape, ab);
|
|
249
|
-
if (!result)
|
|
250
|
-
fail(`${opName}: cond ${showShape(condShape)} incompatible with broadcast(a, b) ${showShape(ab)}`, site);
|
|
251
|
-
return result;
|
|
252
|
-
}
|
|
253
|
-
export function inferReluGrad(opName, xShape, dyShape, site) {
|
|
254
|
-
if (!shapesEqual(xShape, dyShape)) {
|
|
255
|
-
fail(`${opName}: x and dy must have matching shapes, got ${showShape(xShape)} and ${showShape(dyShape)}`, site);
|
|
256
|
-
}
|
|
257
|
-
return xShape;
|
|
258
|
-
}
|
|
259
|
-
//# sourceMappingURL=shape.js.map
|
package/dist/shape.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","sourceRoot":"","sources":["../src/shape.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,4EAA4E;AAC5E,wEAAwE;AACxE,+DAA+D;AAC/D,EAAE;AACF,6CAA6C;AAC7C,0EAA0E;AAC1E,wEAAwE;AACxE,uEAAuE;AACvE,+CAA+C;AAC/C,iDAAiD;AACjD,oDAAoD;AACpD,+DAA+D;AAC/D,qFAAqF;AACrF,6EAA6E;AAC7E,+EAA+E;AAG/E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe,EAAE,IAAqB;QAChD,MAAM,S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D;AAChD,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,SAAgB,EAAE,MAAa,EAAE,MAAa,EAAE,IAAqB;IAC9G,MAAM,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5C,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,GAAG,MAAM,uBAAuB,SAAS,CAAC,MAAM,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAChG,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAC/C,IAAI,CAAC,MAAM;QAAE,IAAI,CAAC,GAAG,MAAM,UAAU,SAAS,CAAC,SAAS,CAAC,sCAAsC,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IACrH,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,MAAa,EAAE,OAAc,EAAE,IAAqB;IAChG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,MAAM,6CAA6C,SAAS,CAAC,MAAM,CAAC,QAAQ,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IACjH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/trace.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// Trace driver. Holds the "current graph" in module-local state so user code
|
|
2
|
-
// can call ops without threading a graph parameter through every function.
|
|
3
|
-
//
|
|
4
|
-
// Usage:
|
|
5
|
-
//
|
|
6
|
-
// const graph = trace(() => {
|
|
7
|
-
// const x = tensorInput('x', [B, T], 'i32')
|
|
8
|
-
// const w = paramInput('w', [V, D], 'f32')
|
|
9
|
-
// // ... user computation building tensors ...
|
|
10
|
-
// return finalLossTensor
|
|
11
|
-
// })
|
|
12
|
-
//
|
|
13
|
-
// `trace` is single-threaded and re-entrant only via nested calls (which share
|
|
14
|
-
// the outer graph — but we don't currently have a use for nesting). Calling an
|
|
15
|
-
// op outside a `trace(...)` block is an error.
|
|
16
|
-
import { makeGraph, addOp, captureSite } from './ir.js';
|
|
17
|
-
// Module-local: the graph being built right now, or null if no trace is active.
|
|
18
|
-
let _current = null;
|
|
19
|
-
// Module-local: whether `capture(name, t)` calls should register on the current
|
|
20
|
-
// graph. True only during the user's forward trace; false during `traceInto`
|
|
21
|
-
// (autograd / optimizer ops shouldn't accidentally publish gradient tensors).
|
|
22
|
-
let _captureEnabled = false;
|
|
23
|
-
export function currentGraph() {
|
|
24
|
-
if (!_current) {
|
|
25
|
-
throw new Error('tensorgrad: ops can only be called inside trace(). ' +
|
|
26
|
-
'Did you forget to wrap your forward pass?');
|
|
27
|
-
}
|
|
28
|
-
return _current;
|
|
29
|
-
}
|
|
30
|
-
export function isCaptureEnabled() {
|
|
31
|
-
return _captureEnabled;
|
|
32
|
-
}
|
|
33
|
-
// Run `fn` with a fresh graph as the current one; capture and return the graph.
|
|
34
|
-
// `fn` must return the tensor (or array of tensors) to mark as graph outputs.
|
|
35
|
-
export function trace(fn) {
|
|
36
|
-
if (_current) {
|
|
37
|
-
throw new Error('tensorgrad: nested trace() is not supported');
|
|
38
|
-
}
|
|
39
|
-
const g = makeGraph();
|
|
40
|
-
_current = g;
|
|
41
|
-
_captureEnabled = true;
|
|
42
|
-
try {
|
|
43
|
-
const result = fn();
|
|
44
|
-
const outputs = Array.isArray(result) ? result : [result];
|
|
45
|
-
for (const t of outputs) {
|
|
46
|
-
;
|
|
47
|
-
g.outputs.push(t.id);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
_current = null;
|
|
52
|
-
_captureEnabled = false;
|
|
53
|
-
}
|
|
54
|
-
return g;
|
|
55
|
-
}
|
|
56
|
-
// Re-enter an existing graph to append more ops. Used by autograd to add
|
|
57
|
-
// backward ops to a graph that's already been traced. `fn` runs with the
|
|
58
|
-
// supplied graph as the current one; any ops it calls append to that graph.
|
|
59
|
-
// Capture is intentionally disabled here — backward / optimizer rules
|
|
60
|
-
// shouldn't publish their internal tensors via `capture()`.
|
|
61
|
-
// Returns whatever `fn` returns.
|
|
62
|
-
export function traceInto(g, fn) {
|
|
63
|
-
if (_current) {
|
|
64
|
-
throw new Error('tensorgrad: traceInto() called while another trace is active');
|
|
65
|
-
}
|
|
66
|
-
_current = g;
|
|
67
|
-
// _captureEnabled stays false (default) — explicit, but not toggled.
|
|
68
|
-
try {
|
|
69
|
-
return fn();
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
_current = null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function assertNameUnused(g, name, kinds, label) {
|
|
76
|
-
if (g.ops.some(op => kinds.includes(op.kind) && op.name === name)) {
|
|
77
|
-
throw new Error(`tensorgrad: ${label} name '${name}' already used in this trace`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
export function paramInput(name, shape, dtype = 'f32') {
|
|
81
|
-
const g = currentGraph();
|
|
82
|
-
assertNameUnused(g, name, ['param_input', 'tensor_input'], 'input');
|
|
83
|
-
const site = captureSite('paramInput');
|
|
84
|
-
return addOp(g, 'param_input', shape, dtype, site, { name });
|
|
85
|
-
}
|
|
86
|
-
export function tensorInput(name, shape, dtype = 'f32') {
|
|
87
|
-
const g = currentGraph();
|
|
88
|
-
assertNameUnused(g, name, ['param_input', 'tensor_input'], 'input');
|
|
89
|
-
const site = captureSite('tensorInput');
|
|
90
|
-
return addOp(g, 'tensor_input', shape, dtype, site, { name });
|
|
91
|
-
}
|
|
92
|
-
// Persistent state buffer. Allocated at compile time, zero-(or initValue-)initialized,
|
|
93
|
-
// and updated across step() calls via writebacks declared by the optimizer helper.
|
|
94
|
-
export function stateInput(name, shape, dtype = 'f32', initValue = 0) {
|
|
95
|
-
const g = currentGraph();
|
|
96
|
-
assertNameUnused(g, name, ['state_input'], 'state');
|
|
97
|
-
const site = captureSite('stateInput');
|
|
98
|
-
return addOp(g, 'state_input', shape, dtype, site, { name, initValue });
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=trace.js.map
|
package/dist/trace.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,SAAS;AACT,EAAE;AACF,gCAAgC;AAChC,gDAAgD;AAChD,+CAA+C;AAC/C,mDAAmD;AACnD,6BAA6B;AAC7B,OAAO;AACP,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,+CAA+C;AAG/C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAEvD,gFAAgF;AAChF,IAAI,QAAQ,GAAiB,IAAI,CAAA;AACjC,gFAAgF;AAChF,6EAA6E;AAC7E,8EAA8E;AAC9E,IAAI,eAAe,GAAG,KAAK,CAAA;AAE3B,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,qDAAqD;YACrD,2CAA2C,CAC5C,CAAA;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,eAAe,CAAA;AACxB,CAAC;AAED,gFAAgF;AAChF,8EAA8E;AAC9E,MAAM,UAAU,KAAK,CAAC,EAA2B;IAC/C,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAChE,CAAC;IACD,MAAM,CAAC,GAAG,SAAS,EAAE,CAAA;IACrB,QAAQ,GAAG,CAAC,CAAA;IACZ,eAAe,GAAG,IAAI,CAAA;IACtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,EAAE,CAAA;QACnB,MAAM,OAAO,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