synthbold.decorator

Reusable decorators for tensor validation and manipulation.

synthbold.decorator.log_call(fn: Callable[[P], T]) Callable[[P], T]

Decorator that logs method name, input/output tensor shapes, and elapsed time at INFO level.

Logs to a logger named after the instance’s module (type(self).__module__), so output is attributed to the concrete subclass regardless of where the decorated method is defined. If the first positional argument (after self) is a tensor, its shape is logged as the input shape; the return value’s shape is logged if it is a tensor.

Parameters:

fn – Bound method to wrap, e.g. a Transform/Model/BaseGeometry __call__.

Returns:

Wrapped method that logs around the call to fn.

synthbold.decorator.to_device(fn: Callable[[P], T]) Callable[[P], T]

Decorator that moves every torch.Tensor argument to self.device before calling the wrapped bound method.

Parameters:

fn – Bound method taking self followed by any mix of tensor and non-tensor positional/keyword arguments.

Returns:

Wrapped method that transfers all tensor arguments to self.device before delegating to fn.