_object_side_effects_to_side_effects
ObjectMutationTracker
dataclass
¶
Keeps track of all views and mutations of objects, after a number of view or mutation operations, by using object ID as the unique ID.
Similar in spirit to the mutation_tracker used by the tracer, but has a slightly different scope, since here we are dealing with Python objects, not linea nodes, and we only care about the composite operations, not every one.
Source code in lineapy/system_tracing/_object_side_effects_to_side_effects.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
object_side_effects_to_side_effects(object_side_effects, input_nodes, output_globals)
¶
Translates a list of object side effects to a list of side effects, by mapping objects to nodes, and only emitting side effects that references only input nodes or the output globals.
The process is not just trimming off internal variables, but also sometimes transitively searching for nodes. Consider the following example:
y = 10
if ...:
z = [y]
a = [z]
del z
We want to establish that a
is a view of y
, and skip z because it's not in
the outer scope that we care about.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
object_side_effects |
Iterable[ObjectSideEffect]
|
The object side effects that were recorded. |
required |
input_nodes |
Mapping[LineaID, object]
|
Mapping of node ID to value for all the nodes that were passed in to this execution. |
required |
output_globals |
Mapping[str, object]
|
Mapping of global identifier to the value of all globals that were set during this execution. |
required |
Source code in lineapy/system_tracing/_object_side_effects_to_side_effects.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|