Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The tracing Python objects technique is very similar to how pytorch traces models to produces a graph representation that can be executed entirely in C++ for performance reasons.

The pytorch one is a little bit more general since it can trace arbitrary models + have custom high level operations that might not be supported by default. You just pass it a python method and an example input.

  import torch
  def foo(x, y):
      return 2*x + y
  traced_foo = torch.jit.trace(foo, (torch.rand(3), torch.rand(3)))
https://pytorch.org/docs/stable/jit.html#torch.jit.ScriptMod...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: