1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 #include "tensorflow/compiler/xla/service/cpu/runtime_conv2d.h"
17
18 #define EIGEN_USE_THREADS
19
20 #include "tensorflow/compiler/xla/executable_run_options.h"
21 #include "tensorflow/compiler/xla/service/cpu/runtime_conv2d_impl.h"
22 #include "tensorflow/compiler/xla/service/cpu/runtime_lightweight_check.h"
23 #include "tensorflow/core/platform/dynamic_annotations.h"
24 #include "tensorflow/core/platform/types.h"
25
__xla_cpu_runtime_EigenConvF32(const void * run_options_ptr,float * out,float * lhs,float * rhs,tensorflow::int64 input_batch,tensorflow::int64 input_rows,tensorflow::int64 input_cols,tensorflow::int64 input_channels,tensorflow::int64 kernel_rows,tensorflow::int64 kernel_cols,tensorflow::int64 kernel_channels,tensorflow::int64 kernel_filters,tensorflow::int64 output_rows,tensorflow::int64 output_cols,tensorflow::int64 row_stride,tensorflow::int64 col_stride,tensorflow::int64 padding_top,tensorflow::int64 padding_bottom,tensorflow::int64 padding_left,tensorflow::int64 padding_right,tensorflow::int64 lhs_row_dilation,tensorflow::int64 lhs_col_dilation,tensorflow::int64 rhs_row_dilation,tensorflow::int64 rhs_col_dilation)26 TF_ATTRIBUTE_NO_SANITIZE_MEMORY void __xla_cpu_runtime_EigenConvF32(
27 const void* run_options_ptr, float* out, float* lhs, float* rhs,
28 tensorflow::int64 input_batch, tensorflow::int64 input_rows,
29 tensorflow::int64 input_cols, tensorflow::int64 input_channels,
30 tensorflow::int64 kernel_rows, tensorflow::int64 kernel_cols,
31 tensorflow::int64 kernel_channels, tensorflow::int64 kernel_filters,
32 tensorflow::int64 output_rows, tensorflow::int64 output_cols,
33 tensorflow::int64 row_stride, tensorflow::int64 col_stride,
34 tensorflow::int64 padding_top, tensorflow::int64 padding_bottom,
35 tensorflow::int64 padding_left, tensorflow::int64 padding_right,
36 tensorflow::int64 lhs_row_dilation, tensorflow::int64 lhs_col_dilation,
37 tensorflow::int64 rhs_row_dilation, tensorflow::int64 rhs_col_dilation) {
38 const xla::ExecutableRunOptions* run_options =
39 static_cast<const xla::ExecutableRunOptions*>(run_options_ptr);
40 XLA_LIGHTWEIGHT_CHECK(run_options->intra_op_thread_pool() != nullptr);
41 tensorflow::xla::EigenConvImpl(
42 *run_options->intra_op_thread_pool(), out, lhs, rhs, input_batch,
43 input_rows, input_cols, input_channels, kernel_rows, kernel_cols,
44 kernel_channels, kernel_filters, output_rows, output_cols, row_stride,
45 col_stride, padding_top, padding_bottom, padding_left, padding_right,
46 lhs_row_dilation, lhs_col_dilation, rhs_row_dilation, rhs_col_dilation);
47 }
48
__xla_cpu_runtime_EigenConvF16(const void * run_options_ptr,Eigen::half * out,Eigen::half * lhs,Eigen::half * rhs,tensorflow::int64 input_batch,tensorflow::int64 input_rows,tensorflow::int64 input_cols,tensorflow::int64 input_channels,tensorflow::int64 kernel_rows,tensorflow::int64 kernel_cols,tensorflow::int64 kernel_channels,tensorflow::int64 kernel_filters,tensorflow::int64 output_rows,tensorflow::int64 output_cols,tensorflow::int64 row_stride,tensorflow::int64 col_stride,tensorflow::int64 padding_top,tensorflow::int64 padding_bottom,tensorflow::int64 padding_left,tensorflow::int64 padding_right,tensorflow::int64 lhs_row_dilation,tensorflow::int64 lhs_col_dilation,tensorflow::int64 rhs_row_dilation,tensorflow::int64 rhs_col_dilation)49 TF_ATTRIBUTE_NO_SANITIZE_MEMORY void __xla_cpu_runtime_EigenConvF16(
50 const void* run_options_ptr, Eigen::half* out, Eigen::half* lhs,
51 Eigen::half* rhs, tensorflow::int64 input_batch,
52 tensorflow::int64 input_rows, tensorflow::int64 input_cols,
53 tensorflow::int64 input_channels, tensorflow::int64 kernel_rows,
54 tensorflow::int64 kernel_cols, tensorflow::int64 kernel_channels,
55 tensorflow::int64 kernel_filters, tensorflow::int64 output_rows,
56 tensorflow::int64 output_cols, tensorflow::int64 row_stride,
57 tensorflow::int64 col_stride, tensorflow::int64 padding_top,
58 tensorflow::int64 padding_bottom, tensorflow::int64 padding_left,
59 tensorflow::int64 padding_right, tensorflow::int64 lhs_row_dilation,
60 tensorflow::int64 lhs_col_dilation, tensorflow::int64 rhs_row_dilation,
61 tensorflow::int64 rhs_col_dilation) {
62 const xla::ExecutableRunOptions* run_options =
63 static_cast<const xla::ExecutableRunOptions*>(run_options_ptr);
64 XLA_LIGHTWEIGHT_CHECK(run_options->intra_op_thread_pool() != nullptr);
65 tensorflow::xla::EigenConvImpl(
66 *run_options->intra_op_thread_pool(), out, lhs, rhs, input_batch,
67 input_rows, input_cols, input_channels, kernel_rows, kernel_cols,
68 kernel_channels, kernel_filters, output_rows, output_cols, row_stride,
69 col_stride, padding_top, padding_bottom, padding_left, padding_right,
70 lhs_row_dilation, lhs_col_dilation, rhs_row_dilation, rhs_col_dilation);
71 }
72