tensorflow/compiler/mlir/tensorflow/translate/derived_attr_populator_gen.cc
// Emits TensorFlow derived attribute populator functions for each of the ops.
Emits TensorFlow derived attribute populator functions for each of the ops.
Emits TensorFlow derived attribute populator functions for each of the ops .
static void EmitOpAttrPopulators(const std::vector<Operator> &ops,
                                 raw_ostream *ostream) {
  raw_ostream &os = *ostream;
  for (const auto &op : ops) {
    auto op_name = op.getCppClassName();
    OUT(0) << "static Status Populate" << op_name
           << "DerivedAttrs(mlir::TF::" << op_name
           << "& op, AttrValueMap *values) {\n";
    for (const auto &named_attr : op.getAttributes()) {
      auto attr_name = named_attr.name;
      const auto &attr = named_attr.attr;
      if (!attr.isDerivedAttr()) continue;
      auto retType = attr.getReturnType();
      if (retType == "ShapedType" || retType == "mlir::TF::OperandShapeRange" ||
          retType == "mlir::TF::ResultShapeRange") {
        OUT(2) << "TF_RETURN_IF_ERROR(SetShapeAttribute(\"" << attr_name
               << "\", op." << attr_name << "(), values));\n";
      } else if (retType == "Type" ||
                 retType == "mlir::OperandElementTypeRange" ||
                 retType == "mlir::ResultElementTypeRange") {
        OUT(2) << "TF_RETURN_IF_ERROR(SetTypeAttribute(\"" << attr_name
               << "\", op." << attr_name << "(), values));\n";
      } else if (attr.isSubClassOf("TF_DerivedOperandSizeAttr") ||
                 attr.isSubClassOf("TF_DerivedResultSizeAttr")) {
        OUT(2) << "TF_RETURN_IF_ERROR(SetSizeAttribute(\"" << attr_name
               << "\", op." << attr_name << "(), values));\n";
      } else {
        PrintFatalError(op.getLoc(),
                        "NYI: attribute populator for derived attributes");
      }
    }
    OUT(2) << "return Status::OK();\n";
    OUT(0) << "}\n\n";
  }
}
static void EmitOpAttrPopulators ( const std :: vector < Operator > & ops , raw_ostream * ostream ) { raw_ostream & os = * ostream ; for ( const auto & op : ops ) { auto op_name = op . getCppClassName ( ) ; OUT ( 0 ) << " " << op_name << " " << op_name << " \n " ; for ( const auto & named_attr : op . getAttributes ( ) ) { auto attr_name = named_attr . name ; const auto & attr = named_attr . attr ; if ( ! attr . isDerivedAttr ( ) ) continue ; auto retType = attr . getReturnType ( ) ; if ( retType == " " || retType == " " || retType == " " ) { OUT ( 2 ) << " \" " << attr_name << " \" " << attr_name << " \n " ; } else if ( retType == " " || retType == " " || retType == " " ) { OUT ( 2 ) << " \" " << attr_name << " \" " << attr_name << " \n " ; } else if ( attr . isSubClassOf ( " " ) || attr . isSubClassOf ( " " ) ) { OUT ( 2 ) << " \" " << attr_name << " \" " << attr_name << " \n " ; } else { PrintFatalError ( op . getLoc ( ) , " " ) ; } } OUT ( 2 ) << " \n " ; OUT ( 0 ) << " \n \n " ; } }
Emits TensorFlow derived attribute populator functions for each of the ops.
Emits TensorFlow derived attribute populator functions for each of the ops .
// TODO(hinsu): Introduce a derived attribute property for ops with no // type attributes. That way an error can be generated if no derived type // attribute or the property is set. This will make sure derived type // attributes are not omitted by mistake. // Emit function signature.