def invert_device_map()

in mozetl/hardware_report/summarize_json.py [0:0]


def invert_device_map(m):
    """Inverts a GPU device map fetched from the jrmuizel's Github repo.

    The layout of the fetched GPU map layout is:
        Vendor ID -> Device Family -> Chipset -> [Device IDs]
    We should convert it to:
        Vendor ID -> Device ID -> [Device Family, Chipset]

    """
    device_id_map = {}
    for vendor, u in m.items():
        device_id_map["0x" + vendor] = {}
        for family, v in u.items():
            for chipset, ids in v.items():
                device_id_map["0x" + vendor].update(
                    {("0x" + gfx_id): [family, chipset] for gfx_id in ids}
                )
    return device_id_map