static adjustPoolAttributes(isGlobalOperator, inputDims, kernelShape, strides, pads) {
        if (!isGlobalOperator && kernelShape.length !== inputDims.length - 2) {
            throw new Error('length of specified kernel shapes should be 2 less than length of input dimensions');
        }
        if (isGlobalOperator) {
            // adjust kernel shape to cover the input dims
            for (let dim = 0; dim < inputDims.length - 2; dim++) {
                if (dim >= kernelShape.length) {
                    kernelShape.push(inputDims[dim + 2]);
                }
                else {
                    kernelShape[dim] = inputDims[dim + 2];
                }
            }
        }
        // adjust strides length to match kernel shape length
        for (let dim = 0; dim < kernelShape.length; dim++) {
            if (dim < strides.length) {
                if (strides[dim] < 0) {
                    throw new Error('strides should be greater than or equal to 1');
                }
            }
            else {
                strides.push(1);
            }
        }
        // adjust pads length to match 2 * kernel shape length
        for (let dim = 0; dim < kernelShape.length * 2; dim++) {
            if (dim < pads.length) {
                if (pads[dim] < 0) {
                    throw new Error('pad should be greater than or equal to 1');
                }
            }
            else {
                pads.push(0);
            }
        }
        // sanity checks for values in kernel shapes and pads
        for (let dim = 0; dim < kernelShape.length; dim++) {
            if (kernelShape[dim] <= 0) {
                throw new Error('kernel shapes need to be greater than 0');
            }
            if (pads[dim] >= kernelShape[dim] || pads[dim + kernelShape.length] >= kernelShape[dim]) {
                throw new Error('pads should be smaller than kernel');
            }
        }
    }
/**
     * Adjust the kernel, strides, pads to correct rank. Set to default value if not present
     * @param isGlobalOperator If true, perform global pooling.
     * @param inputDims The input tensor dimension.
     * @param kernelShape The size of the kernel along each axis.
     * @param strides Stride along each axis.
     * @param pads Padding for the beginning and ending along each axis.
     */
Adjust the kernel, strides, pads to correct rank. Set to default value if not present
@param isGlobalOperator If true, perform global pooling.
@param inputDims The input tensor dimension.
@param kernelShape The size of the kernel along each axis.
@param strides Stride along each axis.
@param pads Padding for the beginning and ending along each axis.
Adjust the kernel strides pads to correct rank . Set to default value if not present @param isGlobalOperator If true perform global pooling . @param inputDims The input tensor dimension . @param kernelShape The size of the kernel along each axis . @param strides Stride along each axis . @param pads Padding for the beginning and ending along each axis .
static adjustPoolAttributes(isGlobalOperator, inputDims, kernelShape, strides, pads) {
        if (!isGlobalOperator && kernelShape.length !== inputDims.length - 2) {
            throw new Error('length of specified kernel shapes should be 2 less than length of input dimensions');
        }
        if (isGlobalOperator) {
            for (let dim = 0; dim < inputDims.length - 2; dim++) {
                if (dim >= kernelShape.length) {
                    kernelShape.push(inputDims[dim + 2]);
                }
                else {
                    kernelShape[dim] = inputDims[dim + 2];
                }
            }
        }
        for (let dim = 0; dim < kernelShape.length; dim++) {
            if (dim < strides.length) {
                if (strides[dim] < 0) {
                    throw new Error('strides should be greater than or equal to 1');
                }
            }
            else {
                strides.push(1);
            }
        }
        for (let dim = 0; dim < kernelShape.length * 2; dim++) {
            if (dim < pads.length) {
                if (pads[dim] < 0) {
                    throw new Error('pad should be greater than or equal to 1');
                }
            }
            else {
                pads.push(0);
            }
        }
        for (let dim = 0; dim < kernelShape.length; dim++) {
            if (kernelShape[dim] <= 0) {
                throw new Error('kernel shapes need to be greater than 0');
            }
            if (pads[dim] >= kernelShape[dim] || pads[dim + kernelShape.length] >= kernelShape[dim]) {
                throw new Error('pads should be smaller than kernel');
            }
        }
    }
static adjustPoolAttributes ( isGlobalOperator , inputDims , kernelShape , strides , pads ) { if ( ! isGlobalOperator && kernelShape . length !== inputDims . length - 2 ) { throw new Error ( 'length of specified kernel shapes should be 2 less than length of input dimensions' ) ; } if ( isGlobalOperator ) { for ( let dim = 0 ; dim < inputDims . length - 2 ; dim ++ ) { if ( dim >= kernelShape . length ) { kernelShape . push ( inputDims [ dim + 2 ] ) ; } else { kernelShape [ dim ] = inputDims [ dim + 2 ] ; } } } for ( let dim = 0 ; dim < kernelShape . length ; dim ++ ) { if ( dim < strides . length ) { if ( strides [ dim ] < 0 ) { throw new Error ( 'strides should be greater than or equal to 1' ) ; } } else { strides . push ( 1 ) ; } } for ( let dim = 0 ; dim < kernelShape . length * 2 ; dim ++ ) { if ( dim < pads . length ) { if ( pads [ dim ] < 0 ) { throw new Error ( 'pad should be greater than or equal to 1' ) ; } } else { pads . push ( 0 ) ; } } for ( let dim = 0 ; dim < kernelShape . length ; dim ++ ) { if ( kernelShape [ dim ] <= 0 ) { throw new Error ( 'kernel shapes need to be greater than 0' ) ; } if ( pads [ dim ] >= kernelShape [ dim ] || pads [ dim + kernelShape . length ] >= kernelShape [ dim ] ) { throw new Error ( 'pads should be smaller than kernel' ) ; } } }
Adjust the kernel, strides, pads to correct rank.
Adjust the kernel strides pads to correct rank .
// adjust kernel shape to cover the input dims // adjust strides length to match kernel shape length // adjust pads length to match 2 * kernel shape length // sanity checks for values in kernel shapes and pads