license import { ENGINE } from '../engine' ; import { Slice , SliceAttrs , SliceInputs } from '../kernel_names' ; import { NamedAttrMap } from '../kernel_registry' ; import { Tensor } from '../tensor' ; import { NamedTensorMap } from '../tensor_types' ; import { convertToTensor } from '../tensor_util_env' ; import { Rank , TensorLike } from '../types' ; import { op } from './operation' ; param x param begin param size doc function slice_ < R extends Rank , T extends Tensor < R > > ( x , begin , size ? ) { const $x = convertToTensor ( x , 'x' , 'slice' , 'string_or_numeric' ) ; if ( $x . rank === 0 ) { throw new Error ( 'Slicing scalar is not possible' ) ; } const inputs = { x : $x } ; const attrs = { begin , size } ; return ENGINE . runKernel ( Slice , inputs as { } as NamedTensorMap , attrs as { } as NamedAttrMap ) ; } export const slice = op ( { slice_ } ) ;