* Split elements of `input` based on `delimiter` into a SparseTensor . * * Let N be the size of source (typically N will be the batch size). Split each * element of `input` based on `delimiter` and return a SparseTensor containing * the splitted tokens. Empty tokens are ignored if `skipEmpty` is
(
input: Tensor1D|TensorLike, delimiter: Scalar|ScalarLike,
skipEmpty = true)
| 56 | * @doc {heading: 'Operations', subheading: 'String'} |
| 57 | */ |
| 58 | function stringSplit_( |
| 59 | input: Tensor1D|TensorLike, delimiter: Scalar|ScalarLike, |
| 60 | skipEmpty = true): NamedTensorMap { |
| 61 | const $input = convertToTensor(input, 'input', 'stringSplit', 'string'); |
| 62 | const $delimiter = |
| 63 | convertToTensor(delimiter, 'delimiter', 'stringSplit', 'string'); |
| 64 | |
| 65 | if ($input.rank !== 1) { |
| 66 | throw new Error( |
| 67 | `Input should be Tensor1D but received shape ${$input.shape}`); |
| 68 | } |
| 69 | if ($delimiter.rank !== 0) { |
| 70 | throw new Error( |
| 71 | `Delimiter should be a scalar but received shape ${$delimiter.shape}`); |
| 72 | } |
| 73 | |
| 74 | const attrs: StringSplitAttrs = {skipEmpty}; |
| 75 | const inputs: StringSplitInputs = {input: $input, delimiter: $delimiter}; |
| 76 | const result: Tensor[] = |
| 77 | ENGINE.runKernel(StringSplit, inputs as {}, attrs as {}); |
| 78 | return {indices: result[0], values: result[1], shape: result[2]}; |
| 79 | } |
| 80 | |
| 81 | export const stringSplit = /* @__PURE__ */ op({stringSplit_}); |
nothing calls this directly
no test coverage detected
searching dependent graphs…