tensorflow/compiler/mlir/tensorflow/transforms/lower_tf.cc
// Returns reduction indices to use while lowering tf.BiasAddGrad op to tf.Sum
// op.
Returns reduction indices to use while lowering tf.BiasAddGrad op to tf.Sum
op.
Returns reduction indices to use while lowering tf . BiasAddGrad op to tf . Sum op .
DenseIntElementsAttr GetBiasAddGradReductionIndices(int64_t rank,
                                                    StringAttr data_format,
                                                    Builder *builder) {
  tensorflow::TensorFormat format;
  if (!FormatFromString(data_format.getValue().str(), &format)) return {};
  int64_t feature_dim = GetTensorFeatureDimIndex(rank, format);
  llvm::SmallVector<int64_t, 4> dims_to_reduce(rank - 1);
  std::iota(dims_to_reduce.begin(), dims_to_reduce.begin() + feature_dim, 0);
  std::iota(dims_to_reduce.begin() + feature_dim, dims_to_reduce.end(),
            feature_dim + 1);
  return GetI64ElementsAttr(dims_to_reduce, builder);
}
DenseIntElementsAttr GetBiasAddGradReductionIndices ( int64_t rank , StringAttr data_format , Builder * builder ) { tensorflow :: TensorFormat format ; if ( ! FormatFromString ( data_format . getValue ( ) . str ( ) , & format ) ) return { } ; int64_t feature_dim = GetTensorFeatureDimIndex ( rank , format ) ; llvm :: SmallVector < int64_t , 4 > dims_to_reduce ( rank - 1 ) ; std :: iota ( dims_to_reduce . begin ( ) , dims_to_reduce . begin ( ) + feature_dim , 0 ) ; std :: iota ( dims_to_reduce . begin ( ) + feature_dim , dims_to_reduce . end ( ) , feature_dim + 1 ) ; return GetI64ElementsAttr ( dims_to_reduce , builder ) ; }
Returns reduction indices to use while lowering tf.BiasAddGrad op to tf.Sum
op.
Returns reduction indices to use while lowering tf . BiasAddGrad op to tf . Sum op .
// Reudce along all dimensions except the feature dimension.