MCPcopy Create free account
hub / github.com/MAC-VO/MAC-VO / implement

Method implement

Utility/Extensions/OnCallCompiler.py:30–44  ·  view source on GitHub ↗
(*args: I.args, **kwargs: I.kwargs)

Source from the content-addressed store, hash-verified

28 def __call__(self, func: Callable[I, O]) -> Callable[I, O]:
29 @wraps(func)
30 def implement(*args: I.args, **kwargs: I.kwargs) -> O:
31 if not self.compile_enabled:
32 return func(*args, **kwargs)
33
34 if self.optimized is None:
35 try:
36 self.optimized = torch.compile(func)
37 return self.optimized(*args, **kwargs)
38 except Exception as e:
39 Logger.write("warn", f"Failed to compile function {func} - reason {e}. Will use unoptimized function instead.")
40 self.compile_enabled = False
41 return func(*args, **kwargs)
42
43 assert self.optimized is not None
44 return self.optimized(*args, **kwargs)
45 return implement

Callers

nothing calls this directly

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected