fill
Static/Dynamic fills.
Every tensor has a fill value: the background value of a sparse tensor, and the value a newly constructed tensor is filled with. The fill value belongs to the tensor, and the tensor's format records whether a kernel may specialize on it:
StaticFillFType-- compile against this value, which is part of the format. It may be folded into generated code. Its values areStaticFills.DynamicFillFType-- do not compile against the value, so only its element type is part of the format. The value may change across invocations, so one compiled kernel serves every fill of the same element type. Its values areDynamicFills.
AbstractFill
Bases: FTyped[AbstractFillFType], ABC
A tensor's fill value. Its ftype says whether kernels may specialize on it.
Source code in src/finch/algebra/fill.py
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 | |
element_type
property
The element type of the fill value, always known.
ftype
abstractmethod
property
The fill of the format which this fill belongs to.
value
abstractmethod
property
The fill value itself, always known.
as_dynamic()
This fill, marked so that kernels will not specialize on its value.
Source code in src/finch/algebra/fill.py
162 163 164 | |
astype(element_type)
abstractmethod
This fill, with its value converted to element_type.
Source code in src/finch/algebra/fill.py
166 167 168 169 | |
AbstractFillFType
The fill of a format: the element type of its fill, and whether kernels may specialize on the value of the fill.
Source code in src/finch/algebra/fill.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
element_type
abstractmethod
property
The element type of the fill, always known.
as_dynamic()
This fill, marked so that kernels will not specialize on its value.
Source code in src/finch/algebra/fill.py
47 48 49 | |
astype(element_type)
abstractmethod
This fill, with its value converted to element_type.
Source code in src/finch/algebra/fill.py
51 52 53 54 | |
DynamicFill
Bases: AbstractFill
A fill value which kernels must not specialize on. The value is known and is bound to the kernel at call time.
Equality and hashing are by element type only, i.e. two equal
DynamicFills may have different .value's.
Source code in src/finch/algebra/fill.py
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 | |
DynamicFillError
Bases: Exception
Raised when a fill value must be specialized on at compile time but the fill is Dynamic. Callers may catch this to fall back to value-specialized compilation.
Source code in src/finch/algebra/fill.py
27 28 29 30 31 32 | |
DynamicFillFType
Bases: AbstractFillFType
The fill of a format which kernels must not specialize on, so only its element type is part of the format. Each tensor holds its own fill value, which is bound to the kernel at call time.
Source code in src/finch/algebra/fill.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
StaticFill
Bases: AbstractFill
A fill value which kernels may specialize on. Equality and hashing are by
value, matching StaticFillFType.
Source code in src/finch/algebra/fill.py
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 | |
StaticFillFType
Bases: AbstractFillFType
The fill of a format which kernels may specialize on, so its value is part of the format. Equality and hashing are by element type and value, so formats with different static fills are distinct and get distinct kernels.
Source code in src/finch/algebra/fill.py
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 | |
apply_fill(op, *fills)
Compute the fill value of mapping op over tensors with fills fills.
A fill stays static only while its value is one the algebra can act on. Combining static fills computes an arbitrary value -- adding 1 repeatedly walks a fill through 1, 2, 3, ... -- and a static fill is compared by value, so keeping those static would key a kernel per distinct value and make a loop cost a compilation per iteration.
Source code in src/finch/algebra/fill.py
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 | |
apply_fill_type(op, *fill_types)
The fill of the format which results from mapping op over tensors whose
formats have the fills fill_types. This is the format of apply_fill.
Source code in src/finch/algebra/fill.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
as_fill(fill)
as_fill(fill: AF) -> AF
as_fill(fill: Any) -> StaticFill
Normalize a raw value to a StaticFill, passing an AbstractFill through.
Source code in src/finch/algebra/fill.py
274 275 276 277 278 | |
resolve_fill(fill_type, fill=None)
The fill of a new tensor of a format whose fill is fill_type. A given
fill takes the element type of the format, and decides whether the fill of
the new tensor is dynamic. Otherwise the fill of the format must be static.
Source code in src/finch/algebra/fill.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |