tensorflow/core/kernels/deep_conv2d.cc
// Approximate cost models for direct and deep convolutions.
Approximate cost models for direct and deep convolutions.
Approximate cost models for direct and deep convolutions .
static int64_t GetDeepConvCost(int input_tile_rows, int input_tile_cols,
                               int out_tile_rows, int out_tile_cols,
                               int in_depth, int out_depth, int out_rows,
                               int out_cols) {
  const int64_t input_tile_spatial_size = input_tile_rows * input_tile_cols;
  const int64_t input_transform_cost =
      input_tile_spatial_size * input_tile_spatial_size * in_depth;
  const int64_t product_cost = input_tile_spatial_size * in_depth * out_depth;
  const int64_t output_tile_spatial_size = out_tile_rows * out_tile_cols;
  const int64_t output_transform_cost =
      output_tile_spatial_size * input_tile_spatial_size * out_depth;
  const int64_t row_tiles = (out_rows + out_tile_rows - 1) / out_tile_rows;
  const int64_t col_tiles = (out_cols + out_tile_cols - 1) / out_tile_cols;
  const int64_t num_tiles = row_tiles * col_tiles;
  return num_tiles *
         (input_transform_cost + product_cost + output_transform_cost);
}
static int64_t GetDeepConvCost ( int input_tile_rows , int input_tile_cols , int out_tile_rows , int out_tile_cols , int in_depth , int out_depth , int out_rows , int out_cols ) { const int64_t input_tile_spatial_size = input_tile_rows * input_tile_cols ; const int64_t input_transform_cost = input_tile_spatial_size * input_tile_spatial_size * in_depth ; const int64_t product_cost = input_tile_spatial_size * in_depth * out_depth ; const int64_t output_tile_spatial_size = out_tile_rows * out_tile_cols ; const int64_t output_transform_cost = output_tile_spatial_size * input_tile_spatial_size * out_depth ; const int64_t row_tiles = ( out_rows + out_tile_rows - 1 ) / out_tile_rows ; const int64_t col_tiles = ( out_cols + out_tile_cols - 1 ) / out_tile_cols ; const int64_t num_tiles = row_tiles * col_tiles ; return num_tiles * ( input_transform_cost + product_cost + output_transform_cost ) ; }
Approximate cost models for direct and deep convolutions.
Approximate cost models for direct and deep convolutions .
// Input transform cost. // Element-wise products (each product is a MatMul across depth). // Output transform cost. // Calculate number of input tiles to process. // Return total cost.