static calcShape(adims, bdims, isMatMul = false) {
        const arank = adims.length;
        const brank = bdims.length;
        if (arank === 0) {
            return bdims;
        }
        if (brank === 0) {
            return adims;
        }
        const crank = Math.max(adims.length, bdims.length);
        const cdims = new Array(crank);
        // calculate the last 2 dimension if it is MatMul
        if (isMatMul) {
            if (arank < 2 || brank < 2) {
                return undefined;
            }
            const cShapeMatMul = MatMulUtil.calcMatMulShape([adims[arank - 2], adims[arank - 1]], [bdims[brank - 2], bdims[brank - 1]]);
            if (cShapeMatMul === undefined) {
                return undefined;
            }
            [cdims[crank - 2], cdims[crank - 1]] = cShapeMatMul;
        }
        for (let i = isMatMul ? 3 : 1; i <= crank; i++) {
            const aLen = arank - i < 0 ? 1 : adims[arank - i];
            const bLen = brank - i < 0 ? 1 : bdims[brank - i];
            if (aLen !== bLen && aLen > 1 && bLen > 1) {
                return undefined;
            }
            cdims[crank - i] = Math.max(aLen, bLen);
        }
        return cdims;
    }
/**
     * Calculate the expected shape when broadcasting 2 tensors
     * @param a The shape of tensor A. Should be an array of positive integers
     * @param b The shape of tensor B. Should be an array of positive integers
     * @param isMatMul Whether the operation is MatMul
     * @returns The expected shape of the result, or undefined if N/A
     */
Calculate the expected shape when broadcasting 2 tensors
@param a The shape of tensor A. Should be an array of positive integers
@param b The shape of tensor B. Should be an array of positive integers
@param isMatMul Whether the operation is MatMul
@returns The expected shape of the result, or undefined if N/A
Calculate the expected shape when broadcasting 2 tensors @param a The shape of tensor A . Should be an array of positive integers @param b The shape of tensor B . Should be an array of positive integers @param isMatMul Whether the operation is MatMul @returns The expected shape of the result or undefined if N / A
static calcShape(adims, bdims, isMatMul = false) {
        const arank = adims.length;
        const brank = bdims.length;
        if (arank === 0) {
            return bdims;
        }
        if (brank === 0) {
            return adims;
        }
        const crank = Math.max(adims.length, bdims.length);
        const cdims = new Array(crank);
        if (isMatMul) {
            if (arank < 2 || brank < 2) {
                return undefined;
            }
            const cShapeMatMul = MatMulUtil.calcMatMulShape([adims[arank - 2], adims[arank - 1]], [bdims[brank - 2], bdims[brank - 1]]);
            if (cShapeMatMul === undefined) {
                return undefined;
            }
            [cdims[crank - 2], cdims[crank - 1]] = cShapeMatMul;
        }
        for (let i = isMatMul ? 3 : 1; i <= crank; i++) {
            const aLen = arank - i < 0 ? 1 : adims[arank - i];
            const bLen = brank - i < 0 ? 1 : bdims[brank - i];
            if (aLen !== bLen && aLen > 1 && bLen > 1) {
                return undefined;
            }
            cdims[crank - i] = Math.max(aLen, bLen);
        }
        return cdims;
    }
static calcShape ( adims , bdims , isMatMul = false ) { const arank = adims . length ; const brank = bdims . length ; if ( arank === 0 ) { return bdims ; } if ( brank === 0 ) { return adims ; } const crank = Math . max ( adims . length , bdims . length ) ; const cdims = new Array ( crank ) ; if ( isMatMul ) { if ( arank < 2 || brank < 2 ) { return undefined ; } const cShapeMatMul = MatMulUtil . calcMatMulShape ( [ adims [ arank - 2 ] , adims [ arank - 1 ] ] , [ bdims [ brank - 2 ] , bdims [ brank - 1 ] ] ) ; if ( cShapeMatMul === undefined ) { return undefined ; } [ cdims [ crank - 2 ] , cdims [ crank - 1 ] ] = cShapeMatMul ; } for ( let i = isMatMul ? 3 : 1 ; i <= crank ; i ++ ) { const aLen = arank - i < 0 ? 1 : adims [ arank - i ] ; const bLen = brank - i < 0 ? 1 : bdims [ brank - i ] ; if ( aLen !== bLen && aLen > 1 && bLen > 1 ) { return undefined ; } cdims [ crank - i ] = Math . max ( aLen , bLen ) ; } return cdims ; }
Calculate the expected shape when broadcasting 2 tensors
 @param a The shape of tensor A.
Calculate the expected shape when broadcasting 2 tensors @param a The shape of tensor A .
// calculate the last 2 dimension if it is MatMul