(
args: {inputs: ConcatInputs, attrs: ConcatAttrs, backend: WebGPUBackend})
| 23 | import {identity} from './Identity'; |
| 24 | |
| 25 | export 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 | |
| 51 | export const concatConfig: KernelConfig = { |
| 52 | kernelName: Concat, |
no test coverage detected
searching dependent graphs…