license import { ENGINE } from '../engine' ; import { DepthToSpace , DepthToSpaceAttrs , DepthToSpaceInputs } from '../kernel_names' ; import { NamedAttrMap } from '../kernel_registry' ; import { Tensor4D } from '../tensor' ; import { NamedTensorMap } from '../tensor_types' ; import { convertToTensor } from '../tensor_util_env' ; import { TensorLike4D } from '../types' ; import * as util from '../util' ; import { op } from './operation' ; param x param blockSIze param dataFormat doc function depthToSpace_ ( x , blockSize , dataFormat = 'NHWC' ) { const $x = convertToTensor ( x , 'x' , 'depthToSpace' , 'float32' ) as Tensor4D ; const inputHeight = ( dataFormat === 'NHWC' ) ? $x . shape [ 1 ] : $x . shape [ 2 ] ; const inputWidth = ( dataFormat === 'NHWC' ) ? $x . shape [ 2 ] : $x . shape [ 3 ] ; const inputDepth = ( dataFormat === 'NHWC' ) ? $x . shape [ 3 ] : $x . shape [ 1 ] ; util . assert ( blockSize > 1 , ( ) => `blockSize should be > 1 for depthToSpace, but was: ${ blockSize }` ) ; util . assert ( inputHeight * blockSize >= 0 , ( ) => `Negative dimension size caused by overflow when multiplying
    ${ inputHeight } and ${ blockSize }  for depthToSpace with input shape
    ${ $x . shape }` ) ; util . assert ( inputWidth * blockSize >= 0 , ( ) => `Negative dimension size caused by overflow when multiplying
    ${ inputWidth } and ${ blockSize } for depthToSpace with input shape
        ${ $x . shape }` ) ; util . assert ( ( inputDepth % ( blockSize * blockSize ) === 0 ) , ( ) => `Dimension size must be evenly divisible by ${ blockSize * blockSize } but is ${ inputDepth } for depthToSpace with input shape ${ $x . shape }` ) ; const inputs = { x : $x } ; const attrs = { blockSize , dataFormat } ; return ENGINE . runKernel ( DepthToSpace , inputs as { } as NamedTensorMap , attrs as { } as NamedAttrMap ) ; } export const depthToSpace = op ( { depthToSpace_ } ) ;