UNPKG

1.85 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 Google LLC. All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 * =============================================================================
16 */
17/// <amd-module name="@tensorflow/tfjs-core/dist/ops/pad" />
18import { Tensor } from '../tensor';
19import { TensorLike } from '../types';
20/**
21 * Pads a `tf.Tensor` with a given value and paddings.
22 *
23 * This operation implements `CONSTANT` mode. For `REFLECT` and `SYMMETRIC`,
24 * refer to `tf.mirrorPad`
25 *
26 * Also available are stricter rank-specific methods with the same signature
27 * as this method that assert that `paddings` is of given length.
28 * - `tf.pad1d`
29 * - `tf.pad2d`
30 * - `tf.pad3d`
31 * - `tf.pad4d`
32 *
33 * ```js
34 * const x = tf.tensor1d([1, 2, 3, 4]);
35 * x.pad([[1, 2]]).print();
36 * ```
37 * @param x The tensor to pad.
38 * @param paddings An array of length `R` (the rank of the tensor), where
39 * each element is a length-2 tuple of ints `[padBefore, padAfter]`,
40 * specifying how much to pad along each dimension of the tensor.
41 * @param constantValue The pad value to use. Defaults to 0.
42 *
43 * @doc {heading: 'Tensors', subheading: 'Transformations'}
44 */
45declare function pad_<T extends Tensor>(x: T | TensorLike, paddings: Array<[number, number]>, constantValue?: number): T;
46export declare const pad: typeof pad_;
47export {};