|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# |
| 3 | +# This source code is licensed under the MIT license found in the |
| 4 | +# LICENSE file in the root directory of this source tree. |
| 5 | + |
| 6 | +from tensordict._lazy import LazyStackedTensorDict |
| 7 | +from tensordict._nestedkey import NestedKey |
| 8 | +from tensordict._td import ( |
| 9 | + cat, |
| 10 | + from_consolidated, |
| 11 | + from_module, |
| 12 | + from_modules, |
| 13 | + from_pytree, |
| 14 | + fromkeys, |
| 15 | + is_tensor_collection, |
| 16 | + lazy_stack, |
| 17 | + load, |
| 18 | + load_memmap, |
| 19 | + maybe_dense_stack, |
| 20 | + memmap, |
| 21 | + save, |
| 22 | + stack, |
| 23 | + TensorDict, |
| 24 | +) |
| 25 | +from tensordict._unbatched import UnbatchedTensor |
| 26 | +from tensordict.base import ( |
| 27 | + _default_is_leaf as default_is_leaf, |
| 28 | + _is_leaf_nontensor as is_leaf_nontensor, |
| 29 | + from_any, |
| 30 | + from_dict, |
| 31 | + from_h5, |
| 32 | + from_namedtuple, |
| 33 | + from_struct_array, |
| 34 | + from_tuple, |
| 35 | + get_defaults_to_none, |
| 36 | + set_get_defaults_to_none, |
| 37 | + TensorDictBase, |
| 38 | +) |
| 39 | +from tensordict.functional import ( |
| 40 | + dense_stack_tds, |
| 41 | + make_tensordict, |
| 42 | + merge_tensordicts, |
| 43 | + pad, |
| 44 | + pad_sequence, |
| 45 | +) |
| 46 | +from tensordict.memmap import MemoryMappedTensor |
| 47 | +from tensordict.nn import as_tensordict_module, TensorDictParams |
| 48 | +from tensordict.persistent import PersistentTensorDict |
| 49 | +from tensordict.tensorclass import ( |
| 50 | + from_dataclass, |
| 51 | + MetaData, |
| 52 | + NonTensorData, |
| 53 | + NonTensorDataBase, |
| 54 | + NonTensorStack, |
| 55 | + TensorClass, |
| 56 | + tensorclass, |
| 57 | +) |
| 58 | +from tensordict.utils import ( |
| 59 | + assert_allclose_td, |
| 60 | + assert_close, |
| 61 | + capture_non_tensor_stack, |
| 62 | + is_batchedtensor, |
| 63 | + is_non_tensor, |
| 64 | + is_tensorclass, |
| 65 | + lazy_legacy, |
| 66 | + list_to_stack, |
| 67 | + parse_tensor_dict_string, |
| 68 | + set_capture_non_tensor_stack, |
| 69 | + set_lazy_legacy, |
| 70 | + set_list_to_stack, |
| 71 | + unravel_key, |
| 72 | + unravel_key_list, |
| 73 | +) |
| 74 | + |
| 75 | +__version__: str | None |
| 76 | + |
| 77 | +__all__ = [ |
| 78 | + # Core classes |
| 79 | + "TensorDict", |
| 80 | + "TensorDictBase", |
| 81 | + "LazyStackedTensorDict", |
| 82 | + "UnbatchedTensor", |
| 83 | + "TensorClass", |
| 84 | + "MemoryMappedTensor", |
| 85 | + "PersistentTensorDict", |
| 86 | + "NestedKey", |
| 87 | + # Factory functions |
| 88 | + "from_dict", |
| 89 | + "from_any", |
| 90 | + "from_h5", |
| 91 | + "from_namedtuple", |
| 92 | + "from_struct_array", |
| 93 | + "from_tuple", |
| 94 | + "from_dataclass", |
| 95 | + "fromkeys", |
| 96 | + "from_module", |
| 97 | + "from_modules", |
| 98 | + "from_pytree", |
| 99 | + "from_consolidated", |
| 100 | + "make_tensordict", |
| 101 | + # Stacking and concatenation |
| 102 | + "stack", |
| 103 | + "cat", |
| 104 | + "lazy_stack", |
| 105 | + "maybe_dense_stack", |
| 106 | + "dense_stack_tds", |
| 107 | + # Memory mapping |
| 108 | + "memmap", |
| 109 | + "load_memmap", |
| 110 | + # Saving and loading |
| 111 | + "save", |
| 112 | + "load", |
| 113 | + # Merging and padding |
| 114 | + "merge_tensordicts", |
| 115 | + "pad", |
| 116 | + "pad_sequence", |
| 117 | + # Utility functions |
| 118 | + "is_tensor_collection", |
| 119 | + "is_batchedtensor", |
| 120 | + "is_non_tensor", |
| 121 | + "is_tensorclass", |
| 122 | + "assert_close", |
| 123 | + "assert_allclose_td", |
| 124 | + "unravel_key", |
| 125 | + "unravel_key_list", |
| 126 | + "parse_tensor_dict_string", |
| 127 | + # Configuration |
| 128 | + "default_is_leaf", |
| 129 | + "is_leaf_nontensor", |
| 130 | + "get_defaults_to_none", |
| 131 | + "set_get_defaults_to_none", |
| 132 | + "capture_non_tensor_stack", |
| 133 | + "set_capture_non_tensor_stack", |
| 134 | + "lazy_legacy", |
| 135 | + "set_lazy_legacy", |
| 136 | + "list_to_stack", |
| 137 | + "set_list_to_stack", |
| 138 | + # TensorClass components |
| 139 | + "tensorclass", |
| 140 | + "MetaData", |
| 141 | + "NonTensorData", |
| 142 | + "NonTensorDataBase", |
| 143 | + "NonTensorStack", |
| 144 | + # NN imports |
| 145 | + "as_tensordict_module", |
| 146 | + "TensorDictParams", |
| 147 | +] |
0 commit comments