Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add depth check for dilation2d #7137

Merged
merged 1 commit into from Dec 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion tfjs-core/src/ops/dilation2d.ts
Expand Up @@ -31,7 +31,7 @@ import {reshape} from './reshape';
* Computes the grayscale dilation over the input `x`.
*
* @param x The input tensor, rank 3 or rank 4 of shape
* `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed.
* `[batch, height, width, depth]`. If rank 3, batch of 1 is assumed.
* @param filter The filter tensor, rank 3, of shape
* `[filterHeight, filterWidth, depth]`.
* @param strides The strides of the sliding window for each dimension of the
Expand Down Expand Up @@ -87,6 +87,11 @@ function dilation2d_<T extends Tensor3D|Tensor4D>(
reshapedTo4D = true;
}

util.assert(
x4D.shape[3] === $filter.shape[2],
() => `Error in dilation2d: input and filter must have the same depth: ${
x4D.shape[3]} vs ${$filter.shape[2]}`);

const inputs: Dilation2DInputs = {x: x4D, filter: $filter};
const attrs: Dilation2DAttrs = {strides, pad, dilations};

Expand Down