TensorBandWindow.window: def of stelliferous@0.0.2.0 Import: import stelliferous@0.0.2.0/tensor_band_window.bend as TensorBandWindow Lines 41-59 of stelliferous@0.0.2.0/tensor_band_window.bend: https://jend.leeeet.dev/read.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&start_line=41&end_line=59 import Base import stelliferous@0.0.2.0/tensor_band.bend as Bands # Output partition boundaries follow the input cores, with the first and last # cores also owning any output rows introduced by padding. The halos hold # every window row outside the core, so a window is its image rows exactly. # Caller geometry checks establish positive stride/height and bounded products. def window(geometry: Geometry,+first: U32,+count: U32) -> RowWindow: Geometry{Bands.Geometry{batch,channels,+height,width},+kernel,+stride,+padding,+output_height,output_width} = geometry +image = (first / height : U32) +core_first = (first % height : U32) +core_end = (core_first + count : U32) +out_first = U32.min(output_height,ceiling(core_first,stride)) +out_end = Bool.pick(U32,U32.is_eq(core_end,height),output_height,U32.min(output_height,ceiling(core_end,stride))) +needed_first = start(height,out_first,stride,padding) +needed_end = U32.min(height,subtract_clipped((subtract_clipped(out_end,1) * stride + kernel : U32),padding)) +above_first = (image * height + needed_first : U32) +above_end = (image * height + U32.min(core_first,needed_end) : U32) +below_first = (image * height + U32.max(core_end,needed_first) : U32) +below_end = (image * height + needed_end : U32) nonempty(U32.is_lt(out_first,out_end),RowWindow{Rows{(image * output_height + out_first : U32),subtract_clipped(out_end,out_first)}, clipped(above_first,above_end),clipped(below_first,below_end),clipped(above_first,below_end)}) Uses (19): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.max https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.min https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mul https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band.bend&name=Geometry https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&name=Geometry https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&name=RowWindow https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&name=Rows https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&name=ceiling https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&name=clipped https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&name=nonempty https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&name=start https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/tensor_band_window.bend&name=subtract_clipped