tensorflow/core/kernels/deep_conv2d.cc
// Returns true if convolution can be computed efficiently by DeepConv2D,
// returns false otherwise.
// TODO(andydavis) Add support for other filter sizes and strides.
// TODO(andydavis) Add support for autotuning.
Returns true if convolution can be computed efficiently by DeepConv2D,
returns false otherwise.
TODO(andydavis) Add support for other filter sizes and strides.
TODO(andydavis) Add support for autotuning.
Returns true if convolution can be computed efficiently by DeepConv2D returns false otherwise . TODO ( andydavis ) Add support for other filter sizes and strides . TODO ( andydavis ) Add support for autotuning .
bool CanUseDeepConv2D(int stride_rows, int stride_cols, int filter_rows,
                      int filter_cols, int in_depth, int out_depth,
                      int out_rows, int out_cols) {
  if (stride_rows > 1 || stride_cols > 1 || filter_rows != 3 ||
      filter_cols != 3) {
    return false;
  }
  if (!ReadBoolFromEnvVar("TF_USE_DEEP_CONV2D", false)) {
    return false;
  }
  WinogradTransform<float> t;
  const int64_t deep_conv_cost = GetDeepConvCost(
      t.input_shape().rows, t.input_shape().cols, t.output_shape().rows,
      t.output_shape().cols, in_depth, out_depth, out_rows, out_cols);
  const int64_t direct_conv_cost = GetDirectConvCost(
      filter_rows, filter_cols, in_depth, out_depth, out_rows, out_cols);
  VLOG(2) << "CanUseDeepConv2D"
          << " deep_conv_cost: " << deep_conv_cost
          << " direct_conv_cost: " << direct_conv_cost << " deep_direct_ratio: "
          << (static_cast<float>(deep_conv_cost) /
              static_cast<float>(direct_conv_cost))
          << " use_deep_conv: " << (deep_conv_cost < direct_conv_cost);
  return deep_conv_cost < direct_conv_cost;
}
bool CanUseDeepConv2D ( int stride_rows , int stride_cols , int filter_rows , int filter_cols , int in_depth , int out_depth , int out_rows , int out_cols ) { if ( stride_rows > 1 || stride_cols > 1 || filter_rows != 3 || filter_cols != 3 ) { return false ; } if ( ! ReadBoolFromEnvVar ( " " , false ) ) { return false ; } WinogradTransform < float > t ; const int64_t deep_conv_cost = GetDeepConvCost ( t . input_shape ( ) . rows , t . input_shape ( ) . cols , t . output_shape ( ) . rows , t . output_shape ( ) . cols , in_depth , out_depth , out_rows , out_cols ) ; const int64_t direct_conv_cost = GetDirectConvCost ( filter_rows , filter_cols , in_depth , out_depth , out_rows , out_cols ) ; VLOG ( 2 ) << " " << " " << deep_conv_cost << " " << direct_conv_cost << " " << ( static_cast < float > ( deep_conv_cost ) / static_cast < float > ( direct_conv_cost ) ) << " " << ( deep_conv_cost < direct_conv_cost ) ; return deep_conv_cost < direct_conv_cost ; }
Returns true if convolution can be computed efficiently by DeepConv2D,
returns false otherwise.
Returns true if convolution can be computed efficiently by DeepConv2D returns false otherwise .
// Check if convolution parameters are supported. // TODO(andydavis) Add support for multiple filter sizes and strides. // Check if deep convolution is enabled by environment variable. // NOTE: IF this environment variable name changes, update conv_ops_test.py. // Check if flop cost of deep convolution is less than direct convolution.