Skip to content

Instantly share code, notes, and snippets.

View ProExpertProg's full-sized avatar

Luka Govedič ProExpertProg

View GitHub Profile
@ProExpertProg
ProExpertProg / mirage-example-fx-graph.py
Last active August 13, 2025 15:58
Mirage starting example
from typing import Optional, Callable, Sequence, Any
import torch
from torch import nn, fx
from torch.library import Library
import torch.nn.functional as F
import torch._inductor
import torch._inductor.compile_fx
mirage_lib = Library("mirage", "FRAGMENT") # noqa

THIS IS STILL A DRAFT - come back soon for an updated version. It has not been tested, just an idea for now.

Abstract

GoogleTest is one of the most popular testing frameworks in C++. It also includes GoogleMock, a comprehensive mocking framework.

GoogleMock works by extending the class we are trying to mock and providing own implementations of the methods. However, because of that, it does not allow mocking of nonvirtual methods. The GoogleTest guide recommends coding to interfaces, where we mock interfaces rather than concrete implementations. That can be a good approach in massive enterprise applications, however, C++ is often chosen for performance-critical reasons. In such cases, we cannot afford to make all public functions virtual

  • there are also other drawback which I descibe in more detail below.