license import { ENGINE } from '../engine' ; import { Select , SelectInputs } from '../kernel_names' ; import { Tensor } from '../tensor' ; import { NamedTensorMap } from '../tensor_types' ; import { convertToTensor } from '../tensor_util_env' ; import { TensorLike } from '../types' ; import { broadcastTo } from './broadcast_to' ; import { assertAndGetBroadcastShape } from './broadcast_util' ; import { op } from './operation' ; param condition param a param b return doc function where_ < T extends Tensor > ( condition , a , b ) { const $a = convertToTensor ( a , 'a' , 'where' ) ; const $b = convertToTensor ( b , 'b' , 'where' ) ; const $condition = convertToTensor ( condition , 'condition' , 'where' , 'bool' ) ; const broadcastShape = assertAndGetBroadcastShape ( assertAndGetBroadcastShape ( $condition . shape , $a . shape ) , $b . shape ) ; const $broadcastedCondition = broadcastTo ( $condition , broadcastShape ) ; const $broadcastedA = broadcastTo ( $a , broadcastShape ) ; const $broadcastedB = broadcastTo ( $b , broadcastShape ) ; const inputs = { condition : $broadcastedCondition , t : $broadcastedA , e : $broadcastedB } ; return ENGINE . runKernel ( Select , inputs as { } as NamedTensorMap ) ; } export const where = op ( { where_ } ) ;