config_setting(
# Add "--define tensorflow_xsmm=1" to your build command to use libxsmm for
- # convolutions (and possibly more in the future). You will also need
- # appropriate -mavx*, as required by specific op you use.
+ # sparse matrix multiplications. You will also need appropriate -mavx*
+ # options, as required by specific op you use.
name = "xsmm",
values = {
"define": "tensorflow_xsmm=1",
)
config_setting(
- # Add "--define tensorflow_xsmm_backward=1" to your build command to use
- # libxsmm for backward convolutions (and possibly more in the future). You
- # will also need appropriate -mavx*, as required by specific op you use.
- name = "xsmm_backward",
+ # Add "--define tensorflow_xsmm_convolutions=1" to your build command to
+ # use libxsmm for forward convolutions. You will also need appropriate
+ # -mavx* # options, as required by specific op you use.
+ name = "xsmm_convolutions",
values = {
- "define": "tensorflow_xsmm_backward=1",
+ "define": "tensorflow_xsmm_convolutions=1",
+ },
+)
+
+config_setting(
+ # Add "--define tensorflow_xsmm_convolutions=1 --define
+ # tensorflow_xsmm_backward_convolutions=1" to your build command to use libxsmm for
+ # backward convolutions (and possibly more in the future). You will also
+ # need appropriate -mavx* options, as required by specific op you use.
+ name = "xsmm_backward_convolutions",
+ values = {
+ "define": "tensorflow_xsmm_backward_convolutions=1",
},
)
name = "xsmm_conv2d_test",
size = "small",
srcs = select({
- ":xsmm": ["xsmm_conv2d_test.cc"],
+ ":xsmm_convolutions": ["xsmm_conv2d_test.cc"],
"//conditions:default": [],
}),
deps = [
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
] + select({
- ":xsmm": [
+ ":xsmm_convolutions": [
"@libxsmm_archive//:xsmm_avx",
],
"//conditions:default": [],
"conv_grad_ops_3d.cc",
"deep_conv2d.cc",
] + select({
- ":xsmm": ["xsmm_conv2d.cc"],
+ ":xsmm_convolutions": ["xsmm_conv2d.cc"],
"//conditions:default": [],
}),
hdrs = [
"gemm_functors.h",
"winograd_transform.h",
] + select({
- ":xsmm": ["xsmm_conv2d.h"],
+ ":xsmm_convolutions": ["xsmm_conv2d.h"],
"//conditions:default": [],
}),
# Override EIGEN_STRONG_INLINE to inline when --define=override_eigen_strong_inline=true,
# on Windows. See https://github.com/tensorflow/tensorflow/issues/10521
copts = if_override_eigen_strong_inline(["/DEIGEN_STRONG_INLINE=inline"]),
defines = select({
- ":xsmm": [
- "TENSORFLOW_USE_LIBXSMM",
- "EIGEN_USE_LIBXSMM",
+ ":xsmm_convolutions": [
+ "TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS",
],
"//conditions:default": [],
}) + select({
- ":xsmm_backward": ["TENSORFLOW_USE_LIBXSMM_BACKWARD"],
+ ":xsmm": ["EIGEN_USE_LIBXSMM"],
+ "//conditions:default": [],
+ }) + select({
+ ":xsmm_backward_convolutions": ["TENSORFLOW_USE_LIBXSMM_BACKWARD_CONVOLUTIONS"],
"//conditions:default": [],
}),
prefix = "conv_ops",
"//tensorflow/core:lib_internal",
"//tensorflow/core:nn_ops_op_lib",
] + select({
- ":xsmm": [
+ ":xsmm_convolutions": [
"@libxsmm_archive//:xsmm_avx",
],
"//conditions:default": [],
"winograd_transform.h",
":android_extended_ops_headers",
] + select({
- ":xsmm": [
+ ":xsmm_convolutions": [
"xsmm_conv2d.h",
"xsmm_conv2d.cc",
],
#include "tensorflow/core/framework/tensor_slice.h"
#include "tensorflow/core/kernels/conv_2d.h"
#include "tensorflow/core/kernels/fill_functor.h"
-#ifdef TENSORFLOW_USE_LIBXSMM
+#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
#include "tensorflow/core/kernels/xsmm_conv2d.h"
#endif
#include "tensorflow/core/kernels/ops_util.h"
}
};
-#ifdef TENSORFLOW_USE_LIBXSMM
+#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
template <typename Device, class T>
struct LaunchXsmmBackwardFilter {
bool operator()(OpKernelContext* context, const Device& d,
return;
}
-#if defined TENSORFLOW_USE_LIBXSMM && defined TENSORFLOW_USE_LIBXSMM_BACKWARD
+#if defined TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS && \
+ defined TENSORFLOW_USE_LIBXSMM_BACKWARD_CONVOLUTIONS
int64 pad_top, pad_bottom;
int64 pad_left, pad_right;
OP_REQUIRES_OK(
dims.spatial_dims[1].input_size, dims.spatial_dims[1].filter_size,
dims.spatial_dims[1].stride, padding_,
&dims.spatial_dims[1].output_size, &pad_left, &pad_right));
-#if defined TENSORFLOW_USE_LIBXSMM && defined TENSORFLOW_USE_LIBXSMM_BACKWARD
+#if defined TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS && \
+ defined TENSORFLOW_USE_LIBXSMM_BACKWARD_CONVOLUTIONS
if (pad_left == pad_right && pad_top == pad_bottom) {
if (LaunchXsmmBackwardFilter<Device, T>()(
context, context->eigen_device<Device>(), input.tensor<T, 4>(),
#include "tensorflow/core/framework/tensor_shape.h"
#include "tensorflow/core/framework/tensor_slice.h"
#include "tensorflow/core/kernels/conv_2d.h"
-#ifdef TENSORFLOW_USE_LIBXSMM
+#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
#include "tensorflow/core/kernels/xsmm_conv2d.h"
#endif
#include "tensorflow/core/kernels/ops_util.h"
}
};
-#ifdef TENSORFLOW_USE_LIBXSMM
+#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
template <typename Device, class T>
struct LaunchXsmmBackwardInputConvolution {
bool operator()(OpKernelContext* context, const Device& d,
return;
}
-#if defined TENSORFLOW_USE_LIBXSMM && defined TENSORFLOW_USE_LIBXSMM_BACKWARD
+#if defined TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS && \
+ defined TENSORFLOW_USE_LIBXSMM_BACKWARD_CONVOLUTIONS
int64 pad_top, pad_bottom;
int64 pad_left, pad_right;
OP_REQUIRES_OK(
// TODO(andydavis) Consider moving code shared with
// Conv2DCustomBackpropFilterOp into a shared helper function.
-#if defined TENSORFLOW_USE_LIBXSMM && defined TENSORFLOW_USE_LIBXSMM_BACKWARD
+#if defined TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS && \
+ defined TENSORFLOW_USE_LIBXSMM_BACKWARD_CONVOLUTIONS
int64 pad_top, pad_bottom;
int64 pad_left, pad_right;
OP_REQUIRES_OK(
#include "tensorflow/core/kernels/conv_2d.h"
#include "tensorflow/core/kernels/deep_conv2d.h"
#include "tensorflow/core/kernels/ops_util.h"
-#ifdef TENSORFLOW_USE_LIBXSMM
+#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
#include "tensorflow/core/kernels/xsmm_conv2d.h"
#endif
#include "tensorflow/core/lib/core/errors.h"
}
};
-#ifdef TENSORFLOW_USE_LIBXSMM
+#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
template <typename Device, typename T>
class LaunchXsmmConvOp {
public:
return;
}
-#ifdef TENSORFLOW_USE_LIBXSMM
+#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
if (LaunchXsmmConvOp<Device, T>::Run(
context, input, filter, batch, input_rows, input_cols, in_depth,
filter_rows, filter_cols, pad_rows, pad_cols, out_rows, out_cols,
// Make this file empty (or nearly empty) so that it can be compiled even when
// libxsmm is not available.
-#ifndef TENSORFLOW_USE_LIBXSMM
+#ifndef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
void dummy_xsmm_conv2d_ensure_file_is_not_empty();
#else
#include "tensorflow/core/lib/core/blocking_counter.h"
#include "tensorflow/core/lib/core/threadpool.h"
-#include "libxsmm_main.h" // TODO(bsteiner): API to avoid incl. header from src/
#include "include/libxsmm_cpuid.h"
#include "include/libxsmm_malloc.h"
+#include "third_party/libxsmm/src/libxsmm_main.h" // TODO(bsteiner): API to avoid incl. header from src/
namespace tensorflow {
InputPtr input, FilterPtr filter,
OutputPtr output) {
#if defined(LIBXSMM_DETAILED_TIMING)
- unsigned long long l_tick1, l_tick2, l_tick3, l_tick4, l_tick5, l_tick6,
- l_tick7, l_tick8, l_tick9, l_tick10;
+ uint64 l_tick1;
+ uint64 l_tick2;
+ uint64 l_tick3;
+ uint64 l_tick4;
+ uint64 l_tick5;
+ uint64 l_tick6;
+ uint64 l_tick7;
+ uint64 l_tick8;
+ uint64 l_tick9;
+ uint64 l_tick10;
l_tick1 = libxsmm_timer_tick();
#endif
// setup scoped allocator, which adopts the allocator from the context
return true; // Succeeded
}
+#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
template <typename T>
struct XsmmFwdConv2D<CPUDevice, T> {
bool operator()(OpKernelContext* ctx, const libxsmm_dnn_conv_desc& desc,
input, filter, output);
}
};
+#endif
+#ifdef TENSORFLOW_USE_LIBXSMM_BACKWARD_CONVOLUTIONS
template <typename T>
struct XsmmBkwInputConv2D<CPUDevice, T> {
bool operator()(OpKernelContext* ctx, const libxsmm_dnn_conv_desc& desc,
input, filter, output);
}
};
+#endif
} // namespace functor
} // namespace tensorflow
-#endif // TENSORFLOW_USE_LIBXSMM
+#endif // TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS