protocolize
CostProtocolizer
¶
Bases: FormattedForm, LogicLoader
Pass a program in FormattedForm to ctx, after choosing the protocol which each table reads each level of its formatted tensor with, as optimize_protocols does under cost_model.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
LogicProtocolizer
¶
Bases: FormattedForm, LogicLoader
Pass a program in FormattedForm to ctx, after reading each level of a formatted tensor with an explicit protocol, as protocolize does.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
alias_costs(prgm, bindings, stats, stats_factory, cost_model, alias, candidates, costs, cache=None)
¶
The cost of each query of prgm, in program order, as choose_protocols gives it, for each format of candidates for alias, with the other tensors formatted as bindings says. The queries which don't touch alias cost what costs says. Formats whose levels agree on whether they filter and on their default protocols give prgm the same loop spaces, so each group of them is priced in one pass: at each loop, every protocol which a format of the group can read each level of alias with is tried with those of the other reads, each access of another tensor is priced once for each choice, and each access of alias once for the kinds of the levels it depends on. Each format then adds up its accesses in order and takes the cheapest choice whose protocols it can read.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
choose_protocols(prgm, bindings, stats, stats_factory, cost_model=PROTOCOL_COST_MODEL, cache=None)
¶
Read each level of each formatted tensor of bindings with the protocol which costs least under cost_model, and return the program with the cost of each of its queries, in program order. The reads at a loop are chosen together, over the product of the protocols each supports, by the cost of the accesses at that loop alone, since the protocols at a loop don't change where the loops within it are entered. A read which gives its protocol keeps it. The calls of one search may share the cache of their stats machines.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
given_protocols(prgm)
¶
The reads of prgm which give their protocol, each as the tensor and fields of its table and the position of the field it reads.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
merged_expr(stmt)
¶
The expression the loops of stmt merge: its right-hand side, or the aggregate an update reduces into its table, as its aggregate query says.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
optimize_protocols(prgm, bindings, stats, stats_factory, cost_model=PROTOCOL_COST_MODEL)
¶
prgm, reading each level with the protocol which costs least under cost_model, as choose_protocols chooses them.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
protocolize(prgm, bindings)
¶
Read each level of a tensor of bindings with the protocol which the level uses by default, where the table which reads it gives none, so that every read of a formatted tensor states the protocol it is lowered with.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
rebuilder(stmt)
¶
The function which rebuilds stmt with another right-hand side.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
touches(stmt, aliases)
¶
Whether stmt reads or writes a tensor of aliases.
Source code in src/finch/autoschedule/protocolizer/protocolize.py
with_protocol(expr, tns, idxs, depth, protocol)
¶
expr, where each table of tns and idxs reads its level at a zero-based stored depth with protocol.