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 | import { ENGINE } from '../engine';
|
18 | import { DepthwiseConv2dNativeBackpropFilter } from '../kernel_names';
|
19 | import { op } from './operation';
|
20 | import { reshape } from './reshape';
|
21 | function depthwiseConv2dNativeBackpropFilter_(x, dy, filterShape, strides, pad, dilations = [1, 1], dimRoundingMode) {
|
22 | let x4D = x;
|
23 | if (x.rank === 3) {
|
24 | x4D = reshape(x, [1, x.shape[0], x.shape[1], x.shape[2]]);
|
25 | }
|
26 | let dy4D = dy;
|
27 | if (dy4D.rank === 3) {
|
28 | dy4D = reshape(dy, [1, dy.shape[0], dy.shape[1], dy.shape[2]]);
|
29 | }
|
30 | const inputs = { x: x4D, dy: dy4D };
|
31 | const attrs = { strides, pad, dimRoundingMode, dilations, filterShape };
|
32 | // tslint:disable-next-line: no-unnecessary-type-assertion
|
33 | return ENGINE.runKernel(DepthwiseConv2dNativeBackpropFilter, inputs, attrs);
|
34 | }
|
35 | export const depthwiseConv2dNativeBackpropFilter = op({ depthwiseConv2dNativeBackpropFilter_ });
|
36 | //# sourceMappingURL=depthwise_conv2d_native_backprop_filter.js.map |
\ | No newline at end of file |