license import { ENGINE } from '../engine' ; import { BatchToSpaceND , BatchToSpaceNDAttrs , BatchToSpaceNDInputs } from '../kernel_names' ; import { NamedAttrMap } from '../kernel_registry' ; import { Tensor } from '../tensor' ; import { NamedTensorMap } from '../tensor_types' ; import { convertToTensor } from '../tensor_util_env' ; import { TensorLike } from '../types' ; import * as util from '../util' ; import { op } from './operation' ; param x param blockShape param crops doc function batchToSpaceND_ < T extends Tensor > ( x , blockShape , crops ) { const $x = convertToTensor ( x , 'x' , 'batchToSpaceND' ) ; const prod = blockShape . reduce ( ( a , b ) => a * b ) ; util . assert ( $x . rank >= 1 + blockShape . length , ( ) => `input rank is ${ $x . rank } but should be > than blockShape.length ${ blockShape . length }` ) ; util . assert ( crops . length === blockShape . length , ( ) => `crops.length is ${ crops . length } but should be equal to blockShape.length  ${ blockShape . length }` ) ; util . assert ( $x . shape [ 0 ] % prod === 0 , ( ) => `input tensor batch is ${ $x . shape [ 0 ] } but is not divisible by the product of ` + `the elements of blockShape ${ blockShape . join ( ' * ' ) } === ${ prod }` ) ; const inputs = { x : $x } ; const attrs = { blockShape , crops } ; return ENGINE . runKernel ( BatchToSpaceND , inputs as { } as NamedTensorMap , attrs as { } as NamedAttrMap ) ; } export const batchToSpaceND = op ( { batchToSpaceND_ } ) ;