Complete worked example
python
from bootstrap_lab import torch_setup
torch = torch_setup()
from torch import nn
def exported_batch(batch_size):
model = nn.Linear(2, 1, bias=False)
with torch.no_grad():
model.weight.fill_(1)
example = torch.ones(2, 2)
exported = torch.export.export(model, (example,))
module = exported.module()
try:
output = module(torch.ones(batch_size, 2))
except (RuntimeError, AssertionError):
return {'accepted': False}
return {'accepted': True, 'shape': list(output.shape), 'values': output.tolist()}- Reasoning
- The fixture exports a known two-feature linear model using a two-example input and reconstructs its callable exported module. The initial export is intentionally static.