UNPKG

2.75 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2018 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/strided_slice" />
18import { Tensor } from '../tensor';
19import { TensorLike } from '../types';
20/**
21 * Extracts a strided slice of a tensor.
22 *
23 * Roughly speaking, this op extracts a slice of size (end-begin)/stride from
24 * the given input tensor (x). Starting at the location specified by begin the
25 * slice continues by adding stride to the index until all dimensions are not
26 * less than end. Note that a stride can be negative, which causes a reverse
27 * slice.
28 *
29 * ```js
30 * const t = tf.tensor3d([1, 1, 1 ,2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],
31 * [3, 2, 3]);
32 * t.stridedSlice([1, 0, 0], [2, 1, 3], [1, 1, 1]).print() // [[[3, 3, 3]]]
33 * t.stridedSlice([1, 0, 0], [2, 2, 3], [1, 1, 1]).print() // [[[3, 3, 3],
34 * // [4, 4, 4]]]
35 * t.stridedSlice([1, -1, 0], [2, -3, 3], [1, -1, 1]).print() // [[[4, 4, 4],
36 * // [3, 3, 3]]]
37 * ```
38 *
39 * @param x The tensor to stride slice.
40 * @param begin The coordinates to start the slice from.
41 * @param end: The coordinates to end the slice at.
42 * @param strides: The size of the slice.
43 * @param beginMask: If the ith bit of beginMask is set, begin[i] is ignored
44 * and the fullest possible range in that dimension is used instead.
45 * @param endMask: If the ith bit of endMask is set, end[i] is ignored
46 * and the fullest possible range in that dimension is used instead.
47 * @param shrinkAxisMask: a bitmask where bit i implies that
48 * the ith specification should shrink the dimensionality. begin and end must
49 * imply a slice of size 1 in the dimension.
50 *
51 * @doc {heading: 'Operations', subheading: 'Slicing and Joining'}
52 */
53declare function stridedSlice_(x: Tensor | TensorLike, begin: number[], end: number[], strides?: number[], beginMask?: number, endMask?: number, ellipsisMask?: number, newAxisMask?: number, shrinkAxisMask?: number): Tensor;
54export declare const stridedSlice: typeof stridedSlice_;
55export {};