cost_models
Affine
¶
Bases: RowMap[C]
The features of each row of a basis followed by a 1, so a linear model of them adds a constant to the cost of each row.
Source code in src/finch/autoschedule/cost_models/cost_models.py
Basis
¶
A basis describes a logic statement by the features of its components, such as queries, loop prefixes, or tensor levels. components yields the components of a program, advancing the StatsMachine past each statement after yielding its components, and get_component_features gives a component one row of n_features for each independently priced part of it. Like a Stage, a Basis inherits the form of statements it accepts. ridge weights the penalty on the square of each coefficient of a linear model of the basis, and feature_names names each feature, by default by its index.
Source code in src/finch/autoschedule/cost_models/cost_models.py
ByKind
¶
Bases: Concat[C], Generic[C, K]
The features of each component under the basis of its kind, which key returns, by default the kind attribute of the component. The features of a component fill the columns of its basis, and the other columns are zero, so a linear model has separate coefficients for each kind.
Source code in src/finch/autoschedule/cost_models/cost_models.py
Concat
¶
Bases: Basis[C]
The features of several bases of the same kind of component, side by side.
Source code in src/finch/autoschedule/cost_models/cost_models.py
CostModel
¶
A linear cost model weights the features its basis gives the components of a logic statement by its coefficients, and sums over their rows, so the cost of a program is the sum of the costs of its components, which predict_component_cost prices one at a time. Runtimes are measured for whole programs, so fit takes the features of each program, as get_features returns them, with its runtime, and finds the nonnegative coefficients which minimize the sum of the squared relative errors of the predicted runtimes, so that fast programs count as much as slow ones, and the cost of a row of nonnegative features is nonnegative, penalized by alpha times the ridge weights of the basis. The runtimes must be positive, and a fit to no programs is zero. to_json writes the coefficients with the names of their features, which from_json checks against the basis of the model it reads them into.
Source code in src/finch/autoschedule/cost_models/cost_models.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
Quadratic
¶
Bases: RowMap[C]
The products of each pair of features of each row of a basis, flattened row-major, so a linear model of them sums a quadratic form of each row.
Source code in src/finch/autoschedule/cost_models/cost_models.py
RowMap
¶
Bases: Basis[C]
A basis whose rows are a function, transform, of the rows of another basis for the same components.
Source code in src/finch/autoschedule/cost_models/cost_models.py
Stratify
¶
Bases: RowMap[C]
The features of each row of a basis, in the block of columns of the regime of the row, with zeros in the blocks of the other regimes. The regime of a row is the number of thresholds its feature at index feature meets or exceeds. A linear model of this basis has separate coefficients for each regime, so a feature can cost differently once, say, the working set exceeds a cache.