license import { ENGINE } from '../engine' ; import { AddN , AddNInputs } from '../kernel_names' ; 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 tensors doc function addN_ < T extends Tensor > ( tensors ) { util . assert ( Array . isArray ( tensors ) , ( ) => 'The argument passed to tf.addN() must be a list of tensors' ) ; util . assert ( tensors . length >= 1 , ( ) => `Must pass at least one tensor to tf.addN(), but got ` + `${ tensors . length }` ) ; const $tensors = tensors . map ( ( t , i ) => convertToTensor ( t , `tensors${ i }` , 'addN' ) ) ; const firstTensor = $tensors [ 0 ] ; $tensors . forEach ( t => { if ( t . dtype !== firstTensor . dtype ) { throw new Error ( 'All tensors passed to tf.addN() must have the same dtype' ) ; } } ) ; $tensors . forEach ( t => { if ( ! util . arraysEqual ( t . shape , firstTensor . shape ) ) { throw new Error ( 'All tensors passed to tf.addN() must have the same shape' ) ; } } ) ; const inputs = $tensors ; return ENGINE . runKernel ( AddN , inputs as { } as NamedTensorMap ) ; } export const addN = op ( { addN_ } ) ;