liangsu9988 commited on
Commit
a9230c4
·
verified ·
1 Parent(s): 6d92987

Add torch213-cxx11-cu130-aarch64-linux artifact

Browse files
build/torch213-cxx11-cu130-aarch64-linux/__init__.py ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FlashRT spatiotemporal layout kernels."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import torch
6
+
7
+ from ._ops import add_op_namespace_prefix, ops
8
+
9
+
10
+ def _check_ncdhw(x: torch.Tensor, name: str) -> None:
11
+ if x.dim() != 5:
12
+ raise RuntimeError(f"{name} must have shape (B, C, T, H, W)")
13
+
14
+
15
+ @torch.library.register_fake(add_op_namespace_prefix("ncdhw_to_blc_bf16"))
16
+ def _ncdhw_to_blc_bf16_fake(x: torch.Tensor, out: torch.Tensor) -> None:
17
+ _check_ncdhw(x, "x")
18
+ b, c, t, h, w = x.shape
19
+ if out.shape != (b, t * h * w, c):
20
+ raise RuntimeError("out must have shape (B, T * H * W, C)")
21
+ return None
22
+
23
+
24
+ @torch.library.register_fake(add_op_namespace_prefix("patch_im2col_bf16"))
25
+ def _patch_im2col_bf16_fake(x: torch.Tensor, out: torch.Tensor) -> None:
26
+ if x.dim() != 4 or x.shape[1:] != (224, 224, 3):
27
+ raise RuntimeError("x must have shape (num_views, 224, 224, 3)")
28
+ if out.shape != (x.shape[0] * 256, 588):
29
+ raise RuntimeError("out must have shape (num_views * 256, 588)")
30
+ return None
31
+
32
+
33
+ @torch.library.register_fake(add_op_namespace_prefix("time_unshuffle2_bf16"))
34
+ def _time_unshuffle2_bf16_fake(x: torch.Tensor, out: torch.Tensor) -> None:
35
+ _check_ncdhw(x, "x")
36
+ b, c2, t, h, w = x.shape
37
+ if c2 % 2 != 0:
38
+ raise RuntimeError("x.shape[1] must be even")
39
+ if out.shape != (b, c2 // 2, 2 * t, h, w):
40
+ raise RuntimeError("out must have shape (B, C / 2, 2 * T, H, W)")
41
+ return None
42
+
43
+
44
+ @torch.library.register_fake(add_op_namespace_prefix("add_bias_ncdhw_bf16"))
45
+ def _add_bias_ncdhw_bf16_fake(x: torch.Tensor, bias: torch.Tensor) -> None:
46
+ _check_ncdhw(x, "x")
47
+ if bias.shape != (x.shape[1],):
48
+ raise RuntimeError("bias must have shape (C,)")
49
+ return None
50
+
51
+
52
+ @torch.library.register_fake(add_op_namespace_prefix("update_cache2_ncdhw_bf16"))
53
+ def _update_cache2_ncdhw_bf16_fake(cur: torch.Tensor, prev: torch.Tensor, out: torch.Tensor) -> None:
54
+ _check_ncdhw(cur, "cur")
55
+ b, c, _, h, w = cur.shape
56
+ if prev.shape != (b, c, 2, h, w) or out.shape != (b, c, 2, h, w):
57
+ raise RuntimeError("prev and out must have shape (B, C, 2, H, W)")
58
+ return None
59
+
60
+
61
+ @torch.library.register_fake(add_op_namespace_prefix("channel_to_space3d_bf16"))
62
+ def _channel_to_space3d_bf16_fake(
63
+ x: torch.Tensor,
64
+ out_channels: int,
65
+ temporal_factor: int,
66
+ spatial_factor: int,
67
+ repeats: int,
68
+ first_chunk: bool,
69
+ out: torch.Tensor,
70
+ ) -> None:
71
+ _check_ncdhw(x, "x")
72
+ out_t = x.shape[2] * temporal_factor - (
73
+ temporal_factor - 1 if first_chunk else 0
74
+ )
75
+ expected = (
76
+ x.shape[0],
77
+ out_channels,
78
+ out_t,
79
+ x.shape[3] * spatial_factor,
80
+ x.shape[4] * spatial_factor,
81
+ )
82
+ if (
83
+ out_channels <= 0
84
+ or temporal_factor <= 0
85
+ or spatial_factor <= 0
86
+ or repeats <= 0
87
+ or x.shape[1] * repeats
88
+ < out_channels * temporal_factor * spatial_factor * spatial_factor
89
+ or out.shape != expected
90
+ ):
91
+ raise RuntimeError("channel_to_space3d_bf16 shape contract failed")
92
+ return None
93
+
94
+
95
+ @torch.library.register_fake(
96
+ add_op_namespace_prefix("pack_causal_cache3_nhwc_bf16")
97
+ )
98
+ def _pack_causal_cache3_nhwc_bf16_fake(
99
+ previous: torch.Tensor, current: torch.Tensor, out: torch.Tensor
100
+ ) -> None:
101
+ _check_ncdhw(previous, "previous")
102
+ _check_ncdhw(current, "current")
103
+ b, c, t, h, w = current.shape
104
+ if (
105
+ t != 1
106
+ or previous.shape != (b, c, 2, h, w)
107
+ or out.shape != (b, h, w, 3 * c)
108
+ ):
109
+ raise RuntimeError("causal cache pack shape contract failed")
110
+ return None
111
+
112
+
113
+ @torch.library.register_fake(add_op_namespace_prefix("avg_pool3d_channels_bf16"))
114
+ def _avg_pool3d_channels_bf16_fake(
115
+ x: torch.Tensor,
116
+ out_channels: int,
117
+ factor_t: int,
118
+ factor_s: int,
119
+ group_size: int,
120
+ out: torch.Tensor,
121
+ ) -> None:
122
+ _check_ncdhw(x, "x")
123
+ expected = (
124
+ x.shape[0],
125
+ out_channels,
126
+ (x.shape[2] + factor_t - 1) // factor_t,
127
+ x.shape[3] // factor_s,
128
+ x.shape[4] // factor_s,
129
+ )
130
+ if out.shape != expected:
131
+ raise RuntimeError("out has the wrong pooled NCDHW shape")
132
+ return None
133
+
134
+
135
+ @torch.library.register_fake(add_op_namespace_prefix("ndhwc_to_ncdhw_bf16"))
136
+ def _ndhwc_to_ncdhw_bf16_fake(x: torch.Tensor, out: torch.Tensor) -> None:
137
+ if x.dim() != 5:
138
+ raise RuntimeError("x must have shape (B, T, H, W, C)")
139
+ expected = (x.shape[0], x.shape[4], x.shape[1], x.shape[2], x.shape[3])
140
+ if out.shape != expected:
141
+ raise RuntimeError("out must have shape (B, C, T, H, W)")
142
+ return None
143
+
144
+
145
+ @torch.library.register_fake(add_op_namespace_prefix("ndhwc_to_ncdhw_bias_bf16"))
146
+ def _ndhwc_to_ncdhw_bias_bf16_fake(
147
+ x: torch.Tensor, bias: torch.Tensor, out: torch.Tensor
148
+ ) -> None:
149
+ _ndhwc_to_ncdhw_bf16_fake(x, out)
150
+ if bias.shape != (x.shape[4],):
151
+ raise RuntimeError("bias must have shape (C,)")
152
+ return None
153
+
154
+
155
+ @torch.library.register_fake(add_op_namespace_prefix("ndhwc_to_ncdhw_add_bf16"))
156
+ def _ndhwc_to_ncdhw_add_bf16_fake(
157
+ x: torch.Tensor, residual: torch.Tensor, out: torch.Tensor
158
+ ) -> None:
159
+ _ndhwc_to_ncdhw_bf16_fake(x, out)
160
+ if residual.shape != out.shape:
161
+ raise RuntimeError("residual must match the NCDHW output shape")
162
+ return None
163
+
164
+
165
+ @torch.library.register_fake(
166
+ add_op_namespace_prefix("ncdhw_quantize_fp8_static_ndhwc_bf16")
167
+ )
168
+ def _ncdhw_quantize_fp8_static_ndhwc_bf16_fake(
169
+ x: torch.Tensor, scale: float, out: torch.Tensor
170
+ ) -> None:
171
+ _check_ncdhw(x, "x")
172
+ expected = (x.shape[0], x.shape[2], x.shape[3], x.shape[4], x.shape[1])
173
+ if out.shape != expected:
174
+ raise RuntimeError("out must have shape (B, T, H, W, C)")
175
+ return None
176
+
177
+
178
+ @torch.library.register_fake(
179
+ add_op_namespace_prefix("upsample2x_quantize_fp8_static_nhwc_bf16")
180
+ )
181
+ def _upsample2x_quantize_fp8_static_nhwc_bf16_fake(
182
+ x: torch.Tensor, scale: float, out: torch.Tensor
183
+ ) -> None:
184
+ if x.dim() != 4:
185
+ raise RuntimeError("x must have shape (N, C, H, W)")
186
+ expected = (x.shape[0], 2 * x.shape[2], 2 * x.shape[3], x.shape[1])
187
+ if out.shape != expected:
188
+ raise RuntimeError("out must have shape (N, 2H, 2W, C)")
189
+ return None
190
+
191
+
192
+ def ncdhw_to_blc_bf16(x: torch.Tensor, out: torch.Tensor | None = None) -> torch.Tensor:
193
+ """Convert BF16 NCDHW tensor to BLC where L = T * H * W."""
194
+
195
+ if out is None:
196
+ out = torch.empty((x.shape[0], x.shape[2] * x.shape[3] * x.shape[4], x.shape[1]), device=x.device, dtype=x.dtype)
197
+ ops.ncdhw_to_blc_bf16(x, out)
198
+ return out
199
+
200
+
201
+ def patch_im2col_bf16(x: torch.Tensor, out: torch.Tensor | None = None) -> torch.Tensor:
202
+ """Convert BF16 NHWC images into flattened 14x14 patch rows."""
203
+
204
+ if out is None:
205
+ out = torch.empty((x.shape[0] * 256, 588), device=x.device, dtype=x.dtype)
206
+ ops.patch_im2col_bf16(x, out)
207
+ return out
208
+
209
+
210
+ def time_unshuffle2_bf16(x: torch.Tensor, out: torch.Tensor | None = None) -> torch.Tensor:
211
+ """Convert BF16 (B, 2C, T, H, W) into (B, C, 2T, H, W)."""
212
+
213
+ if out is None:
214
+ out = torch.empty((x.shape[0], x.shape[1] // 2, 2 * x.shape[2], x.shape[3], x.shape[4]), device=x.device, dtype=x.dtype)
215
+ ops.time_unshuffle2_bf16(x, out)
216
+ return out
217
+
218
+
219
+ def add_bias_ncdhw_bf16(x: torch.Tensor, bias: torch.Tensor) -> torch.Tensor:
220
+ """Add channel bias to an NCDHW tensor in place."""
221
+
222
+ ops.add_bias_ncdhw_bf16(x, bias)
223
+ return x
224
+
225
+
226
+ def update_cache2_ncdhw_bf16(cur: torch.Tensor, prev: torch.Tensor, out: torch.Tensor | None = None) -> torch.Tensor:
227
+ """Update two-frame latent cache from current and previous NCDHW tensors."""
228
+
229
+ if out is None:
230
+ out = torch.empty((cur.shape[0], cur.shape[1], 2, cur.shape[3], cur.shape[4]), device=cur.device, dtype=cur.dtype)
231
+ ops.update_cache2_ncdhw_bf16(cur, prev, out)
232
+ return out
233
+
234
+
235
+ def channel_to_space3d_bf16(
236
+ x: torch.Tensor,
237
+ out_channels: int,
238
+ temporal_factor: int,
239
+ spatial_factor: int,
240
+ repeats: int = 1,
241
+ first_chunk: bool = False,
242
+ out: torch.Tensor | None = None,
243
+ ) -> torch.Tensor:
244
+ """Move expanded channels into temporal/spatial dimensions."""
245
+
246
+ out_t = x.shape[2] * temporal_factor - (
247
+ temporal_factor - 1 if first_chunk else 0
248
+ )
249
+ if out is None:
250
+ out = torch.empty(
251
+ (
252
+ x.shape[0],
253
+ out_channels,
254
+ out_t,
255
+ x.shape[3] * spatial_factor,
256
+ x.shape[4] * spatial_factor,
257
+ ),
258
+ device=x.device,
259
+ dtype=x.dtype,
260
+ )
261
+ ops.channel_to_space3d_bf16(
262
+ x,
263
+ int(out_channels),
264
+ int(temporal_factor),
265
+ int(spatial_factor),
266
+ int(repeats),
267
+ bool(first_chunk),
268
+ out,
269
+ )
270
+ return out
271
+
272
+
273
+ def pack_causal_cache3_nhwc_bf16(
274
+ previous: torch.Tensor,
275
+ current: torch.Tensor,
276
+ out: torch.Tensor | None = None,
277
+ ) -> torch.Tensor:
278
+ """Pack two cached and one current NCDHW frame into NHWC with 3C."""
279
+
280
+ if out is None:
281
+ out = torch.empty(
282
+ (
283
+ current.shape[0],
284
+ current.shape[3],
285
+ current.shape[4],
286
+ 3 * current.shape[1],
287
+ ),
288
+ device=current.device,
289
+ dtype=current.dtype,
290
+ )
291
+ ops.pack_causal_cache3_nhwc_bf16(previous, current, out)
292
+ return out
293
+
294
+
295
+ def avg_pool3d_channels_bf16(
296
+ x: torch.Tensor,
297
+ out_channels: int,
298
+ factor_t: int,
299
+ factor_s: int,
300
+ group_size: int,
301
+ out: torch.Tensor | None = None,
302
+ ) -> torch.Tensor:
303
+ """Pool NCDHW blocks while folding spatiotemporal factors into channels."""
304
+
305
+ if out is None:
306
+ out = torch.empty(
307
+ (
308
+ x.shape[0],
309
+ out_channels,
310
+ (x.shape[2] + factor_t - 1) // factor_t,
311
+ x.shape[3] // factor_s,
312
+ x.shape[4] // factor_s,
313
+ ),
314
+ device=x.device,
315
+ dtype=x.dtype,
316
+ )
317
+ ops.avg_pool3d_channels_bf16(
318
+ x, out_channels, factor_t, factor_s, group_size, out
319
+ )
320
+ return out
321
+
322
+
323
+ def ndhwc_to_ncdhw_bf16(
324
+ x: torch.Tensor, out: torch.Tensor | None = None
325
+ ) -> torch.Tensor:
326
+ """Convert contiguous BF16 NDHWC to contiguous BF16 NCDHW."""
327
+
328
+ if out is None:
329
+ out = torch.empty(
330
+ (x.shape[0], x.shape[4], x.shape[1], x.shape[2], x.shape[3]),
331
+ device=x.device,
332
+ dtype=x.dtype,
333
+ )
334
+ ops.ndhwc_to_ncdhw_bf16(x, out)
335
+ return out
336
+
337
+
338
+ def ndhwc_to_ncdhw_bias_bf16(
339
+ x: torch.Tensor, bias: torch.Tensor, out: torch.Tensor | None = None
340
+ ) -> torch.Tensor:
341
+ """Convert NDHWC to NCDHW and add a BF16 channel bias."""
342
+
343
+ if out is None:
344
+ out = torch.empty(
345
+ (x.shape[0], x.shape[4], x.shape[1], x.shape[2], x.shape[3]),
346
+ device=x.device,
347
+ dtype=x.dtype,
348
+ )
349
+ ops.ndhwc_to_ncdhw_bias_bf16(x, bias, out)
350
+ return out
351
+
352
+
353
+ def ndhwc_to_ncdhw_add_bf16(
354
+ x: torch.Tensor,
355
+ residual: torch.Tensor,
356
+ out: torch.Tensor | None = None,
357
+ ) -> torch.Tensor:
358
+ """Convert NDHWC to NCDHW and add a BF16 NCDHW residual."""
359
+
360
+ if out is None:
361
+ out = torch.empty_like(residual)
362
+ ops.ndhwc_to_ncdhw_add_bf16(x, residual, out)
363
+ return out
364
+
365
+
366
+ def ncdhw_quantize_fp8_static_ndhwc_bf16(
367
+ x: torch.Tensor,
368
+ scale: float,
369
+ out: torch.Tensor | None = None,
370
+ ) -> torch.Tensor:
371
+ """Quantize BF16 NCDHW to FP8 E4M3 NDHWC using a static scale."""
372
+
373
+ if out is None:
374
+ out = torch.empty(
375
+ (x.shape[0], x.shape[2], x.shape[3], x.shape[4], x.shape[1]),
376
+ device=x.device,
377
+ dtype=torch.float8_e4m3fn,
378
+ )
379
+ ops.ncdhw_quantize_fp8_static_ndhwc_bf16(x, scale, out)
380
+ return out
381
+
382
+
383
+ def upsample2x_quantize_fp8_static_nhwc_bf16(
384
+ x: torch.Tensor,
385
+ scale: float,
386
+ out: torch.Tensor | None = None,
387
+ ) -> torch.Tensor:
388
+ """Nearest-neighbor 2x upsample NCHW and emit static-scaled FP8 NHWC."""
389
+
390
+ if out is None:
391
+ out = torch.empty(
392
+ (x.shape[0], 2 * x.shape[2], 2 * x.shape[3], x.shape[1]),
393
+ device=x.device,
394
+ dtype=torch.float8_e4m3fn,
395
+ )
396
+ ops.upsample2x_quantize_fp8_static_nhwc_bf16(x, scale, out)
397
+ return out
398
+
399
+
400
+ __all__ = [
401
+ "ncdhw_to_blc_bf16",
402
+ "patch_im2col_bf16",
403
+ "time_unshuffle2_bf16",
404
+ "add_bias_ncdhw_bf16",
405
+ "update_cache2_ncdhw_bf16",
406
+ "channel_to_space3d_bf16",
407
+ "pack_causal_cache3_nhwc_bf16",
408
+ "avg_pool3d_channels_bf16",
409
+ "ndhwc_to_ncdhw_bf16",
410
+ "ndhwc_to_ncdhw_bias_bf16",
411
+ "ndhwc_to_ncdhw_add_bf16",
412
+ "ncdhw_quantize_fp8_static_ndhwc_bf16",
413
+ "upsample2x_quantize_fp8_static_nhwc_bf16",
414
+ ]
build/torch213-cxx11-cu130-aarch64-linux/_ops.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import flashrt_spatiotemporal_layout_test
3
+ ops = torch.ops.flashrt_spatiotemporal_layout_test
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ return f"flashrt_spatiotemporal_layout_test::{op_name}"
build/torch213-cxx11-cu130-aarch64-linux/flashrt_spatiotemporal_layout/__init__.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ def _import_from_path(file_path: Path):
7
+ path_hash = '{:x}'.format(ctypes.c_size_t(hash(file_path.absolute())).value)
8
+ spec = importlib.util.spec_from_file_location(path_hash, file_path)
9
+ module = importlib.util.module_from_spec(spec)
10
+ sys.modules[path_hash] = module
11
+ spec.loader.exec_module(module)
12
+ return module
13
+
14
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / '__init__.py')))
build/torch213-cxx11-cu130-aarch64-linux/flashrt_spatiotemporal_layout_test.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16f0b72634927e102b0ce7c17a8addd5eaed791906b19d034f2729cf909e895a
3
+ size 461408
build/torch213-cxx11-cu130-aarch64-linux/metadata.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashrt-spatiotemporal-layout",
3
+ "id": "flashrt_spatiotemporal_layout_test",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cuda",
9
+ "archs": [
10
+ "11.0"
11
+ ]
12
+ },
13
+ "digest": {
14
+ "algorithm": "sha256",
15
+ "files": {
16
+ "__init__.py": "4WRzvPydgNf2NK7ZljUlhO8NWc3qbONgjAzNb7YayKE=",
17
+ "flashrt_spatiotemporal_layout_test.abi3.so": "FvC3JjSSfhArDOfBeord1erteRkGsZ0DTycpz5CeiVo=",
18
+ "_ops.py": "P29ghFUoONBA3NS6cY+kzbwr/RczjL8AdMewXrgZDCA=",
19
+ "flashrt_spatiotemporal_layout/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
20
+ }
21
+ },
22
+ "provenance": {
23
+ "kernel": {
24
+ "sha": "456d297",
25
+ "dirty": false
26
+ },
27
+ "validation": {
28
+ "torch": "2.13.0+cu130",
29
+ "cuda": "13.0"
30
+ }
31
+ }
32
+ }