Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/amd-exec/addnorm5120.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / amd-exec / addnorm5120.py` 149 lines · 11065 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Private-output acceptance: exact residual5120 -> rmsnorm5120 equivalence.""" 4 import argparse, hashlib, json, runpy, shutil, struct, subprocess 5 from pathlib import Path 6 import numpy as np 7 from gdnstate_w import PIN,sha,section,bf16 8 NAME='addnorm5120' 9 NAMES=('h','delta','weight','h_new','y') 10 CASES=('random-1','random-2','zero','cancel','tiny','large','subnormal','exceptional') 11 12 13 def fixture(kind): 14 rng=np.random.default_rng(int(kind[-1]) if kind.startswith('random-') else 7) 15 h=rng.uniform(-1,1,5120).astype(np.float32); d=rng.uniform(-0.5,0.5,5120).astype(np.float32) 16 w=bf16(rng.uniform(-1.5,1.5,5120).astype(np.float32)); w[:3]=(-1,0,1) 17 if kind=='zero': h.fill(0); d.fill(0) 18 elif kind=='cancel': d=-h 19 elif kind=='tiny': h*=np.float32(2.0**-16); d*=np.float32(2.0**-16) 20 elif kind=='large': h*=np.float32(2.0**70); d*=np.float32(2.0**70) 21 elif kind=='subnormal': 22 bits=np.array([0,0x80000000,1,0x80000001,0x007fffff,0x807fffff,0x00800000,0x80800000],dtype=np.uint32) 23 h=np.resize(bits,5120).view(np.float32); d=np.resize(bits[::-1],5120).view(np.float32) 24 elif kind=='exceptional': 25 h[:8]=np.array([0x7f800000,0xff800000,0x7fc00000,0x7fa12345,0xffa12345,0x7f7fffff,0xff7fffff,0x80000000],dtype=np.uint32).view(np.float32) 26 d[:8]=h[::-1][:8] 27 blobs=(h.tobytes(),d.tobytes(),w.tobytes(),b'\xa5'*20480,b'\xa5'*20480) 28 spans=[('kernarg',0,40)]; pointers=[]; cursor=128 29 for name,blob in zip(NAMES,blobs): spans.append((name,cursor,len(blob))); pointers.append(cursor); cursor+=len(blob)+128 30 image=bytearray(b'\xa5')*cursor; struct.pack_into('<5Q',image,0,*pointers) 31 for p,blob in zip(pointers,blobs): image[p:p+len(blob)]=blob 32 return image,spans 33 34 35 def residual_reference(image,spans): 36 ptr={name:p for name,p,n in spans} 37 h=np.frombuffer(image,dtype='