license import { Tensor } from '@tensorflow/tfjs-core' ; import * as tfOps from '@tensorflow/tfjs-core/dist/ops/ops_for_converter' ; import { NamedTensorsMap } from '../../data/types' ; import { ExecutionContext } from '../../executor/execution_context' ; import { InternalOpExecutor , Node } from '../types' ; import { getParamValue } from './utils' ; export const executeOp = ( node , tensorMap , context ) : Tensor [ ] => { switch ( node . op ) { case 'TopKV2' : { const x = getParamValue ( 'x' , node , tensorMap , context ) as Tensor ; const k = getParamValue ( 'k' , node , tensorMap , context ) as number ; const sorted = getParamValue ( 'sorted' , node , tensorMap , context ) as boolean ; const result = tfOps . topk ( x , k , sorted ) ; return [ result . values , result . indices ] ; } case 'Unique' : { const x = getParamValue ( 'x' , node , tensorMap , context ) as Tensor ; const result = tfOps . unique ( x ) ; return [ result . values , result . indices ] ; } case 'UniqueV2' : { const x = getParamValue ( 'x' , node , tensorMap , context ) as Tensor ; const axis = getParamValue ( 'axis' , node , tensorMap , context ) as number ; const result = tfOps . unique ( x , axis ) ; return [ result . values , result . indices ] ; } default : throw TypeError ( `Node type ${ node . op } is not implemented` ) ; } } ; export const CATEGORY = 'evaluation' ;