@@ -638,45 +638,33 @@ def fg_blobs(rng):
638638 return out
639639
640640
641- def fg_map (blobs , label = "synthetic FG label" , key_from = "net1_01" ):
642- """A version-1 map with "preset": "FG" for the blobs of fg_blobs: one block source per blob (map order = upload
643- order) and one stage per layer. The tensor layout is a stand-in (weights as [out, K] rows, net1's bias as copy 0
644- of each group of 8, net2's bias as [out]); the spec side's map defines the real names, axis order and stages."""
641+ def fg_map (fg_map_obj , layout_blobs ):
642+ """The delivered preset-FG map (data/fg.v1.map.json, parsed) with our own blobs in place of the real ones: every
643+ stage, tensor, base, axis and offset stays as delivered; each source keeps its name and text but gets the hashes of
644+ our blob. The map's sources are in upload order, so the n-th source is layout blob n (clean/fg/layout.py; the
645+ lengths are checked). Returns (map, {source name: bytes})."""
645646 L = _fg_layout ()
646- m = {
647- "format" : "wronggpu-converter-map" ,
648- "version" : 1 ,
649- "model" : "synthetic frame-generation case" ,
650- "preset" : "FG" ,
651- "channel_order" : "natural" ,
652- "sources" : {b .name : source_entry (b .name , "fake frame-generation weight blob" , "f16le" , blobs [b .name ])
653- for b in L .blobs ()},
654- "key" : {"label" : label , "from" : key_from },
655- "perms" : {},
656- "stages" : [],
657- }
658- f16 = {"name" : "f16" }
659- for l in L .NET1 :
660- m ["stages" ].append ({"stage" : l .name , "digest" : "" , "tensors" : [
661- tensor ("W" , [l .out , l .k ], "float32" , l .name , f16 , 0 , [lin (l .k ), lin (1 )]),
662- tensor ("b" , [l .out // L .NET1_BIAS_GROUP , L .NET1_BIAS_GROUP ], "float32" , l .name , f16 , l .bias_offset ,
663- [lin (L .NET1_BIAS_GROUP * L .NET1_BIAS_COPIES ), lin (1 )]),
664- ]})
665- for l in L .NET2 :
666- m ["stages" ].append ({"stage" : l .name , "digest" : "" , "tensors" : [
667- tensor ("W" , [l .out , 9 * l .cin ], "float32" , l .name + "_w" , f16 , 0 , [lin (9 * l .cin ), lin (1 )]),
668- tensor ("b" , [l .out ], "float32" , l .name + "_b" , f16 , 0 , [lin (1 )]),
669- ]})
670- return m
671-
672-
673- def fg_case (seed = 41 , drop = (), decoy = "net2_07_w" ):
674- """A synthetic frame-generation library: random bytes holding the 67 blobs of fg_blobs in a shuffled order, at
675- 16-aligned, even and odd offsets, with a decoy of one blob (its first 64 bytes, then other bytes) before it.
676- drop: blob names left out of the file (the map still lists them). Returns the Case (placements: {blob: offset})."""
647+ m = copy .deepcopy (fg_map_obj )
648+ names = list (m ["sources" ])
649+ assert len (names ) == len (L .blobs ())
650+ blobs = {}
651+ for name , b in zip (names , L .blobs ()):
652+ data = layout_blobs [b .name ]
653+ assert m ["sources" ][name ]["length" ] == len (data ), name
654+ m ["sources" ][name ] = source_entry (name , m ["sources" ][name ]["what" ], "f16le" , data )
655+ blobs [name ] = data
656+ for st in m ["stages" ]:
657+ st ["digest" ] = ""
658+ return m , blobs
659+
660+
661+ def fg_case (fg_map_obj , seed = 41 , drop = (), decoy = "B07w" ):
662+ """A synthetic frame-generation library for the delivered map's layout: random bytes holding our own 67 blobs
663+ (fg_blobs) in a shuffled order, at 16-aligned, even and odd offsets, with a decoy of one blob (its first 64 bytes,
664+ then other bytes) before it. drop: source names left out of the file (the map still lists them). Returns the Case
665+ (placements: {source: offset})."""
677666 rng = random .Random (seed )
678- blobs = fg_blobs (rng )
679- m = fg_map (blobs )
667+ m , blobs = fg_map (fg_map_obj , fg_blobs (rng ))
680668 order = list (blobs )
681669 rng .shuffle (order )
682670 buf = bytearray (rng .randbytes (4096 ))
0 commit comments