import io from pathlib import Path import torch def save_tensor(tensor, name): f = io.BytesIO() torch.save(tensor, f, _use_new_zipfile_serialization=True) with open(name, "wb") as out_f: out_f.write(f.getbuffer()) def process_forward_dump(dump_path: Path, output_path: Path): output_path.mkdir(exist_ok=True, parents=True) data = torch.load(dump_path) arg_names = [ "bg", "means3D", "colors_precomp", "opacities", "scales", "rotations", "scale_modifier", "cov3Ds_precomp", "viewmatrix", "projmatrix", "tanfovx", "tanfovy", "image_height", "image_width", "sh", "sh_degree", "campos", "prefiltered", "debug", ] for tensor, name in zip(data, arg_names): save_tensor(tensor, str(output_path / name) + ".pt") def process_backward_dump(dump_path: Path, output_path: Path): output_path.mkdir(exist_ok=True, parents=True) data = torch.load(dump_path) arg_names = [ "bg", "means3D", "radii", "colors_precomp", "scales", "rotations", "scale_modifier", "cov3Ds_precomp", "viewmatrix", "projmatrix", "tanfovx", "tanfovy", "grad_out_color", "grad_depth", "grad_out_alpha", "sh", "sh_degree", "campos", "geomBuffer", "num_rendered", "binningBuffer", "imgBuffer", "alpha", "debug" ] for tensor, name in zip(data, arg_names): save_tensor(tensor, str(output_path / name) + ".pt") if __name__ == '__main__': global_path = Path("/home/vy/projects/gaussian-rasterizer/test_data") process_forward_dump(global_path / "snapshot_fw.dump", global_path / "forward_tensors") process_backward_dump(global_path / "snapshot_bw.dump", global_path / "backward_tensors")