| 310 | } while (false) |
| 311 | |
| 312 | Status InitConv2DParameters(const OpKernelConstruction* context, |
| 313 | Conv2DParameters* params) { |
| 314 | TF_RETURN_IF_ERROR(context->GetAttr("dilations", ¶ms->dilations)); |
| 315 | TF_RETURN_IF_ERROR(context->GetAttr("strides", ¶ms->strides)); |
| 316 | TF_RETURN_IF_ERROR(context->GetAttr("padding", ¶ms->padding)); |
| 317 | if (context->HasAttr("explicit_paddings")) { |
| 318 | TF_RETURN_IF_ERROR( |
| 319 | context->GetAttr("explicit_paddings", ¶ms->explicit_paddings)); |
| 320 | } |
| 321 | string data_format_string; |
| 322 | TF_RETURN_IF_ERROR(context->GetAttr("data_format", &data_format_string)); |
| 323 | TF_REQUIRES(FormatFromString(data_format_string, ¶ms->data_format), |
| 324 | errors::InvalidArgument("Invalid data format")); |
| 325 | |
| 326 | const auto& strides = params->strides; |
| 327 | const auto& dilations = params->dilations; |
| 328 | const auto& data_format = params->data_format; |
| 329 | |
| 330 | TF_REQUIRES(dilations.size() == 4, |
| 331 | errors::InvalidArgument("Sliding window dilations field must " |
| 332 | "specify 4 dimensions")); |
| 333 | TF_REQUIRES(strides.size() == 4, |
| 334 | errors::InvalidArgument("Sliding window strides field must " |
| 335 | "specify 4 dimensions")); |
| 336 | const int64 stride_n = GetTensorDim(strides, data_format, 'N'); |
| 337 | const int64 stride_c = GetTensorDim(strides, data_format, 'C'); |
| 338 | const int64 stride_h = GetTensorDim(strides, data_format, 'H'); |
| 339 | const int64 stride_w = GetTensorDim(strides, data_format, 'W'); |
| 340 | TF_REQUIRES( |
| 341 | stride_n == 1 && stride_c == 1, |
| 342 | errors::InvalidArgument("Current implementation does not yet support " |
| 343 | "strides in the batch and depth dimensions.")); |
| 344 | TF_REQUIRES(stride_h > 0 && stride_w > 0, |
| 345 | errors::InvalidArgument( |
| 346 | "Row and column strides should be larger than 0.")); |
| 347 | |
| 348 | const int64 dilation_n = GetTensorDim(dilations, data_format, 'N'); |
| 349 | const int64 dilation_c = GetTensorDim(dilations, data_format, 'C'); |
| 350 | const int64 dilation_h = GetTensorDim(dilations, data_format, 'H'); |
| 351 | const int64 dilation_w = GetTensorDim(dilations, data_format, 'W'); |
| 352 | TF_REQUIRES( |
| 353 | dilation_n == 1 && dilation_c == 1, |
| 354 | errors::InvalidArgument("Current implementation does not yet support " |
| 355 | "dilations in the batch and depth dimensions.")); |
| 356 | TF_REQUIRES( |
| 357 | dilation_h > 0 && dilation_w > 0, |
| 358 | errors::InvalidArgument("Dilated rates should be larger than 0.")); |
| 359 | |
| 360 | TF_RETURN_IF_ERROR(CheckValidPadding(params->padding, |
| 361 | params->explicit_paddings, |
| 362 | /*num_dims=*/4, data_format)); |
| 363 | |
| 364 | return Status::OK(); |
| 365 | } |
| 366 | |
| 367 | Status ComputeConv2DDimension(const Conv2DParameters& params, |
| 368 | const Tensor& input, const Tensor& filter, |
no test coverage detected