MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SetOpAttrListDefault

Function SetOpAttrListDefault

tensorflow/python/eager/pywrap_tfe_src.cc:432–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432void SetOpAttrListDefault(
433 TFE_Context* ctx, TFE_Op* op, const tensorflow::OpDef::AttrDef& attr,
434 const char* key, TF_AttrType type,
435 tensorflow::gtl::FlatMap<string, tensorflow::int64>* attr_list_sizes,
436 TF_Status* status) {
437 if (type == TF_ATTR_STRING) {
438 int num_values = attr.default_value().list().s_size();
439 std::unique_ptr<const void*[]> values(new const void*[num_values]);
440 std::unique_ptr<size_t[]> lengths(new size_t[num_values]);
441 (*attr_list_sizes)[key] = num_values;
442 for (int i = 0; i < num_values; i++) {
443 const string& v = attr.default_value().list().s(i);
444 values[i] = v.data();
445 lengths[i] = v.size();
446 }
447 TFE_OpSetAttrStringList(op, key, values.get(), lengths.get(), num_values);
448 } else if (type == TF_ATTR_INT) {
449 int num_values = attr.default_value().list().i_size();
450 std::unique_ptr<int64_t[]> values(new int64_t[num_values]);
451 (*attr_list_sizes)[key] = num_values;
452 for (int i = 0; i < num_values; i++) {
453 values[i] = attr.default_value().list().i(i);
454 }
455 TFE_OpSetAttrIntList(op, key, values.get(), num_values);
456 } else if (type == TF_ATTR_FLOAT) {
457 int num_values = attr.default_value().list().f_size();
458 std::unique_ptr<float[]> values(new float[num_values]);
459 (*attr_list_sizes)[key] = num_values;
460 for (int i = 0; i < num_values; i++) {
461 values[i] = attr.default_value().list().f(i);
462 }
463 TFE_OpSetAttrFloatList(op, key, values.get(), num_values);
464 } else if (type == TF_ATTR_BOOL) {
465 int num_values = attr.default_value().list().b_size();
466 std::unique_ptr<unsigned char[]> values(new unsigned char[num_values]);
467 (*attr_list_sizes)[key] = num_values;
468 for (int i = 0; i < num_values; i++) {
469 values[i] = attr.default_value().list().b(i);
470 }
471 TFE_OpSetAttrBoolList(op, key, values.get(), num_values);
472 } else if (type == TF_ATTR_TYPE) {
473 int num_values = attr.default_value().list().type_size();
474 std::unique_ptr<int[]> values(new int[num_values]);
475 (*attr_list_sizes)[key] = num_values;
476 for (int i = 0; i < num_values; i++) {
477 values[i] = attr.default_value().list().type(i);
478 }
479 TFE_OpSetAttrTypeList(op, key,
480 reinterpret_cast<const TF_DataType*>(values.get()),
481 attr.default_value().list().type_size());
482 } else if (type == TF_ATTR_SHAPE) {
483 int num_values = attr.default_value().list().shape_size();
484 (*attr_list_sizes)[key] = num_values;
485 int total_dims = 0;
486 for (int i = 0; i < num_values; ++i) {
487 if (!attr.default_value().list().shape(i).unknown_rank()) {
488 total_dims += attr.default_value().list().shape(i).dim_size();
489 }

Callers 1

SetOpAttrWithDefaultsFunction · 0.85

Calls 15

TFE_OpSetAttrStringListFunction · 0.85
TFE_OpSetAttrIntListFunction · 0.85
TFE_OpSetAttrFloatListFunction · 0.85
TFE_OpSetAttrBoolListFunction · 0.85
TFE_OpSetAttrTypeListFunction · 0.85
TFE_OpSetAttrShapeListFunction · 0.85
TF_SetStatusFunction · 0.85
listMethod · 0.80
unknown_rankMethod · 0.80
GetFuncFunction · 0.70
typeMethod · 0.65

Tested by

no test coverage detected