提交 b8831606 编写于 作者: L liuruilong

format files

上级 30d22c55
......@@ -57,7 +57,7 @@
/* Workaround for Microsoft compilers. */
#ifdef _MSC_VER
# define inline __inline
#define inline __inline
#endif
/**
......@@ -81,7 +81,7 @@
#define MAX_UINT64_ENCODED_SIZE 10
#ifndef PROTOBUF_C_UNPACK_ERROR
# define PROTOBUF_C_UNPACK_ERROR(...)
#define PROTOBUF_C_UNPACK_ERROR(...)
#endif
const char protobuf_c_empty_string[] = "";
......@@ -93,7 +93,7 @@ const char protobuf_c_empty_string[] = "";
* STRUCT_MEMBER_PTR().
*/
#define STRUCT_MEMBER_P(struct_p, struct_offset) \
((void *) ((uint8_t *) (struct_p) + (struct_offset)))
((void *)((uint8_t *)(struct_p) + (struct_offset)))
/**
* Return field in a `ProtobufCMessage` based on offset.
......@@ -102,7 +102,7 @@ const char protobuf_c_empty_string[] = "";
* Cast it to the passed type.
*/
#define STRUCT_MEMBER(member_type, struct_p, struct_offset) \
(*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset)))
(*(member_type *)STRUCT_MEMBER_P((struct_p), (struct_offset)))
/**
* Return field in a `ProtobufCMessage` based on offset.
......@@ -111,7 +111,7 @@ const char protobuf_c_empty_string[] = "";
* it to a pointer to the passed type.
*/
#define STRUCT_MEMBER_PTR(member_type, struct_p, struct_offset) \
((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset)))
((member_type *)STRUCT_MEMBER_P((struct_p), (struct_offset)))
/* Assertions for magic numbers. */
......@@ -131,43 +131,24 @@ const char protobuf_c_empty_string[] = "";
/* --- version --- */
const char *
protobuf_c_version(void)
{
return PROTOBUF_C_VERSION;
}
const char *protobuf_c_version(void) { return PROTOBUF_C_VERSION; }
uint32_t
protobuf_c_version_number(void)
{
return PROTOBUF_C_VERSION_NUMBER;
}
uint32_t protobuf_c_version_number(void) { return PROTOBUF_C_VERSION_NUMBER; }
/* --- allocator --- */
static void *
system_alloc(void *allocator_data, size_t size)
{
static void *system_alloc(void *allocator_data, size_t size) {
return malloc(size);
}
static void
system_free(void *allocator_data, void *data)
{
free(data);
}
static void system_free(void *allocator_data, void *data) { free(data); }
static inline void *
do_alloc(ProtobufCAllocator *allocator, size_t size)
{
static inline void *do_alloc(ProtobufCAllocator *allocator, size_t size) {
return allocator->alloc(allocator->allocator_data, size);
}
static inline void
do_free(ProtobufCAllocator *allocator, void *data)
{
if (data != NULL)
allocator->free(allocator->allocator_data, data);
static inline void do_free(ProtobufCAllocator *allocator, void *data) {
if (data != NULL) allocator->free(allocator->allocator_data, data);
}
/*
......@@ -183,11 +164,9 @@ static ProtobufCAllocator protobuf_c__allocator = {
/* === buffer-simple === */
void
protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer,
size_t len, const uint8_t *data)
{
ProtobufCBufferSimple *simp = (ProtobufCBufferSimple *) buffer;
void protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer, size_t len,
const uint8_t *data) {
ProtobufCBufferSimple *simp = (ProtobufCBufferSimple *)buffer;
size_t new_len = simp->len + len;
if (new_len > simp->alloced) {
......@@ -195,13 +174,10 @@ protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer,
size_t new_alloced = simp->alloced * 2;
uint8_t *new_data;
if (allocator == NULL)
allocator = &protobuf_c__allocator;
while (new_alloced < new_len)
new_alloced += new_alloced;
if (allocator == NULL) allocator = &protobuf_c__allocator;
while (new_alloced < new_len) new_alloced += new_alloced;
new_data = do_alloc(allocator, new_alloced);
if (!new_data)
return;
if (!new_data) return;
memcpy(new_data, simp->data, simp->len);
if (simp->must_free_data)
do_free(allocator, simp->data);
......@@ -232,9 +208,7 @@ protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer,
* \return
* Number of bytes required.
*/
static inline size_t
get_tag_size(uint32_t number)
{
static inline size_t get_tag_size(uint32_t number) {
if (number < (1UL << 4)) {
return 1;
} else if (number < (1UL << 11)) {
......@@ -257,9 +231,7 @@ get_tag_size(uint32_t number)
* \return
* Number of bytes required.
*/
static inline size_t
uint32_size(uint32_t v)
{
static inline size_t uint32_size(uint32_t v) {
if (v < (1UL << 7)) {
return 1;
} else if (v < (1UL << 14)) {
......@@ -282,9 +254,7 @@ uint32_size(uint32_t v)
* \return
* Number of bytes required.
*/
static inline size_t
int32_size(int32_t v)
{
static inline size_t int32_size(int32_t v) {
if (v < 0) {
return 10;
} else if (v < (1L << 7)) {
......@@ -309,13 +279,11 @@ int32_size(int32_t v)
* \return
* ZigZag encoded integer.
*/
static inline uint32_t
zigzag32(int32_t v)
{
static inline uint32_t zigzag32(int32_t v) {
if (v < 0)
return (-(uint32_t)v) * 2 - 1;
else
return (uint32_t)(v) * 2;
return (uint32_t)(v)*2;
}
/**
......@@ -328,11 +296,7 @@ zigzag32(int32_t v)
* \return
* Number of bytes required.
*/
static inline size_t
sint32_size(int32_t v)
{
return uint32_size(zigzag32(v));
}
static inline size_t sint32_size(int32_t v) { return uint32_size(zigzag32(v)); }
/**
* Return the number of bytes required to store a 64-bit unsigned integer in
......@@ -343,13 +307,11 @@ sint32_size(int32_t v)
* \return
* Number of bytes required.
*/
static inline size_t
uint64_size(uint64_t v)
{
uint32_t upper_v = (uint32_t) (v >> 32);
static inline size_t uint64_size(uint64_t v) {
uint32_t upper_v = (uint32_t)(v >> 32);
if (upper_v == 0) {
return uint32_size((uint32_t) v);
return uint32_size((uint32_t)v);
} else if (upper_v < (1UL << 3)) {
return 5;
} else if (upper_v < (1UL << 10)) {
......@@ -374,13 +336,11 @@ uint64_size(uint64_t v)
* \return
* ZigZag encoded integer.
*/
static inline uint64_t
zigzag64(int64_t v)
{
static inline uint64_t zigzag64(int64_t v) {
if (v < 0)
return (-(uint64_t)v) * 2 - 1;
else
return (uint64_t)(v) * 2;
return (uint64_t)(v)*2;
}
/**
......@@ -393,11 +353,7 @@ zigzag64(int64_t v)
* \return
* Number of bytes required.
*/
static inline size_t
sint64_size(int64_t v)
{
return uint64_size(zigzag64(v));
}
static inline size_t sint64_size(int64_t v) { return uint64_size(zigzag64(v)); }
/**
* Calculate the serialized size of a single required message field, including
......@@ -410,25 +366,23 @@ sint64_size(int64_t v)
* \return
* Number of bytes required.
*/
static size_t
required_field_get_packed_size(const ProtobufCFieldDescriptor *field,
const void *member)
{
static size_t required_field_get_packed_size(
const ProtobufCFieldDescriptor *field, const void *member) {
size_t rv = get_tag_size(field->id);
switch (field->type) {
case PROTOBUF_C_TYPE_SINT32:
return rv + sint32_size(*(const int32_t *) member);
return rv + sint32_size(*(const int32_t *)member);
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32:
return rv + int32_size(*(const int32_t *) member);
return rv + int32_size(*(const int32_t *)member);
case PROTOBUF_C_TYPE_UINT32:
return rv + uint32_size(*(const uint32_t *) member);
return rv + uint32_size(*(const uint32_t *)member);
case PROTOBUF_C_TYPE_SINT64:
return rv + sint64_size(*(const int64_t *) member);
return rv + sint64_size(*(const int64_t *)member);
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64:
return rv + uint64_size(*(const uint64_t *) member);
return rv + uint64_size(*(const uint64_t *)member);
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
return rv + 4;
......@@ -442,16 +396,16 @@ required_field_get_packed_size(const ProtobufCFieldDescriptor *field,
case PROTOBUF_C_TYPE_DOUBLE:
return rv + 8;
case PROTOBUF_C_TYPE_STRING: {
const char *str = *(char * const *) member;
const char *str = *(char *const *)member;
size_t len = str ? strlen(str) : 0;
return rv + uint32_size(len) + len;
}
case PROTOBUF_C_TYPE_BYTES: {
size_t len = ((const ProtobufCBinaryData *) member)->len;
size_t len = ((const ProtobufCBinaryData *)member)->len;
return rv + uint32_size(len) + len;
}
case PROTOBUF_C_TYPE_MESSAGE: {
const ProtobufCMessage *msg = *(ProtobufCMessage * const *) member;
const ProtobufCMessage *msg = *(ProtobufCMessage *const *)member;
size_t subrv = msg ? protobuf_c_message_get_packed_size(msg) : 0;
return rv + uint32_size(subrv) + subrv;
}
......@@ -474,20 +428,16 @@ required_field_get_packed_size(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes required.
*/
static size_t
oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field,
static size_t oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field,
uint32_t oneof_case,
const void *member)
{
const void *member) {
if (oneof_case != field->id) {
return 0;
}
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void * const *) member;
if (ptr == NULL || ptr == field->default_value)
return 0;
field->type == PROTOBUF_C_TYPE_STRING) {
const void *ptr = *(const void *const *)member;
if (ptr == NULL || ptr == field->default_value) return 0;
}
return required_field_get_packed_size(field, member);
}
......@@ -506,33 +456,26 @@ oneof_field_get_packed_size(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes required.
*/
static size_t
optional_field_get_packed_size(const ProtobufCFieldDescriptor *field,
const protobuf_c_boolean has,
const void *member)
{
static size_t optional_field_get_packed_size(
const ProtobufCFieldDescriptor *field, const protobuf_c_boolean has,
const void *member) {
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void * const *) member;
if (ptr == NULL || ptr == field->default_value)
return 0;
field->type == PROTOBUF_C_TYPE_STRING) {
const void *ptr = *(const void *const *)member;
if (ptr == NULL || ptr == field->default_value) return 0;
} else {
if (!has)
return 0;
if (!has) return 0;
}
return required_field_get_packed_size(field, member);
}
static protobuf_c_boolean
field_is_zeroish(const ProtobufCFieldDescriptor *field,
const void *member)
{
static protobuf_c_boolean field_is_zeroish(
const ProtobufCFieldDescriptor *field, const void *member) {
protobuf_c_boolean ret = FALSE;
switch (field->type) {
case PROTOBUF_C_TYPE_BOOL:
ret = (0 == *(const protobuf_c_boolean *) member);
ret = (0 == *(const protobuf_c_boolean *)member);
break;
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_SINT32:
......@@ -540,28 +483,28 @@ field_is_zeroish(const ProtobufCFieldDescriptor *field,
case PROTOBUF_C_TYPE_UINT32:
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
ret = (0 == *(const uint32_t *) member);
ret = (0 == *(const uint32_t *)member);
break;
case PROTOBUF_C_TYPE_SINT64:
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64:
case PROTOBUF_C_TYPE_SFIXED64:
case PROTOBUF_C_TYPE_FIXED64:
ret = (0 == *(const uint64_t *) member);
ret = (0 == *(const uint64_t *)member);
break;
case PROTOBUF_C_TYPE_FLOAT:
ret = (0 == *(const float *) member);
ret = (0 == *(const float *)member);
break;
case PROTOBUF_C_TYPE_DOUBLE:
ret = (0 == *(const double *) member);
ret = (0 == *(const double *)member);
break;
case PROTOBUF_C_TYPE_STRING:
ret = (NULL == *(const char * const *) member) ||
('\0' == **(const char * const *) member);
ret = (NULL == *(const char *const *)member) ||
('\0' == **(const char *const *)member);
break;
case PROTOBUF_C_TYPE_BYTES:
case PROTOBUF_C_TYPE_MESSAGE:
ret = (NULL == *(const void * const *) member);
ret = (NULL == *(const void *const *)member);
break;
default:
ret = TRUE;
......@@ -584,12 +527,9 @@ field_is_zeroish(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes required.
*/
static size_t
unlabeled_field_get_packed_size(const ProtobufCFieldDescriptor *field,
const void *member)
{
if (field_is_zeroish(field, member))
return 0;
static size_t unlabeled_field_get_packed_size(
const ProtobufCFieldDescriptor *field, const void *member) {
if (field_is_zeroish(field, member)) return 0;
return required_field_get_packed_size(field, member);
}
......@@ -607,43 +547,34 @@ unlabeled_field_get_packed_size(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes required.
*/
static size_t
repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field,
size_t count, const void *member)
{
static size_t repeated_field_get_packed_size(
const ProtobufCFieldDescriptor *field, size_t count, const void *member) {
size_t header_size;
size_t rv = 0;
unsigned i;
void *array = *(void * const *) member;
void *array = *(void *const *)member;
if (count == 0)
return 0;
if (count == 0) return 0;
header_size = get_tag_size(field->id);
if (0 == (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED))
header_size *= count;
if (0 == (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED)) header_size *= count;
switch (field->type) {
case PROTOBUF_C_TYPE_SINT32:
for (i = 0; i < count; i++)
rv += sint32_size(((int32_t *) array)[i]);
for (i = 0; i < count; i++) rv += sint32_size(((int32_t *)array)[i]);
break;
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32:
for (i = 0; i < count; i++)
rv += int32_size(((int32_t *) array)[i]);
for (i = 0; i < count; i++) rv += int32_size(((int32_t *)array)[i]);
break;
case PROTOBUF_C_TYPE_UINT32:
for (i = 0; i < count; i++)
rv += uint32_size(((uint32_t *) array)[i]);
for (i = 0; i < count; i++) rv += uint32_size(((uint32_t *)array)[i]);
break;
case PROTOBUF_C_TYPE_SINT64:
for (i = 0; i < count; i++)
rv += sint64_size(((int64_t *) array)[i]);
for (i = 0; i < count; i++) rv += sint64_size(((int64_t *)array)[i]);
break;
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64:
for (i = 0; i < count; i++)
rv += uint64_size(((uint64_t *) array)[i]);
for (i = 0; i < count; i++) rv += uint64_size(((uint64_t *)array)[i]);
break;
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
......@@ -660,20 +591,20 @@ repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field,
break;
case PROTOBUF_C_TYPE_STRING:
for (i = 0; i < count; i++) {
size_t len = strlen(((char **) array)[i]);
size_t len = strlen(((char **)array)[i]);
rv += uint32_size(len) + len;
}
break;
case PROTOBUF_C_TYPE_BYTES:
for (i = 0; i < count; i++) {
size_t len = ((ProtobufCBinaryData *) array)[i].len;
size_t len = ((ProtobufCBinaryData *)array)[i].len;
rv += uint32_size(len) + len;
}
break;
case PROTOBUF_C_TYPE_MESSAGE:
for (i = 0; i < count; i++) {
size_t len = protobuf_c_message_get_packed_size(
((ProtobufCMessage **) array)[i]);
size_t len =
protobuf_c_message_get_packed_size(((ProtobufCMessage **)array)[i]);
rv += uint32_size(len) + len;
}
break;
......@@ -694,9 +625,8 @@ repeated_field_get_packed_size(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes required.
*/
static inline size_t
unknown_field_get_packed_size(const ProtobufCMessageUnknownField *field)
{
static inline size_t unknown_field_get_packed_size(
const ProtobufCMessageUnknownField *field) {
return get_tag_size(field->tag) + field->len;
}
......@@ -705,47 +635,31 @@ unknown_field_get_packed_size(const ProtobufCMessageUnknownField *field)
/*
* Calculate the serialized size of the message.
*/
size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message)
{
size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message) {
unsigned i;
size_t rv = 0;
ASSERT_IS_MESSAGE(message);
for (i = 0; i < message->descriptor->n_fields; i++) {
const ProtobufCFieldDescriptor *field =
message->descriptor->fields + i;
const void *member =
((const char *) message) + field->offset;
const void *qmember =
((const char *) message) + field->quantifier_offset;
const ProtobufCFieldDescriptor *field = message->descriptor->fields + i;
const void *member = ((const char *)message) + field->offset;
const void *qmember = ((const char *)message) + field->quantifier_offset;
if (field->label == PROTOBUF_C_LABEL_REQUIRED) {
rv += required_field_get_packed_size(field, member);
} else if ((field->label == PROTOBUF_C_LABEL_OPTIONAL ||
field->label == PROTOBUF_C_LABEL_NONE) &&
(0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF))) {
rv += oneof_field_get_packed_size(
field,
*(const uint32_t *) qmember,
member
);
rv += oneof_field_get_packed_size(field, *(const uint32_t *)qmember,
member);
} else if (field->label == PROTOBUF_C_LABEL_OPTIONAL) {
rv += optional_field_get_packed_size(
field,
*(protobuf_c_boolean *) qmember,
member
);
field, *(protobuf_c_boolean *)qmember, member);
} else if (field->label == PROTOBUF_C_LABEL_NONE) {
rv += unlabeled_field_get_packed_size(
field,
member
);
rv += unlabeled_field_get_packed_size(field, member);
} else {
rv += repeated_field_get_packed_size(
field,
*(const size_t *) qmember,
member
);
rv += repeated_field_get_packed_size(field, *(const size_t *)qmember,
member);
}
}
for (i = 0; i < message->n_unknown_fields; i++)
......@@ -773,9 +687,7 @@ size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
uint32_pack(uint32_t value, uint8_t *out)
{
static inline size_t uint32_pack(uint32_t value, uint8_t *out) {
unsigned rv = 0;
if (value >= 0x80) {
......@@ -810,9 +722,7 @@ uint32_pack(uint32_t value, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
int32_pack(int32_t value, uint8_t *out)
{
static inline size_t int32_pack(int32_t value, uint8_t *out) {
if (value < 0) {
out[0] = value | 0x80;
out[1] = (value >> 7) | 0x80;
......@@ -838,9 +748,7 @@ int32_pack(int32_t value, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
sint32_pack(int32_t value, uint8_t *out)
{
static inline size_t sint32_pack(int32_t value, uint8_t *out) {
return uint32_pack(zigzag32(value), out);
}
......@@ -855,15 +763,12 @@ sint32_pack(int32_t value, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static size_t
uint64_pack(uint64_t value, uint8_t *out)
{
uint32_t hi = (uint32_t) (value >> 32);
uint32_t lo = (uint32_t) value;
static size_t uint64_pack(uint64_t value, uint8_t *out) {
uint32_t hi = (uint32_t)(value >> 32);
uint32_t lo = (uint32_t)value;
unsigned rv;
if (hi == 0)
return uint32_pack((uint32_t) lo, out);
if (hi == 0) return uint32_pack((uint32_t)lo, out);
out[0] = (lo) | 0x80;
out[1] = (lo >> 7) | 0x80;
out[2] = (lo >> 14) | 0x80;
......@@ -895,9 +800,7 @@ uint64_pack(uint64_t value, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
sint64_pack(int64_t value, uint8_t *out)
{
static inline size_t sint64_pack(int64_t value, uint8_t *out) {
return uint64_pack(zigzag64(value), out);
}
......@@ -912,9 +815,7 @@ sint64_pack(int64_t value, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
fixed32_pack(uint32_t value, void *out)
{
static inline size_t fixed32_pack(uint32_t value, void *out) {
#if !defined(WORDS_BIGENDIAN)
memcpy(out, &value, 4);
#else
......@@ -943,14 +844,12 @@ fixed32_pack(uint32_t value, void *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
fixed64_pack(uint64_t value, void *out)
{
static inline size_t fixed64_pack(uint64_t value, void *out) {
#if !defined(WORDS_BIGENDIAN)
memcpy(out, &value, 8);
#else
fixed32_pack(value, out);
fixed32_pack(value >> 32, ((char *) out) + 4);
fixed32_pack(value >> 32, ((char *)out) + 4);
#endif
return 8;
}
......@@ -968,9 +867,7 @@ fixed64_pack(uint64_t value, void *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
boolean_pack(protobuf_c_boolean value, uint8_t *out)
{
static inline size_t boolean_pack(protobuf_c_boolean value, uint8_t *out) {
*out = value ? TRUE : FALSE;
return 1;
}
......@@ -990,9 +887,7 @@ boolean_pack(protobuf_c_boolean value, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
string_pack(const char *str, uint8_t *out)
{
static inline size_t string_pack(const char *str, uint8_t *out) {
if (str == NULL) {
out[0] = 0;
return 1;
......@@ -1015,9 +910,8 @@ string_pack(const char *str, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
binary_data_pack(const ProtobufCBinaryData *bd, uint8_t *out)
{
static inline size_t binary_data_pack(const ProtobufCBinaryData *bd,
uint8_t *out) {
size_t len = bd->len;
size_t rv = uint32_pack(len, out);
memcpy(out + rv, bd->data, len);
......@@ -1035,17 +929,15 @@ binary_data_pack(const ProtobufCBinaryData *bd, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static inline size_t
prefixed_message_pack(const ProtobufCMessage *message, uint8_t *out)
{
static inline size_t prefixed_message_pack(const ProtobufCMessage *message,
uint8_t *out) {
if (message == NULL) {
out[0] = 0;
return 1;
} else {
size_t rv = protobuf_c_message_pack(message, out + 1);
uint32_t rv_packed_size = uint32_size(rv);
if (rv_packed_size != 1)
memmove(out + rv_packed_size, out + 1, rv);
if (rv_packed_size != 1) memmove(out + rv_packed_size, out + 1, rv);
return uint32_pack(rv, out) + rv;
}
}
......@@ -1064,13 +956,11 @@ prefixed_message_pack(const ProtobufCMessage *message, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static size_t
tag_pack(uint32_t id, uint8_t *out)
{
static size_t tag_pack(uint32_t id, uint8_t *out) {
if (id < (1UL << (32 - 3)))
return uint32_pack(id << 3, out);
else
return uint64_pack(((uint64_t) id) << 3, out);
return uint64_pack(((uint64_t)id) << 3, out);
}
/**
......@@ -1085,52 +975,52 @@ tag_pack(uint32_t id, uint8_t *out)
* \return
* Number of bytes written to `out`.
*/
static size_t
required_field_pack(const ProtobufCFieldDescriptor *field,
const void *member, uint8_t *out)
{
static size_t required_field_pack(const ProtobufCFieldDescriptor *field,
const void *member, uint8_t *out) {
size_t rv = tag_pack(field->id, out);
switch (field->type) {
case PROTOBUF_C_TYPE_SINT32:
out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
return rv + sint32_pack(*(const int32_t *) member, out + rv);
return rv + sint32_pack(*(const int32_t *)member, out + rv);
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32:
out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
return rv + int32_pack(*(const int32_t *) member, out + rv);
return rv + int32_pack(*(const int32_t *)member, out + rv);
case PROTOBUF_C_TYPE_UINT32:
out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
return rv + uint32_pack(*(const uint32_t *) member, out + rv);
return rv + uint32_pack(*(const uint32_t *)member, out + rv);
case PROTOBUF_C_TYPE_SINT64:
out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
return rv + sint64_pack(*(const int64_t *) member, out + rv);
return rv + sint64_pack(*(const int64_t *)member, out + rv);
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64:
out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
return rv + uint64_pack(*(const uint64_t *) member, out + rv);
return rv + uint64_pack(*(const uint64_t *)member, out + rv);
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_FLOAT:
out[0] |= PROTOBUF_C_WIRE_TYPE_32BIT;
return rv + fixed32_pack(*(const uint32_t *) member, out + rv);
return rv + fixed32_pack(*(const uint32_t *)member, out + rv);
case PROTOBUF_C_TYPE_SFIXED64:
case PROTOBUF_C_TYPE_FIXED64:
case PROTOBUF_C_TYPE_DOUBLE:
out[0] |= PROTOBUF_C_WIRE_TYPE_64BIT;
return rv + fixed64_pack(*(const uint64_t *) member, out + rv);
return rv + fixed64_pack(*(const uint64_t *)member, out + rv);
case PROTOBUF_C_TYPE_BOOL:
out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
return rv + boolean_pack(*(const protobuf_c_boolean *) member, out + rv);
return rv + boolean_pack(*(const protobuf_c_boolean *)member, out + rv);
case PROTOBUF_C_TYPE_STRING:
out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
return rv + string_pack(*(char *const *) member, out + rv);
return rv + string_pack(*(char *const *)member, out + rv);
case PROTOBUF_C_TYPE_BYTES:
out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
return rv + binary_data_pack((const ProtobufCBinaryData *) member, out + rv);
return rv +
binary_data_pack((const ProtobufCBinaryData *)member, out + rv);
case PROTOBUF_C_TYPE_MESSAGE:
out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
return rv + prefixed_message_pack(*(ProtobufCMessage * const *) member, out + rv);
return rv + prefixed_message_pack(*(ProtobufCMessage *const *)member,
out + rv);
}
PROTOBUF_C__ASSERT_NOT_REACHED();
return 0;
......@@ -1151,20 +1041,16 @@ required_field_pack(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes written to `out`.
*/
static size_t
oneof_field_pack(const ProtobufCFieldDescriptor *field,
uint32_t oneof_case,
const void *member, uint8_t *out)
{
static size_t oneof_field_pack(const ProtobufCFieldDescriptor *field,
uint32_t oneof_case, const void *member,
uint8_t *out) {
if (oneof_case != field->id) {
return 0;
}
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void * const *) member;
if (ptr == NULL || ptr == field->default_value)
return 0;
field->type == PROTOBUF_C_TYPE_STRING) {
const void *ptr = *(const void *const *)member;
if (ptr == NULL || ptr == field->default_value) return 0;
}
return required_field_pack(field, member, out);
}
......@@ -1183,20 +1069,15 @@ oneof_field_pack(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes written to `out`.
*/
static size_t
optional_field_pack(const ProtobufCFieldDescriptor *field,
static size_t optional_field_pack(const ProtobufCFieldDescriptor *field,
const protobuf_c_boolean has,
const void *member, uint8_t *out)
{
const void *member, uint8_t *out) {
if (field->type == PROTOBUF_C_TYPE_MESSAGE ||
field->type == PROTOBUF_C_TYPE_STRING)
{
const void *ptr = *(const void * const *) member;
if (ptr == NULL || ptr == field->default_value)
return 0;
field->type == PROTOBUF_C_TYPE_STRING) {
const void *ptr = *(const void *const *)member;
if (ptr == NULL || ptr == field->default_value) return 0;
} else {
if (!has)
return 0;
if (!has) return 0;
}
return required_field_pack(field, member, out);
}
......@@ -1213,12 +1094,9 @@ optional_field_pack(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes written to `out`.
*/
static size_t
unlabeled_field_pack(const ProtobufCFieldDescriptor *field,
const void *member, uint8_t *out)
{
if (field_is_zeroish(field, member))
return 0;
static size_t unlabeled_field_pack(const ProtobufCFieldDescriptor *field,
const void *member, uint8_t *out) {
if (field_is_zeroish(field, member)) return 0;
return required_field_pack(field, member, out);
}
......@@ -1232,9 +1110,7 @@ unlabeled_field_pack(const ProtobufCFieldDescriptor *field,
* \return
* Size of the field.
*/
static inline size_t
sizeof_elt_in_repeated_array(ProtobufCType type)
{
static inline size_t sizeof_elt_in_repeated_array(ProtobufCType type) {
switch (type) {
case PROTOBUF_C_TYPE_SINT32:
case PROTOBUF_C_TYPE_INT32:
......@@ -1273,16 +1149,14 @@ sizeof_elt_in_repeated_array(ProtobufCType type)
* \param[in] n
* Number of elements in the source array.
*/
static void
copy_to_little_endian_32(void *out, const void *in, const unsigned n)
{
static void copy_to_little_endian_32(void *out, const void *in,
const unsigned n) {
#if !defined(WORDS_BIGENDIAN)
memcpy(out, in, n * 4);
#else
unsigned i;
const uint32_t *ini = in;
for (i = 0; i < n; i++)
fixed32_pack(ini[i], (uint32_t *) out + i);
for (i = 0; i < n; i++) fixed32_pack(ini[i], (uint32_t *)out + i);
#endif
}
......@@ -1296,16 +1170,14 @@ copy_to_little_endian_32(void *out, const void *in, const unsigned n)
* \param[in] n
* Number of elements in the source array.
*/
static void
copy_to_little_endian_64(void *out, const void *in, const unsigned n)
{
static void copy_to_little_endian_64(void *out, const void *in,
const unsigned n) {
#if !defined(WORDS_BIGENDIAN)
memcpy(out, in, n * 8);
#else
unsigned i;
const uint64_t *ini = in;
for (i = 0; i < n; i++)
fixed64_pack(ini[i], (uint64_t *) out + i);
for (i = 0; i < n; i++) fixed64_pack(ini[i], (uint64_t *)out + i);
#endif
}
......@@ -1318,19 +1190,13 @@ copy_to_little_endian_64(void *out, const void *in, const unsigned n)
* \return
* Number of bytes.
*/
static unsigned
get_type_min_size(ProtobufCType type)
{
if (type == PROTOBUF_C_TYPE_SFIXED32 ||
type == PROTOBUF_C_TYPE_FIXED32 ||
type == PROTOBUF_C_TYPE_FLOAT)
{
static unsigned get_type_min_size(ProtobufCType type) {
if (type == PROTOBUF_C_TYPE_SFIXED32 || type == PROTOBUF_C_TYPE_FIXED32 ||
type == PROTOBUF_C_TYPE_FLOAT) {
return 4;
}
if (type == PROTOBUF_C_TYPE_SFIXED64 ||
type == PROTOBUF_C_TYPE_FIXED64 ||
type == PROTOBUF_C_TYPE_DOUBLE)
{
if (type == PROTOBUF_C_TYPE_SFIXED64 || type == PROTOBUF_C_TYPE_FIXED64 ||
type == PROTOBUF_C_TYPE_DOUBLE) {
return 8;
}
return 1;
......@@ -1348,10 +1214,8 @@ get_type_min_size(ProtobufCType type)
* \return
* Number of bytes required.
*/
static size_t
get_packed_payload_length(const ProtobufCFieldDescriptor *field,
unsigned count, const void *array)
{
static size_t get_packed_payload_length(const ProtobufCFieldDescriptor *field,
unsigned count, const void *array) {
unsigned rv = 0;
unsigned i;
......@@ -1366,34 +1230,29 @@ get_packed_payload_length(const ProtobufCFieldDescriptor *field,
return count * 8;
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32: {
const int32_t *arr = (const int32_t *) array;
for (i = 0; i < count; i++)
rv += int32_size(arr[i]);
const int32_t *arr = (const int32_t *)array;
for (i = 0; i < count; i++) rv += int32_size(arr[i]);
break;
}
case PROTOBUF_C_TYPE_SINT32: {
const int32_t *arr = (const int32_t *) array;
for (i = 0; i < count; i++)
rv += sint32_size(arr[i]);
const int32_t *arr = (const int32_t *)array;
for (i = 0; i < count; i++) rv += sint32_size(arr[i]);
break;
}
case PROTOBUF_C_TYPE_UINT32: {
const uint32_t *arr = (const uint32_t *) array;
for (i = 0; i < count; i++)
rv += uint32_size(arr[i]);
const uint32_t *arr = (const uint32_t *)array;
for (i = 0; i < count; i++) rv += uint32_size(arr[i]);
break;
}
case PROTOBUF_C_TYPE_SINT64: {
const int64_t *arr = (const int64_t *) array;
for (i = 0; i < count; i++)
rv += sint64_size(arr[i]);
const int64_t *arr = (const int64_t *)array;
for (i = 0; i < count; i++) rv += sint64_size(arr[i]);
break;
}
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64: {
const uint64_t *arr = (const uint64_t *) array;
for (i = 0; i < count; i++)
rv += uint64_size(arr[i]);
const uint64_t *arr = (const uint64_t *)array;
for (i = 0; i < count; i++) rv += uint64_size(arr[i]);
break;
}
case PROTOBUF_C_TYPE_BOOL:
......@@ -1418,11 +1277,9 @@ get_packed_payload_length(const ProtobufCFieldDescriptor *field,
* \return
* Number of bytes packed.
*/
static size_t
pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field,
static size_t pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field,
unsigned count, const void *array,
ProtobufCBuffer *buffer)
{
ProtobufCBuffer *buffer) {
uint8_t scratch[16];
size_t rv = 0;
unsigned i;
......@@ -1436,7 +1293,7 @@ pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field,
goto no_packing_needed;
#else
for (i = 0; i < count; i++) {
unsigned len = fixed32_pack(((uint32_t *) array)[i], scratch);
unsigned len = fixed32_pack(((uint32_t *)array)[i], scratch);
buffer->append(buffer, len, scratch);
rv += len;
}
......@@ -1450,7 +1307,7 @@ pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field,
goto no_packing_needed;
#else
for (i = 0; i < count; i++) {
unsigned len = fixed64_pack(((uint64_t *) array)[i], scratch);
unsigned len = fixed64_pack(((uint64_t *)array)[i], scratch);
buffer->append(buffer, len, scratch);
rv += len;
}
......@@ -1459,28 +1316,28 @@ pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field,
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32:
for (i = 0; i < count; i++) {
unsigned len = int32_pack(((int32_t *) array)[i], scratch);
unsigned len = int32_pack(((int32_t *)array)[i], scratch);
buffer->append(buffer, len, scratch);
rv += len;
}
break;
case PROTOBUF_C_TYPE_SINT32:
for (i = 0; i < count; i++) {
unsigned len = sint32_pack(((int32_t *) array)[i], scratch);
unsigned len = sint32_pack(((int32_t *)array)[i], scratch);
buffer->append(buffer, len, scratch);
rv += len;
}
break;
case PROTOBUF_C_TYPE_UINT32:
for (i = 0; i < count; i++) {
unsigned len = uint32_pack(((uint32_t *) array)[i], scratch);
unsigned len = uint32_pack(((uint32_t *)array)[i], scratch);
buffer->append(buffer, len, scratch);
rv += len;
}
break;
case PROTOBUF_C_TYPE_SINT64:
for (i = 0; i < count; i++) {
unsigned len = sint64_pack(((int64_t *) array)[i], scratch);
unsigned len = sint64_pack(((int64_t *)array)[i], scratch);
buffer->append(buffer, len, scratch);
rv += len;
}
......@@ -1488,14 +1345,14 @@ pack_buffer_packed_payload(const ProtobufCFieldDescriptor *field,
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64:
for (i = 0; i < count; i++) {
unsigned len = uint64_pack(((uint64_t *) array)[i], scratch);
unsigned len = uint64_pack(((uint64_t *)array)[i], scratch);
buffer->append(buffer, len, scratch);
rv += len;
}
break;
case PROTOBUF_C_TYPE_BOOL:
for (i = 0; i < count; i++) {
unsigned len = boolean_pack(((protobuf_c_boolean *) array)[i], scratch);
unsigned len = boolean_pack(((protobuf_c_boolean *)array)[i], scratch);
buffer->append(buffer, len, scratch);
rv += len;
}
......@@ -1512,14 +1369,12 @@ no_packing_needed:
#endif
}
static inline int
int_range_lookup(unsigned n_ranges, const ProtobufCIntRange *ranges, int value)
{
static inline int int_range_lookup(unsigned n_ranges,
const ProtobufCIntRange *ranges, int value) {
unsigned n;
unsigned start;
if (n_ranges == 0)
return -1;
if (n_ranges == 0) return -1;
start = 0;
n = n_ranges;
while (n > 1) {
......@@ -1527,38 +1382,30 @@ int_range_lookup(unsigned n_ranges, const ProtobufCIntRange *ranges, int value)
if (value < ranges[mid].start_value) {
n = mid - start;
} else if (value >= ranges[mid].start_value +
(int) (ranges[mid + 1].orig_index -
ranges[mid].orig_index))
{
} else if (value >=
ranges[mid].start_value +
(int)(ranges[mid + 1].orig_index - ranges[mid].orig_index)) {
unsigned new_start = mid + 1;
n = start + n - new_start;
start = new_start;
} else
return (value - ranges[mid].start_value) +
ranges[mid].orig_index;
return (value - ranges[mid].start_value) + ranges[mid].orig_index;
}
if (n > 0) {
unsigned start_orig_index = ranges[start].orig_index;
unsigned range_size =
ranges[start + 1].orig_index - start_orig_index;
unsigned range_size = ranges[start + 1].orig_index - start_orig_index;
if (ranges[start].start_value <= value &&
value < (int) (ranges[start].start_value + range_size))
{
return (value - ranges[start].start_value) +
start_orig_index;
value < (int)(ranges[start].start_value + range_size)) {
return (value - ranges[start].start_value) + start_orig_index;
}
}
return -1;
}
static size_t
parse_tag_and_wiretype(size_t len,
const uint8_t *data,
static size_t parse_tag_and_wiretype(size_t len, const uint8_t *data,
uint32_t *tag_out,
ProtobufCWireType *wiretype_out)
{
ProtobufCWireType *wiretype_out) {
unsigned max_rv = len > 5 ? 5 : len;
uint32_t tag = (data[0] & 0x7f) >> 3;
unsigned shift = 4;
......@@ -1595,10 +1442,9 @@ struct _ScannedMember {
const uint8_t *data; /**< Pointer to field data. */
};
static inline uint32_t
scan_length_prefixed_data(size_t len, const uint8_t *data,
size_t *prefix_len_out)
{
static inline uint32_t scan_length_prefixed_data(size_t len,
const uint8_t *data,
size_t *prefix_len_out) {
unsigned hdr_max = len < 5 ? len : 5;
unsigned hdr_len;
uint32_t val = 0;
......@@ -1608,8 +1454,7 @@ scan_length_prefixed_data(size_t len, const uint8_t *data,
for (i = 0; i < hdr_max; i++) {
val |= (data[i] & 0x7f) << shift;
shift += 7;
if ((data[i] & 0x80) == 0)
break;
if ((data[i] & 0x80) == 0) break;
}
if (i == hdr_max) {
PROTOBUF_C_UNPACK_ERROR("error parsing length for length-prefixed data");
......@@ -1624,13 +1469,10 @@ scan_length_prefixed_data(size_t len, const uint8_t *data,
return hdr_len + val;
}
static size_t
max_b128_numbers(size_t len, const uint8_t *data)
{
static size_t max_b128_numbers(size_t len, const uint8_t *data) {
size_t rv = 0;
while (len--)
if ((*data++ & 0x80) == 0)
++rv;
if ((*data++ & 0x80) == 0) ++rv;
return rv;
}
......@@ -1650,46 +1492,33 @@ max_b128_numbers(size_t len, const uint8_t *data)
* some of its fields may have been reused and changed to their default
* values during the merge.
*/
static protobuf_c_boolean
merge_messages(ProtobufCMessage *earlier_msg,
static protobuf_c_boolean merge_messages(ProtobufCMessage *earlier_msg,
ProtobufCMessage *latter_msg,
ProtobufCAllocator *allocator)
{
ProtobufCAllocator *allocator) {
unsigned i;
const ProtobufCFieldDescriptor *fields =
latter_msg->descriptor->fields;
const ProtobufCFieldDescriptor *fields = latter_msg->descriptor->fields;
for (i = 0; i < latter_msg->descriptor->n_fields; i++) {
if (fields[i].label == PROTOBUF_C_LABEL_REPEATED) {
size_t *n_earlier =
STRUCT_MEMBER_PTR(size_t, earlier_msg,
fields[i].quantifier_offset);
STRUCT_MEMBER_PTR(size_t, earlier_msg, fields[i].quantifier_offset);
uint8_t **p_earlier =
STRUCT_MEMBER_PTR(uint8_t *, earlier_msg,
fields[i].offset);
STRUCT_MEMBER_PTR(uint8_t *, earlier_msg, fields[i].offset);
size_t *n_latter =
STRUCT_MEMBER_PTR(size_t, latter_msg,
fields[i].quantifier_offset);
STRUCT_MEMBER_PTR(size_t, latter_msg, fields[i].quantifier_offset);
uint8_t **p_latter =
STRUCT_MEMBER_PTR(uint8_t *, latter_msg,
fields[i].offset);
STRUCT_MEMBER_PTR(uint8_t *, latter_msg, fields[i].offset);
if (*n_earlier > 0) {
if (*n_latter > 0) {
/* Concatenate the repeated field */
size_t el_size =
sizeof_elt_in_repeated_array(fields[i].type);
size_t el_size = sizeof_elt_in_repeated_array(fields[i].type);
uint8_t *new_field;
new_field = do_alloc(allocator,
(*n_earlier + *n_latter) * el_size);
if (!new_field)
return FALSE;
new_field = do_alloc(allocator, (*n_earlier + *n_latter) * el_size);
if (!new_field) return FALSE;
memcpy(new_field, *p_earlier,
*n_earlier * el_size);
memcpy(new_field +
*n_earlier * el_size,
*p_latter,
memcpy(new_field, *p_earlier, *n_earlier * el_size);
memcpy(new_field + *n_earlier * el_size, *p_latter,
*n_latter * el_size);
do_free(allocator, *p_latter);
......@@ -1708,14 +1537,10 @@ merge_messages(ProtobufCMessage *earlier_msg,
} else if (fields[i].label == PROTOBUF_C_LABEL_OPTIONAL ||
fields[i].label == PROTOBUF_C_LABEL_NONE) {
const ProtobufCFieldDescriptor *field;
uint32_t *earlier_case_p = STRUCT_MEMBER_PTR(uint32_t,
earlier_msg,
fields[i].
quantifier_offset);
uint32_t *latter_case_p = STRUCT_MEMBER_PTR(uint32_t,
latter_msg,
fields[i].
quantifier_offset);
uint32_t *earlier_case_p =
STRUCT_MEMBER_PTR(uint32_t, earlier_msg, fields[i].quantifier_offset);
uint32_t *latter_case_p =
STRUCT_MEMBER_PTR(uint32_t, latter_msg, fields[i].quantifier_offset);
protobuf_c_boolean need_to_merge = FALSE;
void *earlier_elem;
void *latter_elem;
......@@ -1724,15 +1549,10 @@ merge_messages(ProtobufCMessage *earlier_msg,
if (fields[i].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) {
if (*latter_case_p == 0) {
/* lookup correct oneof field */
int field_index =
int_range_lookup(
latter_msg->descriptor
->n_field_ranges,
latter_msg->descriptor
->field_ranges,
*earlier_case_p);
field = latter_msg->descriptor->fields +
field_index;
int field_index = int_range_lookup(
latter_msg->descriptor->n_field_ranges,
latter_msg->descriptor->field_ranges, *earlier_case_p);
field = latter_msg->descriptor->fields + field_index;
} else {
/* Oneof is present in the latter message, move on */
continue;
......@@ -1747,12 +1567,11 @@ merge_messages(ProtobufCMessage *earlier_msg,
switch (field->type) {
case PROTOBUF_C_TYPE_MESSAGE: {
ProtobufCMessage *em = *(ProtobufCMessage **) earlier_elem;
ProtobufCMessage *lm = *(ProtobufCMessage **) latter_elem;
ProtobufCMessage *em = *(ProtobufCMessage **)earlier_elem;
ProtobufCMessage *lm = *(ProtobufCMessage **)latter_elem;
if (em != NULL) {
if (lm != NULL) {
if (!merge_messages(em, lm, allocator))
return FALSE;
if (!merge_messages(em, lm, allocator)) return FALSE;
/* Already merged */
need_to_merge = FALSE;
} else {
......@@ -1763,25 +1582,18 @@ merge_messages(ProtobufCMessage *earlier_msg,
break;
}
case PROTOBUF_C_TYPE_BYTES: {
uint8_t *e_data =
((ProtobufCBinaryData *) earlier_elem)->data;
uint8_t *l_data =
((ProtobufCBinaryData *) latter_elem)->data;
const ProtobufCBinaryData *d_bd =
(ProtobufCBinaryData *) def_val;
uint8_t *e_data = ((ProtobufCBinaryData *)earlier_elem)->data;
uint8_t *l_data = ((ProtobufCBinaryData *)latter_elem)->data;
const ProtobufCBinaryData *d_bd = (ProtobufCBinaryData *)def_val;
need_to_merge =
(e_data != NULL &&
(d_bd == NULL ||
e_data != d_bd->data)) &&
(l_data == NULL ||
(d_bd != NULL &&
l_data == d_bd->data));
(e_data != NULL && (d_bd == NULL || e_data != d_bd->data)) &&
(l_data == NULL || (d_bd != NULL && l_data == d_bd->data));
break;
}
case PROTOBUF_C_TYPE_STRING: {
char *e_str = *(char **) earlier_elem;
char *l_str = *(char **) latter_elem;
char *e_str = *(char **)earlier_elem;
char *l_str = *(char **)latter_elem;
const char *d_str = def_val;
need_to_merge = e_str != d_str && l_str == d_str;
......@@ -1791,15 +1603,13 @@ merge_messages(ProtobufCMessage *earlier_msg,
/* Could be has field or case enum, the logic is
* equivalent, since 0 (FALSE) means not set for
* oneof */
need_to_merge = (*earlier_case_p != 0) &&
(*latter_case_p == 0);
need_to_merge = (*earlier_case_p != 0) && (*latter_case_p == 0);
break;
}
}
if (need_to_merge) {
size_t el_size =
sizeof_elt_in_repeated_array(field->type);
size_t el_size = sizeof_elt_in_repeated_array(field->type);
memcpy(latter_elem, earlier_elem, el_size);
/*
* Reset the element from the old message to 0
......@@ -1830,16 +1640,16 @@ merge_messages(ProtobufCMessage *earlier_msg,
* others; the remaining error checking is done by
* parse_packed_repeated_member().
*/
static protobuf_c_boolean
count_packed_elements(ProtobufCType type,
size_t len, const uint8_t *data, size_t *count_out)
{
static protobuf_c_boolean count_packed_elements(ProtobufCType type, size_t len,
const uint8_t *data,
size_t *count_out) {
switch (type) {
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_FLOAT:
if (len % 4 != 0) {
PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 4 for fixed-length 32-bit types");
PROTOBUF_C_UNPACK_ERROR(
"length must be a multiple of 4 for fixed-length 32-bit types");
return FALSE;
}
*count_out = len / 4;
......@@ -1848,7 +1658,8 @@ count_packed_elements(ProtobufCType type,
case PROTOBUF_C_TYPE_FIXED64:
case PROTOBUF_C_TYPE_DOUBLE:
if (len % 8 != 0) {
PROTOBUF_C_UNPACK_ERROR("length must be a multiple of 8 for fixed-length 64-bit types");
PROTOBUF_C_UNPACK_ERROR(
"length must be a multiple of 8 for fixed-length 64-bit types");
return FALSE;
}
*count_out = len / 8;
......@@ -1869,117 +1680,92 @@ count_packed_elements(ProtobufCType type,
case PROTOBUF_C_TYPE_BYTES:
case PROTOBUF_C_TYPE_MESSAGE:
default:
PROTOBUF_C_UNPACK_ERROR("bad protobuf-c type %u for packed-repeated", type);
PROTOBUF_C_UNPACK_ERROR("bad protobuf-c type %u for packed-repeated",
type);
return FALSE;
}
}
static inline uint32_t
parse_uint32(unsigned len, const uint8_t *data)
{
static inline uint32_t parse_uint32(unsigned len, const uint8_t *data) {
uint32_t rv = data[0] & 0x7f;
if (len > 1) {
rv |= ((uint32_t) (data[1] & 0x7f) << 7);
rv |= ((uint32_t)(data[1] & 0x7f) << 7);
if (len > 2) {
rv |= ((uint32_t) (data[2] & 0x7f) << 14);
rv |= ((uint32_t)(data[2] & 0x7f) << 14);
if (len > 3) {
rv |= ((uint32_t) (data[3] & 0x7f) << 21);
if (len > 4)
rv |= ((uint32_t) (data[4]) << 28);
rv |= ((uint32_t)(data[3] & 0x7f) << 21);
if (len > 4) rv |= ((uint32_t)(data[4]) << 28);
}
}
}
return rv;
}
static inline uint32_t
parse_int32(unsigned len, const uint8_t *data)
{
static inline uint32_t parse_int32(unsigned len, const uint8_t *data) {
return parse_uint32(len, data);
}
static inline int32_t
unzigzag32(uint32_t v)
{
static inline int32_t unzigzag32(uint32_t v) {
if (v & 1)
return -(v >> 1) - 1;
else
return v >> 1;
}
static inline uint32_t
parse_fixed_uint32(const uint8_t *data)
{
static inline uint32_t parse_fixed_uint32(const uint8_t *data) {
#if !defined(WORDS_BIGENDIAN)
uint32_t t;
memcpy(&t, data, 4);
return t;
#else
return data[0] |
((uint32_t) (data[1]) << 8) |
((uint32_t) (data[2]) << 16) |
((uint32_t) (data[3]) << 24);
return data[0] | ((uint32_t)(data[1]) << 8) | ((uint32_t)(data[2]) << 16) |
((uint32_t)(data[3]) << 24);
#endif
}
static uint64_t
parse_uint64(unsigned len, const uint8_t *data)
{
static uint64_t parse_uint64(unsigned len, const uint8_t *data) {
unsigned shift, i;
uint64_t rv;
if (len < 5)
return parse_uint32(len, data);
rv = ((uint64_t) (data[0] & 0x7f)) |
((uint64_t) (data[1] & 0x7f) << 7) |
((uint64_t) (data[2] & 0x7f) << 14) |
((uint64_t) (data[3] & 0x7f) << 21);
if (len < 5) return parse_uint32(len, data);
rv = ((uint64_t)(data[0] & 0x7f)) | ((uint64_t)(data[1] & 0x7f) << 7) |
((uint64_t)(data[2] & 0x7f) << 14) | ((uint64_t)(data[3] & 0x7f) << 21);
shift = 28;
for (i = 4; i < len; i++) {
rv |= (((uint64_t) (data[i] & 0x7f)) << shift);
rv |= (((uint64_t)(data[i] & 0x7f)) << shift);
shift += 7;
}
return rv;
}
static inline int64_t
unzigzag64(uint64_t v)
{
static inline int64_t unzigzag64(uint64_t v) {
if (v & 1)
return -(v >> 1) - 1;
else
return v >> 1;
}
static inline uint64_t
parse_fixed_uint64(const uint8_t *data)
{
static inline uint64_t parse_fixed_uint64(const uint8_t *data) {
#if !defined(WORDS_BIGENDIAN)
uint64_t t;
memcpy(&t, data, 8);
return t;
#else
return (uint64_t) parse_fixed_uint32(data) |
(((uint64_t) parse_fixed_uint32(data + 4)) << 32);
return (uint64_t)parse_fixed_uint32(data) |
(((uint64_t)parse_fixed_uint32(data + 4)) << 32);
#endif
}
static protobuf_c_boolean
parse_boolean(unsigned len, const uint8_t *data)
{
static protobuf_c_boolean parse_boolean(unsigned len, const uint8_t *data) {
unsigned i;
for (i = 0; i < len; i++)
if (data[i] & 0x7f)
return TRUE;
if (data[i] & 0x7f) return TRUE;
return FALSE;
}
static protobuf_c_boolean
parse_required_member(ScannedMember *scanned_member,
void *member,
ProtobufCAllocator *allocator,
protobuf_c_boolean maybe_clear)
{
static protobuf_c_boolean parse_required_member(
ScannedMember *scanned_member, void *member, ProtobufCAllocator *allocator,
protobuf_c_boolean maybe_clear) {
unsigned len = scanned_member->len;
const uint8_t *data = scanned_member->data;
ProtobufCWireType wire_type = scanned_member->wire_type;
......@@ -1987,63 +1773,53 @@ parse_required_member(ScannedMember *scanned_member,
switch (scanned_member->field->type) {
case PROTOBUF_C_TYPE_ENUM:
case PROTOBUF_C_TYPE_INT32:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
return FALSE;
*(int32_t *) member = parse_int32(len, data);
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(int32_t *)member = parse_int32(len, data);
return TRUE;
case PROTOBUF_C_TYPE_UINT32:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
return FALSE;
*(uint32_t *) member = parse_uint32(len, data);
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(uint32_t *)member = parse_uint32(len, data);
return TRUE;
case PROTOBUF_C_TYPE_SINT32:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
return FALSE;
*(int32_t *) member = unzigzag32(parse_uint32(len, data));
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(int32_t *)member = unzigzag32(parse_uint32(len, data));
return TRUE;
case PROTOBUF_C_TYPE_SFIXED32:
case PROTOBUF_C_TYPE_FIXED32:
case PROTOBUF_C_TYPE_FLOAT:
if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT)
return FALSE;
*(uint32_t *) member = parse_fixed_uint32(data);
if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT) return FALSE;
*(uint32_t *)member = parse_fixed_uint32(data);
return TRUE;
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
return FALSE;
*(uint64_t *) member = parse_uint64(len, data);
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(uint64_t *)member = parse_uint64(len, data);
return TRUE;
case PROTOBUF_C_TYPE_SINT64:
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
return FALSE;
*(int64_t *) member = unzigzag64(parse_uint64(len, data));
if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT) return FALSE;
*(int64_t *)member = unzigzag64(parse_uint64(len, data));
return TRUE;
case PROTOBUF_C_TYPE_SFIXED64:
case PROTOBUF_C_TYPE_FIXED64:
case PROTOBUF_C_TYPE_DOUBLE:
if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT)
return FALSE;
*(uint64_t *) member = parse_fixed_uint64(data);
if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT) return FALSE;
*(uint64_t *)member = parse_fixed_uint64(data);
return TRUE;
case PROTOBUF_C_TYPE_BOOL:
*(protobuf_c_boolean *) member = parse_boolean(len, data);
*(protobuf_c_boolean *)member = parse_boolean(len, data);
return TRUE;
case PROTOBUF_C_TYPE_STRING: {
char **pstr = member;
unsigned pref_len = scanned_member->length_prefix_len;
if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
return FALSE;
if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) return FALSE;
if (maybe_clear && *pstr != NULL) {
const char *def = scanned_member->field->default_value;
if (*pstr != NULL && *pstr != def)
do_free(allocator, *pstr);
if (*pstr != NULL && *pstr != def) do_free(allocator, *pstr);
}
*pstr = do_alloc(allocator, len - pref_len + 1);
if (*pstr == NULL)
return FALSE;
if (*pstr == NULL) return FALSE;
memcpy(*pstr, data + pref_len, len - pref_len);
(*pstr)[len - pref_len] = 0;
return TRUE;
......@@ -2053,20 +1829,16 @@ parse_required_member(ScannedMember *scanned_member,
const ProtobufCBinaryData *def_bd;
unsigned pref_len = scanned_member->length_prefix_len;
if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
return FALSE;
if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) return FALSE;
def_bd = scanned_member->field->default_value;
if (maybe_clear &&
bd->data != NULL &&
(def_bd == NULL || bd->data != def_bd->data))
{
if (maybe_clear && bd->data != NULL &&
(def_bd == NULL || bd->data != def_bd->data)) {
do_free(allocator, bd->data);
}
if (len - pref_len > 0) {
bd->data = do_alloc(allocator, len - pref_len);
if (bd->data == NULL)
return FALSE;
if (bd->data == NULL) return FALSE;
memcpy(bd->data, data + pref_len, len - pref_len);
} else {
bd->data = NULL;
......@@ -2081,49 +1853,40 @@ parse_required_member(ScannedMember *scanned_member,
protobuf_c_boolean merge_successful = TRUE;
unsigned pref_len = scanned_member->length_prefix_len;
if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
return FALSE;
if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED) return FALSE;
def_mess = scanned_member->field->default_value;
subm = protobuf_c_message_unpack(scanned_member->field->descriptor,
allocator,
len - pref_len,
data + pref_len);
if (maybe_clear &&
*pmessage != NULL &&
*pmessage != def_mess)
{
subm =
protobuf_c_message_unpack(scanned_member->field->descriptor,
allocator, len - pref_len, data + pref_len);
if (maybe_clear && *pmessage != NULL && *pmessage != def_mess) {
if (subm != NULL)
merge_successful = merge_messages(*pmessage, subm, allocator);
/* Delete the previous message */
protobuf_c_message_free_unpacked(*pmessage, allocator);
}
*pmessage = subm;
if (subm == NULL || !merge_successful)
return FALSE;
if (subm == NULL || !merge_successful) return FALSE;
return TRUE;
}
}
return FALSE;
}
static protobuf_c_boolean
parse_oneof_member (ScannedMember *scanned_member,
static protobuf_c_boolean parse_oneof_member(ScannedMember *scanned_member,
void *member,
ProtobufCMessage *message,
ProtobufCAllocator *allocator)
{
uint32_t *oneof_case = STRUCT_MEMBER_PTR(uint32_t, message,
scanned_member->field->quantifier_offset);
ProtobufCAllocator *allocator) {
uint32_t *oneof_case = STRUCT_MEMBER_PTR(
uint32_t, message, scanned_member->field->quantifier_offset);
/* If we have already parsed a member of this oneof, free it. */
if (*oneof_case != 0) {
/* lookup field */
int field_index =
int_range_lookup(message->descriptor->n_field_ranges,
message->descriptor->field_ranges,
*oneof_case);
message->descriptor->field_ranges, *oneof_case);
const ProtobufCFieldDescriptor *old_field =
message->descriptor->fields + field_index;
size_t el_size = sizeof_elt_in_repeated_array(old_field->type);
......@@ -2132,16 +1895,13 @@ parse_oneof_member (ScannedMember *scanned_member,
case PROTOBUF_C_TYPE_STRING: {
char **pstr = member;
const char *def = old_field->default_value;
if (*pstr != NULL && *pstr != def)
do_free(allocator, *pstr);
if (*pstr != NULL && *pstr != def) do_free(allocator, *pstr);
break;
}
case PROTOBUF_C_TYPE_BYTES: {
ProtobufCBinaryData *bd = member;
const ProtobufCBinaryData *def_bd = old_field->default_value;
if (bd->data != NULL &&
(def_bd == NULL || bd->data != def_bd->data))
{
if (bd->data != NULL && (def_bd == NULL || bd->data != def_bd->data)) {
do_free(allocator, bd->data);
}
break;
......@@ -2157,74 +1917,59 @@ parse_oneof_member (ScannedMember *scanned_member,
break;
}
memset (member, 0, el_size);
memset(member, 0, el_size);
}
if (!parse_required_member (scanned_member, member, allocator, TRUE))
if (!parse_required_member(scanned_member, member, allocator, TRUE))
return FALSE;
*oneof_case = scanned_member->tag;
return TRUE;
}
static protobuf_c_boolean
parse_optional_member(ScannedMember *scanned_member,
static protobuf_c_boolean parse_optional_member(ScannedMember *scanned_member,
void *member,
ProtobufCMessage *message,
ProtobufCAllocator *allocator)
{
ProtobufCAllocator *allocator) {
if (!parse_required_member(scanned_member, member, allocator, TRUE))
return FALSE;
if (scanned_member->field->quantifier_offset != 0)
STRUCT_MEMBER(protobuf_c_boolean,
message,
STRUCT_MEMBER(protobuf_c_boolean, message,
scanned_member->field->quantifier_offset) = TRUE;
return TRUE;
}
static protobuf_c_boolean
parse_repeated_member(ScannedMember *scanned_member,
static protobuf_c_boolean parse_repeated_member(ScannedMember *scanned_member,
void *member,
ProtobufCMessage *message,
ProtobufCAllocator *allocator)
{
ProtobufCAllocator *allocator) {
const ProtobufCFieldDescriptor *field = scanned_member->field;
size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset);
size_t siz = sizeof_elt_in_repeated_array(field->type);
char *array = *(char **) member;
char *array = *(char **)member;
if (!parse_required_member(scanned_member, array + siz * (*p_n),
allocator, FALSE))
{
if (!parse_required_member(scanned_member, array + siz * (*p_n), allocator,
FALSE)) {
return FALSE;
}
*p_n += 1;
return TRUE;
}
static unsigned
scan_varint(unsigned len, const uint8_t *data)
{
static unsigned scan_varint(unsigned len, const uint8_t *data) {
unsigned i;
if (len > 10)
len = 10;
if (len > 10) len = 10;
for (i = 0; i < len; i++)
if ((data[i] & 0x80) == 0)
break;
if (i == len)
return 0;
if ((data[i] & 0x80) == 0) break;
if (i == len) return 0;
return i + 1;
}
static protobuf_c_boolean
parse_packed_repeated_member(ScannedMember *scanned_member,
void *member,
ProtobufCMessage *message)
{
static protobuf_c_boolean parse_packed_repeated_member(
ScannedMember *scanned_member, void *member, ProtobufCMessage *message) {
const ProtobufCFieldDescriptor *field = scanned_member->field;
size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset);
size_t siz = sizeof_elt_in_repeated_array(field->type);
void *array = *(char **) member + siz * (*p_n);
void *array = *(char **)member + siz * (*p_n);
const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len;
size_t rem = scanned_member->len - scanned_member->length_prefix_len;
size_t count = 0;
......@@ -2239,7 +1984,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
goto no_unpacking_needed;
#else
for (i = 0; i < count; i++) {
((uint32_t *) array)[i] = parse_fixed_uint32(at);
((uint32_t *)array)[i] = parse_fixed_uint32(at);
at += 4;
}
break;
......@@ -2252,7 +1997,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
goto no_unpacking_needed;
#else
for (i = 0; i < count; i++) {
((uint64_t *) array)[i] = parse_fixed_uint64(at);
((uint64_t *)array)[i] = parse_fixed_uint64(at);
at += 8;
}
break;
......@@ -2265,7 +2010,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int32 value");
return FALSE;
}
((int32_t *) array)[count++] = parse_int32(s, at);
((int32_t *)array)[count++] = parse_int32(s, at);
at += s;
rem -= s;
}
......@@ -2277,7 +2022,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint32 value");
return FALSE;
}
((int32_t *) array)[count++] = unzigzag32(parse_uint32(s, at));
((int32_t *)array)[count++] = unzigzag32(parse_uint32(s, at));
at += s;
rem -= s;
}
......@@ -2289,7 +2034,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated enum or uint32 value");
return FALSE;
}
((uint32_t *) array)[count++] = parse_uint32(s, at);
((uint32_t *)array)[count++] = parse_uint32(s, at);
at += s;
rem -= s;
}
......@@ -2302,7 +2047,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated sint64 value");
return FALSE;
}
((int64_t *) array)[count++] = unzigzag64(parse_uint64(s, at));
((int64_t *)array)[count++] = unzigzag64(parse_uint64(s, at));
at += s;
rem -= s;
}
......@@ -2315,7 +2060,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated int64/uint64 value");
return FALSE;
}
((int64_t *) array)[count++] = parse_uint64(s, at);
((int64_t *)array)[count++] = parse_uint64(s, at);
at += s;
rem -= s;
}
......@@ -2327,7 +2072,7 @@ parse_packed_repeated_member(ScannedMember *scanned_member,
PROTOBUF_C_UNPACK_ERROR("bad packed-repeated boolean value");
return FALSE;
}
((protobuf_c_boolean *) array)[i] = at[i];
((protobuf_c_boolean *)array)[i] = at[i];
}
break;
default:
......@@ -2344,61 +2089,47 @@ no_unpacking_needed:
#endif
}
static protobuf_c_boolean
is_packable_type(ProtobufCType type)
{
return
type != PROTOBUF_C_TYPE_STRING &&
type != PROTOBUF_C_TYPE_BYTES &&
static protobuf_c_boolean is_packable_type(ProtobufCType type) {
return type != PROTOBUF_C_TYPE_STRING && type != PROTOBUF_C_TYPE_BYTES &&
type != PROTOBUF_C_TYPE_MESSAGE;
}
static protobuf_c_boolean
parse_member(ScannedMember *scanned_member,
static protobuf_c_boolean parse_member(ScannedMember *scanned_member,
ProtobufCMessage *message,
ProtobufCAllocator *allocator)
{
ProtobufCAllocator *allocator) {
const ProtobufCFieldDescriptor *field = scanned_member->field;
void *member;
if (field == NULL) {
ProtobufCMessageUnknownField *ufield =
message->unknown_fields +
(message->n_unknown_fields++);
message->unknown_fields + (message->n_unknown_fields++);
ufield->tag = scanned_member->tag;
ufield->wire_type = scanned_member->wire_type;
ufield->len = scanned_member->len;
ufield->data = do_alloc(allocator, scanned_member->len);
if (ufield->data == NULL)
return FALSE;
if (ufield->data == NULL) return FALSE;
memcpy(ufield->data, scanned_member->data, ufield->len);
return TRUE;
}
member = (char *) message + field->offset;
member = (char *)message + field->offset;
switch (field->label) {
case PROTOBUF_C_LABEL_REQUIRED:
return parse_required_member(scanned_member, member,
allocator, TRUE);
return parse_required_member(scanned_member, member, allocator, TRUE);
case PROTOBUF_C_LABEL_OPTIONAL:
case PROTOBUF_C_LABEL_NONE:
if (0 != (field->flags & PROTOBUF_C_FIELD_FLAG_ONEOF)) {
return parse_oneof_member(scanned_member, member,
message, allocator);
return parse_oneof_member(scanned_member, member, message, allocator);
} else {
return parse_optional_member(scanned_member, member,
message, allocator);
return parse_optional_member(scanned_member, member, message,
allocator);
}
case PROTOBUF_C_LABEL_REPEATED:
if (scanned_member->wire_type ==
PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED &&
if (scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED &&
(0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) ||
is_packable_type(field->type)))
{
return parse_packed_repeated_member(scanned_member,
member, message);
is_packable_type(field->type))) {
return parse_packed_repeated_member(scanned_member, member, message);
} else {
return parse_repeated_member(scanned_member,
member, message,
return parse_repeated_member(scanned_member, member, message,
allocator);
}
}
......@@ -2413,20 +2144,16 @@ parse_member(ScannedMember *scanned_member,
* for old code, and which would be useful to support allocating
* descriptors dynamically).
*/
static void
message_init_generic(const ProtobufCMessageDescriptor *desc,
ProtobufCMessage *message)
{
static void message_init_generic(const ProtobufCMessageDescriptor *desc,
ProtobufCMessage *message) {
unsigned i;
memset(message, 0, desc->sizeof_message);
message->descriptor = desc;
for (i = 0; i < desc->n_fields; i++) {
if (desc->fields[i].default_value != NULL &&
desc->fields[i].label != PROTOBUF_C_LABEL_REPEATED)
{
void *field =
STRUCT_MEMBER_P(message, desc->fields[i].offset);
desc->fields[i].label != PROTOBUF_C_LABEL_REPEATED) {
void *field = STRUCT_MEMBER_P(message, desc->fields[i].offset);
const void *dv = desc->fields[i].default_value;
switch (desc->fields[i].type) {
......@@ -2460,7 +2187,7 @@ message_init_generic(const ProtobufCMessageDescriptor *desc,
* The next line essentially implements a cast
* from const, which is totally unavoidable.
*/
*(const void **) field = dv;
*(const void **)field = dv;
break;
}
}
......@@ -2486,27 +2213,23 @@ message_init_generic(const ProtobufCMessageDescriptor *desc,
* that we would overflow if we needed a slab larger than provided.
*/
#define MAX_SCANNED_MEMBER_SLAB \
(sizeof(unsigned int)*8 - 1 \
- BOUND_SIZEOF_SCANNED_MEMBER_LOG2 \
- FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2)
(sizeof(unsigned int) * 8 - 1 - BOUND_SIZEOF_SCANNED_MEMBER_LOG2 - \
FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2)
#define REQUIRED_FIELD_BITMAP_SET(index) \
(required_fields_bitmap[(index)/8] |= (1UL<<((index)%8)))
(required_fields_bitmap[(index) / 8] |= (1UL << ((index) % 8)))
#define REQUIRED_FIELD_BITMAP_IS_SET(index) \
(required_fields_bitmap[(index)/8] & (1UL<<((index)%8)))
(required_fields_bitmap[(index) / 8] & (1UL << ((index) % 8)))
ProtobufCMessage *
protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
ProtobufCAllocator *allocator,
size_t len, const uint8_t *data)
{
ProtobufCMessage *protobuf_c_message_unpack(
const ProtobufCMessageDescriptor *desc, ProtobufCAllocator *allocator,
size_t len, const uint8_t *data) {
ProtobufCMessage *rv;
size_t rem = len;
const uint8_t *at = data;
const ProtobufCFieldDescriptor *last_field = desc->fields + 0;
ScannedMember first_member_slab[1UL <<
FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2];
ScannedMember first_member_slab[1UL << FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2];
/*
* scanned_member_slabs[i] is an array of arrays of ScannedMember.
......@@ -2529,12 +2252,10 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
ASSERT_IS_MESSAGE_DESCRIPTOR(desc);
if (allocator == NULL)
allocator = &protobuf_c__allocator;
if (allocator == NULL) allocator = &protobuf_c__allocator;
rv = do_alloc(allocator, desc->sizeof_message);
if (!rv)
return (NULL);
if (!rv) return (NULL);
scanned_member_slabs[0] = first_member_slab;
required_fields_bitmap_len = (desc->n_fields + 7) / 8;
......@@ -2568,7 +2289,7 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
if (used == 0) {
PROTOBUF_C_UNPACK_ERROR("error parsing tag/wiretype at offset %u",
(unsigned) (at - data));
(unsigned)(at - data));
goto error_cleanup_during_scan;
}
/*
......@@ -2578,9 +2299,7 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
if (last_field == NULL || last_field->id != tag) {
/* lookup field */
int field_index =
int_range_lookup(desc->n_field_ranges,
desc->field_ranges,
tag);
int_range_lookup(desc->n_field_ranges, desc->field_ranges, tag);
if (field_index < 0) {
field = NULL;
n_unknown++;
......@@ -2610,11 +2329,10 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
unsigned i;
for (i = 0; i < max_len; i++)
if ((at[i] & 0x80) == 0)
break;
if ((at[i] & 0x80) == 0) break;
if (i == max_len) {
PROTOBUF_C_UNPACK_ERROR("unterminated varint at offset %u",
(unsigned) (at - data));
(unsigned)(at - data));
goto error_cleanup_during_scan;
}
tmp.len = i + 1;
......@@ -2623,7 +2341,7 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
case PROTOBUF_C_WIRE_TYPE_64BIT:
if (rem < 8) {
PROTOBUF_C_UNPACK_ERROR("too short after 64bit wiretype at offset %u",
(unsigned) (at - data));
(unsigned)(at - data));
goto error_cleanup_during_scan;
}
tmp.len = 8;
......@@ -2642,20 +2360,19 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
case PROTOBUF_C_WIRE_TYPE_32BIT:
if (rem < 4) {
PROTOBUF_C_UNPACK_ERROR("too short after 32bit wiretype at offset %u",
(unsigned) (at - data));
(unsigned)(at - data));
goto error_cleanup_during_scan;
}
tmp.len = 4;
break;
default:
PROTOBUF_C_UNPACK_ERROR("unsupported tag %u at offset %u",
wire_type, (unsigned) (at - data));
PROTOBUF_C_UNPACK_ERROR("unsupported tag %u at offset %u", wire_type,
(unsigned)(at - data));
goto error_cleanup_during_scan;
}
if (in_slab_index == (1UL <<
(which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2)))
{
if (in_slab_index ==
(1UL << (which_slab + FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2))) {
size_t size;
in_slab_index = 0;
......@@ -2673,20 +2390,13 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
scanned_member_slabs[which_slab][in_slab_index++] = tmp;
if (field != NULL && field->label == PROTOBUF_C_LABEL_REPEATED) {
size_t *n = STRUCT_MEMBER_PTR(size_t, rv,
field->quantifier_offset);
size_t *n = STRUCT_MEMBER_PTR(size_t, rv, field->quantifier_offset);
if (wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED &&
(0 != (field->flags & PROTOBUF_C_FIELD_FLAG_PACKED) ||
is_packable_type(field->type)))
{
is_packable_type(field->type))) {
size_t count;
if (!count_packed_elements(field->type,
tmp.len -
tmp.length_prefix_len,
tmp.data +
tmp.length_prefix_len,
&count))
{
if (!count_packed_elements(field->type, tmp.len - tmp.length_prefix_len,
tmp.data + tmp.length_prefix_len, &count)) {
PROTOBUF_C_UNPACK_ERROR("counting packed elements");
goto error_cleanup_during_scan;
}
......@@ -2700,26 +2410,23 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
rem -= tmp.len;
}
/* allocate space for repeated fields, also check that all required fields have been set */
/* allocate space for repeated fields, also check that all required fields
* have been set */
for (f = 0; f < desc->n_fields; f++) {
const ProtobufCFieldDescriptor *field = desc->fields + f;
if (field->label == PROTOBUF_C_LABEL_REPEATED) {
size_t siz =
sizeof_elt_in_repeated_array(field->type);
size_t *n_ptr =
STRUCT_MEMBER_PTR(size_t, rv,
field->quantifier_offset);
size_t siz = sizeof_elt_in_repeated_array(field->type);
size_t *n_ptr = STRUCT_MEMBER_PTR(size_t, rv, field->quantifier_offset);
if (*n_ptr != 0) {
unsigned n = *n_ptr;
void *a;
*n_ptr = 0;
assert(rv->descriptor != NULL);
#define CLEAR_REMAINING_N_PTRS() \
for(f++;f < desc->n_fields; f++) \
{ \
for (f++; f < desc->n_fields; f++) { \
field = desc->fields + f; \
if (field->label == PROTOBUF_C_LABEL_REPEATED) \
STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \
STRUCT_MEMBER(size_t, rv, field->quantifier_offset) = 0; \
}
a = do_alloc(allocator, siz * n);
if (!a) {
......@@ -2729,9 +2436,7 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
STRUCT_MEMBER(void *, rv, field->offset) = a;
}
} else if (field->label == PROTOBUF_C_LABEL_REQUIRED) {
if (field->default_value == NULL &&
!REQUIRED_FIELD_BITMAP_IS_SET(f))
{
if (field->default_value == NULL && !REQUIRED_FIELD_BITMAP_IS_SET(f)) {
CLEAR_REMAINING_N_PTRS();
PROTOBUF_C_UNPACK_ERROR("message '%s': missing required field '%s'",
desc->name, field->name);
......@@ -2743,128 +2448,109 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
/* allocate space for unknown fields */
if (n_unknown) {
rv->unknown_fields = do_alloc(allocator,
n_unknown * sizeof(ProtobufCMessageUnknownField));
if (rv->unknown_fields == NULL)
goto error_cleanup;
rv->unknown_fields =
do_alloc(allocator, n_unknown * sizeof(ProtobufCMessageUnknownField));
if (rv->unknown_fields == NULL) goto error_cleanup;
}
/* do real parsing */
for (i_slab = 0; i_slab <= which_slab; i_slab++) {
unsigned max = (i_slab == which_slab) ?
in_slab_index : (1UL << (i_slab + 4));
unsigned max =
(i_slab == which_slab) ? in_slab_index : (1UL << (i_slab + 4));
ScannedMember *slab = scanned_member_slabs[i_slab];
for (j = 0; j < max; j++) {
if (!parse_member(slab + j, rv, allocator)) {
PROTOBUF_C_UNPACK_ERROR("error parsing member %s of %s",
slab->field ? slab->field->name : "*unknown-field*",
desc->name);
PROTOBUF_C_UNPACK_ERROR(
"error parsing member %s of %s",
slab->field ? slab->field->name : "*unknown-field*", desc->name);
goto error_cleanup;
}
}
}
/* cleanup */
for (j = 1; j <= which_slab; j++)
do_free(allocator, scanned_member_slabs[j]);
for (j = 1; j <= which_slab; j++) do_free(allocator, scanned_member_slabs[j]);
if (required_fields_bitmap_alloced)
do_free(allocator, required_fields_bitmap);
return rv;
error_cleanup:
protobuf_c_message_free_unpacked(rv, allocator);
for (j = 1; j <= which_slab; j++)
do_free(allocator, scanned_member_slabs[j]);
for (j = 1; j <= which_slab; j++) do_free(allocator, scanned_member_slabs[j]);
if (required_fields_bitmap_alloced)
do_free(allocator, required_fields_bitmap);
return NULL;
error_cleanup_during_scan:
do_free(allocator, rv);
for (j = 1; j <= which_slab; j++)
do_free(allocator, scanned_member_slabs[j]);
for (j = 1; j <= which_slab; j++) do_free(allocator, scanned_member_slabs[j]);
if (required_fields_bitmap_alloced)
do_free(allocator, required_fields_bitmap);
return NULL;
}
void
protobuf_c_message_free_unpacked(ProtobufCMessage *message,
ProtobufCAllocator *allocator)
{
void protobuf_c_message_free_unpacked(ProtobufCMessage *message,
ProtobufCAllocator *allocator) {
const ProtobufCMessageDescriptor *desc;
unsigned f;
if (message == NULL)
return;
if (message == NULL) return;
desc = message->descriptor;
ASSERT_IS_MESSAGE(message);
if (allocator == NULL)
allocator = &protobuf_c__allocator;
if (allocator == NULL) allocator = &protobuf_c__allocator;
message->descriptor = NULL;
for (f = 0; f < desc->n_fields; f++) {
if (0 != (desc->fields[f].flags & PROTOBUF_C_FIELD_FLAG_ONEOF) &&
desc->fields[f].id !=
STRUCT_MEMBER(uint32_t, message, desc->fields[f].quantifier_offset))
{
STRUCT_MEMBER(uint32_t, message,
desc->fields[f].quantifier_offset)) {
/* This is not the selected oneof, skip it */
continue;
}
if (desc->fields[f].label == PROTOBUF_C_LABEL_REPEATED) {
size_t n = STRUCT_MEMBER(size_t,
message,
desc->fields[f].quantifier_offset);
void *arr = STRUCT_MEMBER(void *,
message,
desc->fields[f].offset);
size_t n =
STRUCT_MEMBER(size_t, message, desc->fields[f].quantifier_offset);
void *arr = STRUCT_MEMBER(void *, message, desc->fields[f].offset);
if (arr != NULL) {
if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) {
unsigned i;
for (i = 0; i < n; i++)
do_free(allocator, ((char **) arr)[i]);
for (i = 0; i < n; i++) do_free(allocator, ((char **)arr)[i]);
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) {
unsigned i;
for (i = 0; i < n; i++)
do_free(allocator, ((ProtobufCBinaryData *) arr)[i].data);
do_free(allocator, ((ProtobufCBinaryData *)arr)[i].data);
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) {
unsigned i;
for (i = 0; i < n; i++)
protobuf_c_message_free_unpacked(
((ProtobufCMessage **) arr)[i],
allocator
);
protobuf_c_message_free_unpacked(((ProtobufCMessage **)arr)[i],
allocator);
}
do_free(allocator, arr);
}
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING) {
char *str = STRUCT_MEMBER(char *, message,
desc->fields[f].offset);
char *str = STRUCT_MEMBER(char *, message, desc->fields[f].offset);
if (str && str != desc->fields[f].default_value)
do_free(allocator, str);
if (str && str != desc->fields[f].default_value) do_free(allocator, str);
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES) {
void *data = STRUCT_MEMBER(ProtobufCBinaryData, message,
desc->fields[f].offset).data;
void *data =
STRUCT_MEMBER(ProtobufCBinaryData, message, desc->fields[f].offset)
.data;
const ProtobufCBinaryData *default_bd;
default_bd = desc->fields[f].default_value;
if (data != NULL &&
(default_bd == NULL ||
default_bd->data != data))
{
if (data != NULL && (default_bd == NULL || default_bd->data != data)) {
do_free(allocator, data);
}
} else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE) {
ProtobufCMessage *sm;
sm = STRUCT_MEMBER(ProtobufCMessage *, message,
desc->fields[f].offset);
sm = STRUCT_MEMBER(ProtobufCMessage *, message, desc->fields[f].offset);
if (sm && sm != desc->fields[f].default_value)
protobuf_c_message_free_unpacked(sm, allocator);
}
......@@ -2878,22 +2564,16 @@ protobuf_c_message_free_unpacked(ProtobufCMessage *message,
do_free(allocator, message);
}
void
protobuf_c_message_init(const ProtobufCMessageDescriptor * descriptor,
void *message)
{
descriptor->message_init((ProtobufCMessage *) (message));
void protobuf_c_message_init(const ProtobufCMessageDescriptor *descriptor,
void *message) {
descriptor->message_init((ProtobufCMessage *)(message));
}
protobuf_c_boolean
protobuf_c_message_check(const ProtobufCMessage *message)
{
protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) {
unsigned i;
if (!message ||
!message->descriptor ||
message->descriptor->magic != PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC)
{
if (!message || !message->descriptor ||
message->descriptor->magic != PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC) {
return FALSE;
}
......@@ -2901,56 +2581,51 @@ protobuf_c_message_check(const ProtobufCMessage *message)
const ProtobufCFieldDescriptor *f = message->descriptor->fields + i;
ProtobufCType type = f->type;
ProtobufCLabel label = f->label;
void *field = STRUCT_MEMBER_P (message, f->offset);
void *field = STRUCT_MEMBER_P(message, f->offset);
if (label == PROTOBUF_C_LABEL_REPEATED) {
size_t *quantity = STRUCT_MEMBER_P (message, f->quantifier_offset);
size_t *quantity = STRUCT_MEMBER_P(message, f->quantifier_offset);
if (*quantity > 0 && *(void **) field == NULL) {
if (*quantity > 0 && *(void **)field == NULL) {
return FALSE;
}
if (type == PROTOBUF_C_TYPE_MESSAGE) {
ProtobufCMessage **submessage = *(ProtobufCMessage ***) field;
ProtobufCMessage **submessage = *(ProtobufCMessage ***)field;
unsigned j;
for (j = 0; j < *quantity; j++) {
if (!protobuf_c_message_check(submessage[j]))
return FALSE;
if (!protobuf_c_message_check(submessage[j])) return FALSE;
}
} else if (type == PROTOBUF_C_TYPE_STRING) {
char **string = *(char ***) field;
char **string = *(char ***)field;
unsigned j;
for (j = 0; j < *quantity; j++) {
if (!string[j])
return FALSE;
if (!string[j]) return FALSE;
}
} else if (type == PROTOBUF_C_TYPE_BYTES) {
ProtobufCBinaryData *bd = *(ProtobufCBinaryData **) field;
ProtobufCBinaryData *bd = *(ProtobufCBinaryData **)field;
unsigned j;
for (j = 0; j < *quantity; j++) {
if (bd[j].len > 0 && bd[j].data == NULL)
return FALSE;
if (bd[j].len > 0 && bd[j].data == NULL) return FALSE;
}
}
} else { /* PROTOBUF_C_LABEL_REQUIRED or PROTOBUF_C_LABEL_OPTIONAL */
if (type == PROTOBUF_C_TYPE_MESSAGE) {
ProtobufCMessage *submessage = *(ProtobufCMessage **) field;
ProtobufCMessage *submessage = *(ProtobufCMessage **)field;
if (label == PROTOBUF_C_LABEL_REQUIRED || submessage != NULL) {
if (!protobuf_c_message_check(submessage))
return FALSE;
if (!protobuf_c_message_check(submessage)) return FALSE;
}
} else if (type == PROTOBUF_C_TYPE_STRING) {
char *string = *(char **) field;
if (label == PROTOBUF_C_LABEL_REQUIRED && string == NULL)
return FALSE;
char *string = *(char **)field;
if (label == PROTOBUF_C_LABEL_REQUIRED && string == NULL) return FALSE;
} else if (type == PROTOBUF_C_TYPE_BYTES) {
protobuf_c_boolean *has = STRUCT_MEMBER_P (message, f->quantifier_offset);
protobuf_c_boolean *has =
STRUCT_MEMBER_P(message, f->quantifier_offset);
ProtobufCBinaryData *bd = field;
if (label == PROTOBUF_C_LABEL_REQUIRED || *has == TRUE) {
if (bd->len > 0 && bd->data == NULL)
return FALSE;
if (bd->len > 0 && bd->data == NULL) return FALSE;
}
}
}
......@@ -2961,17 +2636,13 @@ protobuf_c_message_check(const ProtobufCMessage *message)
/* === services === */
typedef void (*GenericHandler) (void *service,
const ProtobufCMessage *input,
ProtobufCClosure closure,
void *closure_data);
void
protobuf_c_service_invoke_internal(ProtobufCService *service,
typedef void (*GenericHandler)(void *service, const ProtobufCMessage *input,
ProtobufCClosure closure, void *closure_data);
void protobuf_c_service_invoke_internal(ProtobufCService *service,
unsigned method_index,
const ProtobufCMessage *input,
ProtobufCClosure closure,
void *closure_data)
{
void *closure_data) {
GenericHandler *handlers;
GenericHandler handler;
......@@ -2986,7 +2657,7 @@ protobuf_c_service_invoke_internal(ProtobufCService *service,
* Get the array of virtual methods (which are enumerated by the
* generated code).
*/
handlers = (GenericHandler *) (service + 1);
handlers = (GenericHandler *)(service + 1);
/*
* Get our method and invoke it.
......@@ -2996,11 +2667,9 @@ protobuf_c_service_invoke_internal(ProtobufCService *service,
(*handler)(service, input, closure, closure_data);
}
void
protobuf_c_service_generated_init(ProtobufCService *service,
const ProtobufCServiceDescriptor *descriptor,
ProtobufCServiceDestroy destroy)
{
void protobuf_c_service_generated_init(
ProtobufCService *service, const ProtobufCServiceDescriptor *descriptor,
ProtobufCServiceDestroy destroy) {
ASSERT_IS_SERVICE_DESCRIPTOR(descriptor);
service->descriptor = descriptor;
service->destroy = destroy;
......@@ -3008,22 +2677,18 @@ protobuf_c_service_generated_init(ProtobufCService *service,
memset(service + 1, 0, descriptor->n_methods * sizeof(GenericHandler));
}
void protobuf_c_service_destroy(ProtobufCService *service)
{
void protobuf_c_service_destroy(ProtobufCService *service) {
service->destroy(service);
}
/* --- querying the descriptors --- */
const ProtobufCEnumValue *
protobuf_c_enum_descriptor_get_value_by_name(const ProtobufCEnumDescriptor *desc,
const char *name)
{
const ProtobufCEnumValue *protobuf_c_enum_descriptor_get_value_by_name(
const ProtobufCEnumDescriptor *desc, const char *name) {
unsigned start = 0;
unsigned count;
if (desc == NULL || desc->values_by_name == NULL)
return NULL;
if (desc == NULL || desc->values_by_name == NULL) return NULL;
count = desc->n_value_names;
......@@ -3038,33 +2703,26 @@ protobuf_c_enum_descriptor_get_value_by_name(const ProtobufCEnumDescriptor *desc
} else
count = mid - start;
}
if (count == 0)
return NULL;
if (count == 0) return NULL;
if (strcmp(desc->values_by_name[start].name, name) == 0)
return desc->values + desc->values_by_name[start].index;
return NULL;
}
const ProtobufCEnumValue *
protobuf_c_enum_descriptor_get_value(const ProtobufCEnumDescriptor *desc,
int value)
{
const ProtobufCEnumValue *protobuf_c_enum_descriptor_get_value(
const ProtobufCEnumDescriptor *desc, int value) {
int rv = int_range_lookup(desc->n_value_ranges, desc->value_ranges, value);
if (rv < 0)
return NULL;
if (rv < 0) return NULL;
return desc->values + rv;
}
const ProtobufCFieldDescriptor *
protobuf_c_message_descriptor_get_field_by_name(const ProtobufCMessageDescriptor *desc,
const char *name)
{
const ProtobufCFieldDescriptor *protobuf_c_message_descriptor_get_field_by_name(
const ProtobufCMessageDescriptor *desc, const char *name) {
unsigned start = 0;
unsigned count;
const ProtobufCFieldDescriptor *field;
if (desc == NULL || desc->fields_sorted_by_name == NULL)
return NULL;
if (desc == NULL || desc->fields_sorted_by_name == NULL) return NULL;
count = desc->n_fields;
......@@ -3081,33 +2739,26 @@ protobuf_c_message_descriptor_get_field_by_name(const ProtobufCMessageDescriptor
} else
count = mid - start;
}
if (count == 0)
return NULL;
if (count == 0) return NULL;
field = desc->fields + desc->fields_sorted_by_name[start];
if (strcmp(field->name, name) == 0)
return field;
if (strcmp(field->name, name) == 0) return field;
return NULL;
}
const ProtobufCFieldDescriptor *
protobuf_c_message_descriptor_get_field(const ProtobufCMessageDescriptor *desc,
unsigned value)
{
int rv = int_range_lookup(desc->n_field_ranges,desc->field_ranges, value);
if (rv < 0)
return NULL;
const ProtobufCFieldDescriptor *protobuf_c_message_descriptor_get_field(
const ProtobufCMessageDescriptor *desc, unsigned value) {
int rv = int_range_lookup(desc->n_field_ranges, desc->field_ranges, value);
if (rv < 0) return NULL;
return desc->fields + rv;
}
const ProtobufCMethodDescriptor *
protobuf_c_service_descriptor_get_method_by_name(const ProtobufCServiceDescriptor *desc,
const char *name)
{
protobuf_c_service_descriptor_get_method_by_name(
const ProtobufCServiceDescriptor *desc, const char *name) {
unsigned start = 0;
unsigned count;
if (desc == NULL || desc->method_indices_by_name == NULL)
return NULL;
if (desc == NULL || desc->method_indices_by_name == NULL) return NULL;
count = desc->n_methods;
......@@ -3117,8 +2768,7 @@ protobuf_c_service_descriptor_get_method_by_name(const ProtobufCServiceDescripto
const char *mid_name = desc->methods[mid_index].name;
int rv = strcmp(mid_name, name);
if (rv == 0)
return desc->methods + desc->method_indices_by_name[mid];
if (rv == 0) return desc->methods + desc->method_indices_by_name[mid];
if (rv < 0) {
count = start + count - (mid + 1);
start = mid + 1;
......@@ -3126,9 +2776,9 @@ protobuf_c_service_descriptor_get_method_by_name(const ProtobufCServiceDescripto
count = mid - start;
}
}
if (count == 0)
return NULL;
if (strcmp(desc->methods[desc->method_indices_by_name[start]].name, name) == 0)
if (count == 0) return NULL;
if (strcmp(desc->methods[desc->method_indices_by_name[start]].name, name) ==
0)
return desc->methods + desc->method_indices_by_name[start];
return NULL;
}
......@@ -202,34 +202,34 @@ size_t foo__bar__baz_bah__pack_to_buffer
#include <stdint.h>
#ifdef __cplusplus
# define PROTOBUF_C__BEGIN_DECLS extern "C" {
# define PROTOBUF_C__END_DECLS }
#define PROTOBUF_C__BEGIN_DECLS extern "C" {
#define PROTOBUF_C__END_DECLS }
#else
# define PROTOBUF_C__BEGIN_DECLS
# define PROTOBUF_C__END_DECLS
#define PROTOBUF_C__BEGIN_DECLS
#define PROTOBUF_C__END_DECLS
#endif
PROTOBUF_C__BEGIN_DECLS
#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB)
# ifdef PROTOBUF_C_EXPORT
# define PROTOBUF_C__API __declspec(dllexport)
# else
# define PROTOBUF_C__API __declspec(dllimport)
# endif
#ifdef PROTOBUF_C_EXPORT
#define PROTOBUF_C__API __declspec(dllexport)
#else
# define PROTOBUF_C__API
#define PROTOBUF_C__API __declspec(dllimport)
#endif
#else
#define PROTOBUF_C__API
#endif
#if !defined(PROTOBUF_C__NO_DEPRECATED) && \
((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
# define PROTOBUF_C__DEPRECATED __attribute__((__deprecated__))
#define PROTOBUF_C__DEPRECATED __attribute__((__deprecated__))
#else
# define PROTOBUF_C__DEPRECATED
#define PROTOBUF_C__DEPRECATED
#endif
#ifndef PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE
#define PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(enum_name) \
#define PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(enum_name) \
, _##enum_name##_IS_INT_SIZE = INT_MAX
#endif
......@@ -441,9 +441,7 @@ protobuf_c_message_pack_to_buffer(&message, &tmp);
*/
struct ProtobufCBuffer {
/** Append function. Consumes the `len` bytes stored at `data`. */
void (*append)(ProtobufCBuffer *buffer,
size_t len,
const uint8_t *data);
void (*append)(ProtobufCBuffer *buffer, size_t len, const uint8_t *data);
};
/**
......@@ -733,10 +731,8 @@ struct ProtobufCService {
/** Service descriptor. */
const ProtobufCServiceDescriptor *descriptor;
/** Function to invoke the service. */
void (*invoke)(ProtobufCService *service,
unsigned method_index,
const ProtobufCMessage *input,
ProtobufCClosure closure,
void (*invoke)(ProtobufCService *service, unsigned method_index,
const ProtobufCMessage *input, ProtobufCClosure closure,
void *closure_data);
/** Function to destroy the service. */
void (*destroy)(ProtobufCService *service);
......@@ -772,8 +768,7 @@ struct ProtobufCServiceDescriptor {
* \return A string containing the version number of protobuf-c.
*/
PROTOBUF_C__API
const char *
protobuf_c_version(void);
const char *protobuf_c_version(void);
/**
* Get the version of the protobuf-c library. Note that this is the version of
......@@ -783,8 +778,7 @@ protobuf_c_version(void);
* protobuf-c, represented in base-10 as (MAJOR*1E6) + (MINOR*1E3) + PATCH.
*/
PROTOBUF_C__API
uint32_t
protobuf_c_version_number(void);
uint32_t protobuf_c_version_number(void);
/**
* The version of the protobuf-c headers, represented as a string using the same
......@@ -818,10 +812,8 @@ protobuf_c_version_number(void);
* If not found or if the optimize_for = CODE_SIZE option was set.
*/
PROTOBUF_C__API
const ProtobufCEnumValue *
protobuf_c_enum_descriptor_get_value_by_name(
const ProtobufCEnumDescriptor *desc,
const char *name);
const ProtobufCEnumValue *protobuf_c_enum_descriptor_get_value_by_name(
const ProtobufCEnumDescriptor *desc, const char *name);
/**
* Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by numeric
......@@ -839,10 +831,8 @@ protobuf_c_enum_descriptor_get_value_by_name(
* If not found.
*/
PROTOBUF_C__API
const ProtobufCEnumValue *
protobuf_c_enum_descriptor_get_value(
const ProtobufCEnumDescriptor *desc,
int value);
const ProtobufCEnumValue *protobuf_c_enum_descriptor_get_value(
const ProtobufCEnumDescriptor *desc, int value);
/**
* Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by
......@@ -858,10 +848,8 @@ protobuf_c_enum_descriptor_get_value(
* If not found or if the optimize_for = CODE_SIZE option was set.
*/
PROTOBUF_C__API
const ProtobufCFieldDescriptor *
protobuf_c_message_descriptor_get_field_by_name(
const ProtobufCMessageDescriptor *desc,
const char *name);
const ProtobufCFieldDescriptor *protobuf_c_message_descriptor_get_field_by_name(
const ProtobufCMessageDescriptor *desc, const char *name);
/**
* Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by
......@@ -877,10 +865,8 @@ protobuf_c_message_descriptor_get_field_by_name(
* If not found.
*/
PROTOBUF_C__API
const ProtobufCFieldDescriptor *
protobuf_c_message_descriptor_get_field(
const ProtobufCMessageDescriptor *desc,
unsigned value);
const ProtobufCFieldDescriptor *protobuf_c_message_descriptor_get_field(
const ProtobufCMessageDescriptor *desc, unsigned value);
/**
* Determine the number of bytes required to store the serialised message.
......@@ -891,9 +877,7 @@ protobuf_c_message_descriptor_get_field(
* Number of bytes.
*/
PROTOBUF_C__API
size_t
protobuf_c_message_get_packed_size(const ProtobufCMessage *message);
size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message);
/**
* Unpack a serialised message into an in-memory representation.
......@@ -913,12 +897,9 @@ protobuf_c_message_get_packed_size(const ProtobufCMessage *message);
* If an error occurred during unpacking.
*/
PROTOBUF_C__API
ProtobufCMessage *
protobuf_c_message_unpack(
const ProtobufCMessageDescriptor *descriptor,
ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
ProtobufCMessage *protobuf_c_message_unpack(
const ProtobufCMessageDescriptor *descriptor, ProtobufCAllocator *allocator,
size_t len, const uint8_t *data);
/**
* Free an unpacked message object.
......@@ -933,9 +914,7 @@ protobuf_c_message_unpack(
* specify the default allocator.
*/
PROTOBUF_C__API
void
protobuf_c_message_free_unpacked(
ProtobufCMessage *message,
void protobuf_c_message_free_unpacked(ProtobufCMessage *message,
ProtobufCAllocator *allocator);
/**
......@@ -950,11 +929,11 @@ protobuf_c_message_free_unpacked(
* Message is invalid.
*/
PROTOBUF_C__API
protobuf_c_boolean
protobuf_c_message_check(const ProtobufCMessage *);
protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *);
/** Message initialiser. */
#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL }
#define PROTOBUF_C_MESSAGE_INIT(descriptor) \
{ descriptor, 0, NULL }
/**
* Initialise a message object from a message descriptor.
......@@ -965,9 +944,7 @@ protobuf_c_message_check(const ProtobufCMessage *);
* Allocated block of memory of size `descriptor->sizeof_message`.
*/
PROTOBUF_C__API
void
protobuf_c_message_init(
const ProtobufCMessageDescriptor *descriptor,
void protobuf_c_message_init(const ProtobufCMessageDescriptor *descriptor,
void *message);
/**
......@@ -977,8 +954,7 @@ protobuf_c_message_init(
* The service object to free.
*/
PROTOBUF_C__API
void
protobuf_c_service_destroy(ProtobufCService *service);
void protobuf_c_service_destroy(ProtobufCService *service);
/**
* Look up a `ProtobufCMethodDescriptor` by name.
......@@ -996,36 +972,29 @@ protobuf_c_service_destroy(ProtobufCService *service);
PROTOBUF_C__API
const ProtobufCMethodDescriptor *
protobuf_c_service_descriptor_get_method_by_name(
const ProtobufCServiceDescriptor *desc,
const char *name);
const ProtobufCServiceDescriptor *desc, const char *name);
/**
* Initialise a `ProtobufCBufferSimple` object.
*/
#define PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) \
{ \
{ protobuf_c_buffer_simple_append }, \
sizeof(array_of_bytes), \
0, \
(array_of_bytes), \
0, \
NULL \
}
{ \
{protobuf_c_buffer_simple_append}, sizeof(array_of_bytes), 0, \
(array_of_bytes), 0, NULL \
}
/**
* Clear a `ProtobufCBufferSimple` object, freeing any allocated memory.
*/
#define PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) \
do { \
do { \
if ((simp_buf)->must_free_data) { \
if ((simp_buf)->allocator != NULL) \
(simp_buf)->allocator->free( \
(simp_buf)->allocator, \
(simp_buf)->data); \
(simp_buf)->allocator->free((simp_buf)->allocator, (simp_buf)->data); \
else \
free((simp_buf)->data); \
} \
} while (0)
} while (0)
/**
* The `append` method for `ProtobufCBufferSimple`.
......@@ -1039,23 +1008,16 @@ do { \
* Data to append.
*/
PROTOBUF_C__API
void
protobuf_c_buffer_simple_append(
ProtobufCBuffer *buffer,
size_t len,
void protobuf_c_buffer_simple_append(ProtobufCBuffer *buffer, size_t len,
const unsigned char *data);
PROTOBUF_C__API
void
protobuf_c_service_generated_init(
ProtobufCService *service,
const ProtobufCServiceDescriptor *descriptor,
void protobuf_c_service_generated_init(
ProtobufCService *service, const ProtobufCServiceDescriptor *descriptor,
ProtobufCServiceDestroy destroy);
PROTOBUF_C__API
void
protobuf_c_service_invoke_internal(
ProtobufCService *service,
void protobuf_c_service_invoke_internal(ProtobufCService *service,
unsigned method_index,
const ProtobufCMessage *input,
ProtobufCClosure closure,
......
......@@ -16,8 +16,8 @@ limitations under the License. */
#include <map>
#include <string>
#include <vector>
#include <unordered_set>
#include <vector>
#include "framework/attribute.h"
#include "framework/scope.h"
......
......@@ -15,8 +15,8 @@ limitations under the License. */
#pragma once
#include <unordered_map>
#include "common/log.h"
#include "common/enforce.h"
#include "common/log.h"
#include "common/variant.h"
#include "framework/framework.pb-c.h"
......@@ -27,7 +27,6 @@ class BlockDesc;
class Attribute {
public:
/*
* PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT = 0,
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOAT = 1,
......@@ -42,7 +41,8 @@ class Attribute {
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE)
*
* */
static Attribute GetAttrValue(PaddleMobile__Framework__Proto__OpDesc__Attr *attr_desc) {
static Attribute GetAttrValue(
PaddleMobile__Framework__Proto__OpDesc__Attr *attr_desc) {
// std::cout << "begin get attr value" << std::endl;
Attribute attr;
switch (attr_desc->type) {
......
......@@ -7,405 +7,337 @@
#endif
#include "framework.pb-c.h"
void paddle_mobile__framework__proto__op_desc__attr__init
(PaddleMobile__Framework__Proto__OpDesc__Attr *message)
{
static const PaddleMobile__Framework__Proto__OpDesc__Attr init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__ATTR__INIT;
void paddle_mobile__framework__proto__op_desc__attr__init(
PaddleMobile__Framework__Proto__OpDesc__Attr *message) {
static const PaddleMobile__Framework__Proto__OpDesc__Attr init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__ATTR__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__op_desc__var__init
(PaddleMobile__Framework__Proto__OpDesc__Var *message)
{
static const PaddleMobile__Framework__Proto__OpDesc__Var init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__VAR__INIT;
void paddle_mobile__framework__proto__op_desc__var__init(
PaddleMobile__Framework__Proto__OpDesc__Var *message) {
static const PaddleMobile__Framework__Proto__OpDesc__Var init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__VAR__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__op_desc__init
(PaddleMobile__Framework__Proto__OpDesc *message)
{
static const PaddleMobile__Framework__Proto__OpDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__INIT;
void paddle_mobile__framework__proto__op_desc__init(
PaddleMobile__Framework__Proto__OpDesc *message) {
static const PaddleMobile__Framework__Proto__OpDesc init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__INIT;
*message = init_value;
}
size_t paddle_mobile__framework__proto__op_desc__get_packed_size
(const PaddleMobile__Framework__Proto__OpDesc *message)
{
assert(message->base.descriptor == &paddle_mobile__framework__proto__op_desc__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
size_t paddle_mobile__framework__proto__op_desc__get_packed_size(
const PaddleMobile__Framework__Proto__OpDesc *message) {
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__op_desc__descriptor);
return protobuf_c_message_get_packed_size(
(const ProtobufCMessage *)(message));
}
PaddleMobile__Framework__Proto__OpDesc *
paddle_mobile__framework__proto__op_desc__unpack
(ProtobufCAllocator *allocator,
paddle_mobile__framework__proto__op_desc__unpack(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (PaddleMobile__Framework__Proto__OpDesc *)
protobuf_c_message_unpack (&paddle_mobile__framework__proto__op_desc__descriptor,
allocator, len, data);
const uint8_t *data) {
return (PaddleMobile__Framework__Proto__OpDesc *)protobuf_c_message_unpack(
&paddle_mobile__framework__proto__op_desc__descriptor, allocator, len,
data);
}
void paddle_mobile__framework__proto__op_desc__free_unpacked
(PaddleMobile__Framework__Proto__OpDesc *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &paddle_mobile__framework__proto__op_desc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
void paddle_mobile__framework__proto__op_desc__free_unpacked(
PaddleMobile__Framework__Proto__OpDesc *message,
ProtobufCAllocator *allocator) {
if (!message) return;
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__op_desc__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator);
}
void paddle_mobile__framework__proto__op_proto__var__init
(PaddleMobile__Framework__Proto__OpProto__Var *message)
{
static const PaddleMobile__Framework__Proto__OpProto__Var init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__VAR__INIT;
void paddle_mobile__framework__proto__op_proto__var__init(
PaddleMobile__Framework__Proto__OpProto__Var *message) {
static const PaddleMobile__Framework__Proto__OpProto__Var init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__VAR__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__op_proto__attr__init
(PaddleMobile__Framework__Proto__OpProto__Attr *message)
{
static const PaddleMobile__Framework__Proto__OpProto__Attr init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__ATTR__INIT;
void paddle_mobile__framework__proto__op_proto__attr__init(
PaddleMobile__Framework__Proto__OpProto__Attr *message) {
static const PaddleMobile__Framework__Proto__OpProto__Attr init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__ATTR__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__op_proto__init
(PaddleMobile__Framework__Proto__OpProto *message)
{
static const PaddleMobile__Framework__Proto__OpProto init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__INIT;
void paddle_mobile__framework__proto__op_proto__init(
PaddleMobile__Framework__Proto__OpProto *message) {
static const PaddleMobile__Framework__Proto__OpProto init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__INIT;
*message = init_value;
}
size_t paddle_mobile__framework__proto__op_proto__get_packed_size
(const PaddleMobile__Framework__Proto__OpProto *message)
{
assert(message->base.descriptor == &paddle_mobile__framework__proto__op_proto__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
size_t paddle_mobile__framework__proto__op_proto__get_packed_size(
const PaddleMobile__Framework__Proto__OpProto *message) {
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__op_proto__descriptor);
return protobuf_c_message_get_packed_size(
(const ProtobufCMessage *)(message));
}
PaddleMobile__Framework__Proto__OpProto *
paddle_mobile__framework__proto__op_proto__unpack
(ProtobufCAllocator *allocator,
paddle_mobile__framework__proto__op_proto__unpack(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (PaddleMobile__Framework__Proto__OpProto *)
protobuf_c_message_unpack (&paddle_mobile__framework__proto__op_proto__descriptor,
allocator, len, data);
const uint8_t *data) {
return (PaddleMobile__Framework__Proto__OpProto *)protobuf_c_message_unpack(
&paddle_mobile__framework__proto__op_proto__descriptor, allocator, len,
data);
}
void paddle_mobile__framework__proto__op_proto__free_unpacked
(PaddleMobile__Framework__Proto__OpProto *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &paddle_mobile__framework__proto__op_proto__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
void paddle_mobile__framework__proto__op_proto__free_unpacked(
PaddleMobile__Framework__Proto__OpProto *message,
ProtobufCAllocator *allocator) {
if (!message) return;
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__op_proto__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator);
}
void paddle_mobile__framework__proto__var_type__tensor_desc__init
(PaddleMobile__Framework__Proto__VarType__TensorDesc *message)
{
static const PaddleMobile__Framework__Proto__VarType__TensorDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TENSOR_DESC__INIT;
void paddle_mobile__framework__proto__var_type__tensor_desc__init(
PaddleMobile__Framework__Proto__VarType__TensorDesc *message) {
static const PaddleMobile__Framework__Proto__VarType__TensorDesc init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TENSOR_DESC__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__var_type__lo_dtensor_desc__init
(PaddleMobile__Framework__Proto__VarType__LoDTensorDesc *message)
{
static const PaddleMobile__Framework__Proto__VarType__LoDTensorDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__LO_DTENSOR_DESC__INIT;
void paddle_mobile__framework__proto__var_type__lo_dtensor_desc__init(
PaddleMobile__Framework__Proto__VarType__LoDTensorDesc *message) {
static const PaddleMobile__Framework__Proto__VarType__LoDTensorDesc
init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__LO_DTENSOR_DESC__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__init
(PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc *message)
{
static const PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__LO_DTENSOR_ARRAY_DESC__INIT;
void paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__init(
PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc *message) {
static const PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc
init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__LO_DTENSOR_ARRAY_DESC__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__var_type__reader_desc__init
(PaddleMobile__Framework__Proto__VarType__ReaderDesc *message)
{
static const PaddleMobile__Framework__Proto__VarType__ReaderDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__READER_DESC__INIT;
void paddle_mobile__framework__proto__var_type__reader_desc__init(
PaddleMobile__Framework__Proto__VarType__ReaderDesc *message) {
static const PaddleMobile__Framework__Proto__VarType__ReaderDesc init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__READER_DESC__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__var_type__channel_desc__init
(PaddleMobile__Framework__Proto__VarType__ChannelDesc *message)
{
static const PaddleMobile__Framework__Proto__VarType__ChannelDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__CHANNEL_DESC__INIT;
void paddle_mobile__framework__proto__var_type__channel_desc__init(
PaddleMobile__Framework__Proto__VarType__ChannelDesc *message) {
static const PaddleMobile__Framework__Proto__VarType__ChannelDesc init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__CHANNEL_DESC__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__var_type__tuple__init
(PaddleMobile__Framework__Proto__VarType__Tuple *message)
{
static const PaddleMobile__Framework__Proto__VarType__Tuple init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TUPLE__INIT;
void paddle_mobile__framework__proto__var_type__tuple__init(
PaddleMobile__Framework__Proto__VarType__Tuple *message) {
static const PaddleMobile__Framework__Proto__VarType__Tuple init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TUPLE__INIT;
*message = init_value;
}
void paddle_mobile__framework__proto__var_type__init
(PaddleMobile__Framework__Proto__VarType *message)
{
static const PaddleMobile__Framework__Proto__VarType init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__INIT;
void paddle_mobile__framework__proto__var_type__init(
PaddleMobile__Framework__Proto__VarType *message) {
static const PaddleMobile__Framework__Proto__VarType init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__INIT;
*message = init_value;
}
size_t paddle_mobile__framework__proto__var_type__get_packed_size
(const PaddleMobile__Framework__Proto__VarType *message)
{
assert(message->base.descriptor == &paddle_mobile__framework__proto__var_type__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
size_t paddle_mobile__framework__proto__var_type__get_packed_size(
const PaddleMobile__Framework__Proto__VarType *message) {
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__var_type__descriptor);
return protobuf_c_message_get_packed_size(
(const ProtobufCMessage *)(message));
}
PaddleMobile__Framework__Proto__VarType *
paddle_mobile__framework__proto__var_type__unpack
(ProtobufCAllocator *allocator,
paddle_mobile__framework__proto__var_type__unpack(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (PaddleMobile__Framework__Proto__VarType *)
protobuf_c_message_unpack (&paddle_mobile__framework__proto__var_type__descriptor,
allocator, len, data);
const uint8_t *data) {
return (PaddleMobile__Framework__Proto__VarType *)protobuf_c_message_unpack(
&paddle_mobile__framework__proto__var_type__descriptor, allocator, len,
data);
}
void paddle_mobile__framework__proto__var_type__free_unpacked
(PaddleMobile__Framework__Proto__VarType *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &paddle_mobile__framework__proto__var_type__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
void paddle_mobile__framework__proto__var_type__free_unpacked(
PaddleMobile__Framework__Proto__VarType *message,
ProtobufCAllocator *allocator) {
if (!message) return;
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__var_type__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator);
}
void paddle_mobile__framework__proto__var_desc__init
(PaddleMobile__Framework__Proto__VarDesc *message)
{
static const PaddleMobile__Framework__Proto__VarDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_DESC__INIT;
void paddle_mobile__framework__proto__var_desc__init(
PaddleMobile__Framework__Proto__VarDesc *message) {
static const PaddleMobile__Framework__Proto__VarDesc init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_DESC__INIT;
*message = init_value;
}
size_t paddle_mobile__framework__proto__var_desc__get_packed_size
(const PaddleMobile__Framework__Proto__VarDesc *message)
{
assert(message->base.descriptor == &paddle_mobile__framework__proto__var_desc__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
size_t paddle_mobile__framework__proto__var_desc__get_packed_size(
const PaddleMobile__Framework__Proto__VarDesc *message) {
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__var_desc__descriptor);
return protobuf_c_message_get_packed_size(
(const ProtobufCMessage *)(message));
}
PaddleMobile__Framework__Proto__VarDesc *
paddle_mobile__framework__proto__var_desc__unpack
(ProtobufCAllocator *allocator,
paddle_mobile__framework__proto__var_desc__unpack(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (PaddleMobile__Framework__Proto__VarDesc *)
protobuf_c_message_unpack (&paddle_mobile__framework__proto__var_desc__descriptor,
allocator, len, data);
const uint8_t *data) {
return (PaddleMobile__Framework__Proto__VarDesc *)protobuf_c_message_unpack(
&paddle_mobile__framework__proto__var_desc__descriptor, allocator, len,
data);
}
void paddle_mobile__framework__proto__var_desc__free_unpacked
(PaddleMobile__Framework__Proto__VarDesc *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &paddle_mobile__framework__proto__var_desc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
void paddle_mobile__framework__proto__var_desc__free_unpacked(
PaddleMobile__Framework__Proto__VarDesc *message,
ProtobufCAllocator *allocator) {
if (!message) return;
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__var_desc__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator);
}
void paddle_mobile__framework__proto__block_desc__init
(PaddleMobile__Framework__Proto__BlockDesc *message)
{
static const PaddleMobile__Framework__Proto__BlockDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__BLOCK_DESC__INIT;
void paddle_mobile__framework__proto__block_desc__init(
PaddleMobile__Framework__Proto__BlockDesc *message) {
static const PaddleMobile__Framework__Proto__BlockDesc init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__BLOCK_DESC__INIT;
*message = init_value;
}
size_t paddle_mobile__framework__proto__block_desc__get_packed_size
(const PaddleMobile__Framework__Proto__BlockDesc *message)
{
assert(message->base.descriptor == &paddle_mobile__framework__proto__block_desc__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
size_t paddle_mobile__framework__proto__block_desc__get_packed_size(
const PaddleMobile__Framework__Proto__BlockDesc *message) {
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__block_desc__descriptor);
return protobuf_c_message_get_packed_size(
(const ProtobufCMessage *)(message));
}
PaddleMobile__Framework__Proto__BlockDesc *
paddle_mobile__framework__proto__block_desc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (PaddleMobile__Framework__Proto__BlockDesc *)
protobuf_c_message_unpack (&paddle_mobile__framework__proto__block_desc__descriptor,
allocator, len, data);
paddle_mobile__framework__proto__block_desc__unpack(
ProtobufCAllocator *allocator, size_t len, const uint8_t *data) {
return (PaddleMobile__Framework__Proto__BlockDesc *)protobuf_c_message_unpack(
&paddle_mobile__framework__proto__block_desc__descriptor, allocator, len,
data);
}
void paddle_mobile__framework__proto__block_desc__free_unpacked
(PaddleMobile__Framework__Proto__BlockDesc *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &paddle_mobile__framework__proto__block_desc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
void paddle_mobile__framework__proto__block_desc__free_unpacked(
PaddleMobile__Framework__Proto__BlockDesc *message,
ProtobufCAllocator *allocator) {
if (!message) return;
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__block_desc__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator);
}
void paddle_mobile__framework__proto__program_desc__init
(PaddleMobile__Framework__Proto__ProgramDesc *message)
{
static const PaddleMobile__Framework__Proto__ProgramDesc init_value = PADDLE_MOBILE__FRAMEWORK__PROTO__PROGRAM_DESC__INIT;
void paddle_mobile__framework__proto__program_desc__init(
PaddleMobile__Framework__Proto__ProgramDesc *message) {
static const PaddleMobile__Framework__Proto__ProgramDesc init_value =
PADDLE_MOBILE__FRAMEWORK__PROTO__PROGRAM_DESC__INIT;
*message = init_value;
}
size_t paddle_mobile__framework__proto__program_desc__get_packed_size
(const PaddleMobile__Framework__Proto__ProgramDesc *message)
{
assert(message->base.descriptor == &paddle_mobile__framework__proto__program_desc__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
size_t paddle_mobile__framework__proto__program_desc__get_packed_size(
const PaddleMobile__Framework__Proto__ProgramDesc *message) {
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__program_desc__descriptor);
return protobuf_c_message_get_packed_size(
(const ProtobufCMessage *)(message));
}
PaddleMobile__Framework__Proto__ProgramDesc *
paddle_mobile__framework__proto__program_desc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
paddle_mobile__framework__proto__program_desc__unpack(
ProtobufCAllocator *allocator, size_t len, const uint8_t *data) {
return (PaddleMobile__Framework__Proto__ProgramDesc *)
protobuf_c_message_unpack (&paddle_mobile__framework__proto__program_desc__descriptor,
allocator, len, data);
protobuf_c_message_unpack(
&paddle_mobile__framework__proto__program_desc__descriptor, allocator,
len, data);
}
void paddle_mobile__framework__proto__program_desc__free_unpacked
(PaddleMobile__Framework__Proto__ProgramDesc *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &paddle_mobile__framework__proto__program_desc__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
void paddle_mobile__framework__proto__program_desc__free_unpacked(
PaddleMobile__Framework__Proto__ProgramDesc *message,
ProtobufCAllocator *allocator) {
if (!message) return;
assert(message->base.descriptor ==
&paddle_mobile__framework__proto__program_desc__descriptor);
protobuf_c_message_free_unpacked((ProtobufCMessage *)message, allocator);
}
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__op_desc__attr__field_descriptors[12] =
{
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_desc__attr__field_descriptors[12] = {
{
"name",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
"name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, name),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, name), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"type",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_ENUM,
"type", 2, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, type),
&paddle_mobile__framework__proto__attr_type__descriptor,
NULL,
&paddle_mobile__framework__proto__attr_type__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"i",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_INT32,
"i", 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, has_i),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, i),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, i), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"f",
4,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_FLOAT,
"f", 4, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_FLOAT,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, has_f),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, f),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, f), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"s",
5,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_STRING,
"s", 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, s),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, s), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"ints",
6,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_INT32,
"ints", 6, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_INT32,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, n_ints),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, ints),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, ints), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"floats",
7,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_FLOAT,
"floats", 7, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_FLOAT,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, n_floats),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, floats),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"strings",
8,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_STRING,
"strings", 8, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_STRING,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, n_strings),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, strings),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"b",
10,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BOOL,
"b", 10, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, has_b),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, b),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, b), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"bools",
11,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_BOOL,
"bools", 11, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, n_bools),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, bools),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, bools), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"block_idx",
12,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_INT32,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, has_block_idx),
"block_idx", 12, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT32,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr,
has_block_idx),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, block_idx),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"l",
13,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_INT64,
"l", 13, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT64,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, has_l),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, l),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Attr, l), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__op_desc__attr__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__op_desc__attr__field_indices_by_name[] = {
8, /* field[8] = b */
10, /* field[10] = block_idx */
9, /* field[9] = bools */
......@@ -419,14 +351,11 @@ static const unsigned paddle_mobile__framework__proto__op_desc__attr__field_indi
7, /* field[7] = strings */
1, /* field[1] = type */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__op_desc__attr__number_ranges[2 + 1] =
{
{ 1, 0 },
{ 10, 8 },
{ 0, 12 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__attr__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__op_desc__attr__number_ranges[2 + 1] = {
{1, 0}, {10, 8}, {0, 12}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__attr__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpDesc.Attr",
"Attr",
......@@ -436,48 +365,41 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__attr_
12,
paddle_mobile__framework__proto__op_desc__attr__field_descriptors,
paddle_mobile__framework__proto__op_desc__attr__field_indices_by_name,
2, paddle_mobile__framework__proto__op_desc__attr__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__op_desc__attr__init,
NULL,NULL,NULL /* reserved[123] */
2,
paddle_mobile__framework__proto__op_desc__attr__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__op_desc__attr__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__op_desc__var__field_descriptors[2] =
{
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_desc__var__field_descriptors[2] = {
{
"parameter",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
"parameter", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpDesc__Var, parameter),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"arguments",
2,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_STRING,
"arguments", 2, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_STRING,
offsetof(PaddleMobile__Framework__Proto__OpDesc__Var, n_arguments),
offsetof(PaddleMobile__Framework__Proto__OpDesc__Var, arguments),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__op_desc__var__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__op_desc__var__field_indices_by_name[] = {
1, /* field[1] = arguments */
0, /* field[0] = parameter */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__op_desc__var__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__var__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__op_desc__var__number_ranges[1 + 1] = {
{1, 0}, {0, 2}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__var__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpDesc.Var",
"Var",
......@@ -487,88 +409,71 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__var__
2,
paddle_mobile__framework__proto__op_desc__var__field_descriptors,
paddle_mobile__framework__proto__op_desc__var__field_indices_by_name,
1, paddle_mobile__framework__proto__op_desc__var__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__op_desc__var__init,
NULL,NULL,NULL /* reserved[123] */
1,
paddle_mobile__framework__proto__op_desc__var__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__op_desc__var__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const protobuf_c_boolean paddle_mobile__framework__proto__op_desc__is_target__default_value = 0;
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__op_desc__field_descriptors[5] =
{
static const protobuf_c_boolean
paddle_mobile__framework__proto__op_desc__is_target__default_value = 0;
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_desc__field_descriptors[5] = {
{
"inputs",
1,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"inputs", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__OpDesc, n_inputs),
offsetof(PaddleMobile__Framework__Proto__OpDesc, inputs),
&paddle_mobile__framework__proto__op_desc__var__descriptor,
NULL,
&paddle_mobile__framework__proto__op_desc__var__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"outputs",
2,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"outputs", 2, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__OpDesc, n_outputs),
offsetof(PaddleMobile__Framework__Proto__OpDesc, outputs),
&paddle_mobile__framework__proto__op_desc__var__descriptor,
NULL,
&paddle_mobile__framework__proto__op_desc__var__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"type",
3,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
"type", 3, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpDesc, type),
NULL,
NULL,
offsetof(PaddleMobile__Framework__Proto__OpDesc, type), NULL, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"attrs",
4,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"attrs", 4, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__OpDesc, n_attrs),
offsetof(PaddleMobile__Framework__Proto__OpDesc, attrs),
&paddle_mobile__framework__proto__op_desc__attr__descriptor,
NULL,
&paddle_mobile__framework__proto__op_desc__attr__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"is_target",
5,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BOOL,
"is_target", 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpDesc, has_is_target),
offsetof(PaddleMobile__Framework__Proto__OpDesc, is_target),
NULL,
offsetof(PaddleMobile__Framework__Proto__OpDesc, is_target), NULL,
&paddle_mobile__framework__proto__op_desc__is_target__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__op_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__op_desc__field_indices_by_name[] = {
3, /* field[3] = attrs */
0, /* field[0] = inputs */
4, /* field[4] = is_target */
1, /* field[1] = outputs */
2, /* field[2] = type */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__op_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 5 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__op_desc__number_ranges[1 + 1] = {{1, 0},
{0, 5}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpDesc",
"OpDesc",
......@@ -578,90 +483,83 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__descr
5,
paddle_mobile__framework__proto__op_desc__field_descriptors,
paddle_mobile__framework__proto__op_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__op_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__op_desc__init,
NULL,NULL,NULL /* reserved[123] */
};
static const protobuf_c_boolean paddle_mobile__framework__proto__op_proto__var__duplicable__default_value = 0;
static const protobuf_c_boolean paddle_mobile__framework__proto__op_proto__var__intermediate__default_value = 0;
static const protobuf_c_boolean paddle_mobile__framework__proto__op_proto__var__dispensable__default_value = 0;
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__op_proto__var__field_descriptors[5] =
{
{
"name",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
paddle_mobile__framework__proto__op_desc__number_ranges,
(ProtobufCMessageInit)paddle_mobile__framework__proto__op_desc__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const protobuf_c_boolean
paddle_mobile__framework__proto__op_proto__var__duplicable__default_value =
0;
static const protobuf_c_boolean
paddle_mobile__framework__proto__op_proto__var__intermediate__default_value =
0;
static const protobuf_c_boolean
paddle_mobile__framework__proto__op_proto__var__dispensable__default_value =
0;
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_proto__var__field_descriptors[5] = {
{
"name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, name),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, name), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"comment",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
"comment", 2, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, comment),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"duplicable",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, has_duplicable),
"duplicable", 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpProto__Var,
has_duplicable),
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, duplicable),
NULL,
&paddle_mobile__framework__proto__op_proto__var__duplicable__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"intermediate",
4,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, has_intermediate),
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, intermediate),
"intermediate", 4, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpProto__Var,
has_intermediate),
offsetof(PaddleMobile__Framework__Proto__OpProto__Var,
intermediate),
NULL,
&paddle_mobile__framework__proto__op_proto__var__intermediate__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"dispensable",
5,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, has_dispensable),
"dispensable", 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpProto__Var,
has_dispensable),
offsetof(PaddleMobile__Framework__Proto__OpProto__Var, dispensable),
NULL,
&paddle_mobile__framework__proto__op_proto__var__dispensable__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__op_proto__var__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__op_proto__var__field_indices_by_name[] = {
1, /* field[1] = comment */
4, /* field[4] = dispensable */
2, /* field[2] = duplicable */
3, /* field[3] = intermediate */
0, /* field[0] = name */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__op_proto__var__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 5 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__var__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__op_proto__var__number_ranges[1 + 1] = {
{1, 0}, {0, 5}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__var__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpProto.Var",
"Var",
......@@ -671,75 +569,64 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__var_
5,
paddle_mobile__framework__proto__op_proto__var__field_descriptors,
paddle_mobile__framework__proto__op_proto__var__field_indices_by_name,
1, paddle_mobile__framework__proto__op_proto__var__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__op_proto__var__init,
NULL,NULL,NULL /* reserved[123] */
};
static const protobuf_c_boolean paddle_mobile__framework__proto__op_proto__attr__generated__default_value = 0;
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__op_proto__attr__field_descriptors[4] =
{
{
"name",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto__Attr, name),
paddle_mobile__framework__proto__op_proto__var__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__op_proto__var__init,
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL /* reserved[123] */
};
static const protobuf_c_boolean
paddle_mobile__framework__proto__op_proto__attr__generated__default_value =
0;
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_proto__attr__field_descriptors[4] = {
{
"name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto__Attr, name), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"type",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_ENUM,
"type", 2, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto__Attr, type),
&paddle_mobile__framework__proto__attr_type__descriptor,
NULL,
&paddle_mobile__framework__proto__attr_type__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"comment",
3,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
"comment", 3, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto__Attr, comment),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"generated",
4,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpProto__Attr, has_generated),
"generated", 4, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__OpProto__Attr,
has_generated),
offsetof(PaddleMobile__Framework__Proto__OpProto__Attr, generated),
NULL,
&paddle_mobile__framework__proto__op_proto__attr__generated__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__op_proto__attr__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__op_proto__attr__field_indices_by_name[] = {
2, /* field[2] = comment */
3, /* field[3] = generated */
0, /* field[0] = name */
1, /* field[1] = type */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__op_proto__attr__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 4 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__attr__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__op_proto__attr__number_ranges[1 + 1] = {
{1, 0}, {0, 4}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__attr__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpProto.Attr",
"Attr",
......@@ -749,87 +636,68 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__attr
4,
paddle_mobile__framework__proto__op_proto__attr__field_descriptors,
paddle_mobile__framework__proto__op_proto__attr__field_indices_by_name,
1, paddle_mobile__framework__proto__op_proto__attr__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__op_proto__attr__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__op_proto__field_descriptors[5] =
{
{
"type",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto, type),
paddle_mobile__framework__proto__op_proto__attr__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__op_proto__attr__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__op_proto__field_descriptors[5] = {
{
"type", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto, type), NULL, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"inputs",
2,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"inputs", 2, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__OpProto, n_inputs),
offsetof(PaddleMobile__Framework__Proto__OpProto, inputs),
&paddle_mobile__framework__proto__op_proto__var__descriptor,
NULL,
&paddle_mobile__framework__proto__op_proto__var__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"outputs",
3,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"outputs", 3, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__OpProto, n_outputs),
offsetof(PaddleMobile__Framework__Proto__OpProto, outputs),
&paddle_mobile__framework__proto__op_proto__var__descriptor,
NULL,
&paddle_mobile__framework__proto__op_proto__var__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"attrs",
4,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"attrs", 4, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__OpProto, n_attrs),
offsetof(PaddleMobile__Framework__Proto__OpProto, attrs),
&paddle_mobile__framework__proto__op_proto__attr__descriptor,
NULL,
&paddle_mobile__framework__proto__op_proto__attr__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"comment",
5,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
"comment", 5, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__OpProto, comment),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__OpProto, comment), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__op_proto__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__op_proto__field_indices_by_name[] = {
3, /* field[3] = attrs */
4, /* field[4] = comment */
1, /* field[1] = inputs */
2, /* field[2] = outputs */
0, /* field[0] = type */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__op_proto__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 5 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__op_proto__number_ranges[1 + 1] = {{1, 0},
{0, 5}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.OpProto",
"OpProto",
......@@ -839,48 +707,47 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__desc
5,
paddle_mobile__framework__proto__op_proto__field_descriptors,
paddle_mobile__framework__proto__op_proto__field_indices_by_name,
1, paddle_mobile__framework__proto__op_proto__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__op_proto__init,
NULL,NULL,NULL /* reserved[123] */
1,
paddle_mobile__framework__proto__op_proto__number_ranges,
(ProtobufCMessageInit)paddle_mobile__framework__proto__op_proto__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__var_type__tensor_desc__field_descriptors[2] =
{
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__tensor_desc__field_descriptors
[2] = {
{
"data_type",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_ENUM,
"data_type", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType__TensorDesc, data_type),
offsetof(PaddleMobile__Framework__Proto__VarType__TensorDesc,
data_type),
&paddle_mobile__framework__proto__var_type__type__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"dims",
2,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_INT64,
offsetof(PaddleMobile__Framework__Proto__VarType__TensorDesc, n_dims),
offsetof(PaddleMobile__Framework__Proto__VarType__TensorDesc, dims),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
"dims", 2, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_INT64,
offsetof(PaddleMobile__Framework__Proto__VarType__TensorDesc,
n_dims),
offsetof(PaddleMobile__Framework__Proto__VarType__TensorDesc,
dims),
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__var_type__tensor_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__var_type__tensor_desc__field_indices_by_name
[] = {
0, /* field[0] = data_type */
1, /* field[1] = dims */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_type__tensor_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__tensor_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_type__tensor_desc__number_ranges[1 +
1] = {
{1, 0}, {0, 2}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__tensor_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.TensorDesc",
"TensorDesc",
......@@ -890,49 +757,53 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__tens
2,
paddle_mobile__framework__proto__var_type__tensor_desc__field_descriptors,
paddle_mobile__framework__proto__var_type__tensor_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__var_type__tensor_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__var_type__tensor_desc__init,
NULL,NULL,NULL /* reserved[123] */
1,
paddle_mobile__framework__proto__var_type__tensor_desc__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__var_type__tensor_desc__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const int32_t paddle_mobile__framework__proto__var_type__lo_dtensor_desc__lod_level__default_value = 0;
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__var_type__lo_dtensor_desc__field_descriptors[2] =
{
static const int32_t
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__lod_level__default_value =
0;
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__field_descriptors
[2] = {
{
"tensor",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
"tensor", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorDesc, tensor),
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorDesc,
tensor),
&paddle_mobile__framework__proto__var_type__tensor_desc__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"lod_level",
2,
PROTOBUF_C_LABEL_OPTIONAL,
"lod_level", 2, PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_INT32,
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorDesc, has_lod_level),
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorDesc, lod_level),
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorDesc,
has_lod_level),
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorDesc,
lod_level),
NULL,
&paddle_mobile__framework__proto__var_type__lo_dtensor_desc__lod_level__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__var_type__lo_dtensor_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__field_indices_by_name
[] = {
1, /* field[1] = lod_level */
0, /* field[0] = tensor */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_type__lo_dtensor_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__number_ranges
[1 + 1] = {{1, 0}, {0, 2}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.LoDTensorDesc",
"LoDTensorDesc",
......@@ -942,49 +813,56 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__lo_d
2,
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__field_descriptors,
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__var_type__lo_dtensor_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__var_type__lo_dtensor_desc__init,
NULL,NULL,NULL /* reserved[123] */
1,
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const int32_t paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__lod_level__default_value = 0;
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__field_descriptors[2] =
{
static const int32_t
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__lod_level__default_value =
0;
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__field_descriptors
[2] = {
{
"tensor",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
"tensor", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc, tensor),
offsetof(
PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc,
tensor),
&paddle_mobile__framework__proto__var_type__tensor_desc__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"lod_level",
2,
PROTOBUF_C_LABEL_OPTIONAL,
"lod_level", 2, PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_INT32,
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc, has_lod_level),
offsetof(PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc, lod_level),
offsetof(
PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc,
has_lod_level),
offsetof(
PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc,
lod_level),
NULL,
&paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__lod_level__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__field_indices_by_name
[] = {
1, /* field[1] = lod_level */
0, /* field[0] = tensor */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__number_ranges
[1 + 1] = {{1, 0}, {0, 2}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.LoDTensorArrayDesc",
"LoDTensorArrayDesc",
......@@ -994,35 +872,38 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__lo_d
2,
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__field_descriptors,
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__init,
NULL,NULL,NULL /* reserved[123] */
1,
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__var_type__reader_desc__field_descriptors[1] =
{
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__reader_desc__field_descriptors[1] = {
{
"lod_tensor",
1,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__VarType__ReaderDesc, n_lod_tensor),
offsetof(PaddleMobile__Framework__Proto__VarType__ReaderDesc, lod_tensor),
"lod_tensor", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__VarType__ReaderDesc,
n_lod_tensor),
offsetof(PaddleMobile__Framework__Proto__VarType__ReaderDesc,
lod_tensor),
&paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__var_type__reader_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__var_type__reader_desc__field_indices_by_name
[] = {
0, /* field[0] = lod_tensor */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_type__reader_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__reader_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_type__reader_desc__number_ranges[1 +
1] = {
{1, 0}, {0, 1}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__reader_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.ReaderDesc",
"ReaderDesc",
......@@ -1032,48 +913,47 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__read
1,
paddle_mobile__framework__proto__var_type__reader_desc__field_descriptors,
paddle_mobile__framework__proto__var_type__reader_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__var_type__reader_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__var_type__reader_desc__init,
NULL,NULL,NULL /* reserved[123] */
1,
paddle_mobile__framework__proto__var_type__reader_desc__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__var_type__reader_desc__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__var_type__channel_desc__field_descriptors[2] =
{
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__channel_desc__field_descriptors
[2] = {
{
"data_type",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_ENUM,
"data_type", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType__ChannelDesc, data_type),
offsetof(PaddleMobile__Framework__Proto__VarType__ChannelDesc,
data_type),
&paddle_mobile__framework__proto__var_type__type__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"capacity",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT64,
"capacity", 2, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT64,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType__ChannelDesc, capacity),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
offsetof(PaddleMobile__Framework__Proto__VarType__ChannelDesc,
capacity),
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__var_type__channel_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__var_type__channel_desc__field_indices_by_name
[] = {
1, /* field[1] = capacity */
0, /* field[0] = data_type */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_type__channel_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__channel_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_type__channel_desc__number_ranges[1 +
1] =
{{1, 0}, {0, 2}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__channel_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.ChannelDesc",
"ChannelDesc",
......@@ -1083,35 +963,37 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__chan
2,
paddle_mobile__framework__proto__var_type__channel_desc__field_descriptors,
paddle_mobile__framework__proto__var_type__channel_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__var_type__channel_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__var_type__channel_desc__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__var_type__tuple__field_descriptors[1] =
{
{
"element_type",
1,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_ENUM,
offsetof(PaddleMobile__Framework__Proto__VarType__Tuple, n_element_type),
offsetof(PaddleMobile__Framework__Proto__VarType__Tuple, element_type),
&paddle_mobile__framework__proto__var_type__type__descriptor,
paddle_mobile__framework__proto__var_type__channel_desc__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__var_type__channel_desc__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__tuple__field_descriptors[1] = {
{
"element_type", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_ENUM,
offsetof(PaddleMobile__Framework__Proto__VarType__Tuple,
n_element_type),
offsetof(PaddleMobile__Framework__Proto__VarType__Tuple,
element_type),
&paddle_mobile__framework__proto__var_type__type__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__var_type__tuple__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__var_type__tuple__field_indices_by_name[] =
{
0, /* field[0] = element_type */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_type__tuple__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__tuple__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_type__tuple__number_ranges[1 + 1] = {
{1, 0}, {0, 1}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__tuple__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.Tuple",
"Tuple",
......@@ -1121,59 +1003,88 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__tupl
1,
paddle_mobile__framework__proto__var_type__tuple__field_descriptors,
paddle_mobile__framework__proto__var_type__tuple__field_indices_by_name,
1, paddle_mobile__framework__proto__var_type__tuple__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__var_type__tuple__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCEnumValue paddle_mobile__framework__proto__var_type__type__enum_values_by_number[19] =
{
{ "BOOL", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL", 0 },
{ "INT16", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__INT16", 1 },
{ "INT32", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__INT32", 2 },
{ "INT64", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__INT64", 3 },
{ "FP16", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FP16", 4 },
{ "FP32", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FP32", 5 },
{ "FP64", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FP64", 6 },
{ "LOD_TENSOR", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__LOD_TENSOR", 7 },
{ "SELECTED_ROWS", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__SELECTED_ROWS", 8 },
{ "FEED_MINIBATCH", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FEED_MINIBATCH", 9 },
{ "FETCH_LIST", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FETCH_LIST", 10 },
{ "STEP_SCOPES", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__STEP_SCOPES", 11 },
{ "LOD_RANK_TABLE", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__LOD_RANK_TABLE", 12 },
{ "LOD_TENSOR_ARRAY", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__LOD_TENSOR_ARRAY", 13 },
{ "PLACE_LIST", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__PLACE_LIST", 14 },
{ "READER", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__READER", 15 },
{ "CHANNEL", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__CHANNEL", 16 },
{ "RAW", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__RAW", 17 },
{ "TUPLE", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__TUPLE", 18 },
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_type__type__value_ranges[] = {
{0, 0},{0, 19}
};
static const ProtobufCEnumValueIndex paddle_mobile__framework__proto__var_type__type__enum_values_by_name[19] =
{
{ "BOOL", 0 },
{ "CHANNEL", 16 },
{ "FEED_MINIBATCH", 9 },
{ "FETCH_LIST", 10 },
{ "FP16", 4 },
{ "FP32", 5 },
{ "FP64", 6 },
{ "INT16", 1 },
{ "INT32", 2 },
{ "INT64", 3 },
{ "LOD_RANK_TABLE", 12 },
{ "LOD_TENSOR", 7 },
{ "LOD_TENSOR_ARRAY", 13 },
{ "PLACE_LIST", 14 },
{ "RAW", 17 },
{ "READER", 15 },
{ "SELECTED_ROWS", 8 },
{ "STEP_SCOPES", 11 },
{ "TUPLE", 18 },
1,
paddle_mobile__framework__proto__var_type__tuple__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__var_type__tuple__init,
NULL,
NULL,
NULL /* reserved[123] */
};
const ProtobufCEnumDescriptor paddle_mobile__framework__proto__var_type__type__descriptor =
{
static const ProtobufCEnumValue
paddle_mobile__framework__proto__var_type__type__enum_values_by_number[19] =
{
{"BOOL", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL",
0},
{"INT16", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__INT16",
1},
{"INT32", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__INT32",
2},
{"INT64", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__INT64",
3},
{"FP16", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FP16",
4},
{"FP32", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FP32",
5},
{"FP64", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FP64",
6},
{"LOD_TENSOR",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__LOD_TENSOR", 7},
{"SELECTED_ROWS",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__SELECTED_ROWS",
8},
{"FEED_MINIBATCH",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FEED_MINIBATCH",
9},
{"FETCH_LIST",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__FETCH_LIST", 10},
{"STEP_SCOPES",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__STEP_SCOPES",
11},
{"LOD_RANK_TABLE",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__LOD_RANK_TABLE",
12},
{"LOD_TENSOR_ARRAY",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__LOD_TENSOR_"
"ARRAY",
13},
{"PLACE_LIST",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__PLACE_LIST", 14},
{"READER",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__READER", 15},
{"CHANNEL",
"PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__CHANNEL", 16},
{"RAW", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__RAW", 17},
{"TUPLE", "PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__TUPLE",
18},
};
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_type__type__value_ranges[] = {{0, 0},
{0, 19}};
static const ProtobufCEnumValueIndex
paddle_mobile__framework__proto__var_type__type__enum_values_by_name[19] = {
{"BOOL", 0},
{"CHANNEL", 16},
{"FEED_MINIBATCH", 9},
{"FETCH_LIST", 10},
{"FP16", 4},
{"FP32", 5},
{"FP64", 6},
{"INT16", 1},
{"INT32", 2},
{"INT64", 3},
{"LOD_RANK_TABLE", 12},
{"LOD_TENSOR", 7},
{"LOD_TENSOR_ARRAY", 13},
{"PLACE_LIST", 14},
{"RAW", 17},
{"READER", 15},
{"SELECTED_ROWS", 8},
{"STEP_SCOPES", 11},
{"TUPLE", 18},
};
const ProtobufCEnumDescriptor
paddle_mobile__framework__proto__var_type__type__descriptor = {
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType.Type",
"Type",
......@@ -1185,96 +1096,72 @@ const ProtobufCEnumDescriptor paddle_mobile__framework__proto__var_type__type__d
paddle_mobile__framework__proto__var_type__type__enum_values_by_name,
1,
paddle_mobile__framework__proto__var_type__type__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
NULL,
NULL,
NULL,
NULL /* reserved[1234] */
};
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__var_type__field_descriptors[7] =
{
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_type__field_descriptors[7] = {
{
"type",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_ENUM,
"type", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_ENUM,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType, type),
&paddle_mobile__framework__proto__var_type__type__descriptor,
NULL,
&paddle_mobile__framework__proto__var_type__type__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"selected_rows",
2,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
"selected_rows", 2, PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType, selected_rows),
&paddle_mobile__framework__proto__var_type__tensor_desc__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"lod_tensor",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
"lod_tensor", 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType, lod_tensor),
&paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"tensor_array",
4,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
"tensor_array", 4, PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType, tensor_array),
&paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"reader",
5,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
"reader", 5, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType, reader),
&paddle_mobile__framework__proto__var_type__reader_desc__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"channel",
6,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
"channel", 6, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType, channel),
&paddle_mobile__framework__proto__var_type__channel_desc__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"tuple",
7,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_MESSAGE,
"tuple", 7, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarType, tuple),
&paddle_mobile__framework__proto__var_type__tuple__descriptor,
NULL,
&paddle_mobile__framework__proto__var_type__tuple__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__var_type__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__var_type__field_indices_by_name[] = {
5, /* field[5] = channel */
2, /* field[2] = lod_tensor */
4, /* field[4] = reader */
......@@ -1283,13 +1170,11 @@ static const unsigned paddle_mobile__framework__proto__var_type__field_indices_b
6, /* field[6] = tuple */
0, /* field[0] = type */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_type__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 7 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_type__number_ranges[1 + 1] = {{1, 0},
{0, 7}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarType",
"VarType",
......@@ -1299,62 +1184,53 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__desc
7,
paddle_mobile__framework__proto__var_type__field_descriptors,
paddle_mobile__framework__proto__var_type__field_indices_by_name,
1, paddle_mobile__framework__proto__var_type__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__var_type__init,
NULL,NULL,NULL /* reserved[123] */
};
static const protobuf_c_boolean paddle_mobile__framework__proto__var_desc__persistable__default_value = 0;
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__var_desc__field_descriptors[3] =
{
{
"name",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarDesc, name),
paddle_mobile__framework__proto__var_type__number_ranges,
(ProtobufCMessageInit)paddle_mobile__framework__proto__var_type__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const protobuf_c_boolean
paddle_mobile__framework__proto__var_desc__persistable__default_value = 0;
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__var_desc__field_descriptors[3] = {
{
"name", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarDesc, name), NULL, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"type",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_MESSAGE,
"type", 2, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_MESSAGE,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__VarDesc, type),
&paddle_mobile__framework__proto__var_type__descriptor,
NULL,
&paddle_mobile__framework__proto__var_type__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"persistable",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BOOL,
"persistable", 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL,
offsetof(PaddleMobile__Framework__Proto__VarDesc, has_persistable),
offsetof(PaddleMobile__Framework__Proto__VarDesc, persistable),
NULL,
&paddle_mobile__framework__proto__var_desc__persistable__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__var_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__var_desc__field_indices_by_name[] = {
0, /* field[0] = name */
2, /* field[2] = persistable */
1, /* field[1] = type */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__var_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 3 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__var_desc__number_ranges[1 + 1] = {{1, 0},
{0, 3}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.VarDesc",
"VarDesc",
......@@ -1364,88 +1240,74 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_desc__desc
3,
paddle_mobile__framework__proto__var_desc__field_descriptors,
paddle_mobile__framework__proto__var_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__var_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__var_desc__init,
NULL,NULL,NULL /* reserved[123] */
};
static const int32_t paddle_mobile__framework__proto__block_desc__forward_block_idx__default_value = -1;
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__block_desc__field_descriptors[5] =
{
{
"idx",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__BlockDesc, idx),
paddle_mobile__framework__proto__var_desc__number_ranges,
(ProtobufCMessageInit)paddle_mobile__framework__proto__var_desc__init,
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL /* reserved[123] */
};
static const int32_t
paddle_mobile__framework__proto__block_desc__forward_block_idx__default_value =
-1;
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__block_desc__field_descriptors[5] = {
{
"idx", 1, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__BlockDesc, idx), NULL,
NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"parent_idx",
2,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_INT32,
"parent_idx", 2, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
offsetof(PaddleMobile__Framework__Proto__BlockDesc, parent_idx),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
NULL, NULL, 0, /* flags */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"vars",
3,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"vars", 3, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__BlockDesc, n_vars),
offsetof(PaddleMobile__Framework__Proto__BlockDesc, vars),
&paddle_mobile__framework__proto__var_desc__descriptor,
NULL,
&paddle_mobile__framework__proto__var_desc__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"ops",
4,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"ops", 4, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__BlockDesc, n_ops),
offsetof(PaddleMobile__Framework__Proto__BlockDesc, ops),
&paddle_mobile__framework__proto__op_desc__descriptor,
NULL,
&paddle_mobile__framework__proto__op_desc__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
{
"forward_block_idx",
5,
PROTOBUF_C_LABEL_OPTIONAL,
"forward_block_idx", 5, PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_INT32,
offsetof(PaddleMobile__Framework__Proto__BlockDesc, has_forward_block_idx),
offsetof(PaddleMobile__Framework__Proto__BlockDesc, forward_block_idx),
offsetof(PaddleMobile__Framework__Proto__BlockDesc,
has_forward_block_idx),
offsetof(PaddleMobile__Framework__Proto__BlockDesc,
forward_block_idx),
NULL,
&paddle_mobile__framework__proto__block_desc__forward_block_idx__default_value,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__block_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__block_desc__field_indices_by_name[] = {
4, /* field[4] = forward_block_idx */
0, /* field[0] = idx */
3, /* field[3] = ops */
1, /* field[1] = parent_idx */
2, /* field[2] = vars */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__block_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 5 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__block_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__block_desc__number_ranges[1 + 1] = {
{1, 0}, {0, 5}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__block_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.BlockDesc",
"BlockDesc",
......@@ -1455,35 +1317,33 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__block_desc__de
5,
paddle_mobile__framework__proto__block_desc__field_descriptors,
paddle_mobile__framework__proto__block_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__block_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__block_desc__init,
NULL,NULL,NULL /* reserved[123] */
1,
paddle_mobile__framework__proto__block_desc__number_ranges,
(ProtobufCMessageInit)paddle_mobile__framework__proto__block_desc__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor paddle_mobile__framework__proto__program_desc__field_descriptors[1] =
{
static const ProtobufCFieldDescriptor
paddle_mobile__framework__proto__program_desc__field_descriptors[1] = {
{
"blocks",
1,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
"blocks", 1, PROTOBUF_C_LABEL_REPEATED, PROTOBUF_C_TYPE_MESSAGE,
offsetof(PaddleMobile__Framework__Proto__ProgramDesc, n_blocks),
offsetof(PaddleMobile__Framework__Proto__ProgramDesc, blocks),
&paddle_mobile__framework__proto__block_desc__descriptor,
NULL,
&paddle_mobile__framework__proto__block_desc__descriptor, NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
0, NULL, NULL /* reserved1,reserved2, etc */
},
};
static const unsigned paddle_mobile__framework__proto__program_desc__field_indices_by_name[] = {
static const unsigned
paddle_mobile__framework__proto__program_desc__field_indices_by_name[] = {
0, /* field[0] = blocks */
};
static const ProtobufCIntRange paddle_mobile__framework__proto__program_desc__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor paddle_mobile__framework__proto__program_desc__descriptor =
{
static const ProtobufCIntRange
paddle_mobile__framework__proto__program_desc__number_ranges[1 + 1] = {
{1, 0}, {0, 1}};
const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__program_desc__descriptor = {
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.ProgramDesc",
"ProgramDesc",
......@@ -1493,41 +1353,38 @@ const ProtobufCMessageDescriptor paddle_mobile__framework__proto__program_desc__
1,
paddle_mobile__framework__proto__program_desc__field_descriptors,
paddle_mobile__framework__proto__program_desc__field_indices_by_name,
1, paddle_mobile__framework__proto__program_desc__number_ranges,
(ProtobufCMessageInit) paddle_mobile__framework__proto__program_desc__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCEnumValue paddle_mobile__framework__proto__attr_type__enum_values_by_number[10] =
{
{ "INT", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT", 0 },
{ "FLOAT", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOAT", 1 },
{ "STRING", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__STRING", 2 },
{ "INTS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INTS", 3 },
{ "FLOATS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOATS", 4 },
{ "STRINGS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__STRINGS", 5 },
{ "BOOLEAN", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BOOLEAN", 6 },
{ "BOOLEANS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BOOLEANS", 7 },
{ "BLOCK", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BLOCK", 8 },
{ "LONG", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__LONG", 9 },
};
static const ProtobufCIntRange paddle_mobile__framework__proto__attr_type__value_ranges[] = {
{0, 0},{0, 10}
};
static const ProtobufCEnumValueIndex paddle_mobile__framework__proto__attr_type__enum_values_by_name[10] =
{
{ "BLOCK", 8 },
{ "BOOLEAN", 6 },
{ "BOOLEANS", 7 },
{ "FLOAT", 1 },
{ "FLOATS", 4 },
{ "INT", 0 },
{ "INTS", 3 },
{ "LONG", 9 },
{ "STRING", 2 },
{ "STRINGS", 5 },
};
const ProtobufCEnumDescriptor paddle_mobile__framework__proto__attr_type__descriptor =
{
1,
paddle_mobile__framework__proto__program_desc__number_ranges,
(ProtobufCMessageInit)
paddle_mobile__framework__proto__program_desc__init,
NULL,
NULL,
NULL /* reserved[123] */
};
static const ProtobufCEnumValue
paddle_mobile__framework__proto__attr_type__enum_values_by_number[10] = {
{"INT", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT", 0},
{"FLOAT", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOAT", 1},
{"STRING", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__STRING", 2},
{"INTS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INTS", 3},
{"FLOATS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__FLOATS", 4},
{"STRINGS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__STRINGS", 5},
{"BOOLEAN", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BOOLEAN", 6},
{"BOOLEANS", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BOOLEANS", 7},
{"BLOCK", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BLOCK", 8},
{"LONG", "PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__LONG", 9},
};
static const ProtobufCIntRange
paddle_mobile__framework__proto__attr_type__value_ranges[] = {{0, 0},
{0, 10}};
static const ProtobufCEnumValueIndex
paddle_mobile__framework__proto__attr_type__enum_values_by_name[10] = {
{"BLOCK", 8}, {"BOOLEAN", 6}, {"BOOLEANS", 7}, {"FLOAT", 1},
{"FLOATS", 4}, {"INT", 0}, {"INTS", 3}, {"LONG", 9},
{"STRING", 2}, {"STRINGS", 5},
};
const ProtobufCEnumDescriptor
paddle_mobile__framework__proto__attr_type__descriptor = {
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
"paddle_mobile.framework.proto.AttrType",
"AttrType",
......@@ -1539,5 +1396,8 @@ const ProtobufCEnumDescriptor paddle_mobile__framework__proto__attr_type__descri
paddle_mobile__framework__proto__attr_type__enum_values_by_name,
1,
paddle_mobile__framework__proto__attr_type__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
NULL,
NULL,
NULL,
NULL /* reserved[1234] */
};
......@@ -14,24 +14,38 @@ PROTOBUF_C__BEGIN_DECLS
# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c.
#endif
typedef struct _PaddleMobile__Framework__Proto__OpDesc PaddleMobile__Framework__Proto__OpDesc;
typedef struct _PaddleMobile__Framework__Proto__OpDesc__Attr PaddleMobile__Framework__Proto__OpDesc__Attr;
typedef struct _PaddleMobile__Framework__Proto__OpDesc__Var PaddleMobile__Framework__Proto__OpDesc__Var;
typedef struct _PaddleMobile__Framework__Proto__OpProto PaddleMobile__Framework__Proto__OpProto;
typedef struct _PaddleMobile__Framework__Proto__OpProto__Var PaddleMobile__Framework__Proto__OpProto__Var;
typedef struct _PaddleMobile__Framework__Proto__OpProto__Attr PaddleMobile__Framework__Proto__OpProto__Attr;
typedef struct _PaddleMobile__Framework__Proto__VarType PaddleMobile__Framework__Proto__VarType;
typedef struct _PaddleMobile__Framework__Proto__VarType__TensorDesc PaddleMobile__Framework__Proto__VarType__TensorDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__LoDTensorDesc PaddleMobile__Framework__Proto__VarType__LoDTensorDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__ReaderDesc PaddleMobile__Framework__Proto__VarType__ReaderDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__ChannelDesc PaddleMobile__Framework__Proto__VarType__ChannelDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__Tuple PaddleMobile__Framework__Proto__VarType__Tuple;
typedef struct _PaddleMobile__Framework__Proto__VarDesc PaddleMobile__Framework__Proto__VarDesc;
typedef struct _PaddleMobile__Framework__Proto__BlockDesc PaddleMobile__Framework__Proto__BlockDesc;
typedef struct _PaddleMobile__Framework__Proto__ProgramDesc PaddleMobile__Framework__Proto__ProgramDesc;
typedef struct _PaddleMobile__Framework__Proto__OpDesc
PaddleMobile__Framework__Proto__OpDesc;
typedef struct _PaddleMobile__Framework__Proto__OpDesc__Attr
PaddleMobile__Framework__Proto__OpDesc__Attr;
typedef struct _PaddleMobile__Framework__Proto__OpDesc__Var
PaddleMobile__Framework__Proto__OpDesc__Var;
typedef struct _PaddleMobile__Framework__Proto__OpProto
PaddleMobile__Framework__Proto__OpProto;
typedef struct _PaddleMobile__Framework__Proto__OpProto__Var
PaddleMobile__Framework__Proto__OpProto__Var;
typedef struct _PaddleMobile__Framework__Proto__OpProto__Attr
PaddleMobile__Framework__Proto__OpProto__Attr;
typedef struct _PaddleMobile__Framework__Proto__VarType
PaddleMobile__Framework__Proto__VarType;
typedef struct _PaddleMobile__Framework__Proto__VarType__TensorDesc
PaddleMobile__Framework__Proto__VarType__TensorDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__LoDTensorDesc
PaddleMobile__Framework__Proto__VarType__LoDTensorDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc
PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__ReaderDesc
PaddleMobile__Framework__Proto__VarType__ReaderDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__ChannelDesc
PaddleMobile__Framework__Proto__VarType__ChannelDesc;
typedef struct _PaddleMobile__Framework__Proto__VarType__Tuple
PaddleMobile__Framework__Proto__VarType__Tuple;
typedef struct _PaddleMobile__Framework__Proto__VarDesc
PaddleMobile__Framework__Proto__VarDesc;
typedef struct _PaddleMobile__Framework__Proto__BlockDesc
PaddleMobile__Framework__Proto__BlockDesc;
typedef struct _PaddleMobile__Framework__Proto__ProgramDesc
PaddleMobile__Framework__Proto__ProgramDesc;
/* --- enums --- */
......@@ -65,8 +79,9 @@ typedef enum _PaddleMobile__Framework__Proto__VarType__Type {
* in operators like nccl_op
*/
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__RAW = 17,
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__TUPLE = 18
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE)
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__TUPLE =
18 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(
PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE)
} PaddleMobile__Framework__Proto__VarType__Type;
typedef enum _PaddleMobile__Framework__Proto__AttrType {
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT = 0,
......@@ -78,14 +93,14 @@ typedef enum _PaddleMobile__Framework__Proto__AttrType {
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BOOLEAN = 6,
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BOOLEANS = 7,
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__BLOCK = 8,
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__LONG = 9
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE)
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__LONG =
9 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(
PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE)
} PaddleMobile__Framework__Proto__AttrType;
/* --- messages --- */
struct _PaddleMobile__Framework__Proto__OpDesc__Attr
{
struct _PaddleMobile__Framework__Proto__OpDesc__Attr {
ProtobufCMessage base;
char *name;
PaddleMobile__Framework__Proto__AttrType type;
......@@ -110,28 +125,31 @@ struct _PaddleMobile__Framework__Proto__OpDesc__Attr
int64_t l;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__ATTR__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__op_desc__attr__descriptor) \
, NULL, PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT, 0, 0, 0, 0, NULL, 0,NULL, 0,NULL, 0,NULL, 0, 0, 0,NULL, 0, 0, 0, 0 }
struct _PaddleMobile__Framework__Proto__OpDesc__Var
{
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__op_desc__attr__descriptor) \
, NULL, PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT, 0, 0, 0, 0, NULL, \
0, NULL, 0, NULL, 0, NULL, 0, 0, 0, NULL, 0, 0, 0, 0 \
}
struct _PaddleMobile__Framework__Proto__OpDesc__Var {
ProtobufCMessage base;
char *parameter;
size_t n_arguments;
char **arguments;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__VAR__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__op_desc__var__descriptor) \
, NULL, 0,NULL }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__op_desc__var__descriptor) \
, NULL, 0, NULL \
}
/*
* OpDesc describes an instance of a C++ framework::OperatorBase
* derived class type.
*/
struct _PaddleMobile__Framework__Proto__OpDesc
{
struct _PaddleMobile__Framework__Proto__OpDesc {
ProtobufCMessage base;
char *type;
size_t n_inputs;
......@@ -144,15 +162,16 @@ struct _PaddleMobile__Framework__Proto__OpDesc
protobuf_c_boolean is_target;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__OP_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__op_desc__descriptor) \
, NULL, 0,NULL, 0,NULL, 0,NULL, 0, 0 }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__op_desc__descriptor) \
, NULL, 0, NULL, 0, NULL, 0, NULL, 0, 0 \
}
/*
* VarProto describes the C++ type framework::Variable.
*/
struct _PaddleMobile__Framework__Proto__OpProto__Var
{
struct _PaddleMobile__Framework__Proto__OpProto__Var {
ProtobufCMessage base;
char *name;
char *comment;
......@@ -164,15 +183,16 @@ struct _PaddleMobile__Framework__Proto__OpProto__Var
protobuf_c_boolean dispensable;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__VAR__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__op_proto__var__descriptor) \
, NULL, NULL, 0, 0, 0, 0, 0, 0 }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__op_proto__var__descriptor) \
, NULL, NULL, 0, 0, 0, 0, 0, 0 \
}
/*
* AttrProto describes the C++ type Attribute.
*/
struct _PaddleMobile__Framework__Proto__OpProto__Attr
{
struct _PaddleMobile__Framework__Proto__OpProto__Attr {
ProtobufCMessage base;
char *name;
PaddleMobile__Framework__Proto__AttrType type;
......@@ -186,15 +206,16 @@ struct _PaddleMobile__Framework__Proto__OpProto__Attr
protobuf_c_boolean generated;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__ATTR__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__op_proto__attr__descriptor) \
, NULL, PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT, NULL, 0, 0 }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__op_proto__attr__descriptor) \
, NULL, PADDLE_MOBILE__FRAMEWORK__PROTO__ATTR_TYPE__INT, NULL, 0, 0 \
}
/*
* OpProto describes a C++ framework::OperatorBase derived class.
*/
struct _PaddleMobile__Framework__Proto__OpProto
{
struct _PaddleMobile__Framework__Proto__OpProto {
ProtobufCMessage base;
char *type;
size_t n_inputs;
......@@ -206,12 +227,13 @@ struct _PaddleMobile__Framework__Proto__OpProto
char *comment;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__OP_PROTO__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__op_proto__descriptor) \
, NULL, 0,NULL, 0,NULL, 0,NULL, NULL }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__op_proto__descriptor) \
, NULL, 0, NULL, 0, NULL, 0, NULL, NULL \
}
struct _PaddleMobile__Framework__Proto__VarType__TensorDesc
{
struct _PaddleMobile__Framework__Proto__VarType__TensorDesc {
ProtobufCMessage base;
/*
* Should only be PODType. Is enforced in C++
......@@ -224,69 +246,75 @@ struct _PaddleMobile__Framework__Proto__VarType__TensorDesc
int64_t *dims;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TENSOR_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__var_type__tensor_desc__descriptor) \
, PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL, 0,NULL }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__var_type__tensor_desc__descriptor) \
, PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL, 0, NULL \
}
struct _PaddleMobile__Framework__Proto__VarType__LoDTensorDesc
{
struct _PaddleMobile__Framework__Proto__VarType__LoDTensorDesc {
ProtobufCMessage base;
PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor;
protobuf_c_boolean has_lod_level;
int32_t lod_level;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__LO_DTENSOR_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor) \
, NULL, 0, 0 }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor) \
, NULL, 0, 0 \
}
struct _PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc
{
struct _PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc {
ProtobufCMessage base;
PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor;
protobuf_c_boolean has_lod_level;
int32_t lod_level;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__LO_DTENSOR_ARRAY_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor) \
, NULL, 0, 0 }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor) \
, NULL, 0, 0 \
}
struct _PaddleMobile__Framework__Proto__VarType__ReaderDesc
{
struct _PaddleMobile__Framework__Proto__VarType__ReaderDesc {
ProtobufCMessage base;
size_t n_lod_tensor;
PaddleMobile__Framework__Proto__VarType__LoDTensorDesc **lod_tensor;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__READER_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__var_type__reader_desc__descriptor) \
, 0,NULL }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__var_type__reader_desc__descriptor) \
, 0, NULL \
}
struct _PaddleMobile__Framework__Proto__VarType__ChannelDesc
{
struct _PaddleMobile__Framework__Proto__VarType__ChannelDesc {
ProtobufCMessage base;
PaddleMobile__Framework__Proto__VarType__Type data_type;
int64_t capacity;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__CHANNEL_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__var_type__channel_desc__descriptor) \
, PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL, 0 }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__var_type__channel_desc__descriptor) \
, PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL, 0 \
}
struct _PaddleMobile__Framework__Proto__VarType__Tuple
{
struct _PaddleMobile__Framework__Proto__VarType__Tuple {
ProtobufCMessage base;
size_t n_element_type;
PaddleMobile__Framework__Proto__VarType__Type *element_type;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TUPLE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__var_type__tuple__descriptor) \
, 0,NULL }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__var_type__tuple__descriptor) \
, 0, NULL \
}
struct _PaddleMobile__Framework__Proto__VarType
{
struct _PaddleMobile__Framework__Proto__VarType {
ProtobufCMessage base;
PaddleMobile__Framework__Proto__VarType__Type type;
PaddleMobile__Framework__Proto__VarType__TensorDesc *selected_rows;
......@@ -297,12 +325,14 @@ struct _PaddleMobile__Framework__Proto__VarType
PaddleMobile__Framework__Proto__VarType__Tuple *tuple;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__var_type__descriptor) \
, PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL, NULL, NULL, NULL, NULL, NULL, NULL }
struct _PaddleMobile__Framework__Proto__VarDesc
{
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__var_type__descriptor) \
, PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL, NULL, NULL, NULL, \
NULL, NULL, NULL \
}
struct _PaddleMobile__Framework__Proto__VarDesc {
ProtobufCMessage base;
char *name;
PaddleMobile__Framework__Proto__VarType *type;
......@@ -310,12 +340,13 @@ struct _PaddleMobile__Framework__Proto__VarDesc
protobuf_c_boolean persistable;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__var_desc__descriptor) \
, NULL, NULL, 0, 0 }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__var_desc__descriptor) \
, NULL, NULL, 0, 0 \
}
struct _PaddleMobile__Framework__Proto__BlockDesc
{
struct _PaddleMobile__Framework__Proto__BlockDesc {
ProtobufCMessage base;
int32_t idx;
int32_t parent_idx;
......@@ -327,9 +358,11 @@ struct _PaddleMobile__Framework__Proto__BlockDesc
int32_t forward_block_idx;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__BLOCK_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__block_desc__descriptor) \
, 0, 0, 0,NULL, 0,NULL, 0, -1 }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__block_desc__descriptor) \
, 0, 0, 0, NULL, 0, NULL, 0, -1 \
}
/*
* Please refer to
......@@ -338,203 +371,209 @@ struct _PaddleMobile__Framework__Proto__BlockDesc
* TODO(panyx0718): A model can have multiple programs. Need a
* way to distinguish them. Maybe ID or name?
*/
struct _PaddleMobile__Framework__Proto__ProgramDesc
{
struct _PaddleMobile__Framework__Proto__ProgramDesc {
ProtobufCMessage base;
size_t n_blocks;
PaddleMobile__Framework__Proto__BlockDesc **blocks;
};
#define PADDLE_MOBILE__FRAMEWORK__PROTO__PROGRAM_DESC__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&paddle_mobile__framework__proto__program_desc__descriptor) \
, 0,NULL }
{ \
PROTOBUF_C_MESSAGE_INIT( \
&paddle_mobile__framework__proto__program_desc__descriptor) \
, 0, NULL \
}
/* PaddleMobile__Framework__Proto__OpDesc__Attr methods */
void paddle_mobile__framework__proto__op_desc__attr__init
(PaddleMobile__Framework__Proto__OpDesc__Attr *message);
void paddle_mobile__framework__proto__op_desc__attr__init(
PaddleMobile__Framework__Proto__OpDesc__Attr *message);
/* PaddleMobile__Framework__Proto__OpDesc__Var methods */
void paddle_mobile__framework__proto__op_desc__var__init
(PaddleMobile__Framework__Proto__OpDesc__Var *message);
void paddle_mobile__framework__proto__op_desc__var__init(
PaddleMobile__Framework__Proto__OpDesc__Var *message);
/* PaddleMobile__Framework__Proto__OpDesc methods */
void paddle_mobile__framework__proto__op_desc__init
(PaddleMobile__Framework__Proto__OpDesc *message);
void paddle_mobile__framework__proto__op_desc__init(
PaddleMobile__Framework__Proto__OpDesc *message);
size_t paddle_mobile__framework__proto__op_desc__get_packed_size
(const PaddleMobile__Framework__Proto__OpDesc *message);
size_t paddle_mobile__framework__proto__op_desc__get_packed_size(
const PaddleMobile__Framework__Proto__OpDesc *message);
PaddleMobile__Framework__Proto__OpDesc *
paddle_mobile__framework__proto__op_desc__unpack
(ProtobufCAllocator *allocator,
paddle_mobile__framework__proto__op_desc__unpack(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void paddle_mobile__framework__proto__op_desc__free_unpacked
(PaddleMobile__Framework__Proto__OpDesc *message,
void paddle_mobile__framework__proto__op_desc__free_unpacked(
PaddleMobile__Framework__Proto__OpDesc *message,
ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__OpProto__Var methods */
void paddle_mobile__framework__proto__op_proto__var__init
(PaddleMobile__Framework__Proto__OpProto__Var *message);
void paddle_mobile__framework__proto__op_proto__var__init(
PaddleMobile__Framework__Proto__OpProto__Var *message);
/* PaddleMobile__Framework__Proto__OpProto__Attr methods */
void paddle_mobile__framework__proto__op_proto__attr__init
(PaddleMobile__Framework__Proto__OpProto__Attr *message);
void paddle_mobile__framework__proto__op_proto__attr__init(
PaddleMobile__Framework__Proto__OpProto__Attr *message);
/* PaddleMobile__Framework__Proto__OpProto methods */
void paddle_mobile__framework__proto__op_proto__init
(PaddleMobile__Framework__Proto__OpProto *message);
size_t paddle_mobile__framework__proto__op_proto__get_packed_size
(const PaddleMobile__Framework__Proto__OpProto *message);
void paddle_mobile__framework__proto__op_proto__init(
PaddleMobile__Framework__Proto__OpProto *message);
size_t paddle_mobile__framework__proto__op_proto__get_packed_size(
const PaddleMobile__Framework__Proto__OpProto *message);
PaddleMobile__Framework__Proto__OpProto *
paddle_mobile__framework__proto__op_proto__unpack
(ProtobufCAllocator *allocator,
paddle_mobile__framework__proto__op_proto__unpack(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void paddle_mobile__framework__proto__op_proto__free_unpacked
(PaddleMobile__Framework__Proto__OpProto *message,
void paddle_mobile__framework__proto__op_proto__free_unpacked(
PaddleMobile__Framework__Proto__OpProto *message,
ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__VarType__TensorDesc methods */
void paddle_mobile__framework__proto__var_type__tensor_desc__init
(PaddleMobile__Framework__Proto__VarType__TensorDesc *message);
void paddle_mobile__framework__proto__var_type__tensor_desc__init(
PaddleMobile__Framework__Proto__VarType__TensorDesc *message);
/* PaddleMobile__Framework__Proto__VarType__LoDTensorDesc methods */
void paddle_mobile__framework__proto__var_type__lo_dtensor_desc__init
(PaddleMobile__Framework__Proto__VarType__LoDTensorDesc *message);
void paddle_mobile__framework__proto__var_type__lo_dtensor_desc__init(
PaddleMobile__Framework__Proto__VarType__LoDTensorDesc *message);
/* PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc methods */
void paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__init
(PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc *message);
void paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__init(
PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc *message);
/* PaddleMobile__Framework__Proto__VarType__ReaderDesc methods */
void paddle_mobile__framework__proto__var_type__reader_desc__init
(PaddleMobile__Framework__Proto__VarType__ReaderDesc *message);
void paddle_mobile__framework__proto__var_type__reader_desc__init(
PaddleMobile__Framework__Proto__VarType__ReaderDesc *message);
/* PaddleMobile__Framework__Proto__VarType__ChannelDesc methods */
void paddle_mobile__framework__proto__var_type__channel_desc__init
(PaddleMobile__Framework__Proto__VarType__ChannelDesc *message);
void paddle_mobile__framework__proto__var_type__channel_desc__init(
PaddleMobile__Framework__Proto__VarType__ChannelDesc *message);
/* PaddleMobile__Framework__Proto__VarType__Tuple methods */
void paddle_mobile__framework__proto__var_type__tuple__init
(PaddleMobile__Framework__Proto__VarType__Tuple *message);
void paddle_mobile__framework__proto__var_type__tuple__init(
PaddleMobile__Framework__Proto__VarType__Tuple *message);
/* PaddleMobile__Framework__Proto__VarType methods */
void paddle_mobile__framework__proto__var_type__init
(PaddleMobile__Framework__Proto__VarType *message);
size_t paddle_mobile__framework__proto__var_type__get_packed_size
(const PaddleMobile__Framework__Proto__VarType *message);
void paddle_mobile__framework__proto__var_type__init(
PaddleMobile__Framework__Proto__VarType *message);
size_t paddle_mobile__framework__proto__var_type__get_packed_size(
const PaddleMobile__Framework__Proto__VarType *message);
PaddleMobile__Framework__Proto__VarType *
paddle_mobile__framework__proto__var_type__unpack
(ProtobufCAllocator *allocator,
paddle_mobile__framework__proto__var_type__unpack(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void paddle_mobile__framework__proto__var_type__free_unpacked
(PaddleMobile__Framework__Proto__VarType *message,
void paddle_mobile__framework__proto__var_type__free_unpacked(
PaddleMobile__Framework__Proto__VarType *message,
ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__VarDesc methods */
void paddle_mobile__framework__proto__var_desc__init
(PaddleMobile__Framework__Proto__VarDesc *message);
size_t paddle_mobile__framework__proto__var_desc__get_packed_size
(const PaddleMobile__Framework__Proto__VarDesc *message);
void paddle_mobile__framework__proto__var_desc__init(
PaddleMobile__Framework__Proto__VarDesc *message);
size_t paddle_mobile__framework__proto__var_desc__get_packed_size(
const PaddleMobile__Framework__Proto__VarDesc *message);
PaddleMobile__Framework__Proto__VarDesc *
paddle_mobile__framework__proto__var_desc__unpack
(ProtobufCAllocator *allocator,
paddle_mobile__framework__proto__var_desc__unpack(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void paddle_mobile__framework__proto__var_desc__free_unpacked
(PaddleMobile__Framework__Proto__VarDesc *message,
void paddle_mobile__framework__proto__var_desc__free_unpacked(
PaddleMobile__Framework__Proto__VarDesc *message,
ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__BlockDesc methods */
void paddle_mobile__framework__proto__block_desc__init
(PaddleMobile__Framework__Proto__BlockDesc *message);
size_t paddle_mobile__framework__proto__block_desc__get_packed_size
(const PaddleMobile__Framework__Proto__BlockDesc *message);
void paddle_mobile__framework__proto__block_desc__init(
PaddleMobile__Framework__Proto__BlockDesc *message);
size_t paddle_mobile__framework__proto__block_desc__get_packed_size(
const PaddleMobile__Framework__Proto__BlockDesc *message);
PaddleMobile__Framework__Proto__BlockDesc *
paddle_mobile__framework__proto__block_desc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void paddle_mobile__framework__proto__block_desc__free_unpacked
(PaddleMobile__Framework__Proto__BlockDesc *message,
paddle_mobile__framework__proto__block_desc__unpack(
ProtobufCAllocator *allocator, size_t len, const uint8_t *data);
void paddle_mobile__framework__proto__block_desc__free_unpacked(
PaddleMobile__Framework__Proto__BlockDesc *message,
ProtobufCAllocator *allocator);
/* PaddleMobile__Framework__Proto__ProgramDesc methods */
void paddle_mobile__framework__proto__program_desc__init
(PaddleMobile__Framework__Proto__ProgramDesc *message);
size_t paddle_mobile__framework__proto__program_desc__get_packed_size
(const PaddleMobile__Framework__Proto__ProgramDesc *message);
void paddle_mobile__framework__proto__program_desc__init(
PaddleMobile__Framework__Proto__ProgramDesc *message);
size_t paddle_mobile__framework__proto__program_desc__get_packed_size(
const PaddleMobile__Framework__Proto__ProgramDesc *message);
PaddleMobile__Framework__Proto__ProgramDesc *
paddle_mobile__framework__proto__program_desc__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void paddle_mobile__framework__proto__program_desc__free_unpacked
(PaddleMobile__Framework__Proto__ProgramDesc *message,
paddle_mobile__framework__proto__program_desc__unpack(
ProtobufCAllocator *allocator, size_t len, const uint8_t *data);
void paddle_mobile__framework__proto__program_desc__free_unpacked(
PaddleMobile__Framework__Proto__ProgramDesc *message,
ProtobufCAllocator *allocator);
/* --- per-message closures --- */
typedef void (*PaddleMobile__Framework__Proto__OpDesc__Attr_Closure)
(const PaddleMobile__Framework__Proto__OpDesc__Attr *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__OpDesc__Var_Closure)
(const PaddleMobile__Framework__Proto__OpDesc__Var *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__OpDesc_Closure)
(const PaddleMobile__Framework__Proto__OpDesc *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__OpProto__Var_Closure)
(const PaddleMobile__Framework__Proto__OpProto__Var *message,
typedef void (*PaddleMobile__Framework__Proto__OpDesc__Attr_Closure)(
const PaddleMobile__Framework__Proto__OpDesc__Attr *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__OpProto__Attr_Closure)
(const PaddleMobile__Framework__Proto__OpProto__Attr *message,
typedef void (*PaddleMobile__Framework__Proto__OpDesc__Var_Closure)(
const PaddleMobile__Framework__Proto__OpDesc__Var *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__OpProto_Closure)
(const PaddleMobile__Framework__Proto__OpProto *message,
typedef void (*PaddleMobile__Framework__Proto__OpDesc_Closure)(
const PaddleMobile__Framework__Proto__OpDesc *message, void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__OpProto__Var_Closure)(
const PaddleMobile__Framework__Proto__OpProto__Var *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarType__TensorDesc_Closure)
(const PaddleMobile__Framework__Proto__VarType__TensorDesc *message,
typedef void (*PaddleMobile__Framework__Proto__OpProto__Attr_Closure)(
const PaddleMobile__Framework__Proto__OpProto__Attr *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarType__LoDTensorDesc_Closure)
(const PaddleMobile__Framework__Proto__VarType__LoDTensorDesc *message,
typedef void (*PaddleMobile__Framework__Proto__OpProto_Closure)(
const PaddleMobile__Framework__Proto__OpProto *message, void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarType__TensorDesc_Closure)(
const PaddleMobile__Framework__Proto__VarType__TensorDesc *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc_Closure)
(const PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc *message,
typedef void (*PaddleMobile__Framework__Proto__VarType__LoDTensorDesc_Closure)(
const PaddleMobile__Framework__Proto__VarType__LoDTensorDesc *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarType__ReaderDesc_Closure)
(const PaddleMobile__Framework__Proto__VarType__ReaderDesc *message,
typedef void (
*PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc_Closure)(
const PaddleMobile__Framework__Proto__VarType__LoDTensorArrayDesc *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarType__ChannelDesc_Closure)
(const PaddleMobile__Framework__Proto__VarType__ChannelDesc *message,
typedef void (*PaddleMobile__Framework__Proto__VarType__ReaderDesc_Closure)(
const PaddleMobile__Framework__Proto__VarType__ReaderDesc *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarType__Tuple_Closure)
(const PaddleMobile__Framework__Proto__VarType__Tuple *message,
typedef void (*PaddleMobile__Framework__Proto__VarType__ChannelDesc_Closure)(
const PaddleMobile__Framework__Proto__VarType__ChannelDesc *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarType_Closure)
(const PaddleMobile__Framework__Proto__VarType *message,
typedef void (*PaddleMobile__Framework__Proto__VarType__Tuple_Closure)(
const PaddleMobile__Framework__Proto__VarType__Tuple *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarDesc_Closure)
(const PaddleMobile__Framework__Proto__VarDesc *message,
typedef void (*PaddleMobile__Framework__Proto__VarType_Closure)(
const PaddleMobile__Framework__Proto__VarType *message, void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__VarDesc_Closure)(
const PaddleMobile__Framework__Proto__VarDesc *message, void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__BlockDesc_Closure)(
const PaddleMobile__Framework__Proto__BlockDesc *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__BlockDesc_Closure)
(const PaddleMobile__Framework__Proto__BlockDesc *message,
void *closure_data);
typedef void (*PaddleMobile__Framework__Proto__ProgramDesc_Closure)
(const PaddleMobile__Framework__Proto__ProgramDesc *message,
typedef void (*PaddleMobile__Framework__Proto__ProgramDesc_Closure)(
const PaddleMobile__Framework__Proto__ProgramDesc *message,
void *closure_data);
/* --- services --- */
/* --- descriptors --- */
extern const ProtobufCEnumDescriptor paddle_mobile__framework__proto__attr_type__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__attr__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_desc__var__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__var__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__op_proto__attr__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__tensor_desc__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__reader_desc__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__channel_desc__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_type__tuple__descriptor;
extern const ProtobufCEnumDescriptor paddle_mobile__framework__proto__var_type__type__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__var_desc__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__block_desc__descriptor;
extern const ProtobufCMessageDescriptor paddle_mobile__framework__proto__program_desc__descriptor;
extern const ProtobufCEnumDescriptor
paddle_mobile__framework__proto__attr_type__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__attr__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_desc__var__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__var__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__op_proto__attr__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__tensor_desc__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_desc__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__lo_dtensor_array_desc__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__reader_desc__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__channel_desc__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_type__tuple__descriptor;
extern const ProtobufCEnumDescriptor
paddle_mobile__framework__proto__var_type__type__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__var_desc__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__block_desc__descriptor;
extern const ProtobufCMessageDescriptor
paddle_mobile__framework__proto__program_desc__descriptor;
PROTOBUF_C__END_DECLS
#endif /* PROTOBUF_C_framework_2eproto__INCLUDED */
......@@ -33,17 +33,18 @@ std::vector<std::shared_ptr<OpDesc>> BlockDesc::Ops() const {
return res;
}
BlockDesc::BlockDesc(PaddleMobile__Framework__Proto__BlockDesc *desc): index_(desc->idx), parent_index_(desc->idx) {
BlockDesc::BlockDesc(PaddleMobile__Framework__Proto__BlockDesc *desc)
: index_(desc->idx), parent_index_(desc->idx) {
for (int i = 0; i < desc->n_vars; ++i) {
PaddleMobile__Framework__Proto__VarDesc *var_desc = desc->vars[i];
vars_[std::string(var_desc->name)] = std::shared_ptr<VarDesc>(new VarDesc(var_desc));
vars_[std::string(var_desc->name)] =
std::shared_ptr<VarDesc>(new VarDesc(var_desc));
}
for (int j = 0; j < desc->n_ops; ++j) {
PaddleMobile__Framework__Proto__OpDesc *op_desc = desc->ops[j];
ops_.emplace_back(new framework::OpDesc(op_desc));
}
}
} // namespace framework
......
......@@ -15,9 +15,9 @@ limitations under the License. */
#pragma once
#include "framework/framework.pb-c.h"
#include "framework/paddle_mobile_object.h"
#include "framework/program/op_desc.h"
#include "framework/program/var_desc.h"
#include "framework/paddle_mobile_object.h"
namespace paddle_mobile {
namespace framework {
......
......@@ -15,8 +15,8 @@ limitations under the License. */
#include <string>
#include <vector>
#include "program_desc.h"
#include "framework/program/tensor_desc.h"
#include "program_desc.h"
namespace paddle_mobile {
namespace framework {
......@@ -70,7 +70,6 @@ void ProgramDesc::Description(std::string header) {
}
}
}
}
#endif
}
......
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
//
// Created by liuRuiLong on 2018/5/26.
//
......
......@@ -21,7 +21,7 @@ limitations under the License. */
namespace paddle_mobile {
namespace framework {
enum VarType_Type{
enum VarType_Type {
VARTYPE_TYPE_BOOL = 0,
VARTYPE_TYPE_INT16 = 1,
VARTYPE_TYPE_INT32 = 2,
......@@ -59,17 +59,13 @@ class TensorDesc {
data_type_ = (VarType_Type)desc->data_type;
}
std::vector<int64_t> Dims() const {
return dims_;
};
VarType_Type DataType() const {
return data_type_;
}
std::vector<int64_t> Dims() const { return dims_; };
VarType_Type DataType() const { return data_type_; }
private:
std::vector<int64_t> dims_;
VarType_Type data_type_;
};
}
}
} // namespace framework
} // namespace paddle_mobile
......@@ -16,8 +16,5 @@ limitations under the License. */
namespace paddle_mobile {
namespace framework {
} // namespace framework
namespace framework {} // namespace framework
} // namespace paddle_mobile
......@@ -15,8 +15,8 @@ limitations under the License. */
#pragma once
#include "framework/framework.pb-c.h"
#include "framework/program/tensor_desc.h"
#include "framework/paddle_mobile_object.h"
#include "framework/program/tensor_desc.h"
namespace paddle_mobile {
namespace framework {
......@@ -48,7 +48,6 @@ PADDLE_MOBILE__FRAMEWORK__PROTO__VAR_TYPE__TYPE__BOOL = 0,
*/
class VarDesc {
public:
VarDesc(const VarDesc &var_desc) {
......@@ -65,7 +64,6 @@ class VarDesc {
VarType_Type type_;
VarType_Type data_type_;
* */
}
VarDesc(PaddleMobile__Framework__Proto__VarDesc *desc) {
type_ = (VarType_Type)desc->type->type;
......@@ -94,9 +92,7 @@ class VarDesc {
default:
data_type_ = tensor_desc_.DataType();
break;
}
}
std::string Name() const { return name_; }
......@@ -104,42 +100,40 @@ class VarDesc {
bool Persistable() const { return persistable_; }
const TensorDesc &Tensor_desc() const {
return tensor_desc_;
}
const TensorDesc &Tensor_desc() const { return tensor_desc_; }
// const proto::VarType::ChannelDesc &channel_desc() const {
// switch (desc_.type().type()) {
// case proto::VarType::CHANNEL:
// return desc_.type().channel();
// default:
// break;
// }
// }
// proto::VarType::Type GetDataType() const {
// switch (desc_.type().type()) {
// case proto::VarType::CHANNEL:
// return channel_desc().data_type();
// break;
// default:
// return tensor_desc().data_type();
// }
// }
// template <typename T>
// std::vector<T> RepeatedToVector(
// const google::protobuf::RepeatedField<T> &repeated_field) const {
// std::vector<T> ret;
// ret.reserve(repeated_field.size());
// std::copy(repeated_field.begin(), repeated_field.end(),
// std::back_inserter(ret));
// return ret;
// }
// std::vector<int64_t> GetShape() const {
// return this->RepeatedToVector(tensor_desc().dims());
// }
// switch (desc_.type().type()) {
// case proto::VarType::CHANNEL:
// return desc_.type().channel();
// default:
// break;
// }
// }
// proto::VarType::Type GetDataType() const {
// switch (desc_.type().type()) {
// case proto::VarType::CHANNEL:
// return channel_desc().data_type();
// break;
// default:
// return tensor_desc().data_type();
// }
// }
// template <typename T>
// std::vector<T> RepeatedToVector(
// const google::protobuf::RepeatedField<T> &repeated_field) const {
// std::vector<T> ret;
// ret.reserve(repeated_field.size());
// std::copy(repeated_field.begin(), repeated_field.end(),
// std::back_inserter(ret));
// return ret;
// }
// std::vector<int64_t> GetShape() const {
// return this->RepeatedToVector(tensor_desc().dims());
// }
private:
std::string name_;
......@@ -147,7 +141,6 @@ class VarDesc {
TensorDesc tensor_desc_;
VarType_Type type_;
VarType_Type data_type_;
};
} // namespace framework
......
......@@ -16,15 +16,15 @@ limitations under the License. */
#include <fstream>
#include <vector>
#include "common/log.h"
#include "common/enforce.h"
#include "framework/scope.h"
#include "framework/tensor.h"
#include "framework/operator.h"
#include "framework/lod_tensor.h"
#include "common/log.h"
#include "framework/framework.pb-c.h"
#include "framework/program/var_desc.h"
#include "framework/lod_tensor.h"
#include "framework/operator.h"
#include "framework/program/program_desc.h"
#include "framework/program/var_desc.h"
#include "framework/scope.h"
#include "framework/tensor.h"
namespace paddle_mobile {
......@@ -40,7 +40,7 @@ void ReadBinaryFile(const std::string &filename, std::string *contents) {
fin.close();
}
static size_t ReadBuffer (const char *file_name, uint8_t **out) {
static size_t ReadBuffer(const char *file_name, uint8_t **out) {
printf("%s \n", file_name);
FILE *fp;
fp = fopen(file_name, "rb");
......@@ -56,7 +56,7 @@ static size_t ReadBuffer (const char *file_name, uint8_t **out) {
size_t cur_len = 0;
size_t nread;
while ((nread=fread(*out + cur_len, 1, size - cur_len, fp)) != 0) {
while ((nread = fread(*out + cur_len, 1, size - cur_len, fp)) != 0) {
cur_len += nread;
}
fclose(fp);
......@@ -64,7 +64,8 @@ static size_t ReadBuffer (const char *file_name, uint8_t **out) {
}
template <typename Dtype, Precision P>
void Loader<Dtype, P>::LoadVar(framework::Variable *variable, const framework::VarDesc &var_desc,
void Loader<Dtype, P>::LoadVar(framework::Variable *variable,
const framework::VarDesc &var_desc,
const std::string &file_path) {
auto tensor = variable->GetMutable<framework::LoDTensor>();
std::ifstream is(file_path);
......@@ -109,22 +110,22 @@ void Loader<Dtype, P>::LoadVar(framework::Variable *variable, const framework::V
const framework::TensorDesc &desc = var_desc.Tensor_desc();
PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor_desc = NULL;
// void *v;
// PaddleMobile__Framework__Proto__VarType__TensorDesc_Closure()(tensor_desc, buf.get());
// DLOG << "PaddleMobile__Framework__Proto__VarType__TensorDesc_Closure- " << tensor_desc;
// void *v;
// PaddleMobile__Framework__Proto__VarType__TensorDesc_Closure()(tensor_desc,
// buf.get());
// DLOG << "PaddleMobile__Framework__Proto__VarType__TensorDesc_Closure- " <<
// tensor_desc;
// framework::TensorDesc &tensor_desc = variable->
// PaddleMobile__Framework__Proto__ProgramDesc *c_program;
// uint8_t *proto_buf = NULL;
// size_t read_size = ReadBuffer(file_path.c_str(), &proto_buf);
// c_program = paddle_mobile__framework__proto__program_desc__unpack(NULL, read_size, buf);
// paddle_mobile__framework__proto__var_type__tensor_desc__init()
// framework::TensorDesc &tensor_desc = variable->
// PaddleMobile__Framework__Proto__ProgramDesc *c_program;
// uint8_t *proto_buf = NULL;
// size_t read_size = ReadBuffer(file_path.c_str(), &proto_buf);
// c_program = paddle_mobile__framework__proto__program_desc__unpack(NULL,
// read_size, buf);
// paddle_mobile__framework__proto__var_type__tensor_desc__init()
int memory_size = 1;
for (auto l : desc.Dims()) {
......@@ -173,7 +174,8 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(
PADDLE_MOBILE_ENFORCE(buf != NULL, "read from __model__ is null");
c_program = paddle_mobile__framework__proto__program_desc__unpack(NULL, read_size, buf);
c_program = paddle_mobile__framework__proto__program_desc__unpack(
NULL, read_size, buf);
PADDLE_MOBILE_ENFORCE(c_program != NULL, "program is null");
......@@ -194,14 +196,14 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(
for (const auto &block : originProgramDesc->Blocks()) {
for (int i = 0; i < block->Vars().size(); ++i) {
std::shared_ptr<framework::VarDesc> var_desc = block->Vars()[i];
// DLOG << "var name-- " << var_desc->Name();
// DLOG << "var name-- " << var_desc->Name();
auto var = scope->Var(var_desc->Name());
if (var_desc->Type() == framework::VARTYPE_TYPE_LOD_TENSOR) {
if (var_desc->Persistable() &&
var_desc->Type() != framework::VARTYPE_TYPE_FEED_MINIBATCH &&
var_desc->Type() != framework::VARTYPE_TYPE_FETCH_LIST) {
// DLOG << "to load var ";
// DLOG << "to load var ";
LoadVar(var, *var_desc, dirname + "/" + var_desc->Name());
}
......@@ -247,7 +249,8 @@ Executor<Dtype, P>::Executor(const framework::Program<Dtype> p) : program_(p) {
}
template <typename Dtype, Precision P>
void Executor<Dtype, P>::LoadMemory(const framework::VarDesc var_desc, framework::LoDTensor *tensor,
void Executor<Dtype, P>::LoadMemory(const framework::VarDesc var_desc,
framework::LoDTensor *tensor,
const std::string &file_path) {
std::ifstream is(file_path);
PADDLE_MOBILE_ENFORCE(is.is_open(), "open file: %s failed",
......@@ -290,7 +293,6 @@ void Executor<Dtype, P>::LoadMemory(const framework::VarDesc var_desc, framework
const framework::TensorDesc &desc = var_desc.Tensor_desc();
int memory_size = 1;
for (auto l : desc.Dims()) {
memory_size *= l;
......@@ -335,7 +337,8 @@ void Executor<Dtype, P>::InitMemory() {
auto var = program_.scope->Var(var_desc->Name());
if (var_desc->Persistable()) {
auto tensor = var->template GetMutable<framework::LoDTensor>();
LoadMemory(*var_desc, tensor, program_.model_path + "/" + var_desc->Name());
LoadMemory(*var_desc, tensor,
program_.model_path + "/" + var_desc->Name());
} else {
if (var_desc->Type() == framework::VARTYPE_TYPE_LOD_TENSOR) {
auto tensor = var->template GetMutable<framework::Tensor>();
......
......@@ -33,7 +33,9 @@ class Loader : PaddleMobileObject {
const framework::Program<Dtype, P> Load(const std::string &dirname);
private:
void LoadVar(framework::Variable *variable, const framework::VarDesc &var_desc, const std::string &file_path);
void LoadVar(framework::Variable *variable,
const framework::VarDesc &var_desc,
const std::string &file_path);
};
template <typename Dtype, Precision P = Precision::FP32>
......@@ -52,7 +54,8 @@ class Executor {
protected:
void InitMemory();
void LoadMemory(const framework::VarDesc var_desc, framework::LoDTensor *tensor, const std::string &file_path);
void LoadMemory(const framework::VarDesc var_desc,
framework::LoDTensor *tensor, const std::string &file_path);
framework::Program<Dtype> program_;
std::shared_ptr<framework::ProgramDesc> to_predict_program_;
void predict(const framework::Tensor &t, int block_id);
......
......@@ -116,8 +116,7 @@ inline std::string DataTypeToString(const VarType_Type type) {
}
}
inline std::ostream &operator<<(std::ostream &out,
const VarType_Type &type) {
inline std::ostream &operator<<(std::ostream &out, const VarType_Type &type) {
out << DataTypeToString(type);
return out;
}
......
......@@ -58,7 +58,6 @@ class Executor4Test : public Executor<DeviceType> {
for (std::shared_ptr<BlockDesc> block_desc : blocks) {
std::vector<std::shared_ptr<OpDesc>> ops = block_desc->Ops();
for (std::shared_ptr<OpDesc> op : ops) {
if (op->Type() == op_type) {
/// test first meeting op in program
std::shared_ptr<paddle_mobile::framework::OperatorBase<DeviceType>>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册