MCPcopy Create free account
hub / github.com/tensorflow/tfjs / stringSplit_

Function stringSplit_

tfjs-core/src/ops/string/string_split.ts:58–79  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

56 * @doc {heading: 'Operations', subheading: 'String'}
57 */
58function 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
81export const stringSplit = /* @__PURE__ */ op({stringSplit_});

Callers

nothing calls this directly

Calls 2

convertToTensorFunction · 0.90
runKernelMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…