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

Function concat

tfjs-backend-webgpu/src/kernels/Concat.ts:25–49  ·  view source on GitHub ↗
(
    args: {inputs: ConcatInputs, attrs: ConcatAttrs, backend: WebGPUBackend})

Source from the content-addressed store, hash-verified

23import {identity} from './Identity';
24
25export function concat(
26 args: {inputs: ConcatInputs, attrs: ConcatAttrs, backend: WebGPUBackend}):
27 TensorInfo {
28 const {inputs, backend, attrs} = args;
29 const {axis} = attrs;
30
31 const $axis = util.parseAxisParam(axis, inputs[0].shape)[0];
32
33 const shapes = inputs.map(t => t.shape);
34 backend_util.assertParamsConsistent(shapes, $axis);
35
36 const outShape =
37 backend_util.computeOutShape(inputs.map(t => t.shape), $axis);
38 if (util.sizeFromShape(outShape) === 0) {
39 return backend.makeTensorInfo(outShape, inputs[0].dtype, []);
40 }
41
42 // Keep only non-empty tensors (ignore tensors with 0 in their shape).
43 const $inputs = inputs.filter(t => util.sizeFromShape(t.shape) > 0);
44 if ($inputs.length === 1) {
45 return identity({inputs: {x: $inputs[0]}, backend});
46 }
47
48 return concatImpl($inputs, $axis, backend);
49}
50
51export const concatConfig: KernelConfig = {
52 kernelName: Concat,

Callers 1

packFunction · 0.90

Calls 3

identityFunction · 0.90
concatImplFunction · 0.90
makeTensorInfoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…