tensorflow/python/framework/op_def_library_pybind.cc
// Converts attr values to AttrValues.
Converts attr values to AttrValues.
Converts attr values to AttrValues .
void ExtractAttrProto(const std::string& op_type_name, const OpDef& op_def,
                      const py::dict& attrs, py::dict& attr_protos,
                      AttrProtosMap& attr_protos_map) {
  for (const AttrDef& attr_def : op_def.attr()) {
    const std::string& attr_name = attr_def.name();
    const py::object attr = attrs[attr_name.c_str()].cast<py::object>();
    if (attr_def.has_default_value() && attr.is_none()) {
      SetAttrProto(attr_name, attr_def.default_value(), attr_protos,
                   attr_protos_map);
      continue;
    }
    const AttrValue attr_value =
        ValueToAttrValue(attr, attr_def.type(), attr_name);
    const AttributeType attr_type = AttributeTypeFromName(attr_def.type());
    AssertSatisfiesLengthConstraint(attr, attr_def, attr_name, op_type_name);
    AssertSatisfiesAllowedStringsConstraint(attr_value, attr_def, attr_name,
                                            attr_type, op_type_name);
    AssertSatisfiesIntMinimumConstraint(attr_value, attr_def, attr_name,
                                        attr_type, op_type_name);
    AssertSatisfiesTypeConstraint(attr_value, attr_def, attr_name, attr_type,
                                  op_type_name);
    SetAttrProto(attr_name, attr_value, attr_protos, attr_protos_map);
  }
}
void ExtractAttrProto ( const std :: string & op_type_name , const OpDef & op_def , const py :: dict & attrs , py :: dict & attr_protos , AttrProtosMap & attr_protos_map ) { for ( const AttrDef & attr_def : op_def . attr ( ) ) { const std :: string & attr_name = attr_def . name ( ) ; const py :: object attr = attrs [ attr_name . c_str ( ) ] . cast < py :: object > ( ) ; if ( attr_def . has_default_value ( ) && attr . is_none ( ) ) { SetAttrProto ( attr_name , attr_def . default_value ( ) , attr_protos , attr_protos_map ) ; continue ; } const AttrValue attr_value = ValueToAttrValue ( attr , attr_def . type ( ) , attr_name ) ; const AttributeType attr_type = AttributeTypeFromName ( attr_def . type ( ) ) ; AssertSatisfiesLengthConstraint ( attr , attr_def , attr_name , op_type_name ) ; AssertSatisfiesAllowedStringsConstraint ( attr_value , attr_def , attr_name , attr_type , op_type_name ) ; AssertSatisfiesIntMinimumConstraint ( attr_value , attr_def , attr_name , attr_type , op_type_name ) ; AssertSatisfiesTypeConstraint ( attr_value , attr_def , attr_name , attr_type , op_type_name ) ; SetAttrProto ( attr_name , attr_value , attr_protos , attr_protos_map ) ; } }
Converts attr values to AttrValues.
Converts attr values to AttrValues .