Generated reference › Pooling 2D — Machine Learning/Neural Networks
kind: generated#block#machine-learning-neural-networks

Pooling 2D — Machine Learning/Neural Networks

Machine_Learning/Neural_Networks/Pooling_2D · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Pooling 2D

Machine Learning / Neural Networks

Downsamples a matrix by reducing each sliding 2-D window to one value:

yab = max or mean over u[a·SR … a·SR+PR−1][b·SC … b·SC+PC−1], with Rout = ⌊(R − PR) ÷ SR⌋ + 1 and Cout = ⌊(C − PC) ÷ SC⌋ + 1

The downsampler of a 2-D CNN, and the companion to Pooling 1D. Every ICore signal is already a matrix, so this needs no new signal concept – only a second window and a second stride.

Ports

  • u – the input, any [R,C] matrix with R ≥ Pool Rows and C ≥ Pool Columns, or there is no complete window and the block is reported.
  • Outputy, [Rout,Cout] as above. The block resizes its output when the input size or any of the four counts changes.

Parameters

  • PoolingMax (the default; keeps the strongest response in each window) or Average (their mean).
  • Pool Rows / Pool Columns – the window height and width, whole numbers ≥ 1. Rounded to the nearest whole number.
  • Row Stride / Column Stride – how far the window advances down and across, whole numbers ≥ 1. Setting each stride equal to its window size is non-overlapping pooling, the usual choice and the default.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

The two axes are configured independently on purpose. A non-square window is genuinely useful (a spectrogram is not isotropic), and it is also what makes a rows/columns transposition in the indexing detectable at all – see Notes.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. Every window is unrolled at export time, so no backend emits a loop bound or an index type. The mode and the geometry are structural and baked in; there is no tunable parameter.

The three HDL targets are ordinary Q16.16 fixed point and are offered for synthesis: a max is a comparison chain, and an average is a sum times a constant reciprocal formed at export time, so no divider and no transcendental appears in the datapath.

Simulink bridge

None. Simulink's pooling lives inside its Deep Learning layer blocks, which take a trained network object rather than a signal. The bridge reports the block rather than dropping it silently, and it has no parity testbench, which is the documented consequence of Support::None.

Notes

  • Algebraic and stateless: the whole window comes from the current input matrix, not from past samples. This pools within a sample, not across time.
  • Nonlinear in Max mode, so it carries no state space; Average is linear, but a state space valid in only one of two configurations would be worse than none.
  • Why the two axes are separate. With a square window and equal strides, an implementation that transposed rows and columns somewhere in its indexing produces exactly the same answer as a correct one, in every language. Independent counts are what make that fault expressible, and the verification rig deliberately runs an asymmetric window with asymmetric strides.
  • The tail is dropped in both axes, exactly as in every framework: rows or columns past the last complete window are not read. Nothing is padded – that is Conv 2D's job.

Code facts#

FactValue
registered typeMachine_Learning/Neural_Networks/Pooling_2D
familyMachine_Learning/Neural_Networks
solver environment classICoreBlock_0_Machine_Learning_1_Neural_Networks_2_Pooling_2D
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Neural_Networks/Pooling_2D/ICoreBlock_0_Machine_Learning_1_Neural_Networks_2_Pooling_2D.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Neural_Networks/Pooling_2D/ICoreBlock_0_Machine_Learning_1_Neural_Networks_2_Pooling_2D.h
default size on canvas116 × 84 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoubleu
2outICoreDoubley

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
PoolingMax%~%Average~~Max
Pool Rows2
Pool Columns2
Row Stride2
Column Stride2

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): no Simulink equivalent as a signal block: its pooling exists only inside the Deep Learning layer blocks, which take a trained network OBJECT rather than a signal, and no config value crosses the bridge as an object

Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:

  • B0 every stimulus in the sample errored — cross-checks skipped

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Pooling 2D — max or average over a sliding 2-D window y[a][b] = max/mean over u[a*SR .. +PR-1][b*SC .. +PC-1] Rout = floor((R-PR)/SR)+1 Cout = floor((C-PC)/SC)+1

Pooling_1D in both axes, with the same two properties: every window UNROLLED at export time (all four counts and the input size are known once the model is built), and Average emitted as sum * (1/(PR*PC)) with the reciprocal formed at export time so no divider reaches the three HDL datapaths. Those stay genuine Q16.16 -- a max is a comparison chain and an average is a multiply-accumulate.

See the header for why the window and stride are per-axis rather than one number each.

Sample results#

No stimulus produced a sampled output in this rig — Window larger than the signal at: ICore Blocks/Home/Pooling 2D. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.

Category unsampled · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60

Sample data: docs/generated/samples/Machine_Learning__Neural_Networks__Pooling_2D.json