Skip to content

Commit

Permalink
Add custom treespec fqn field
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/pytorch#112428

Custom classes that are serialized with pytree are serialized by default with `f”{class.__module__}.{class.__name__}”`. This is a dependency from our serialized program directly into the outer Python environment. If a user moves the class to a different directory, the serialized program will be unable to be loaded. So, we will require users to pass in an FQN if they want to serialize their custom treespec type.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng avikchaudhuri gmagogsfm zhxchen17 tugsbayasgalan suo

imported-using-ghimport

Reviewed By: suo

Differential Revision: D50886366

Pulled By: angelayi

fbshipit-source-id: 276af112307e3d89137ff10af999ebeb5935a5ad
  • Loading branch information
angelayi authored and facebook-github-bot committed Nov 2, 2023
1 parent bd6a766 commit 94f54e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion userbenchmark/dynamo/dynamobench/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,10 @@ def _register_dataclass_output_as_pytree(example_outputs) -> None:
for output_type in output_dataclass_types:
from torch._export.utils import register_dataclass_as_pytree_node

register_dataclass_as_pytree_node(output_type)
register_dataclass_as_pytree_node(
output_type,
serialized_type_name=f"{output_type.__module__}.{output_type.__name__}",
)


class Stats:
Expand Down

0 comments on commit 94f54e8

Please sign in to comment.