| 482 | } |
| 483 | |
| 484 | void Compute(OpKernelContext* context) override { |
| 485 | // Input tensor is of the following dimensions: |
| 486 | // [ batch, in_rows, in_cols, in_depth ] |
| 487 | const Tensor& input = context->input(0); |
| 488 | |
| 489 | // Input filter is of the following dimensions: |
| 490 | // [ filter_rows, filter_cols, in_depth, out_depth] |
| 491 | const Tensor& filter = context->input(1); |
| 492 | |
| 493 | Conv2DDimensions dimensions; |
| 494 | OP_REQUIRES_OK(context, |
| 495 | ComputeConv2DDimension(params_, input, filter, &dimensions)); |
| 496 | |
| 497 | TensorShape out_shape = ShapeFromFormat( |
| 498 | params_.data_format, dimensions.batch, dimensions.out_rows, |
| 499 | dimensions.out_cols, dimensions.out_depth); |
| 500 | |
| 501 | // Output tensor is of the following dimensions: |
| 502 | // [ in_batch, out_rows, out_cols, out_depth ] |
| 503 | Tensor* output = nullptr; |
| 504 | OP_REQUIRES_OK(context, context->allocate_output(0, out_shape, &output)); |
| 505 | |
| 506 | VLOG(2) << "Conv2D: in_depth = " << dimensions.in_depth |
| 507 | << ", patch_depth = " << dimensions.patch_depth |
| 508 | << ", input_cols = " << dimensions.input_cols |
| 509 | << ", filter_cols = " << dimensions.filter_cols |
| 510 | << ", input_rows = " << dimensions.input_rows |
| 511 | << ", filter_rows = " << dimensions.filter_rows |
| 512 | << ", stride_rows = " << dimensions.stride_rows |
| 513 | << ", stride_cols = " << dimensions.stride_cols |
| 514 | << ", dilation_rows = " << dimensions.dilation_rows |
| 515 | << ", dilation_cols = " << dimensions.dilation_cols |
| 516 | << ", out_depth = " << dimensions.out_depth; |
| 517 | |
| 518 | // If there is nothing to compute, return. |
| 519 | if (out_shape.num_elements() == 0) { |
| 520 | return; |
| 521 | } |
| 522 | |
| 523 | #ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS |
| 524 | if (params_.padding != EXPLICIT && |
| 525 | LaunchXsmmConvOp<Device, T>::Run( |
| 526 | context, input, filter, dimensions.batch, dimensions.input_rows, |
| 527 | dimensions.input_cols, dimensions.in_depth, dimensions.filter_rows, |
| 528 | dimensions.filter_cols, dimensions.pad_rows_before, |
| 529 | dimensions.pad_cols_before, dimensions.out_rows, |
| 530 | dimensions.out_cols, dimensions.out_depth, dimensions.dilation_rows, |
| 531 | dimensions.dilation_cols, dimensions.stride_rows, |
| 532 | dimensions.stride_cols, output, params_.data_format)) { |
| 533 | return; |
| 534 | } |
| 535 | #endif |
| 536 | |
| 537 | if (params_.padding != EXPLICIT && |
| 538 | LaunchDeepConvOp<Device, T>::Run( |
| 539 | context, input, filter, dimensions.batch, dimensions.input_rows, |
| 540 | dimensions.input_cols, dimensions.in_depth, dimensions.filter_rows, |
| 541 | dimensions.filter_cols, dimensions.pad_rows_before, |
nothing calls this directly
no test coverage detected