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

Function GetOpAttributes

tensorflow/lite/toco/dump_graphviz.cc:355–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355Attributes GetOpAttributes(const Model& model, const Operator& op) {
356 Attributes attrs;
357 switch (op.fused_activation_function) {
358 case FusedActivationFunctionType::kRelu:
359 attrs["func"] = "ReLU";
360 break;
361 case FusedActivationFunctionType::kRelu6:
362 attrs["func"] = "ReLU6";
363 break;
364 case FusedActivationFunctionType::kRelu1:
365 attrs["func"] = "ReLU1";
366 break;
367 default:
368 break;
369 }
370 // Output state of member vars on derived operators.
371 switch (op.type) {
372 case OperatorType::kConv: {
373 const auto& conv_op = static_cast<const ConvOperator&>(op);
374 string stride;
375 AppendF(&stride, "%d", conv_op.stride_width);
376 stride += kUnicodeMult;
377 AppendF(&stride, "%d", conv_op.stride_height);
378 attrs["stride"] = stride;
379 attrs["padding"] =
380 (conv_op.padding.type == PaddingType::kSame) ? "same" : "valid";
381 break;
382 }
383 case OperatorType::kDepthwiseConv: {
384 const auto& depthconv_op = static_cast<const ConvOperator&>(op);
385 string stride;
386 AppendF(&stride, "%d", depthconv_op.stride_width);
387 stride += kUnicodeMult;
388 AppendF(&stride, "%d", depthconv_op.stride_height);
389 attrs["stride"] = stride;
390 attrs["padding"] =
391 (depthconv_op.padding.type == PaddingType::kSame) ? "same" : "valid";
392 break;
393 }
394 case OperatorType::kFakeQuant: {
395 const auto& fakequant_op = static_cast<const FakeQuantOperator&>(op);
396 attrs["bits"] = StringF("%d", fakequant_op.num_bits);
397 if (fakequant_op.minmax) {
398 attrs["range"] = StringF("[%g,%g]", fakequant_op.minmax->min,
399 fakequant_op.minmax->max);
400 } else {
401 attrs["range"] = "[?,?]";
402 }
403 break;
404 }
405 default:
406 break;
407 }
408 int64 math_ops_count;
409 if (EstimateArithmeticOpsCount(model, op, &math_ops_count) &&
410 (math_ops_count != 0)) {
411 attrs["math"] = FormattedNumber(math_ops_count) + "ops";
412 }

Callers 1

GetOpLabelFunction · 0.85

Calls 4

AppendFFunction · 0.85
StringFFunction · 0.85
FormattedNumberFunction · 0.85

Tested by

no test coverage detected