Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Alibaba MNN Protobuf Duration PB CC

From Leeroopedia


Knowledge Sources
Domains Serialization, Type_System
Last Updated 2026-02-10 12:00 GMT

Overview

Generated C++ implementation for the Protocol Buffers Duration well-known type representing a signed, fixed-length span of time.

Description

This file implements the google::protobuf::Duration message, which represents a time duration as a combination of seconds and nanoseconds. The Duration type is one of the protobuf well-known types used for time-related data in serialized messages. MNN vendors this generated file as part of the complete protobuf runtime needed to parse TensorFlow and Caffe model formats, where Duration may appear in training configuration, profiling metadata, or timeout specifications embedded in model files.

Usage

Vendored dependency used internally by MNN for parsing protobuf-based model formats (TensorFlow, Caffe). Not directly imported by end users.

Code Reference

Source Location

  • Repository: Alibaba_MNN
  • File: 3rd_party/protobuf/src/google/protobuf/duration.pb.cc
  • Lines: 1-300

Signature

namespace google {
namespace protobuf {
class Duration final : public ::PROTOBUF_NAMESPACE_ID::Message {
  int64 seconds() const;
  void set_seconds(int64 value);
  int32 nanos() const;
  void set_nanos(int32 value);
};
}  // namespace protobuf
}  // namespace google

Import

#include "3rd_party/protobuf/src/google/protobuf/duration.pb.h"

I/O Contract

Inputs

Name Type Required Description
seconds int64 Yes Signed seconds component of the duration
nanos int32 No Signed nanoseconds component (must be in range -999999999 to 999999999)

Outputs

Name Type Description
Duration google::protobuf::Duration Serializable duration message with seconds and nanoseconds fields

Usage Examples

// MNN internal usage
google::protobuf::Duration duration;
duration.set_seconds(120);
duration.set_nanos(500000000);
std::string serialized;
duration.SerializeToString(&serialized);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment