tensorflow/compiler/tf2xla/kernels/conv_op_helpers.cc
// Performs some basic checks on ConvOpAttrs that are true for all kinds of XLA
// convolutions (as currently implemented).
Performs some basic checks on ConvOpAttrs that are true for all kinds of XLA
convolutions (as currently implemented).
Performs some basic checks on ConvOpAttrs that are true for all kinds of XLA convolutions ( as currently implemented ) .
Status CheckConvAttrs(const ConvOpAttrs& attrs) {
  const int num_dims = attrs.num_spatial_dims + 2;
  const int attrs_strides_size = attrs.strides.size();
  if (attrs_strides_size != num_dims) {
    return errors::InvalidArgument("Sliding window strides field must specify ",
                                   num_dims, " dimensions");
  }
  int batch_dim = GetTensorBatchDimIndex(num_dims, attrs.data_format);
  int feature_dim = GetTensorFeatureDimIndex(num_dims, attrs.data_format);
  if (attrs.strides[batch_dim] != 1 || attrs.strides[feature_dim] != 1) {
    return errors::Unimplemented(
        "Current implementation does not yet support strides in the batch and "
        "depth dimensions.");
  }
  const int attrs_dilations_size = attrs.dilations.size();
  if (attrs_dilations_size != num_dims) {
    return errors::InvalidArgument("Dilations field must specify ", num_dims,
                                   " dimensions");
  }
  if (attrs.dilations[batch_dim] != 1 || attrs.dilations[feature_dim] != 1) {
    return errors::Unimplemented(
        "Current implementation does not support dilations in the batch and "
        "depth dimensions.");
  }
  for (int i = 0; i < attrs.num_spatial_dims; ++i) {
    int input_dim = GetTensorSpatialDimIndex(num_dims, attrs.data_format, i);
    if (attrs.dilations[input_dim] < 1) {
      return errors::Unimplemented("Dilation values must be positive; ", i,
                                   "th spatial dimension had dilation ",
                                   attrs.dilations[input_dim]);
    }
  }
  return Status::OK();
}
Status CheckConvAttrs ( const ConvOpAttrs & attrs ) { const int num_dims = attrs . num_spatial_dims + 2 ; const int attrs_strides_size = attrs . strides . size ( ) ; if ( attrs_strides_size != num_dims ) { return errors :: InvalidArgument ( " " , num_dims , " " ) ; } int batch_dim = GetTensorBatchDimIndex ( num_dims , attrs . data_format ) ; int feature_dim = GetTensorFeatureDimIndex ( num_dims , attrs . data_format ) ; if ( attrs . strides [ batch_dim ] != 1 || attrs . strides [ feature_dim ] != 1 ) { return errors :: Unimplemented ( " " " " ) ; } const int attrs_dilations_size = attrs . dilations . size ( ) ; if ( attrs_dilations_size != num_dims ) { return errors :: InvalidArgument ( " " , num_dims , " " ) ; } if ( attrs . dilations [ batch_dim ] != 1 || attrs . dilations [ feature_dim ] != 1 ) { return errors :: Unimplemented ( " " " " ) ; } for ( int i = 0 ; i < attrs . num_spatial_dims ; ++ i ) { int input_dim = GetTensorSpatialDimIndex ( num_dims , attrs . data_format , i ) ; if ( attrs . dilations [ input_dim ] < 1 ) { return errors :: Unimplemented ( " " , i , " " , attrs . dilations [ input_dim ] ) ; } } return Status :: OK ( ) ; }
Performs some basic checks on ConvOpAttrs that are true for all kinds of XLA
convolutions (as currently implemented).
Performs some basic checks on ConvOpAttrs that are true for all kinds of XLA convolutions ( as currently implemented ) .