Splitting out common_shape_fns.cc:
* Shape functions under shape_inference:: namespace stay in common_shape_fns.cc. * Other functions are moved to kernel_shape_util.h. Also, I removed common_shape_fns.h include in ops_util.h since it is not used in ops_util and only by files that include ops_util.h. PiperOrigin-RevId: 298692539 Change-Id: I79df418a377d4eaed67aeec6f3736acb9d5b111d
This commit is contained in:
parent
ddabed4285
commit
8f7e34982d
@ -46,7 +46,7 @@ limitations under the License.
|
|||||||
#include "tensorflow/compiler/mlir/xla/transforms/passes.h"
|
#include "tensorflow/compiler/mlir/xla/transforms/passes.h"
|
||||||
#include "tensorflow/compiler/xla/client/padding.h"
|
#include "tensorflow/compiler/xla/client/padding.h"
|
||||||
#include "tensorflow/compiler/xla/xla_data.pb.h"
|
#include "tensorflow/compiler/xla/xla_data.pb.h"
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/kernels/conv_grad_shape_utils.h"
|
#include "tensorflow/core/kernels/conv_grad_shape_utils.h"
|
||||||
#include "tensorflow/core/util/padding.h"
|
#include "tensorflow/core/util/padding.h"
|
||||||
#include "tensorflow/core/util/tensor_format.h"
|
#include "tensorflow/core/util/tensor_format.h"
|
||||||
|
@ -29,10 +29,10 @@ limitations under the License.
|
|||||||
#include "tensorflow/compiler/xla/literal_util.h"
|
#include "tensorflow/compiler/xla/literal_util.h"
|
||||||
#include "tensorflow/compiler/xla/util.h"
|
#include "tensorflow/compiler/xla/util.h"
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/node_def_util.h"
|
#include "tensorflow/core/framework/node_def_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/ops_util.h"
|
|
||||||
#include "tensorflow/core/framework/tensor.h"
|
#include "tensorflow/core/framework/tensor.h"
|
||||||
#include "tensorflow/core/framework/tensor_shape.h"
|
#include "tensorflow/core/framework/tensor_shape.h"
|
||||||
#include "tensorflow/core/framework/tensor_slice.h"
|
#include "tensorflow/core/framework/tensor_slice.h"
|
||||||
|
@ -23,6 +23,7 @@ limitations under the License.
|
|||||||
#include "tensorflow/compiler/xla/client/xla_builder.h"
|
#include "tensorflow/compiler/xla/client/xla_builder.h"
|
||||||
#include "tensorflow/compiler/xla/shape_util.h"
|
#include "tensorflow/compiler/xla/shape_util.h"
|
||||||
#include "tensorflow/compiler/xla/util.h"
|
#include "tensorflow/compiler/xla/util.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/types.pb.h"
|
#include "tensorflow/core/framework/types.pb.h"
|
||||||
#include "tensorflow/core/util/tensor_format.h"
|
#include "tensorflow/core/util/tensor_format.h"
|
||||||
|
|
||||||
|
@ -469,6 +469,7 @@ tf_cuda_library(
|
|||||||
"//tensorflow/core/framework:graph_to_functiondef.h",
|
"//tensorflow/core/framework:graph_to_functiondef.h",
|
||||||
"//tensorflow/core/framework:kernel_def_builder.h",
|
"//tensorflow/core/framework:kernel_def_builder.h",
|
||||||
"//tensorflow/core/framework:kernel_def_util.h",
|
"//tensorflow/core/framework:kernel_def_util.h",
|
||||||
|
"//tensorflow/core/framework:kernel_shape_util.h",
|
||||||
"//tensorflow/core/framework:log_memory.h",
|
"//tensorflow/core/framework:log_memory.h",
|
||||||
"//tensorflow/core/framework:logging.h",
|
"//tensorflow/core/framework:logging.h",
|
||||||
"//tensorflow/core/framework:lookup_interface.h",
|
"//tensorflow/core/framework:lookup_interface.h",
|
||||||
@ -2351,6 +2352,7 @@ tf_cuda_library(
|
|||||||
"//tensorflow/core/framework:attr_value_util",
|
"//tensorflow/core/framework:attr_value_util",
|
||||||
"//tensorflow/core/framework:bfloat16",
|
"//tensorflow/core/framework:bfloat16",
|
||||||
"//tensorflow/core/framework:common_shape_fns",
|
"//tensorflow/core/framework:common_shape_fns",
|
||||||
|
"//tensorflow/core/framework:kernel_shape_util",
|
||||||
"//tensorflow/core/framework:node_def_util",
|
"//tensorflow/core/framework:node_def_util",
|
||||||
"//tensorflow/core/framework:node_properties",
|
"//tensorflow/core/framework:node_properties",
|
||||||
"//tensorflow/core/framework:numeric_types",
|
"//tensorflow/core/framework:numeric_types",
|
||||||
|
@ -129,6 +129,7 @@ exports_files(
|
|||||||
[
|
[
|
||||||
"attr_value_util.h",
|
"attr_value_util.h",
|
||||||
"common_shape_fns.h",
|
"common_shape_fns.h",
|
||||||
|
"kernel_shape_util.h",
|
||||||
"node_def_util.h",
|
"node_def_util.h",
|
||||||
"node_properties.h",
|
"node_properties.h",
|
||||||
"op.h",
|
"op.h",
|
||||||
@ -166,6 +167,7 @@ filegroup(
|
|||||||
"graph_to_functiondef.h",
|
"graph_to_functiondef.h",
|
||||||
"kernel_def_builder.h",
|
"kernel_def_builder.h",
|
||||||
"kernel_def_util.h",
|
"kernel_def_util.h",
|
||||||
|
"kernel_shape_util.h",
|
||||||
"local_rendezvous.h",
|
"local_rendezvous.h",
|
||||||
"log_memory.h",
|
"log_memory.h",
|
||||||
"logging.h",
|
"logging.h",
|
||||||
@ -269,6 +271,8 @@ filegroup(
|
|||||||
"bfloat16.h",
|
"bfloat16.h",
|
||||||
"bounds_check.h",
|
"bounds_check.h",
|
||||||
"cpu_allocator_impl.cc",
|
"cpu_allocator_impl.cc",
|
||||||
|
"kernel_shape_util.cc",
|
||||||
|
"kernel_shape_util.h",
|
||||||
"log_memory.cc",
|
"log_memory.cc",
|
||||||
"log_memory.h",
|
"log_memory.h",
|
||||||
"numeric_types.h",
|
"numeric_types.h",
|
||||||
@ -775,6 +779,19 @@ cc_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "kernel_shape_util",
|
||||||
|
srcs = ["kernel_shape_util.cc"],
|
||||||
|
hdrs = ["kernel_shape_util.h"],
|
||||||
|
deps = [
|
||||||
|
":tensor",
|
||||||
|
":tensor_shape",
|
||||||
|
"//tensorflow/core/lib/core:errors",
|
||||||
|
"//tensorflow/core/platform:status",
|
||||||
|
"//tensorflow/core/util:padding",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "common_shape_fns",
|
name = "common_shape_fns",
|
||||||
srcs = ["common_shape_fns.cc"],
|
srcs = ["common_shape_fns.cc"],
|
||||||
|
@ -27,118 +27,6 @@ limitations under the License.
|
|||||||
|
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
|
|
||||||
Status GetWindowedOutputSizeVerboseV2(int64 input_size, int64 filter_size,
|
|
||||||
int64 dilation_rate, int64 stride,
|
|
||||||
Padding padding_type, int64* output_size,
|
|
||||||
int64* padding_before,
|
|
||||||
int64* padding_after) {
|
|
||||||
if (stride <= 0) {
|
|
||||||
return errors::InvalidArgument("Stride must be > 0, but got ", stride);
|
|
||||||
}
|
|
||||||
if (dilation_rate < 1) {
|
|
||||||
return errors::InvalidArgument("Dilation rate must be >= 1, but got ",
|
|
||||||
dilation_rate);
|
|
||||||
}
|
|
||||||
|
|
||||||
// See also the parallel implementation in GetWindowedOutputSizeFromDimsV2.
|
|
||||||
int64 effective_filter_size = (filter_size - 1) * dilation_rate + 1;
|
|
||||||
switch (padding_type) {
|
|
||||||
case Padding::VALID:
|
|
||||||
*output_size = (input_size - effective_filter_size + stride) / stride;
|
|
||||||
*padding_before = *padding_after = 0;
|
|
||||||
break;
|
|
||||||
case Padding::EXPLICIT:
|
|
||||||
*output_size = (input_size + *padding_before + *padding_after -
|
|
||||||
effective_filter_size + stride) /
|
|
||||||
stride;
|
|
||||||
break;
|
|
||||||
case Padding::SAME:
|
|
||||||
*output_size = (input_size + stride - 1) / stride;
|
|
||||||
const int64 padding_needed =
|
|
||||||
std::max(int64{0}, (*output_size - 1) * stride +
|
|
||||||
effective_filter_size - input_size);
|
|
||||||
// For odd values of total padding, add more padding at the 'right'
|
|
||||||
// side of the given dimension.
|
|
||||||
*padding_before = padding_needed / 2;
|
|
||||||
*padding_after = padding_needed - *padding_before;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (*output_size < 0) {
|
|
||||||
return errors::InvalidArgument(
|
|
||||||
"Computed output size would be negative: ", *output_size,
|
|
||||||
" [input_size: ", input_size,
|
|
||||||
", effective_filter_size: ", effective_filter_size,
|
|
||||||
", stride: ", stride, "]");
|
|
||||||
}
|
|
||||||
return Status::OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
Status GetWindowedOutputSizeVerbose(int64 input_size, int64 filter_size,
|
|
||||||
int64 stride, Padding padding_type,
|
|
||||||
int64* output_size, int64* padding_before,
|
|
||||||
int64* padding_after) {
|
|
||||||
return GetWindowedOutputSizeVerboseV2(input_size, filter_size,
|
|
||||||
/*dilation_rate=*/1, stride,
|
|
||||||
padding_type, output_size,
|
|
||||||
padding_before, padding_after);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status GetWindowedOutputSize(int64 input_size, int64 filter_size, int64 stride,
|
|
||||||
Padding padding_type, int64* output_size,
|
|
||||||
int64* padding_size) {
|
|
||||||
if (padding_type == Padding::EXPLICIT) {
|
|
||||||
return errors::Internal(
|
|
||||||
"GetWindowedOutputSize does not handle EXPLICIT padding; call "
|
|
||||||
"GetWindowedOutputSizeVerbose instead");
|
|
||||||
}
|
|
||||||
int64 padding_after_unused;
|
|
||||||
return GetWindowedOutputSizeVerbose(input_size, filter_size, stride,
|
|
||||||
padding_type, output_size, padding_size,
|
|
||||||
&padding_after_unused);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status GetWindowedOutputSizeV2(int64 input_size, int64 filter_size,
|
|
||||||
int64 dilation_rate, int64 stride,
|
|
||||||
Padding padding_type, int64* output_size,
|
|
||||||
int64* padding_size) {
|
|
||||||
if (padding_type == Padding::EXPLICIT) {
|
|
||||||
return errors::Internal(
|
|
||||||
"GetWindowedOutputSizeV2 does not handle EXPLICIT padding; call "
|
|
||||||
"GetWindowedOutputSizeVerboseV2 instead");
|
|
||||||
}
|
|
||||||
int64 padding_after_unused;
|
|
||||||
return GetWindowedOutputSizeVerboseV2(input_size, filter_size, dilation_rate,
|
|
||||||
stride, padding_type, output_size,
|
|
||||||
padding_size, &padding_after_unused);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status Get3dOutputSize(const std::array<int64, 3>& input,
|
|
||||||
const std::array<int64, 3>& window,
|
|
||||||
const std::array<int64, 3>& strides,
|
|
||||||
Padding padding_type, std::array<int64, 3>* output_ptr,
|
|
||||||
std::array<int64, 3>* padding_ptr) {
|
|
||||||
for (size_t i = 0; i < input.size(); ++i) {
|
|
||||||
TF_RETURN_IF_ERROR(GetWindowedOutputSize(input[i], window[i], strides[i],
|
|
||||||
padding_type, &(*output_ptr)[i],
|
|
||||||
&(*padding_ptr)[i]));
|
|
||||||
}
|
|
||||||
return Status::OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
Status Get3dOutputSizeV2(const std::array<int64, 3>& input,
|
|
||||||
const std::array<int64, 3>& window,
|
|
||||||
const std::array<int64, 3>& dilations,
|
|
||||||
const std::array<int64, 3>& strides,
|
|
||||||
Padding padding_type, std::array<int64, 3>* output_ptr,
|
|
||||||
std::array<int64, 3>* padding_ptr) {
|
|
||||||
for (size_t i = 0; i < input.size(); ++i) {
|
|
||||||
TF_RETURN_IF_ERROR(GetWindowedOutputSizeV2(
|
|
||||||
input[i], window[i], dilations[i], strides[i], padding_type,
|
|
||||||
&(*output_ptr)[i], &(*padding_ptr)[i]));
|
|
||||||
}
|
|
||||||
return Status::OK();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace shape_inference {
|
namespace shape_inference {
|
||||||
|
|
||||||
// The V2 version computes windowed output size with arbitrary dilation_rate,
|
// The V2 version computes windowed output size with arbitrary dilation_rate,
|
||||||
|
@ -23,129 +23,6 @@ limitations under the License.
|
|||||||
|
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
|
|
||||||
// GetWindowedOutputSize(): Given an input tensor, kernel, stride and padding
|
|
||||||
// type, the function computes the output and padding dimensions.
|
|
||||||
//
|
|
||||||
// For example, ignoring batches or multiple features, a 1D convolution
|
|
||||||
// takes as input a 1D tensor of shape (H), and convolves it with a filter of
|
|
||||||
// shape (K).
|
|
||||||
//
|
|
||||||
// It also takes in a few additional parameters:
|
|
||||||
//
|
|
||||||
// Stride (S): the stride with which we apply the filters. This is the offset
|
|
||||||
// between locations where we apply the filters. A larger stride
|
|
||||||
// means that the output will be spatially smaller.
|
|
||||||
//
|
|
||||||
// Padding (P): the padding we apply to the input tensor along each
|
|
||||||
// dimension. This is usually used to make sure that the spatial dimensions
|
|
||||||
// do not shrink when we progress with convolutions. This function supports two
|
|
||||||
// types of padding.
|
|
||||||
// SAME: the pad value is computed so that the output will have size H/S.
|
|
||||||
// VALID: no padding is carried out.
|
|
||||||
// If you want to use EXPLICIT padding, GetWindowedOutputSizeVerbose must be
|
|
||||||
// called instead. Note the padded area is zero-filled.
|
|
||||||
//
|
|
||||||
// The output dimensions for convolution and many other operations, when given
|
|
||||||
// all the parameters above, are as follows:
|
|
||||||
// - When Padding = SAME: the output size is (H'), where
|
|
||||||
// H' = ceil(float(H) / float(S))
|
|
||||||
// where ceil is the ceiling function. The number of padded cells
|
|
||||||
// is computed as:
|
|
||||||
// Pc = ((H' - 1) * S + K - H) / 2
|
|
||||||
// When the stride is 1, the expression simplifies to
|
|
||||||
// H' = H, Pc = (K-1)/2.
|
|
||||||
// This is where SAME comes from - the output has the same size as the input
|
|
||||||
// has.
|
|
||||||
//
|
|
||||||
// - When Padding = VALID: the output size is computed as
|
|
||||||
// H' = ceil(float(H - K + 1) / float(S))
|
|
||||||
// and the number of padded cells is always zero.
|
|
||||||
// When the stride is 1, the expression simplifies to
|
|
||||||
// H' = H-K+1.
|
|
||||||
//
|
|
||||||
// For convolution, mathematically, the output value at location (r')
|
|
||||||
// is the inner product of two vectors: the chunk of input at
|
|
||||||
// ((r'*S-Pr) : (r'*S-Pr+K)),
|
|
||||||
// and the filter.
|
|
||||||
//
|
|
||||||
// For 2D and 3D convolutions, the spatial dimensions are orthogonal, so the
|
|
||||||
// size and padding of each spatial dimension can be computed by calling
|
|
||||||
// GetWindowedOutputSize separately for each dimension.
|
|
||||||
//
|
|
||||||
Status GetWindowedOutputSize(int64 input_size, int64 filter_size, int64 stride,
|
|
||||||
Padding padding_type, int64* output_size,
|
|
||||||
int64* padding_size);
|
|
||||||
|
|
||||||
// The V2 version computes the same outputs with arbitrary dilation_rate.
|
|
||||||
// The output dimensions are computed as follows:
|
|
||||||
// - When adding dilation_rate (D), we compute an effective filter size (K'):
|
|
||||||
// K' = (K - 1) * D + 1
|
|
||||||
// - When Padding = SAME: the output size is (H'), where
|
|
||||||
// H' = ceil(float(H) / float(S))
|
|
||||||
// where ceil is the ceiling function. The number of padded cells
|
|
||||||
// is computed as:
|
|
||||||
// Pc = ((H' - 1) * S + K' - H) / 2
|
|
||||||
// When the stride is 1, the expression simplifies to
|
|
||||||
// H' = H, Pc = (K'-1)/2.
|
|
||||||
// This is where SAME comes from - the output has the same size as the input
|
|
||||||
// has.
|
|
||||||
//
|
|
||||||
// - When Padding = VALID: the output size is computed as
|
|
||||||
// H' = ceil(float(H - K' + 1) / float(S))
|
|
||||||
// and the number of padded cells is always zero.
|
|
||||||
// When the stride is 1, the expression simplifies to
|
|
||||||
// H' = H-K'+1.
|
|
||||||
//
|
|
||||||
// If you want to use EXPLICIT padding, GetWindowedOutputSizeVerboseV2 must be
|
|
||||||
// called instead
|
|
||||||
//
|
|
||||||
// TODO(b/67112639): Merge V2 versions and the original versions eventually.
|
|
||||||
Status GetWindowedOutputSizeV2(int64 input_size, int64 filter_size,
|
|
||||||
int64 dilation_rate, int64 stride,
|
|
||||||
Padding padding_type, int64* output_size,
|
|
||||||
int64* padding_size);
|
|
||||||
|
|
||||||
// Returns the same output dimensions as in GetWindowedOutputSize, but returns
|
|
||||||
// verbose padding dimensions (before/after), and EXPLICIT padding is supported.
|
|
||||||
// When padding_type is EXPLICIT, *padding_before and *padding_after must
|
|
||||||
// already point to initialized integers with the padding amounts. Otherwise,
|
|
||||||
// *padding_before and *padding_after are set by this function, and any
|
|
||||||
// excess padding (caused by an odd padding size value) is added to the
|
|
||||||
// 'padding_after' dimension.
|
|
||||||
Status GetWindowedOutputSizeVerbose(int64 input_size, int64 filter_size,
|
|
||||||
int64 stride, Padding padding_type,
|
|
||||||
int64* output_size, int64* padding_before,
|
|
||||||
int64* padding_after);
|
|
||||||
|
|
||||||
// The V2 version computes the same outputs with arbitrary dilation_rate. For
|
|
||||||
// detailed equations, refer to the comments for GetWindowedOutputSizeV2().
|
|
||||||
Status GetWindowedOutputSizeVerboseV2(int64 input_size, int64 filter_size,
|
|
||||||
int64 dilation_rate, int64 stride,
|
|
||||||
Padding padding_type, int64* output_size,
|
|
||||||
int64* padding_before,
|
|
||||||
int64* padding_after);
|
|
||||||
|
|
||||||
// Given an input tensor, kernel, stride and padding type, populates the 3D size
|
|
||||||
// of the output tensor and padding to be applied to the input tensor at the
|
|
||||||
// lower end of every dimension. Use for 3D convolutions, where the input data
|
|
||||||
// is padded with zeros, as well as for 3D avg/max pooling, where the input data
|
|
||||||
// is padded with invalid values that are not considered for pooling. EXPLICIT
|
|
||||||
// padding is not supported.
|
|
||||||
Status Get3dOutputSize(const std::array<int64, 3>& input,
|
|
||||||
const std::array<int64, 3>& window,
|
|
||||||
const std::array<int64, 3>& strides,
|
|
||||||
Padding padding_type, std::array<int64, 3>* output_ptr,
|
|
||||||
std::array<int64, 3>* padding_ptr);
|
|
||||||
|
|
||||||
// The V2 version computes the same outputs with arbitrary dilation_rate. For
|
|
||||||
// detailed equations, refer to the comments for GetWindowedOutputSizeV2().
|
|
||||||
Status Get3dOutputSizeV2(const std::array<int64, 3>& input,
|
|
||||||
const std::array<int64, 3>& window,
|
|
||||||
const std::array<int64, 3>& dilations,
|
|
||||||
const std::array<int64, 3>& strides,
|
|
||||||
Padding padding_type, std::array<int64, 3>* output_ptr,
|
|
||||||
std::array<int64, 3>* padding_ptr);
|
|
||||||
|
|
||||||
namespace shape_inference {
|
namespace shape_inference {
|
||||||
|
|
||||||
// Like GetWindowedOutputSize, but deals with DimensionHandles. Does not support
|
// Like GetWindowedOutputSize, but deals with DimensionHandles. Does not support
|
||||||
|
131
tensorflow/core/framework/kernel_shape_util.cc
Normal file
131
tensorflow/core/framework/kernel_shape_util.cc
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
==============================================================================*/
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
|
|
||||||
|
#include "tensorflow/core/lib/core/errors.h"
|
||||||
|
|
||||||
|
namespace tensorflow {
|
||||||
|
Status GetWindowedOutputSizeVerboseV2(int64 input_size, int64 filter_size,
|
||||||
|
int64 dilation_rate, int64 stride,
|
||||||
|
Padding padding_type, int64* output_size,
|
||||||
|
int64* padding_before,
|
||||||
|
int64* padding_after) {
|
||||||
|
if (stride <= 0) {
|
||||||
|
return errors::InvalidArgument("Stride must be > 0, but got ", stride);
|
||||||
|
}
|
||||||
|
if (dilation_rate < 1) {
|
||||||
|
return errors::InvalidArgument("Dilation rate must be >= 1, but got ",
|
||||||
|
dilation_rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// See also the parallel implementation in GetWindowedOutputSizeFromDimsV2.
|
||||||
|
int64 effective_filter_size = (filter_size - 1) * dilation_rate + 1;
|
||||||
|
switch (padding_type) {
|
||||||
|
case Padding::VALID:
|
||||||
|
*output_size = (input_size - effective_filter_size + stride) / stride;
|
||||||
|
*padding_before = *padding_after = 0;
|
||||||
|
break;
|
||||||
|
case Padding::EXPLICIT:
|
||||||
|
*output_size = (input_size + *padding_before + *padding_after -
|
||||||
|
effective_filter_size + stride) /
|
||||||
|
stride;
|
||||||
|
break;
|
||||||
|
case Padding::SAME:
|
||||||
|
*output_size = (input_size + stride - 1) / stride;
|
||||||
|
const int64 padding_needed =
|
||||||
|
std::max(int64{0}, (*output_size - 1) * stride +
|
||||||
|
effective_filter_size - input_size);
|
||||||
|
// For odd values of total padding, add more padding at the 'right'
|
||||||
|
// side of the given dimension.
|
||||||
|
*padding_before = padding_needed / 2;
|
||||||
|
*padding_after = padding_needed - *padding_before;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*output_size < 0) {
|
||||||
|
return errors::InvalidArgument(
|
||||||
|
"Computed output size would be negative: ", *output_size,
|
||||||
|
" [input_size: ", input_size,
|
||||||
|
", effective_filter_size: ", effective_filter_size,
|
||||||
|
", stride: ", stride, "]");
|
||||||
|
}
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
Status GetWindowedOutputSizeVerbose(int64 input_size, int64 filter_size,
|
||||||
|
int64 stride, Padding padding_type,
|
||||||
|
int64* output_size, int64* padding_before,
|
||||||
|
int64* padding_after) {
|
||||||
|
return GetWindowedOutputSizeVerboseV2(input_size, filter_size,
|
||||||
|
/*dilation_rate=*/1, stride,
|
||||||
|
padding_type, output_size,
|
||||||
|
padding_before, padding_after);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status GetWindowedOutputSize(int64 input_size, int64 filter_size, int64 stride,
|
||||||
|
Padding padding_type, int64* output_size,
|
||||||
|
int64* padding_size) {
|
||||||
|
if (padding_type == Padding::EXPLICIT) {
|
||||||
|
return errors::Internal(
|
||||||
|
"GetWindowedOutputSize does not handle EXPLICIT padding; call "
|
||||||
|
"GetWindowedOutputSizeVerbose instead");
|
||||||
|
}
|
||||||
|
int64 padding_after_unused;
|
||||||
|
return GetWindowedOutputSizeVerbose(input_size, filter_size, stride,
|
||||||
|
padding_type, output_size, padding_size,
|
||||||
|
&padding_after_unused);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status GetWindowedOutputSizeV2(int64 input_size, int64 filter_size,
|
||||||
|
int64 dilation_rate, int64 stride,
|
||||||
|
Padding padding_type, int64* output_size,
|
||||||
|
int64* padding_size) {
|
||||||
|
if (padding_type == Padding::EXPLICIT) {
|
||||||
|
return errors::Internal(
|
||||||
|
"GetWindowedOutputSizeV2 does not handle EXPLICIT padding; call "
|
||||||
|
"GetWindowedOutputSizeVerboseV2 instead");
|
||||||
|
}
|
||||||
|
int64 padding_after_unused;
|
||||||
|
return GetWindowedOutputSizeVerboseV2(input_size, filter_size, dilation_rate,
|
||||||
|
stride, padding_type, output_size,
|
||||||
|
padding_size, &padding_after_unused);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status Get3dOutputSize(const std::array<int64, 3>& input,
|
||||||
|
const std::array<int64, 3>& window,
|
||||||
|
const std::array<int64, 3>& strides,
|
||||||
|
Padding padding_type, std::array<int64, 3>* output_ptr,
|
||||||
|
std::array<int64, 3>* padding_ptr) {
|
||||||
|
for (size_t i = 0; i < input.size(); ++i) {
|
||||||
|
TF_RETURN_IF_ERROR(GetWindowedOutputSize(input[i], window[i], strides[i],
|
||||||
|
padding_type, &(*output_ptr)[i],
|
||||||
|
&(*padding_ptr)[i]));
|
||||||
|
}
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
Status Get3dOutputSizeV2(const std::array<int64, 3>& input,
|
||||||
|
const std::array<int64, 3>& window,
|
||||||
|
const std::array<int64, 3>& dilations,
|
||||||
|
const std::array<int64, 3>& strides,
|
||||||
|
Padding padding_type, std::array<int64, 3>* output_ptr,
|
||||||
|
std::array<int64, 3>* padding_ptr) {
|
||||||
|
for (size_t i = 0; i < input.size(); ++i) {
|
||||||
|
TF_RETURN_IF_ERROR(GetWindowedOutputSizeV2(
|
||||||
|
input[i], window[i], dilations[i], strides[i], padding_type,
|
||||||
|
&(*output_ptr)[i], &(*padding_ptr)[i]));
|
||||||
|
}
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
|
} // namespace tensorflow
|
149
tensorflow/core/framework/kernel_shape_util.h
Normal file
149
tensorflow/core/framework/kernel_shape_util.h
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#ifndef TENSORFLOW_CORE_FRAMEWORK_KERNEL_SHAPE_UTIL_H_
|
||||||
|
#define TENSORFLOW_CORE_FRAMEWORK_KERNEL_SHAPE_UTIL_H_
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "tensorflow/core/platform/status.h"
|
||||||
|
#include "tensorflow/core/util/padding.h"
|
||||||
|
|
||||||
|
namespace tensorflow {
|
||||||
|
// GetWindowedOutputSize(): Given an input tensor, kernel, stride and padding
|
||||||
|
// type, the function computes the output and padding dimensions.
|
||||||
|
//
|
||||||
|
// For example, ignoring batches or multiple features, a 1D convolution
|
||||||
|
// takes as input a 1D tensor of shape (H), and convolves it with a filter of
|
||||||
|
// shape (K).
|
||||||
|
//
|
||||||
|
// It also takes in a few additional parameters:
|
||||||
|
//
|
||||||
|
// Stride (S): the stride with which we apply the filters. This is the offset
|
||||||
|
// between locations where we apply the filters. A larger stride
|
||||||
|
// means that the output will be spatially smaller.
|
||||||
|
//
|
||||||
|
// Padding (P): the padding we apply to the input tensor along each
|
||||||
|
// dimension. This is usually used to make sure that the spatial dimensions
|
||||||
|
// do not shrink when we progress with convolutions. This function supports two
|
||||||
|
// types of padding.
|
||||||
|
// SAME: the pad value is computed so that the output will have size H/S.
|
||||||
|
// VALID: no padding is carried out.
|
||||||
|
// If you want to use EXPLICIT padding, GetWindowedOutputSizeVerbose must be
|
||||||
|
// called instead. Note the padded area is zero-filled.
|
||||||
|
//
|
||||||
|
// The output dimensions for convolution and many other operations, when given
|
||||||
|
// all the parameters above, are as follows:
|
||||||
|
// - When Padding = SAME: the output size is (H'), where
|
||||||
|
// H' = ceil(float(H) / float(S))
|
||||||
|
// where ceil is the ceiling function. The number of padded cells
|
||||||
|
// is computed as:
|
||||||
|
// Pc = ((H' - 1) * S + K - H) / 2
|
||||||
|
// When the stride is 1, the expression simplifies to
|
||||||
|
// H' = H, Pc = (K-1)/2.
|
||||||
|
// This is where SAME comes from - the output has the same size as the input
|
||||||
|
// has.
|
||||||
|
//
|
||||||
|
// - When Padding = VALID: the output size is computed as
|
||||||
|
// H' = ceil(float(H - K + 1) / float(S))
|
||||||
|
// and the number of padded cells is always zero.
|
||||||
|
// When the stride is 1, the expression simplifies to
|
||||||
|
// H' = H-K+1.
|
||||||
|
//
|
||||||
|
// For convolution, mathematically, the output value at location (r')
|
||||||
|
// is the inner product of two vectors: the chunk of input at
|
||||||
|
// ((r'*S-Pr) : (r'*S-Pr+K)),
|
||||||
|
// and the filter.
|
||||||
|
//
|
||||||
|
// For 2D and 3D convolutions, the spatial dimensions are orthogonal, so the
|
||||||
|
// size and padding of each spatial dimension can be computed by calling
|
||||||
|
// GetWindowedOutputSize separately for each dimension.
|
||||||
|
//
|
||||||
|
Status GetWindowedOutputSize(int64 input_size, int64 filter_size, int64 stride,
|
||||||
|
Padding padding_type, int64* output_size,
|
||||||
|
int64* padding_size);
|
||||||
|
|
||||||
|
// The V2 version computes the same outputs with arbitrary dilation_rate.
|
||||||
|
// The output dimensions are computed as follows:
|
||||||
|
// - When adding dilation_rate (D), we compute an effective filter size (K'):
|
||||||
|
// K' = (K - 1) * D + 1
|
||||||
|
// - When Padding = SAME: the output size is (H'), where
|
||||||
|
// H' = ceil(float(H) / float(S))
|
||||||
|
// where ceil is the ceiling function. The number of padded cells
|
||||||
|
// is computed as:
|
||||||
|
// Pc = ((H' - 1) * S + K' - H) / 2
|
||||||
|
// When the stride is 1, the expression simplifies to
|
||||||
|
// H' = H, Pc = (K'-1)/2.
|
||||||
|
// This is where SAME comes from - the output has the same size as the input
|
||||||
|
// has.
|
||||||
|
//
|
||||||
|
// - When Padding = VALID: the output size is computed as
|
||||||
|
// H' = ceil(float(H - K' + 1) / float(S))
|
||||||
|
// and the number of padded cells is always zero.
|
||||||
|
// When the stride is 1, the expression simplifies to
|
||||||
|
// H' = H-K'+1.
|
||||||
|
//
|
||||||
|
// If you want to use EXPLICIT padding, GetWindowedOutputSizeVerboseV2 must be
|
||||||
|
// called instead
|
||||||
|
//
|
||||||
|
// TODO(b/67112639): Merge V2 versions and the original versions eventually.
|
||||||
|
Status GetWindowedOutputSizeV2(int64 input_size, int64 filter_size,
|
||||||
|
int64 dilation_rate, int64 stride,
|
||||||
|
Padding padding_type, int64* output_size,
|
||||||
|
int64* padding_size);
|
||||||
|
|
||||||
|
// Returns the same output dimensions as in GetWindowedOutputSize, but returns
|
||||||
|
// verbose padding dimensions (before/after), and EXPLICIT padding is supported.
|
||||||
|
// When padding_type is EXPLICIT, *padding_before and *padding_after must
|
||||||
|
// already point to initialized integers with the padding amounts. Otherwise,
|
||||||
|
// *padding_before and *padding_after are set by this function, and any
|
||||||
|
// excess padding (caused by an odd padding size value) is added to the
|
||||||
|
// 'padding_after' dimension.
|
||||||
|
Status GetWindowedOutputSizeVerbose(int64 input_size, int64 filter_size,
|
||||||
|
int64 stride, Padding padding_type,
|
||||||
|
int64* output_size, int64* padding_before,
|
||||||
|
int64* padding_after);
|
||||||
|
|
||||||
|
// The V2 version computes the same outputs with arbitrary dilation_rate. For
|
||||||
|
// detailed equations, refer to the comments for GetWindowedOutputSizeV2().
|
||||||
|
Status GetWindowedOutputSizeVerboseV2(int64 input_size, int64 filter_size,
|
||||||
|
int64 dilation_rate, int64 stride,
|
||||||
|
Padding padding_type, int64* output_size,
|
||||||
|
int64* padding_before,
|
||||||
|
int64* padding_after);
|
||||||
|
|
||||||
|
// Given an input tensor, kernel, stride and padding type, populates the 3D size
|
||||||
|
// of the output tensor and padding to be applied to the input tensor at the
|
||||||
|
// lower end of every dimension. Use for 3D convolutions, where the input data
|
||||||
|
// is padded with zeros, as well as for 3D avg/max pooling, where the input data
|
||||||
|
// is padded with invalid values that are not considered for pooling. EXPLICIT
|
||||||
|
// padding is not supported.
|
||||||
|
Status Get3dOutputSize(const std::array<int64, 3>& input,
|
||||||
|
const std::array<int64, 3>& window,
|
||||||
|
const std::array<int64, 3>& strides,
|
||||||
|
Padding padding_type, std::array<int64, 3>* output_ptr,
|
||||||
|
std::array<int64, 3>* padding_ptr);
|
||||||
|
|
||||||
|
// The V2 version computes the same outputs with arbitrary dilation_rate. For
|
||||||
|
// detailed equations, refer to the comments for GetWindowedOutputSizeV2().
|
||||||
|
Status Get3dOutputSizeV2(const std::array<int64, 3>& input,
|
||||||
|
const std::array<int64, 3>& window,
|
||||||
|
const std::array<int64, 3>& dilations,
|
||||||
|
const std::array<int64, 3>& strides,
|
||||||
|
Padding padding_type, std::array<int64, 3>* output_ptr,
|
||||||
|
std::array<int64, 3>* padding_ptr);
|
||||||
|
|
||||||
|
} // namespace tensorflow
|
||||||
|
#endif // TENSORFLOW_CORE_FRAMEWORK_KERNEL_SHAPE_UTIL_H_
|
@ -21,7 +21,6 @@ limitations under the License.
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
|
||||||
#include "tensorflow/core/framework/tensor_shape.h"
|
#include "tensorflow/core/framework/tensor_shape.h"
|
||||||
#include "tensorflow/core/framework/tensor_types.h"
|
#include "tensorflow/core/framework/tensor_types.h"
|
||||||
#include "tensorflow/core/lib/core/status.h"
|
#include "tensorflow/core/lib/core/status.h"
|
||||||
|
@ -14,8 +14,10 @@ limitations under the License.
|
|||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
#include "tensorflow/core/grappler/optimizers/layout_optimizer.h"
|
#include "tensorflow/core/grappler/optimizers/layout_optimizer.h"
|
||||||
|
|
||||||
#include "tensorflow/cc/ops/standard_ops.h"
|
#include "tensorflow/cc/ops/standard_ops.h"
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
#include "tensorflow/core/framework/common_shape_fns.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/node_def.pb.h"
|
#include "tensorflow/core/framework/node_def.pb.h"
|
||||||
#include "tensorflow/core/framework/tensor_testutil.h"
|
#include "tensorflow/core/framework/tensor_testutil.h"
|
||||||
#include "tensorflow/core/grappler/clusters/single_machine.h"
|
#include "tensorflow/core/grappler/clusters/single_machine.h"
|
||||||
|
@ -20,7 +20,9 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/kernels/avgpooling_op.h"
|
#include "tensorflow/core/kernels/avgpooling_op.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
|
@ -21,6 +21,7 @@ limitations under the License.
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
@ -34,7 +35,6 @@ limitations under the License.
|
|||||||
#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
|
#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
|
||||||
#include "tensorflow/core/kernels/xsmm_conv2d.h"
|
#include "tensorflow/core/kernels/xsmm_conv2d.h"
|
||||||
#endif
|
#endif
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/lib/core/errors.h"
|
#include "tensorflow/core/lib/core/errors.h"
|
||||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||||
#include "tensorflow/core/platform/logging.h"
|
#include "tensorflow/core/platform/logging.h"
|
||||||
|
@ -24,6 +24,7 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "absl/base/dynamic_annotations.h"
|
#include "absl/base/dynamic_annotations.h"
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
@ -36,7 +37,6 @@ limitations under the License.
|
|||||||
#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
|
#ifdef TENSORFLOW_USE_LIBXSMM_CONVOLUTIONS
|
||||||
#include "tensorflow/core/kernels/xsmm_conv2d.h"
|
#include "tensorflow/core/kernels/xsmm_conv2d.h"
|
||||||
#endif
|
#endif
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/lib/core/errors.h"
|
#include "tensorflow/core/lib/core/errors.h"
|
||||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||||
#include "tensorflow/core/platform/logging.h"
|
#include "tensorflow/core/platform/logging.h"
|
||||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
|||||||
#define USE_EIGEN_TENSOR
|
#define USE_EIGEN_TENSOR
|
||||||
#define EIGEN_USE_THREADS
|
#define EIGEN_USE_THREADS
|
||||||
|
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
@ -28,7 +29,6 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/kernels/conv_grad_ops.h"
|
#include "tensorflow/core/kernels/conv_grad_ops.h"
|
||||||
#include "tensorflow/core/kernels/conv_grad_shape_utils.h"
|
#include "tensorflow/core/kernels/conv_grad_shape_utils.h"
|
||||||
#include "tensorflow/core/kernels/conv_ops_gpu.h"
|
#include "tensorflow/core/kernels/conv_ops_gpu.h"
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/lib/core/errors.h"
|
#include "tensorflow/core/lib/core/errors.h"
|
||||||
#include "tensorflow/core/lib/gtl/inlined_vector.h"
|
#include "tensorflow/core/lib/gtl/inlined_vector.h"
|
||||||
#include "tensorflow/core/util/padding.h"
|
#include "tensorflow/core/util/padding.h"
|
||||||
|
@ -24,6 +24,7 @@ limitations under the License.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
#include "tensorflow/core/framework/common_shape_fns.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
#include "tensorflow/core/framework/tensor.h"
|
#include "tensorflow/core/framework/tensor.h"
|
||||||
|
@ -32,6 +32,7 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "tensorflow/core/framework/allocator.h"
|
#include "tensorflow/core/framework/allocator.h"
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
|||||||
#define USE_EIGEN_TENSOR
|
#define USE_EIGEN_TENSOR
|
||||||
#define EIGEN_USE_THREADS
|
#define EIGEN_USE_THREADS
|
||||||
|
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
|
@ -21,8 +21,9 @@ limitations under the License.
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
|
@ -47,10 +47,12 @@ limitations under the License.
|
|||||||
#define EIGEN_USE_THREADS
|
#define EIGEN_USE_THREADS
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
|
@ -19,6 +19,7 @@ limitations under the License.
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
@ -28,7 +29,6 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/framework/types.h"
|
#include "tensorflow/core/framework/types.h"
|
||||||
#include "tensorflow/core/kernels/conv_grad_ops.h"
|
#include "tensorflow/core/kernels/conv_grad_ops.h"
|
||||||
#include "tensorflow/core/kernels/depthwise_conv_op.h"
|
#include "tensorflow/core/kernels/depthwise_conv_op.h"
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/lib/core/status.h"
|
#include "tensorflow/core/lib/core/status.h"
|
||||||
#include "tensorflow/core/platform/logging.h"
|
#include "tensorflow/core/platform/logging.h"
|
||||||
#include "tensorflow/core/platform/types.h"
|
#include "tensorflow/core/platform/types.h"
|
||||||
|
@ -15,11 +15,14 @@ limitations under the License.
|
|||||||
|
|
||||||
#define EIGEN_USE_THREADS
|
#define EIGEN_USE_THREADS
|
||||||
|
|
||||||
|
#include "tensorflow/core/kernels/depthwise_conv_op.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
@ -28,8 +31,6 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/framework/tensor_types.h"
|
#include "tensorflow/core/framework/tensor_types.h"
|
||||||
#include "tensorflow/core/framework/types.h"
|
#include "tensorflow/core/framework/types.h"
|
||||||
#include "tensorflow/core/kernels/conv_ops.h"
|
#include "tensorflow/core/kernels/conv_ops.h"
|
||||||
#include "tensorflow/core/kernels/depthwise_conv_op.h"
|
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/lib/core/status.h"
|
#include "tensorflow/core/lib/core/status.h"
|
||||||
#include "tensorflow/core/platform/logging.h"
|
#include "tensorflow/core/platform/logging.h"
|
||||||
#include "tensorflow/core/platform/types.h"
|
#include "tensorflow/core/platform/types.h"
|
||||||
|
@ -17,20 +17,20 @@ limitations under the License.
|
|||||||
|
|
||||||
#define EIGEN_USE_THREADS
|
#define EIGEN_USE_THREADS
|
||||||
|
|
||||||
|
#include "tensorflow/core/kernels/dilation_ops.h"
|
||||||
|
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "tensorflow/core/kernels/dilation_ops.h"
|
|
||||||
|
|
||||||
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
||||||
#include "tensorflow/core/common_runtime/device.h"
|
#include "tensorflow/core/common_runtime/device.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
#include "tensorflow/core/framework/tensor.h"
|
#include "tensorflow/core/framework/tensor.h"
|
||||||
#include "tensorflow/core/framework/tensor_shape.h"
|
#include "tensorflow/core/framework/tensor_shape.h"
|
||||||
#include "tensorflow/core/framework/tensor_slice.h"
|
#include "tensorflow/core/framework/tensor_slice.h"
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/lib/core/errors.h"
|
#include "tensorflow/core/lib/core/errors.h"
|
||||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||||
#include "tensorflow/core/util/padding.h"
|
#include "tensorflow/core/util/padding.h"
|
||||||
|
@ -19,8 +19,11 @@ limitations under the License.
|
|||||||
#define EIGEN_USE_THREADS
|
#define EIGEN_USE_THREADS
|
||||||
|
|
||||||
#include "tensorflow/core/kernels/extract_image_patches_op.h"
|
#include "tensorflow/core/kernels/extract_image_patches_op.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
|
@ -25,8 +25,11 @@ when rates are to be added.
|
|||||||
#define EIGEN_USE_THREADS
|
#define EIGEN_USE_THREADS
|
||||||
|
|
||||||
#include "tensorflow/core/kernels/extract_volume_patches_op.h"
|
#include "tensorflow/core/kernels/extract_volume_patches_op.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
|
@ -22,7 +22,7 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "tensorflow/core/common_runtime/device.h"
|
#include "tensorflow/core/common_runtime/device.h"
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
|
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
using mkldnn::prop_kind;
|
using mkldnn::prop_kind;
|
||||||
|
@ -20,6 +20,7 @@ limitations under the License.
|
|||||||
#define GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK
|
#define GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK
|
||||||
#include "public/gemmlowp.h"
|
#include "public/gemmlowp.h"
|
||||||
#include "tensorflow/core/framework/bounds_check.h"
|
#include "tensorflow/core/framework/bounds_check.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
@ -28,7 +29,6 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/framework/tensor_types.h"
|
#include "tensorflow/core/framework/tensor_types.h"
|
||||||
#include "tensorflow/core/framework/types.h"
|
#include "tensorflow/core/framework/types.h"
|
||||||
#include "tensorflow/core/kernels/neon/depthwiseconv_float.h"
|
#include "tensorflow/core/kernels/neon/depthwiseconv_float.h"
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/lib/core/status.h"
|
#include "tensorflow/core/lib/core/status.h"
|
||||||
#include "tensorflow/core/platform/logging.h"
|
#include "tensorflow/core/platform/logging.h"
|
||||||
#include "tensorflow/core/platform/mem.h"
|
#include "tensorflow/core/platform/mem.h"
|
||||||
|
@ -35,6 +35,7 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/framework/allocator.h"
|
#include "tensorflow/core/framework/allocator.h"
|
||||||
#include "tensorflow/core/framework/fake_input.h"
|
#include "tensorflow/core/framework/fake_input.h"
|
||||||
#include "tensorflow/core/framework/graph.pb.h"
|
#include "tensorflow/core/framework/graph.pb.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/node_def_builder.h"
|
#include "tensorflow/core/framework/node_def_builder.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/tensor.h"
|
#include "tensorflow/core/framework/tensor.h"
|
||||||
@ -44,7 +45,6 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/graph/graph_constructor.h"
|
#include "tensorflow/core/graph/graph_constructor.h"
|
||||||
#include "tensorflow/core/graph/graph_def_builder.h"
|
#include "tensorflow/core/graph/graph_def_builder.h"
|
||||||
#include "tensorflow/core/kernels/ops_testutil.h"
|
#include "tensorflow/core/kernels/ops_testutil.h"
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/lib/core/status_test_util.h"
|
#include "tensorflow/core/lib/core/status_test_util.h"
|
||||||
#include "tensorflow/core/lib/core/threadpool.h"
|
#include "tensorflow/core/lib/core/threadpool.h"
|
||||||
#include "tensorflow/core/platform/logging.h"
|
#include "tensorflow/core/platform/logging.h"
|
||||||
|
@ -14,7 +14,9 @@ limitations under the License.
|
|||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
#include "tensorflow/core/kernels/ops_util.h"
|
||||||
|
|
||||||
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/tensor.h"
|
#include "tensorflow/core/framework/tensor.h"
|
||||||
#include "tensorflow/core/platform/test.h"
|
#include "tensorflow/core/platform/test.h"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "third_party/eigen3/Eigen/Core"
|
#include "third_party/eigen3/Eigen/Core"
|
||||||
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "tensorflow/core/common_runtime/device.h"
|
#include "tensorflow/core/common_runtime/device.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/register_types.h"
|
#include "tensorflow/core/framework/register_types.h"
|
||||||
#include "tensorflow/core/framework/tensor.h"
|
#include "tensorflow/core/framework/tensor.h"
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ limitations under the License.
|
|||||||
|
|
||||||
#define GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK
|
#define GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK
|
||||||
#include "public/gemmlowp.h"
|
#include "public/gemmlowp.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/op_kernel.h"
|
#include "tensorflow/core/framework/op_kernel.h"
|
||||||
#include "tensorflow/core/framework/tensor.h"
|
#include "tensorflow/core/framework/tensor.h"
|
||||||
#include "tensorflow/core/kernels/conv_ops.h"
|
#include "tensorflow/core/kernels/conv_ops.h"
|
||||||
#include "tensorflow/core/kernels/meta_support.h"
|
#include "tensorflow/core/kernels/meta_support.h"
|
||||||
#include "tensorflow/core/kernels/ops_util.h"
|
|
||||||
#include "tensorflow/core/kernels/quantization_utils.h"
|
#include "tensorflow/core/kernels/quantization_utils.h"
|
||||||
#include "tensorflow/core/kernels/reference_gemm.h"
|
#include "tensorflow/core/kernels/reference_gemm.h"
|
||||||
#include "tensorflow/core/lib/core/errors.h"
|
#include "tensorflow/core/lib/core/errors.h"
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
#include "tensorflow/core/framework/common_shape_fns.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/op.h"
|
#include "tensorflow/core/framework/op.h"
|
||||||
#include "tensorflow/core/framework/shape_inference.h"
|
#include "tensorflow/core/framework/shape_inference.h"
|
||||||
#include "tensorflow/core/framework/tensor.pb.h"
|
#include "tensorflow/core/framework/tensor.pb.h"
|
||||||
|
@ -14,7 +14,9 @@ limitations under the License.
|
|||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "tensorflow/core/framework/common_shape_fns.h"
|
#include "tensorflow/core/framework/common_shape_fns.h"
|
||||||
|
#include "tensorflow/core/framework/kernel_shape_util.h"
|
||||||
#include "tensorflow/core/framework/numeric_op.h"
|
#include "tensorflow/core/framework/numeric_op.h"
|
||||||
#include "tensorflow/core/framework/op.h"
|
#include "tensorflow/core/framework/op.h"
|
||||||
#include "tensorflow/core/framework/shape_inference.h"
|
#include "tensorflow/core/framework/shape_inference.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user