diff --git a/README.md b/README.md index b90f660e..990e8606 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,15 @@ In other cases you can contact the developer via email: RAW Bayer
RGB565 | 1/6.5" | | GC2145 | 1600 x 1200 | color | YUV/YCbCr422
RAW Bayer
RGB565 | 1/5" | | BF3005 | 640 x 480 | color | YUV/YCbCr422
RAW Bayer
RGB565 | 1/4" | +| BF20A6 | 640 x 480 | color | YUV/YCbCr422
RAW Bayer | 1/10" | +| SC101IOT| 1280 x 720 | color | YUV/YCbCr422
Raw RGB | 1/4.2" | +| SC030IOT| 640 x 480 | color | YUV/YCbCr422
RAW Bayer | 1/6.5" | ## Important to Remember @@ -128,8 +131,8 @@ static camera_config_t camera_config = { .pin_pwdn = CAM_PIN_PWDN, .pin_reset = CAM_PIN_RESET, .pin_xclk = CAM_PIN_XCLK, - .pin_sscb_sda = CAM_PIN_SIOD, - .pin_sscb_scl = CAM_PIN_SIOC, + .pin_sccb_sda = CAM_PIN_SIOD, + .pin_sccb_scl = CAM_PIN_SIOC, .pin_d7 = CAM_PIN_D7, .pin_d6 = CAM_PIN_D6, diff --git a/code/components/esp32-camera-master/conversions/esp_jpg_decode.c b/code/components/esp32-camera-master/conversions/esp_jpg_decode.c index a9615e36..52833a73 100644 --- a/code/components/esp32-camera-master/conversions/esp_jpg_decode.c +++ b/code/components/esp32-camera-master/conversions/esp_jpg_decode.c @@ -21,6 +21,10 @@ #include "tjpgd.h" #elif CONFIG_IDF_TARGET_ESP32S3 #include "esp32s3/rom/tjpgd.h" +#elif CONFIG_IDF_TARGET_ESP32C3 +#include "esp32c3/rom/tjpgd.h" +#elif CONFIG_IDF_TARGET_ESP32H2 +#include "esp32h2/rom/tjpgd.h" #else #error Target CONFIG_IDF_TARGET is not supported #endif @@ -57,7 +61,7 @@ static const char * jd_errors[] = { "Not supported JPEG standard" }; -static uint32_t _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) +static unsigned int _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) { uint16_t x = rect->left; uint16_t y = rect->top; @@ -73,7 +77,7 @@ static uint32_t _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) return 0; } -static uint32_t _jpg_read(JDEC *decoder, uint8_t *buf, uint32_t len) +static unsigned int _jpg_read(JDEC *decoder, uint8_t *buf, unsigned int len) { esp_jpg_decoder_t * jpeg = (esp_jpg_decoder_t *)decoder->device; if (jpeg->len && len > (jpeg->len - jpeg->index)) { diff --git a/code/components/esp32-camera-master/conversions/jpge.cpp b/code/components/esp32-camera-master/conversions/jpge.cpp index a8ab93e0..dd6790e6 100644 --- a/code/components/esp32-camera-master/conversions/jpge.cpp +++ b/code/components/esp32-camera-master/conversions/jpge.cpp @@ -29,7 +29,12 @@ namespace jpge { if(b){ return b; } + // check if SPIRAM is enabled and allocate on SPIRAM if allocatable +#if (CONFIG_SPIRAM_SUPPORT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC)) return heap_caps_malloc(nSize, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); +#else + return NULL; +#endif } static inline void jpge_free(void *p) { free(p); } diff --git a/code/components/esp32-camera-master/conversions/to_bmp.c b/code/components/esp32-camera-master/conversions/to_bmp.c index 5a54bdba..27072f71 100644 --- a/code/components/esp32-camera-master/conversions/to_bmp.c +++ b/code/components/esp32-camera-master/conversions/to_bmp.c @@ -21,19 +21,6 @@ #include "esp_jpg_decode.h" #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ -#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 -#include "esp32/spiram.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/spiram.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/spiram.h" -#else -#error Target CONFIG_IDF_TARGET is not supported -#endif -#else // ESP32 Before IDF 4.0 -#include "esp_spiram.h" -#endif #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) #include "esp32-hal-log.h" @@ -72,7 +59,12 @@ typedef struct { static void *_malloc(size_t size) { + // check if SPIRAM is enabled and allocate on SPIRAM if allocatable +#if (CONFIG_SPIRAM_SUPPORT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC)) return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); +#endif + // try allocating in internal memory + return malloc(size); } //output buffer and image width @@ -168,7 +160,7 @@ static bool _rgb565_write(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16 } //input buffer -static uint32_t _jpg_read(void * arg, size_t index, uint8_t *buf, size_t len) +static unsigned int _jpg_read(void * arg, size_t index, uint8_t *buf, size_t len) { rgb_jpg_decoder * jpeg = (rgb_jpg_decoder *)arg; if(buf) { @@ -310,7 +302,13 @@ bool fmt2bmp(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixf *out_len = 0; int pix_count = width*height; - size_t out_size = (pix_count * 3) + BMP_HEADER_LEN; + + // With BMP, 8-bit greyscale requires a palette. + // For a 640x480 image though, that's a savings + // over going RGB-24. + int bpp = (format == PIXFORMAT_GRAYSCALE) ? 1 : 3; + int palette_size = (format == PIXFORMAT_GRAYSCALE) ? 4 * 256 : 0; + size_t out_size = (pix_count * bpp) + BMP_HEADER_LEN + palette_size; uint8_t * out_buf = (uint8_t *)_malloc(out_size); if(!out_buf) { ESP_LOGE(TAG, "_malloc failed! %u", out_size); @@ -322,45 +320,51 @@ bool fmt2bmp(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixf bmp_header_t * bitmap = (bmp_header_t*)&out_buf[2]; bitmap->reserved = 0; bitmap->filesize = out_size; - bitmap->fileoffset_to_pixelarray = BMP_HEADER_LEN; + bitmap->fileoffset_to_pixelarray = BMP_HEADER_LEN + palette_size; bitmap->dibheadersize = 40; bitmap->width = width; bitmap->height = -height;//set negative for top to bottom bitmap->planes = 1; - bitmap->bitsperpixel = 24; + bitmap->bitsperpixel = bpp * 8; bitmap->compression = 0; - bitmap->imagesize = pix_count * 3; + bitmap->imagesize = pix_count * bpp; bitmap->ypixelpermeter = 0x0B13 ; //2835 , 72 DPI bitmap->xpixelpermeter = 0x0B13 ; //2835 , 72 DPI bitmap->numcolorspallette = 0; bitmap->mostimpcolor = 0; - uint8_t * rgb_buf = out_buf + BMP_HEADER_LEN; + uint8_t * palette_buf = out_buf + BMP_HEADER_LEN; + uint8_t * pix_buf = palette_buf + palette_size; uint8_t * src_buf = src; + if (palette_size > 0) { + // Grayscale palette + for (int i = 0; i < 256; ++i) { + for (int j = 0; j < 3; ++j) { + *palette_buf = i; + palette_buf++; + } + // Reserved / alpha channel. + *palette_buf = 0; + palette_buf++; + } + } //convert data to RGB888 if(format == PIXFORMAT_RGB888) { - memcpy(rgb_buf, src_buf, pix_count*3); + memcpy(pix_buf, src_buf, pix_count*3); } else if(format == PIXFORMAT_RGB565) { int i; uint8_t hb, lb; for(i=0; i> 3; - *rgb_buf++ = hb & 0xF8; + *pix_buf++ = (lb & 0x1F) << 3; + *pix_buf++ = (hb & 0x07) << 5 | (lb & 0xE0) >> 3; + *pix_buf++ = hb & 0xF8; } } else if(format == PIXFORMAT_GRAYSCALE) { - int i; - uint8_t b; - for(i=0; i= 4 // IDF 4+ -#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 -#include "esp32/spiram.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/spiram.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/spiram.h" -#else -#error Target CONFIG_IDF_TARGET is not supported -#endif -#else // ESP32 Before IDF 4.0 -#include "esp_spiram.h" -#endif - #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) #include "esp32-hal-log.h" #define TAG "" @@ -50,7 +35,12 @@ static void *_malloc(size_t size) if(res) { return res; } + + // check if SPIRAM is enabled and is allocatable +#if (CONFIG_SPIRAM_SUPPORT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC)) return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); +#endif + return NULL; } static IRAM_ATTR void convert_line_format(uint8_t * src, pixformat_t format, uint8_t * dst, size_t width, size_t in_channels, size_t line) diff --git a/code/components/esp32-camera-master/driver/cam_hal.c b/code/components/esp32-camera-master/driver/cam_hal.c index 9b7e12b5..27f66b68 100644 --- a/code/components/esp32-camera-master/driver/cam_hal.c +++ b/code/components/esp32-camera-master/driver/cam_hal.c @@ -18,8 +18,27 @@ #include "ll_cam.h" #include "cam_hal.h" -static const char *TAG = "cam_hal"; +#if (ESP_IDF_VERSION_MAJOR == 3) && (ESP_IDF_VERSION_MINOR == 3) +#include "rom/ets_sys.h" +#else +#include "esp_timer.h" +#if CONFIG_IDF_TARGET_ESP32 +#include "esp32/rom/ets_sys.h" // will be removed in idf v5.0 +#elif CONFIG_IDF_TARGET_ESP32S2 +#include "esp32s2/rom/ets_sys.h" +#elif CONFIG_IDF_TARGET_ESP32S3 +#include "esp32s3/rom/ets_sys.h" +#endif +#endif // ESP_IDF_VERSION_MAJOR +#define ESP_CAMERA_ETS_PRINTF ets_printf +#if CONFIG_CAM_TASK_STACK_SIZE +#define CAM_TASK_STACK CONFIG_CAM_TASK_STACK_SIZE +#else +#define CAM_TASK_STACK (2*1024) +#endif + +static const char *TAG = "cam_hal"; static cam_obj_t *cam_obj = NULL; static const uint32_t JPEG_SOI_MARKER = 0xFFD8FF; // written in little-endian for esp32 @@ -32,7 +51,7 @@ static int cam_verify_jpeg_soi(const uint8_t *inbuf, uint32_t length) for (uint32_t i = 0; i < length; i++) { sig = *((uint32_t *)(&inbuf[i])) & 0xFFFFFF; if (sig == JPEG_SOI_MARKER) { - ESP_LOGW(TAG, "SOI: %d", i); + ESP_LOGW(TAG, "SOI: %d", (int) i); return i; } } @@ -93,7 +112,7 @@ void IRAM_ATTR ll_cam_send_event(cam_obj_t *cam, cam_event_t cam_event, BaseType if (xQueueSendFromISR(cam->event_queue, (void *)&cam_event, HPTaskAwoken) != pdTRUE) { ll_cam_stop(cam); cam->state = CAM_STATE_IDLE; - ESP_EARLY_LOGE(TAG, "EV-%s-OVF", cam_event==CAM_IN_SUC_EOF_EVENT ? "EOF" : "VSYNC"); + ESP_CAMERA_ETS_PRINTF(DRAM_STR("cam_hal: EV-%s-OVF\r\n"), cam_event==CAM_IN_SUC_EOF_EVENT ? DRAM_STR("EOF") : DRAM_STR("VSYNC")); } } @@ -104,7 +123,7 @@ static void cam_task(void *arg) int frame_pos = 0; cam_obj->state = CAM_STATE_IDLE; cam_event_t cam_event = 0; - + xQueueReset(cam_obj->event_queue); while (1) { @@ -127,7 +146,7 @@ static void cam_task(void *arg) case CAM_STATE_READ_BUF: { camera_fb_t * frame_buffer_event = &cam_obj->frames[frame_pos].fb; size_t pixels_per_dma = (cam_obj->dma_half_buffer_size * cam_obj->fb_bytes_per_pixel) / (cam_obj->dma_bytes_per_item * cam_obj->in_bytes_per_pixel); - + if (cam_event == CAM_IN_SUC_EOF_EVENT) { if(!cam_obj->psram_mode){ if (cam_obj->fb_size < (frame_buffer_event->len + pixels_per_dma)) { @@ -137,8 +156,8 @@ static void cam_task(void *arg) continue; } frame_buffer_event->len += ll_cam_memcpy(cam_obj, - &frame_buffer_event->buf[frame_buffer_event->len], - &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size], + &frame_buffer_event->buf[frame_buffer_event->len], + &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size], cam_obj->dma_half_buffer_size); } //Check for JPEG SOI in the first buffer. stop if not found @@ -160,8 +179,8 @@ static void cam_task(void *arg) cnt--; } else { frame_buffer_event->len += ll_cam_memcpy(cam_obj, - &frame_buffer_event->buf[frame_buffer_event->len], - &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size], + &frame_buffer_event->buf[frame_buffer_event->len], + &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size], cam_obj->dma_half_buffer_size); } } @@ -179,7 +198,7 @@ static void cam_task(void *arg) } else if (!cam_obj->jpeg_mode) { if (frame_buffer_event->len != cam_obj->fb_size) { cam_obj->frames[frame_pos].en = 1; - ESP_LOGE(TAG, "FB-SIZE: %u != %u", frame_buffer_event->len, cam_obj->fb_size); + ESP_LOGE(TAG, "FB-SIZE: %u != %u", frame_buffer_event->len, (unsigned) cam_obj->fb_size); } } //send frame @@ -245,8 +264,9 @@ static esp_err_t cam_dma_config(const camera_config_t *config) cam_obj->dma_node_cnt = (cam_obj->dma_buffer_size) / cam_obj->dma_node_buffer_size; // Number of DMA nodes cam_obj->frame_copy_cnt = cam_obj->recv_size / cam_obj->dma_half_buffer_size; // Number of interrupted copies, ping-pong copy - ESP_LOGI(TAG, "buffer_size: %d, half_buffer_size: %d, node_buffer_size: %d, node_cnt: %d, total_cnt: %d", - cam_obj->dma_buffer_size, cam_obj->dma_half_buffer_size, cam_obj->dma_node_buffer_size, cam_obj->dma_node_cnt, cam_obj->frame_copy_cnt); + ESP_LOGI(TAG, "buffer_size: %d, half_buffer_size: %d, node_buffer_size: %d, node_cnt: %d, total_cnt: %d", + (int) cam_obj->dma_buffer_size, (int) cam_obj->dma_half_buffer_size, (int) cam_obj->dma_node_buffer_size, + (int) cam_obj->dma_node_cnt, (int) cam_obj->frame_copy_cnt); cam_obj->dma_buffer = NULL; cam_obj->dma = NULL; @@ -276,13 +296,19 @@ static esp_err_t cam_dma_config(const camera_config_t *config) cam_obj->frames[x].fb_offset = 0; cam_obj->frames[x].en = 0; ESP_LOGI(TAG, "Allocating %d Byte frame buffer in %s", alloc_size, _caps & MALLOC_CAP_SPIRAM ? "PSRAM" : "OnBoard RAM"); +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) + // In IDF v4.2 and earlier, memory returned by heap_caps_aligned_alloc must be freed using heap_caps_aligned_free. + // And heap_caps_aligned_free is deprecated on v4.3. + cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_aligned_alloc(16, alloc_size, _caps); +#else cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_malloc(alloc_size, _caps); +#endif CAM_CHECK(cam_obj->frames[x].fb.buf != NULL, "frame buffer malloc failed", ESP_FAIL); if (cam_obj->psram_mode) { //align PSRAM buffer. TODO: save the offset so proper address can be freed later cam_obj->frames[x].fb_offset = dma_align - ((uint32_t)cam_obj->frames[x].fb.buf & (dma_align - 1)); cam_obj->frames[x].fb.buf += cam_obj->frames[x].fb_offset; - ESP_LOGI(TAG, "Frame[%d]: Offset: %u, Addr: 0x%08X", x, cam_obj->frames[x].fb_offset, (uint32_t)cam_obj->frames[x].fb.buf); + ESP_LOGI(TAG, "Frame[%d]: Offset: %u, Addr: 0x%08X", x, cam_obj->frames[x].fb_offset, (unsigned) cam_obj->frames[x].fb.buf); cam_obj->frames[x].dma = allocate_dma_descriptors(cam_obj->dma_node_cnt, cam_obj->dma_node_buffer_size, cam_obj->frames[x].fb.buf); CAM_CHECK(cam_obj->frames[x].dma != NULL, "frame dma malloc failed", ESP_FAIL); } @@ -292,8 +318,8 @@ static esp_err_t cam_dma_config(const camera_config_t *config) if (!cam_obj->psram_mode) { cam_obj->dma_buffer = (uint8_t *)heap_caps_malloc(cam_obj->dma_buffer_size * sizeof(uint8_t), MALLOC_CAP_DMA); if(NULL == cam_obj->dma_buffer) { - ESP_LOGE(TAG,"%s(%d): DMA buffer %d Byte malloc failed, the current largest free block:%d Byte", __FUNCTION__, __LINE__, - cam_obj->dma_buffer_size, heap_caps_get_largest_free_block(MALLOC_CAP_DMA)); + ESP_LOGE(TAG,"%s(%d): DMA buffer %d Byte malloc failed, the current largest free block:%d Byte", __FUNCTION__, __LINE__, + (int) cam_obj->dma_buffer_size, (int) heap_caps_get_largest_free_block(MALLOC_CAP_DMA)); return ESP_FAIL; } @@ -359,7 +385,7 @@ esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint cam_obj->recv_size = cam_obj->width * cam_obj->height * cam_obj->in_bytes_per_pixel; cam_obj->fb_size = cam_obj->width * cam_obj->height * cam_obj->fb_bytes_per_pixel; } - + ret = cam_dma_config(config); CAM_CHECK_GOTO(ret == ESP_OK, "cam_dma_config failed", err); @@ -376,13 +402,13 @@ esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint ret = ll_cam_init_isr(cam_obj); CAM_CHECK_GOTO(ret == ESP_OK, "cam intr alloc failed", err); - + #if CONFIG_CAMERA_CORE0 - xTaskCreatePinnedToCore(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 0); + xTaskCreatePinnedToCore(cam_task, "cam_task", CAM_TASK_STACK, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 0); #elif CONFIG_CAMERA_CORE1 - xTaskCreatePinnedToCore(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 1); + xTaskCreatePinnedToCore(cam_task, "cam_task", CAM_TASK_STACK, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 1); #else - xTaskCreate(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle); + xTaskCreate(cam_task, "cam_task", CAM_TASK_STACK, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle); #endif ESP_LOGI(TAG, "cam config ok"); diff --git a/code/components/esp32-camera-master/driver/esp_camera.c b/code/components/esp32-camera-master/driver/esp_camera.c index 5b671c0e..5d6c97d0 100644 --- a/code/components/esp32-camera-master/driver/esp_camera.c +++ b/code/components/esp32-camera-master/driver/esp_camera.c @@ -57,6 +57,15 @@ #if CONFIG_BF3005_SUPPORT #include "bf3005.h" #endif +#if CONFIG_BF20A6_SUPPORT +#include "bf20a6.h" +#endif +#if CONFIG_SC101IOT_SUPPORT +#include "sc101iot.h" +#endif +#if CONFIG_SC030IOT_SUPPORT +#include "sc030iot.h" +#endif #if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) #include "esp32-hal-log.h" @@ -119,10 +128,20 @@ static const sensor_func_t g_sensors[] = { #if CONFIG_BF3005_SUPPORT {bf3005_detect, bf3005_init}, #endif +#if CONFIG_BF20A6_SUPPORT + {bf20a6_detect, bf20a6_init}, +#endif +#if CONFIG_SC101IOT_SUPPORT + {sc101iot_detect, sc101iot_init}, +#endif +#if CONFIG_SC030IOT_SUPPORT + {sc030iot_detect, sc030iot_init}, +#endif }; static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out_camera_model) { + esp_err_t ret = ESP_OK; *out_camera_model = CAMERA_NONE; if (s_state != NULL) { return ESP_ERR_INVALID_STATE; @@ -138,9 +157,17 @@ static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out CAMERA_ENABLE_OUT_CLOCK(config); } - if (config->pin_sscb_sda != -1) { - ESP_LOGD(TAG, "Initializing SSCB"); - SCCB_Init(config->pin_sscb_sda, config->pin_sscb_scl); + if (config->pin_sccb_sda != -1) { + ESP_LOGD(TAG, "Initializing SCCB"); + ret = SCCB_Init(config->pin_sccb_sda, config->pin_sccb_scl); + } else { + ESP_LOGD(TAG, "Using existing I2C port"); + ret = SCCB_Use_Port(config->sccb_i2c_port); + } + + if(ret != ESP_OK) { + ESP_LOGE(TAG, "sccb init err"); + goto err; } if (config->pin_pwdn >= 0) { @@ -170,15 +197,14 @@ static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out vTaskDelay(10 / portTICK_PERIOD_MS); } - ESP_LOGD(TAG, "Searching for camera address"); vTaskDelay(10 / portTICK_PERIOD_MS); uint8_t slv_addr = SCCB_Probe(); if (slv_addr == 0) { - CAMERA_DISABLE_OUT_CLOCK(); - return ESP_ERR_NOT_FOUND; + ret = ESP_ERR_NOT_FOUND; + goto err; } ESP_LOGI(TAG, "Detected camera at address=0x%02x", slv_addr); @@ -203,9 +229,9 @@ static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out } if (CAMERA_NONE == *out_camera_model) { //If no supported sensors are detected - CAMERA_DISABLE_OUT_CLOCK(); ESP_LOGE(TAG, "Detected camera not supported."); - return ESP_ERR_NOT_SUPPORTED; + ret = ESP_ERR_NOT_SUPPORTED; + goto err; } ESP_LOGI(TAG, "Camera PID=0x%02x VER=0x%02x MIDL=0x%02x MIDH=0x%02x", @@ -213,11 +239,30 @@ static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out ESP_LOGD(TAG, "Doing SW reset of sensor"); vTaskDelay(10 / portTICK_PERIOD_MS); - s_state->sensor.reset(&s_state->sensor); - - return ESP_OK; + + return s_state->sensor.reset(&s_state->sensor); +err : + CAMERA_DISABLE_OUT_CLOCK(); + return ret; } +#if CONFIG_CAMERA_CONVERTER_ENABLED +static pixformat_t get_output_data_format(camera_conv_mode_t conv_mode) +{ + pixformat_t format = PIXFORMAT_RGB565; + switch (conv_mode) { + case YUV422_TO_YUV420: + format = PIXFORMAT_YUV420; + break; + case YUV422_TO_RGB565: // default format is RGB565 + default: + break; + } + ESP_LOGD(TAG, "Convert to %d format enabled", format); + return format; +} +#endif + esp_err_t esp_camera_init(const camera_config_t *config) { esp_err_t err; @@ -256,6 +301,7 @@ esp_err_t esp_camera_init(const camera_config_t *config) s_state->sensor.status.framesize = frame_size; s_state->sensor.pixformat = pix_format; + ESP_LOGD(TAG, "Setting frame size to %dx%d", resolution[frame_size].width, resolution[frame_size].height); if (s_state->sensor.set_framesize(&s_state->sensor, frame_size) != 0) { ESP_LOGE(TAG, "Failed to set frame size"); @@ -263,6 +309,11 @@ esp_err_t esp_camera_init(const camera_config_t *config) goto fail; } s_state->sensor.set_pixformat(&s_state->sensor, pix_format); +#if CONFIG_CAMERA_CONVERTER_ENABLED + if(config->conv_mode) { + s_state->sensor.pixformat = get_output_data_format(config->conv_mode); // If conversion enabled, change the out data format by conversion mode + } +#endif if (s_state->sensor.id.PID == OV2640_PID) { s_state->sensor.set_gainceiling(&s_state->sensor, GAINCEILING_2X); diff --git a/code/components/esp32-camera-master/driver/include/esp_camera.h b/code/components/esp32-camera-master/driver/include/esp_camera.h index b6047d31..ee84b307 100644 --- a/code/components/esp32-camera-master/driver/include/esp_camera.h +++ b/code/components/esp32-camera-master/driver/include/esp_camera.h @@ -18,8 +18,8 @@ .pin_pwdn = PIN_PWDN, .pin_reset = PIN_RESET, .pin_xclk = PIN_XCLK, - .pin_sscb_sda = PIN_SIOD, - .pin_sscb_scl = PIN_SIOC, + .pin_sccb_sda = PIN_SIOD, + .pin_sccb_scl = PIN_SIOC, .pin_d7 = PIN_D7, .pin_d6 = PIN_D6, .pin_d5 = PIN_D5, @@ -70,6 +70,7 @@ #include "driver/ledc.h" #include "sensor.h" #include "sys/time.h" +#include "sdkconfig.h" #ifdef __cplusplus extern "C" { @@ -91,6 +92,19 @@ typedef enum { CAMERA_FB_IN_DRAM /*!< Frame buffer is placed in internal DRAM */ } camera_fb_location_t; +#if CONFIG_CAMERA_CONVERTER_ENABLED +/** + * @brief Camera RGB\YUV conversion mode + */ +typedef enum { + CONV_DISABLE, + RGB565_TO_YUV422, + + YUV422_TO_RGB565, + YUV422_TO_YUV420 +} camera_conv_mode_t; +#endif + /** * @brief Configuration structure for camera initialization */ @@ -98,8 +112,14 @@ typedef struct { int pin_pwdn; /*!< GPIO pin for camera power down line */ int pin_reset; /*!< GPIO pin for camera reset line */ int pin_xclk; /*!< GPIO pin for camera XCLK line */ - int pin_sscb_sda; /*!< GPIO pin for camera SDA line */ - int pin_sscb_scl; /*!< GPIO pin for camera SCL line */ + union { + int pin_sccb_sda; /*!< GPIO pin for camera SDA line */ + int pin_sscb_sda __attribute__((deprecated("please use pin_sccb_sda instead"))); /*!< GPIO pin for camera SDA line (legacy name) */ + }; + union { + int pin_sccb_scl; /*!< GPIO pin for camera SCL line */ + int pin_sscb_scl __attribute__((deprecated("please use pin_sccb_scl instead"))); /*!< GPIO pin for camera SCL line (legacy name) */ + }; int pin_d7; /*!< GPIO pin for camera D7 line */ int pin_d6; /*!< GPIO pin for camera D6 line */ int pin_d5; /*!< GPIO pin for camera D5 line */ @@ -124,6 +144,11 @@ typedef struct { size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */ camera_fb_location_t fb_location; /*!< The location where the frame buffer will be allocated */ camera_grab_mode_t grab_mode; /*!< When buffers should be filled */ +#if CONFIG_CAMERA_CONVERTER_ENABLED + camera_conv_mode_t conv_mode; /*!< RGB<->YUV Conversion mode */ +#endif + + int sccb_i2c_port; /*!< If pin_sccb_sda is -1, use the already configured I2C bus by number */ } camera_config_t; /** diff --git a/code/components/esp32-camera-master/driver/include/sensor.h b/code/components/esp32-camera-master/driver/include/sensor.h index b2bf55f1..4aa14c90 100644 --- a/code/components/esp32-camera-master/driver/include/sensor.h +++ b/code/components/esp32-camera-master/driver/include/sensor.h @@ -27,6 +27,9 @@ typedef enum { GC032A_PID = 0x232a, GC0308_PID = 0x9b, BF3005_PID = 0x30, + BF20A6_PID = 0x20a6, + SC101IOT_PID = 0xda4a, + SC030IOT_PID = 0x9a46, } camera_pid_t; typedef enum { @@ -40,6 +43,9 @@ typedef enum { CAMERA_GC032A, CAMERA_GC0308, CAMERA_BF3005, + CAMERA_BF20A6, + CAMERA_SC101IOT, + CAMERA_SC030IOT, CAMERA_MODEL_MAX, CAMERA_NONE, } camera_model_t; @@ -55,11 +61,15 @@ typedef enum { GC032A_SCCB_ADDR = 0x21,// 0x42 >> 1 GC0308_SCCB_ADDR = 0x21,// 0x42 >> 1 BF3005_SCCB_ADDR = 0x6E, + BF20A6_SCCB_ADDR = 0x6E, + SC101IOT_SCCB_ADDR = 0x68,// 0xd0 >> 1 + SC030IOT_SCCB_ADDR = 0x68,// 0xd0 >> 1 } camera_sccb_addr_t; typedef enum { PIXFORMAT_RGB565, // 2BPP/RGB565 PIXFORMAT_YUV422, // 2BPP/YUV422 + PIXFORMAT_YUV420, // 1.5BPP/YUV420 PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE PIXFORMAT_JPEG, // JPEG/COMPRESSED PIXFORMAT_RGB888, // 3BPP/RGB888 @@ -199,7 +209,7 @@ typedef struct _sensor { // Sensor function pointers int (*init_status) (sensor_t *sensor); - int (*reset) (sensor_t *sensor); + int (*reset) (sensor_t *sensor); // Reset the configuration of the sensor, and return ESP_OK if reset is successful int (*set_pixformat) (sensor_t *sensor, pixformat_t pixformat); int (*set_framesize) (sensor_t *sensor, framesize_t framesize); int (*set_contrast) (sensor_t *sensor, int level); diff --git a/code/components/esp32-camera-master/driver/private_include/sccb.h b/code/components/esp32-camera-master/driver/private_include/sccb.h index ace081a4..9e445338 100644 --- a/code/components/esp32-camera-master/driver/private_include/sccb.h +++ b/code/components/esp32-camera-master/driver/private_include/sccb.h @@ -10,6 +10,7 @@ #define __SCCB_H__ #include int SCCB_Init(int pin_sda, int pin_scl); +int SCCB_Use_Port(int sccb_i2c_port); int SCCB_Deinit(void); uint8_t SCCB_Probe(); uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg); diff --git a/code/components/esp32-camera-master/driver/sccb.c b/code/components/esp32-camera-master/driver/sccb.c index 314dd982..945bd9bd 100644 --- a/code/components/esp32-camera-master/driver/sccb.c +++ b/code/components/esp32-camera-master/driver/sccb.c @@ -25,6 +25,11 @@ static const char* TAG = "sccb"; #include "driver/i2c.h" +// support IDF 5.x +#ifndef portTICK_RATE_MS +#define portTICK_RATE_MS portTICK_PERIOD_MS +#endif + #define SCCB_FREQ CONFIG_SCCB_CLK_FREQ /*!< I2C master frequency*/ #define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */ #define READ_BIT I2C_MASTER_READ /*!< I2C master read */ @@ -33,16 +38,26 @@ static const char* TAG = "sccb"; #define ACK_VAL 0x0 /*!< I2C ack value */ #define NACK_VAL 0x1 /*!< I2C nack value */ #if CONFIG_SCCB_HARDWARE_I2C_PORT1 -const int SCCB_I2C_PORT = 1; +const int SCCB_I2C_PORT_DEFAULT = 1; #else -const int SCCB_I2C_PORT = 0; +const int SCCB_I2C_PORT_DEFAULT = 0; #endif +static int sccb_i2c_port; +static bool sccb_owns_i2c_port; + int SCCB_Init(int pin_sda, int pin_scl) { ESP_LOGI(TAG, "pin_sda %d pin_scl %d", pin_sda, pin_scl); i2c_config_t conf; + esp_err_t ret; + memset(&conf, 0, sizeof(i2c_config_t)); + + sccb_i2c_port = SCCB_I2C_PORT_DEFAULT; + sccb_owns_i2c_port = true; + ESP_LOGI(TAG, "sccb_i2c_port=%d\n", sccb_i2c_port); + conf.mode = I2C_MODE_MASTER; conf.sda_io_num = pin_sda; conf.sda_pullup_en = GPIO_PULLUP_ENABLE; @@ -50,30 +65,37 @@ int SCCB_Init(int pin_sda, int pin_scl) conf.scl_pullup_en = GPIO_PULLUP_ENABLE; conf.master.clk_speed = SCCB_FREQ; - i2c_param_config(SCCB_I2C_PORT, &conf); - i2c_driver_install(SCCB_I2C_PORT, conf.mode, 0, 0, 0); - return 0; + if ((ret = i2c_param_config(sccb_i2c_port, &conf)) != ESP_OK) { + return ret; + } + + return i2c_driver_install(sccb_i2c_port, conf.mode, 0, 0, 0); +} + +int SCCB_Use_Port(int i2c_num) { // sccb use an already initialized I2C port + if (sccb_owns_i2c_port) { + SCCB_Deinit(); + } + if (i2c_num < 0 || i2c_num > I2C_NUM_MAX) { + return ESP_ERR_INVALID_ARG; + } + sccb_i2c_port = i2c_num; + return ESP_OK; } int SCCB_Deinit(void) { - return i2c_driver_delete(SCCB_I2C_PORT); + if (!sccb_owns_i2c_port) { + return ESP_OK; + } + sccb_owns_i2c_port = false; + return i2c_driver_delete(sccb_i2c_port); } uint8_t SCCB_Probe(void) { uint8_t slave_addr = 0x0; - // for (size_t i = 1; i < 0x80; i++) { - // i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - // i2c_master_start(cmd); - // i2c_master_write_byte(cmd, ( i << 1 ) | WRITE_BIT, ACK_CHECK_EN); - // i2c_master_stop(cmd); - // esp_err_t ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - // i2c_cmd_link_delete(cmd); - // if( ret == ESP_OK) { - // ESP_LOGW(TAG, "Found I2C Device at 0x%02X", i); - // } - // } + for (size_t i = 0; i < CAMERA_MODEL_MAX; i++) { if (slave_addr == camera_sensor[i].sccb_addr) { continue; @@ -83,7 +105,7 @@ uint8_t SCCB_Probe(void) i2c_master_start(cmd); i2c_master_write_byte(cmd, ( slave_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); i2c_master_stop(cmd); - esp_err_t ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + esp_err_t ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); if( ret == ESP_OK) { return slave_addr; @@ -101,7 +123,7 @@ uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg) i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); i2c_master_write_byte(cmd, reg, ACK_CHECK_EN); i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); if(ret != ESP_OK) return -1; cmd = i2c_cmd_link_create(); @@ -109,7 +131,7 @@ uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg) i2c_master_write_byte(cmd, ( slv_addr << 1 ) | READ_BIT, ACK_CHECK_EN); i2c_master_read_byte(cmd, &data, NACK_VAL); i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); if(ret != ESP_OK) { ESP_LOGE(TAG, "SCCB_Read Failed addr:0x%02x, reg:0x%02x, data:0x%02x, ret:%d", slv_addr, reg, data, ret); @@ -126,7 +148,7 @@ uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data) i2c_master_write_byte(cmd, reg, ACK_CHECK_EN); i2c_master_write_byte(cmd, data, ACK_CHECK_EN); i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); if(ret != ESP_OK) { ESP_LOGE(TAG, "SCCB_Write Failed addr:0x%02x, reg:0x%02x, data:0x%02x, ret:%d", slv_addr, reg, data, ret); @@ -146,7 +168,7 @@ uint8_t SCCB_Read16(uint8_t slv_addr, uint16_t reg) i2c_master_write_byte(cmd, reg_u8[0], ACK_CHECK_EN); i2c_master_write_byte(cmd, reg_u8[1], ACK_CHECK_EN); i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); if(ret != ESP_OK) return -1; cmd = i2c_cmd_link_create(); @@ -154,7 +176,7 @@ uint8_t SCCB_Read16(uint8_t slv_addr, uint16_t reg) i2c_master_write_byte(cmd, ( slv_addr << 1 ) | READ_BIT, ACK_CHECK_EN); i2c_master_read_byte(cmd, &data, NACK_VAL); i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); if(ret != ESP_OK) { ESP_LOGE(TAG, "W [%04x]=%02x fail\n", reg, data); @@ -175,7 +197,7 @@ uint8_t SCCB_Write16(uint8_t slv_addr, uint16_t reg, uint8_t data) i2c_master_write_byte(cmd, reg_u8[1], ACK_CHECK_EN); i2c_master_write_byte(cmd, data, ACK_CHECK_EN); i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + ret = i2c_master_cmd_begin(sccb_i2c_port, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); if(ret != ESP_OK) { ESP_LOGE(TAG, "W [%04x]=%02x %d fail\n", reg, data, i++); diff --git a/code/components/esp32-camera-master/driver/sensor.c b/code/components/esp32-camera-master/driver/sensor.c index bf6d313f..2f4c9711 100644 --- a/code/components/esp32-camera-master/driver/sensor.c +++ b/code/components/esp32-camera-master/driver/sensor.c @@ -13,6 +13,9 @@ const camera_sensor_info_t camera_sensor[CAMERA_MODEL_MAX] = { {CAMERA_GC032A, "GC032A", GC032A_SCCB_ADDR, GC032A_PID, FRAMESIZE_VGA, false}, {CAMERA_GC0308, "GC0308", GC0308_SCCB_ADDR, GC0308_PID, FRAMESIZE_VGA, false}, {CAMERA_BF3005, "BF3005", BF3005_SCCB_ADDR, BF3005_PID, FRAMESIZE_VGA, false}, + {CAMERA_BF20A6, "BF20A6", BF20A6_SCCB_ADDR, BF20A6_PID, FRAMESIZE_VGA, false}, + {CAMERA_SC101IOT, "SC101IOT", SC101IOT_SCCB_ADDR, SC101IOT_PID, FRAMESIZE_HD, false}, + {CAMERA_SC030IOT, "SC030IOT", SC030IOT_SCCB_ADDR, SC030IOT_PID, FRAMESIZE_VGA, false}, }; const resolution_info_t resolution[FRAMESIZE_INVALID] = { diff --git a/code/components/esp32-camera-master/examples/main/take_picture.c b/code/components/esp32-camera-master/examples/main/take_picture.c index 1cbad908..783fcc01 100644 --- a/code/components/esp32-camera-master/examples/main/take_picture.c +++ b/code/components/esp32-camera-master/examples/main/take_picture.c @@ -38,6 +38,11 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" +// support IDF 5.x +#ifndef portTICK_RATE_MS +#define portTICK_RATE_MS portTICK_PERIOD_MS +#endif + #include "esp_camera.h" #define BOARD_WROVER_KIT 1 @@ -94,8 +99,8 @@ static camera_config_t camera_config = { .pin_pwdn = CAM_PIN_PWDN, .pin_reset = CAM_PIN_RESET, .pin_xclk = CAM_PIN_XCLK, - .pin_sscb_sda = CAM_PIN_SIOD, - .pin_sscb_scl = CAM_PIN_SIOC, + .pin_sccb_sda = CAM_PIN_SIOD, + .pin_sccb_scl = CAM_PIN_SIOC, .pin_d7 = CAM_PIN_D7, .pin_d6 = CAM_PIN_D6, diff --git a/code/components/esp32-camera-master/idf_component.yml b/code/components/esp32-camera-master/idf_component.yml index 848e1cd8..2b98f8d0 100644 --- a/code/components/esp32-camera-master/idf_component.yml +++ b/code/components/esp32-camera-master/idf_component.yml @@ -1,5 +1,2 @@ description: ESP32 compatible driver for OV2640, OV3660, OV5640, OV7670 and OV7725 image sensors. -targets: - - esp32 - - esp32s2 - - esp32s3 +url: https://github.com/espressif/esp32-camera diff --git a/code/components/esp32-camera-master/sensors/bf20a6.c b/code/components/esp32-camera-master/sensors/bf20a6.c new file mode 100644 index 00000000..b1179c30 --- /dev/null +++ b/code/components/esp32-camera-master/sensors/bf20a6.c @@ -0,0 +1,404 @@ +// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD +// +// 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. + +#include +#include +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "sccb.h" +#include "bf20a6.h" +#include "bf20a6_regs.h" +#include "bf20a6_settings.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char *TAG = "bf20a6"; +#endif + +#define H8(v) ((v)>>8) +#define L8(v) ((v)&0xff) + +//#define REG_DEBUG_ON + +static int read_reg(uint8_t slv_addr, const uint16_t reg) +{ + int ret = SCCB_Read(slv_addr, reg); + // ESP_LOGI(TAG, "READ Register 0x%02x VALUE: 0x%02x", reg, ret); +#ifdef REG_DEBUG_ON + if (ret < 0) { + ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) +{ + int ret = SCCB_Write(slv_addr, reg, value); +#ifdef REG_DEBUG_ON + if (ret < 0) { + ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +#ifdef DEBUG_PRINT_REG +static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) +{ + return (read_reg(slv_addr, reg) & mask) == mask; +} + +static void print_regs(uint8_t slv_addr) +{ + vTaskDelay(pdMS_TO_TICKS(100)); + ESP_LOGI(TAG, "REG list look ======================"); + for (size_t i = 0xf0; i <= 0xfe; i++) { + ESP_LOGI(TAG, "reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + ESP_LOGI(TAG, "\npage 0 ==="); + write_reg(slv_addr, 0xfe, 0x00); // page 0 + for (size_t i = 0x03; i <= 0x24; i++) { + ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + for (size_t i = 0x40; i <= 0x95; i++) { + ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + ESP_LOGI(TAG, "\npage 3 ==="); + write_reg(slv_addr, 0xfe, 0x03); // page 3 + for (size_t i = 0x01; i <= 0x43; i++) { + ESP_LOGI(TAG, "p3 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } +} + +static int read_regs(uint8_t slv_addr, const uint16_t(*regs)[2]) +{ + int i = 0, ret = 0; + while (regs[i][0] != REGLIST_TAIL) { + if (regs[i][0] == REG_DLY) { + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); + } else { + ret = read_reg(slv_addr, regs[i][0]); + } + i++; + } + return ret; +} +#endif + +static int set_reg_bits(sensor_t *sensor, uint8_t reg, uint8_t offset, uint8_t length, uint8_t value) +{ + int ret = 0; + + ret = SCCB_Read(sensor->slv_addr, reg); + if (ret < 0) { + return ret; + } + uint8_t mask = ((1 << length) - 1) << offset; + value = (ret & ~mask) | ((value << offset) & mask); + ret = SCCB_Write(sensor->slv_addr, reg & 0xFF, value); + return ret; +} + +static int write_regs(uint8_t slv_addr, const uint16_t(*regs)[2]) +{ + int i = 0, ret = 0; + while (!ret && regs[i][0] != REGLIST_TAIL) { + if (regs[i][0] == REG_DLY) { + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); + } else { + ret = write_reg(slv_addr, regs[i][0], regs[i][1]); + } + i++; + } + return ret; +} + +static int reset(sensor_t *sensor) +{ + int ret; + // Software Reset: clear all registers and reset them to their default values + ret = write_reg(sensor->slv_addr, RESET_RELATED, 0x01); + if (ret) { + ESP_LOGE(TAG, "Software Reset FAILED!"); + return ret; + } + vTaskDelay(100 / portTICK_PERIOD_MS); + + ret = write_regs(sensor->slv_addr, bf20a6_default_init_regs); + if (ret == 0) { + ESP_LOGD(TAG, "Camera defaults loaded"); + vTaskDelay(100 / portTICK_PERIOD_MS); + } + + // int test_value = read_regs(sensor->slv_addr, bf20a6_default_init_regs); + + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret = 0; + switch (pixformat) { + case PIXFORMAT_YUV422: + set_reg_bits(sensor, 0x12, 0, 1, 0); + break; + case PIXFORMAT_RAW: + set_reg_bits(sensor, 0x12, 0, 1, 0x1); + break; + default: + ESP_LOGW(TAG, "set_pix unsupport format"); + ret = -1; + break; + } + if (ret == 0) { + sensor->pixformat = pixformat; + ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); + } + + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret = 0; + if (framesize > FRAMESIZE_VGA) { + return -1; + } + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + + sensor->status.framesize = framesize; + + // Write MSBs + ret |= SCCB_Write(sensor->slv_addr, 0x17, 0); + ret |= SCCB_Write(sensor->slv_addr, 0x18, w >> 2); + + ret |= SCCB_Write(sensor->slv_addr, 0x19, 0); + ret |= SCCB_Write(sensor->slv_addr, 0x1a, h >> 2); + + // Write LSBs + ret |= SCCB_Write(sensor->slv_addr, 0x1b, 0); + + if ((w <= 320) && (h <= 240)) { + ret |= SCCB_Write(sensor->slv_addr, 0x17, (80 - w / 4)); + ret |= SCCB_Write(sensor->slv_addr, 0x18, (80 + w / 4)); + + ret |= SCCB_Write(sensor->slv_addr, 0x19, (60 - h / 4)); + + ret |= SCCB_Write(sensor->slv_addr, 0x1a, (60 + h / 4)); + + } else if ((w <= 640) && (h <= 480)) { + ret |= SCCB_Write(sensor->slv_addr, 0x17, (80 - w / 8)); + ret |= SCCB_Write(sensor->slv_addr, 0x18, (80 + w / 8)); + + ret |= SCCB_Write(sensor->slv_addr, 0x19, (60 - h / 8)); + + ret |= SCCB_Write(sensor->slv_addr, 0x1a, (60 + h / 8)); + } + + // Delay + vTaskDelay(30 / portTICK_PERIOD_MS); + + return ret; +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.hmirror = enable; + //ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor, 0x4a, 3, 0x01, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set h-mirror to: %d", enable); + } + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.vflip = enable; + //ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor, 0x4a, 2, 0x01, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set v-flip to: %d", enable); + } + return ret; +} + +static int set_colorbar(sensor_t *sensor, int value) +{ + int ret = 0; + ret = write_reg(sensor->slv_addr, 0xb6, value); + if (ret == 0) { + sensor->status.colorbar = value; + ESP_LOGD(TAG, "Set colorbar to: %d", value); + } + return ret; +} + +static int set_sharpness(sensor_t *sensor, int level) +{ + int ret = 0; + ret = SCCB_Write(sensor->slv_addr, 0x70, level); + if (ret == 0) { + ESP_LOGD(TAG, "Set sharpness to: %d", level); + sensor->status.sharpness = level; + } + return ret; +} + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = 0; + if (mask > 0xFF) { + ESP_LOGE(TAG, "mask should not more than 0xff"); + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if (ret > 0) { + ret &= mask; + } + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0; + if (mask > 0xFF) { + ESP_LOGE(TAG, "mask should not more than 0xff"); + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if (ret < 0) { + return ret; + } + value = (ret & ~mask) | (value & mask); + + if (mask > 0xFF) { + + } else { + ret = write_reg(sensor->slv_addr, reg, value); + } + return ret; +} + +static int init_status(sensor_t *sensor) +{ + // write_reg(sensor->slv_addr, 0xfe, 0x00); + sensor->status.brightness = SCCB_Read(sensor->slv_addr, 0x6f); + sensor->status.contrast = SCCB_Read(sensor->slv_addr, 0xd6); + sensor->status.saturation = 0; + sensor->status.sharpness = SCCB_Read(sensor->slv_addr, 0x70); + sensor->status.denoise = 0; + sensor->status.ae_level = 0; + sensor->status.gainceiling = SCCB_Read(sensor->slv_addr, 0x13); + sensor->status.awb = 0; + sensor->status.dcw = 0; + sensor->status.agc = 0; + sensor->status.aec = 0; + sensor->status.hmirror = 0;// check_reg_mask(sensor->slv_addr, P0_CISCTL_MODE1, 0x01); + sensor->status.vflip = 0;// check_reg_mask(sensor->slv_addr, P0_CISCTL_MODE1, 0x02); + sensor->status.colorbar = 0; + sensor->status.bpc = 0; + sensor->status.wpc = 0; + sensor->status.raw_gma = 0; + sensor->status.lenc = 0; + sensor->status.quality = 0; + sensor->status.special_effect = 0; + sensor->status.wb_mode = 0; + sensor->status.awb_gain = 0; + sensor->status.agc_gain = 0; + sensor->status.aec_value = 0; + sensor->status.aec2 = 0; + return 0; +} + +static int set_dummy(sensor_t *sensor, int val) +{ + ESP_LOGW(TAG, "dummy Unsupported"); + return -1; +} +static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val) +{ + ESP_LOGW(TAG, "gainceiling Unsupported"); + return -1; +} + +int bf20a6_detect(int slv_addr, sensor_id_t *id) +{ + if (BF20A6_SCCB_ADDR == slv_addr) { + uint8_t MIDL = SCCB_Read(slv_addr, SENSOR_ID_LOW); + uint8_t MIDH = SCCB_Read(slv_addr, SENSOR_ID_HIGH); + uint16_t PID = MIDH << 8 | MIDL; + if (BF20A6_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int bf20a6_init(sensor_t *sensor) +{ + sensor->init_status = init_status; + sensor->reset = reset; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_contrast = set_dummy; + sensor->set_brightness = set_dummy; + sensor->set_saturation = set_dummy; + sensor->set_sharpness = set_sharpness; + sensor->set_denoise = set_dummy; + sensor->set_gainceiling = set_gainceiling_dummy; + sensor->set_quality = set_dummy; + sensor->set_colorbar = set_colorbar; + sensor->set_whitebal = set_dummy; + sensor->set_gain_ctrl = set_dummy; + sensor->set_exposure_ctrl = set_dummy; + sensor->set_hmirror = set_hmirror; // set_hmirror; + sensor->set_vflip = set_vflip; // set_vflip; + + sensor->set_aec2 = set_dummy; + sensor->set_awb_gain = set_dummy; + sensor->set_agc_gain = set_dummy; + sensor->set_aec_value = set_dummy; + + sensor->set_special_effect = set_dummy; + sensor->set_wb_mode = set_dummy; + sensor->set_ae_level = set_dummy; + + sensor->set_dcw = set_dummy; + sensor->set_bpc = set_dummy; + sensor->set_wpc = set_dummy; + + sensor->set_raw_gma = set_dummy; + sensor->set_lenc = set_dummy; + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = NULL; + sensor->set_pll = NULL; + sensor->set_xclk = NULL; + + ESP_LOGD(TAG, "BF20A6 Attached"); + return 0; +} diff --git a/code/components/esp32-camera-master/sensors/gc0308.c b/code/components/esp32-camera-master/sensors/gc0308.c index 8b106a3a..f19025eb 100644 --- a/code/components/esp32-camera-master/sensors/gc0308.c +++ b/code/components/esp32-camera-master/sensors/gc0308.c @@ -88,10 +88,10 @@ static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t return ret; } -static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) +static int write_regs(uint8_t slv_addr, const uint8_t (*regs)[2], size_t regs_size) { int i = 0, ret = 0; - while (!ret && regs[i][0] != REGLIST_TAIL) { + while (!ret && (i < regs_size)) { if (regs[i][0] == REG_DLY) { vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); } else { @@ -132,11 +132,12 @@ static int reset(sensor_t *sensor) ESP_LOGE(TAG, "Software Reset FAILED!"); return ret; } - vTaskDelay(100 / portTICK_PERIOD_MS); - ret = write_regs(sensor->slv_addr, gc0308_sensor_default_regs); + + vTaskDelay(80 / portTICK_PERIOD_MS); + ret = write_regs(sensor->slv_addr, gc0308_sensor_default_regs, sizeof(gc0308_sensor_default_regs)/(sizeof(uint8_t) * 2)); if (ret == 0) { ESP_LOGD(TAG, "Camera defaults loaded"); - vTaskDelay(100 / portTICK_PERIOD_MS); + vTaskDelay(80 / portTICK_PERIOD_MS); write_reg(sensor->slv_addr, 0xfe, 0x00); #ifdef CONFIG_IDF_TARGET_ESP32 set_reg_bits(sensor->slv_addr, 0x28, 4, 0x07, 1); //frequency division for esp32, ensure pclk <= 15MHz diff --git a/code/components/esp32-camera-master/sensors/private_include/bf20a6.h b/code/components/esp32-camera-master/sensors/private_include/bf20a6.h new file mode 100644 index 00000000..8c925eb5 --- /dev/null +++ b/code/components/esp32-camera-master/sensors/private_include/bf20a6.h @@ -0,0 +1,27 @@ + +#ifndef __BF20A6_H__ +#define __BF20A6_H__ + +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int bf20a6_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int bf20a6_init(sensor_t *sensor); + +#endif // __BF20A6_H__ diff --git a/code/components/esp32-camera-master/sensors/private_include/bf20a6_regs.h b/code/components/esp32-camera-master/sensors/private_include/bf20a6_regs.h new file mode 100644 index 00000000..ab1ff69e --- /dev/null +++ b/code/components/esp32-camera-master/sensors/private_include/bf20a6_regs.h @@ -0,0 +1,12 @@ +/* + * BF20A6 register definitions. + */ +#ifndef __BF20A6_REG_REGS_H__ +#define __BF20A6_REG_REGS_H__ + +#define SENSOR_ID_HIGH 0XFC +#define SENSOR_ID_LOW 0XFD +#define RESET_RELATED 0XF2 + + +#endif //__BF20A6_REG_REGS_H__ diff --git a/code/components/esp32-camera-master/sensors/private_include/bf20a6_settings.h b/code/components/esp32-camera-master/sensors/private_include/bf20a6_settings.h new file mode 100644 index 00000000..0414bbac --- /dev/null +++ b/code/components/esp32-camera-master/sensors/private_include/bf20a6_settings.h @@ -0,0 +1,158 @@ + +#include + +#define REG_DLY 0xffff +#define REGLIST_TAIL 0xffff /* Array end token */ + +static const uint16_t bf20a6_default_init_regs[][2] = { + {0xf2,0x01}, + {0x12,0x20}, + {0x3a,0x00}, + {0xe1,0x92}, + {0xe3,0x12},// PLL Control, important for framerate(choice: 0x02\0x12\0x22\0x32\0x82) + {0xe0,0x00}, + {0x2a,0x98}, + {0xcd,0x17}, + {0xc0,0x10}, + {0xc6,0x1d}, + {0x10,0x35}, + {0xe2,0x09}, + {0xe4,0x72}, + {0xe5,0x22}, + {0xe6,0x24}, + {0xe7,0x64}, + {0xe8,0xa2}, // DVP:a2}, SPI:f2 VDDIO=1.8V,E8[2]=1},VDDIO=2.8V,E8[2]=0}, + {0x4a,0x00}, + {0x00,0x03}, + {0x1f,0x02}, + {0x22,0x02}, + {0x0c,0x31}, + + {0x00,0x00}, + {0x60,0x81}, + {0x61,0x81}, + + {0xa0,0x08}, + {0x01,0x1a}, + // {0x01,0x1a}, + // {0x01,0x1a}, + // {0x02,0x15}, + // {0x02,0x15}, + {0x02,0x15}, + {0x13,0x08}, + {0x8a,0x96}, + {0x8b,0x06}, + {0x87,0x18}, + + + {0x34,0x48}, // lens + {0x35,0x40}, + {0x36,0x40}, + + {0x71,0x44}, + {0x72,0x48}, + {0x74,0xa2}, + {0x75,0xa9}, + {0x78,0x12}, + {0x79,0xa0}, + {0x7a,0x94}, + {0x7c,0x97}, + {0x40,0x30}, + {0x41,0x30}, + {0x42,0x28}, + {0x43,0x1f}, + {0x44,0x1c}, + {0x45,0x16}, + {0x46,0x13}, + {0x47,0x10}, + {0x48,0x0D}, + {0x49,0x0C}, + {0x4B,0x0A}, + {0x4C,0x0B}, + {0x4E,0x09}, + {0x4F,0x08}, + {0x50,0x08}, + + + {0x5f,0x29}, + {0x23,0x33}, + {0xa1,0x10}, // AWB + {0xa2,0x0d}, + {0xa3,0x30}, + {0xa4,0x06}, + {0xa5,0x22}, + {0xa6,0x56}, + {0xa7,0x18}, + {0xa8,0x1a}, + {0xa9,0x12}, + {0xaa,0x12}, + {0xab,0x16}, + {0xac,0xb1}, + {0xba,0x12}, + {0xbb,0x12}, + {0xad,0x12}, + {0xae,0x56}, + {0xaf,0x0a}, + {0x3b,0x30}, + {0x3c,0x12}, + {0x3d,0x22}, + {0x3e,0x3f}, + {0x3f,0x28}, + {0xb8,0xc3}, + {0xb9,0xa3}, + {0x39,0x47}, // pure color threshold + {0x26,0x13}, + {0x27,0x16}, + {0x28,0x14}, + {0x29,0x18}, + {0xee,0x0d}, + + + {0x13,0x05}, + {0x24,0x3C}, + {0x81,0x20}, + {0x82,0x40}, + {0x83,0x30}, + {0x84,0x58}, + {0x85,0x30}, + {0x92,0x08}, + {0x86,0x80}, + {0x8a,0x96}, + {0x91,0xff}, + {0x94,0x62}, + {0x9a,0x18}, // outdoor threshold + {0xf0,0x45}, // integral time control, important for framerate(choice: 0x46\0x45\0x44..) + {0x51,0x17}, // color normal + {0x52,0x03}, + {0x53,0x5F}, + {0x54,0x47}, + {0x55,0x66}, + {0x56,0x0F}, + {0x7e,0x14}, + {0x57,0x36}, // color + {0x58,0x2A}, + {0x59,0xAA}, + {0x5a,0xA8}, + {0x5b,0x43}, + {0x5c,0x10}, + {0x5d,0x00}, + {0x7d,0x36}, + {0x5e,0x10}, + + {0xd6,0x88}, // contrast + {0xd5,0x20}, // bright + {0xb0,0x84}, // low light ctrl in gray section + {0xb5,0x08}, // the threshold of GLB_GAIN + {0xb1,0xc8}, // saturation + {0xb2,0xc0}, + {0xb3,0xd0}, + {0xb4,0xB0}, + + {0x32,0x10}, + // {0x8a,0x00}, + // {0x8b,0x10}, + {0xa0,0x09}, + {0x00,0x03}, + {0x0b,0x02}, + {REGLIST_TAIL, 0x00}, +}; diff --git a/code/components/esp32-camera-master/sensors/private_include/gc0308_settings.h b/code/components/esp32-camera-master/sensors/private_include/gc0308_settings.h index 32ef3816..adf5f28d 100644 --- a/code/components/esp32-camera-master/sensors/private_include/gc0308_settings.h +++ b/code/components/esp32-camera-master/sensors/private_include/gc0308_settings.h @@ -3,10 +3,9 @@ #include -#define REG_DLY 0xffff -#define REGLIST_TAIL 0x0000 /* Array end token */ +#define REG_DLY 0xff -static const uint16_t gc0308_sensor_default_regs[][2] = { +static const uint8_t gc0308_sensor_default_regs[][2] = { {0xfe, 0x00}, {0xec, 0x20}, {0x05, 0x00}, @@ -239,7 +238,21 @@ static const uint16_t gc0308_sensor_default_regs[][2] = { {0x65, 0xd3}, {0x66, 0x60}, {0xfe, 0x00}, - {REGLIST_TAIL, 0x00}, + + {0x01, 0x32}, //frame setting + {0x02, 0x0c}, + {0x0f, 0x01}, + {0xe2, 0x00}, + {0xe3, 0x78}, + {0xe4, 0x00}, + {0xe5, 0xfe}, + {0xe6, 0x01}, + {0xe7, 0xe0}, + {0xe8, 0x01}, + {0xe9, 0xe0}, + {0xea, 0x01}, + {0xeb, 0xe0}, + {0xfe, 0x00}, }; #endif diff --git a/code/components/esp32-camera-master/sensors/private_include/ov5640_settings.h b/code/components/esp32-camera-master/sensors/private_include/ov5640_settings.h index fec7d679..f52572fa 100644 --- a/code/components/esp32-camera-master/sensors/private_include/ov5640_settings.h +++ b/code/components/esp32-camera-master/sensors/private_include/ov5640_settings.h @@ -42,7 +42,8 @@ static const DRAM_ATTR uint16_t sensor_default_regs[][2] = { {ISP_CONTROL_01, 0x83}, // turn color matrix, awb and SDE //sys reset - {0x3000, 0x00}, + {0x3000, 0x20}, // reset MCU + {REG_DLY, 10}, // delay 10ms {0x3002, 0x1c}, //clock enable diff --git a/code/components/esp32-camera-master/sensors/private_include/sc030iot.h b/code/components/esp32-camera-master/sensors/private_include/sc030iot.h new file mode 100644 index 00000000..19298b76 --- /dev/null +++ b/code/components/esp32-camera-master/sensors/private_include/sc030iot.h @@ -0,0 +1,31 @@ +/* + * + * SC030IOT DVP driver. + * + */ +#ifndef __SC030IOT_H__ +#define __SC030IOT_H__ + +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int sc030iot_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int sc030iot_init(sensor_t *sensor); + +#endif // __SC030IOT_H__ diff --git a/code/components/esp32-camera-master/sensors/private_include/sc030iot_settings.h b/code/components/esp32-camera-master/sensors/private_include/sc030iot_settings.h new file mode 100644 index 00000000..56f5654c --- /dev/null +++ b/code/components/esp32-camera-master/sensors/private_include/sc030iot_settings.h @@ -0,0 +1,491 @@ +//version: V01P00_20220303 +//Preview Type:0:DVP Raw 10 bit// 1:Raw 8 bit// 2:YUV422// 3:RAW16 +//Preview Type:4:RGB565// 5:Pixart SPI// 6:MIPI 10bit// 7:MIPI 12bit// 8: MTK SPI +//port 0:MIPI// 1:Parallel// 2:MTK// 3:SPI// 4:TEST// 5: HISPI// 6 : Z2P/Z4P +//I2C Mode :0:Normal 8Addr,8Data// 1:Samsung 8 Addr,8Data// 2:Micron 8 Addr,16Data +//I2C Mode :3:Stmicro 16Addr,8Data//4:Micron2 16 Addr,16Data +//Out Format :0:YCbYCr/RG_GB// 1:YCrYCb/GR_BG// 2:CbYCrY/GB_RG// 3:CrYCbY/BG_GR +//MCLK Speed :0:6M//1:8M//2:10M//3:11.4M//4:12M//5:12.5M//6:13.5M//7:15M//8:18M//9:24M +//pin :BIT0 pwdn// BIT1:reset +//avdd 0:3.3V// 1:2.5V// 2:1.8V +//dovdd 0:2.8V// 1:2.5V// 2:1.8V +//dvdd 0:1.8V// 1:1.5V// 2:1.2V + +/* +[DataBase] +DBName=Dothinkey + +[Vendor] +VendorName=SmartSens + +[Sensor] +SensorName=SC031IOT +width=640 +height=480 +port=1 +type=2 +pin=3 +SlaveID=0xd0 +mode=0 +FlagReg=0xf7 +FlagMask=0xff +FlagData=0xfa +FlagReg1=0xf8 +FlagMask1=0xff +FlagData1=0x46 +outformat=0 +mclk=20 +avdd=2.80000 +dovdd=2.800000 +dvdd=1.5 + +Ext0=0 +Ext1=0 +Ext2=0 +AFVCC=0.0000 +VPP=0.000000 +*/ +#include + +static const uint8_t sc030iot_default_init_regs[][2] = { + {0xf0, 0x30}, + {0x01, 0xff}, + {0x02, 0xff}, + {0x22, 0x07}, + {0x19, 0xff}, + {0x3f, 0x82}, + {0x30, 0x02}, + {0xf0, 0x01}, + {0x70, 0x00}, + {0x71, 0x80}, + {0x72, 0x20}, + {0x73, 0x00}, + {0x74, 0xe0}, + {0x75, 0x10}, + {0x76, 0x81}, + {0x77, 0x88}, + {0x78, 0xe1}, + {0x79, 0x01}, + {0xf5, 0x01}, + {0xf4, 0x0a}, + {0xf0, 0x36}, + {0x37, 0x79}, + {0x31, 0x82}, + {0x3e, 0x60}, + {0x30, 0xf0}, + {0x33, 0x33}, + {0xf0, 0x32}, + {0x48, 0x02}, + {0xf0, 0x33}, + {0x02, 0x12}, + {0x7c, 0x02}, + {0x7d, 0x0e}, + {0xa2, 0x04}, + {0x5e, 0x06}, + {0x5f, 0x0a}, + {0x0b, 0x58}, + {0x06, 0x38}, + {0xf0, 0x32}, + {0x48, 0x02}, + {0xf0, 0x39}, + {0x02, 0x70}, + {0xf0, 0x45}, + {0x09, 0x1c}, + {0xf0, 0x37}, + {0x22, 0x0d}, + {0xf0, 0x33}, + {0x33, 0x10}, + {0xb1, 0x80}, + {0x34, 0x40}, + {0x0b, 0x54}, + {0xb2, 0x78}, + {0xf0, 0x36}, + {0x11, 0x80}, + {0xf0, 0x30}, + {0x38, 0x44}, + {0xf0, 0x33}, + {0xb3, 0x51}, + {0x01, 0x10}, + {0x0b, 0x6c}, + {0x06, 0x24}, + {0xf0, 0x36}, + {0x31, 0x82}, + {0x3e, 0x60}, + {0x30, 0xf0}, + {0x33, 0x33}, + {0xf0, 0x34}, + {0x9f, 0x02}, + {0xa6, 0x40}, + {0xa7, 0x47}, + {0xe8, 0x5f}, + {0xa8, 0x51}, + {0xa9, 0x44}, + {0xe9, 0x36}, + {0xf0, 0x33}, + {0xb3, 0x51}, + {0x64, 0x17}, + {0x90, 0x01}, + {0x91, 0x03}, + {0x92, 0x07}, + {0x01, 0x10}, + {0x93, 0x10}, + {0x94, 0x10}, + {0x95, 0x10}, + {0x96, 0x01}, + {0x97, 0x07}, + {0x98, 0x1f}, + {0x99, 0x10}, + {0x9a, 0x20}, + {0x9b, 0x28}, + {0x9c, 0x28}, + {0xf0, 0x36}, + {0x70, 0x54}, + {0xb6, 0x40}, + {0xb7, 0x41}, + {0xb8, 0x43}, + {0xb9, 0x47}, + {0xba, 0x4f}, + {0xb0, 0x8b}, + {0xb1, 0x8b}, + {0xb2, 0x8b}, + {0xb3, 0x9b}, + {0xb4, 0xb8}, + {0xb5, 0xf0}, + {0x7e, 0x41}, + {0x7f, 0x47}, + {0x77, 0x80}, + {0x78, 0x84}, + {0x79, 0x8a}, + {0xa0, 0x47}, + {0xa1, 0x5f}, + {0x96, 0x43}, + {0x97, 0x44}, + {0x98, 0x54}, + {0xf0, 0x00}, + {0xf0, 0x01}, + {0x73, 0x00}, + {0x74, 0xe0}, + {0x70, 0x00}, + {0x71, 0x80}, + {0xf0, 0x36}, + {0x37, 0x74}, + {0xf0, 0x3f}, + {0x03, 0xa1}, + {0xf0, 0x36},//cvbs_off + {0x11, 0x80}, + {0xf0, 0x01}, + {0x79, 0xc1}, + {0xf0, 0x37}, + {0x24, 0x21}, + {0xf0, 0x36}, + {0x41, 0x00}, + {0xea, 0x09}, + {0xeb, 0x03}, + {0xec, 0x19}, + {0xed, 0x38}, + {0xe9, 0x30}, + {0xf0, 0x33}, + {0x33, 0x00}, + {0x34, 0x00}, + {0xb1, 0x00}, + {0xf0, 0x00}, + {0xe0, 0x04}, + {0xf0, 0x01}, + {0x73, 0x00}, + {0x74, 0xe0}, + {0x70, 0x00}, + {0x71, 0x80}, + {0xf0, 0x36}, + {0x32, 0x44}, + {0xf0, 0x36}, + {0x3e, 0xe0}, + {0x70, 0x56}, + {0x7c, 0x43}, + {0x7d, 0x47}, + {0x74, 0x00}, + {0x75, 0x00}, + {0x76, 0x00}, + {0xa0, 0x47}, + {0xa1, 0x5f}, + {0x96, 0x22}, + {0x97, 0x22}, + {0x98, 0x22}, + {0xf0, 0x00}, + {0x72, 0x38}, + {0x7a, 0x80}, + {0x85, 0x18}, + {0x9b, 0x35}, + {0x9e, 0x20}, + {0xd0, 0x66}, + {0xd1, 0x34}, + {0Xd3, 0x44}, + {0xd6, 0x44}, + {0xb0, 0x41}, + {0xb2, 0x48}, + {0xb3, 0xf4}, + {0xb4, 0x0b}, + {0xb5, 0x78}, + {0xba, 0xff}, + {0xbb, 0xc0}, + {0xbc, 0x90}, + {0xbd, 0x3a}, + {0xc1, 0x67}, + {0xf0, 0x01}, + {0x20, 0x11}, + {0x23, 0x90}, + {0x24, 0x15}, + {0x25, 0x87}, + {0xbc, 0x9f}, + {0xbd, 0x3a}, + {0x48, 0xe6}, + {0x49, 0xc0}, + {0x4a, 0xd0}, + {0x4b, 0x48}, + + // [cvbs_on] + {0xf0, 0x36}, + {0x11, 0x00}, + {0xf0, 0x01}, + {0x79, 0xf1}, + + // [cvbs_off] + {0xf0, 0x36}, + {0x11, 0x80}, + {0xf0, 0x01}, + {0x79, 0xc1}, +}; + +/* +[Sensor] +SensorName=SC031IOT +width=640 +height=480 +port=1 +type=2 +pin=3 +SlaveID=0xd0 +mode=0 +FlagReg=0xf7 +FlagMask=0xff +FlagData=0xfa +FlagReg1=0xf8 +FlagMask1=0xff +FlagData1=0x46 +outformat=0 +mclk=27 +avdd=2.80000 +dovdd=2.800000 +dvdd=1.5 + +Ext0=0 +Ext1=0 +Ext2=0 +AFVCC=0.0000 +VPP=0.000000 +*/ +/* 27M MCLK, 30fps +static const uint8_t sc030iot_default_init_regs[][2] = { + {0xf0, 0x30}, + {0x01, 0xff}, + {0x02, 0xff}, + {0x22, 0x07}, + {0x19, 0xff}, + {0x3f, 0x82}, + {0x30, 0x02}, + {0xf0, 0x01}, + {0x70, 0x00}, + {0x71, 0x80}, + {0x72, 0x20}, + {0x73, 0x00}, + {0x74, 0xe0}, + {0x75, 0x10}, + {0x76, 0x81}, + {0x77, 0x88}, + {0x78, 0xe1}, + {0x79, 0x01}, + {0xf5, 0x01}, + {0xf4, 0x0a}, + {0xf0, 0x36}, + {0x37, 0x79}, + {0x31, 0x82}, + {0x3e, 0x60}, + {0x30, 0xf0}, + {0x33, 0x33}, + {0xf0, 0x32}, + {0x48, 0x02}, + {0xf0, 0x33}, + {0x02, 0x12}, + {0x7c, 0x02}, + {0x7d, 0x0e}, + {0xa2, 0x04}, + {0x5e, 0x06}, + {0x5f, 0x0a}, + {0x0b, 0x58}, + {0x06, 0x38}, + {0xf0, 0x32}, + {0x48, 0x02}, + {0xf0, 0x39}, + {0x02, 0x70}, + {0xf0, 0x45}, + {0x09, 0x1c}, + {0xf0, 0x37}, + {0x22, 0x0d}, + {0xf0, 0x33}, + {0x33, 0x10}, + {0xb1, 0x80}, + {0x34, 0x40}, + {0x0b, 0x54}, + {0xb2, 0x78}, + {0xf0, 0x36}, + {0x11, 0x80}, + {0xf0, 0x30}, + {0x38, 0x44}, + {0xf0, 0x33}, + {0xb3, 0x51}, + {0x01, 0x10}, + {0x0b, 0x6c}, + {0x06, 0x24}, + {0xf0, 0x36}, + {0x31, 0x82}, + {0x3e, 0x60}, + {0x30, 0xf0}, + {0x33, 0x33}, + {0xf0, 0x34}, + {0x9f, 0x02}, + {0xa6, 0x40}, + {0xa7, 0x47}, + {0xe8, 0x5f}, + {0xa8, 0x51}, + {0xa9, 0x44}, + {0xe9, 0x36}, + {0xf0, 0x33}, + {0xb3, 0x51}, + {0x64, 0x17}, + {0x90, 0x01}, + {0x91, 0x03}, + {0x92, 0x07}, + {0x01, 0x10}, + {0x93, 0x10}, + {0x94, 0x10}, + {0x95, 0x10}, + {0x96, 0x01}, + {0x97, 0x07}, + {0x98, 0x1f}, + {0x99, 0x10}, + {0x9a, 0x20}, + {0x9b, 0x28}, + {0x9c, 0x28}, + {0xf0, 0x36}, + {0x70, 0x54}, + {0xb6, 0x40}, + {0xb7, 0x41}, + {0xb8, 0x43}, + {0xb9, 0x47}, + {0xba, 0x4f}, + {0xb0, 0x8b}, + {0xb1, 0x8b}, + {0xb2, 0x8b}, + {0xb3, 0x9b}, + {0xb4, 0xb8}, + {0xb5, 0xf0}, + {0x7e, 0x41}, + {0x7f, 0x47}, + {0x77, 0x80}, + {0x78, 0x84}, + {0x79, 0x8a}, + {0xa0, 0x47}, + {0xa1, 0x5f}, + {0x96, 0x43}, + {0x97, 0x44}, + {0x98, 0x54}, + {0xf0, 0x00}, + {0xf0, 0x01}, + {0x73, 0x00}, + {0x74, 0xe0}, + {0x70, 0x00}, + {0x71, 0x80}, + {0xf0, 0x36}, + {0x37, 0x74}, + {0xf0, 0x3f}, + {0x03, 0x93}, + {0xf0, 0x36},//cvbs_off + {0x11, 0x80}, + {0xf0, 0x01}, + {0x79, 0xc1}, + {0xf0, 0x37}, + {0x24, 0x21}, + {0xf0, 0x36}, + {0x41, 0x00}, + {0xe9, 0x2c}, + {0xf0, 0x33}, + {0x33, 0x00}, + {0x34, 0x00}, + {0xb1, 0x00}, + {0xf0, 0x00}, + {0xe0, 0x04}, + {0xf0, 0x01}, + {0x73, 0x00}, + {0x74, 0xe0}, + {0x70, 0x00}, + {0x71, 0x80}, + {0xf0, 0x36}, + {0x32, 0x44}, + {0xf0, 0x36}, + {0x3e, 0xe0}, + {0x70, 0x56}, + {0x7c, 0x43}, + {0x7d, 0x47}, + {0x74, 0x00}, + {0x75, 0x00}, + {0x76, 0x00}, + {0xa0, 0x47}, + {0xa1, 0x5f}, + {0x96, 0x22}, + {0x97, 0x22}, + {0x98, 0x22}, + {0xf0, 0x00}, + {0x72, 0x38}, + {0x7a, 0x80}, + {0x85, 0x18}, + {0x9b, 0x35}, + {0x9e, 0x20}, + {0xd0, 0x66}, + {0xd1, 0x34}, + {0Xd3, 0x44}, + {0xd6, 0x44}, + {0xb0, 0x41}, + {0xb2, 0x48}, + {0xb3, 0xf4}, + {0xb4, 0x0b}, + {0xb5, 0x78}, + {0xba, 0xff}, + {0xbb, 0xc0}, + {0xbc, 0x90}, + {0xbd, 0x3a}, + {0xc1, 0x67}, + {0xf0, 0x01}, + {0x20, 0x11}, + {0x23, 0x90}, + {0x24, 0x15}, + {0x25, 0x87}, + {0xbc, 0x9f}, + {0xbd, 0x3a}, + {0x48, 0xe6}, + {0x49, 0xc0}, + {0x4a, 0xd0}, + {0x4b, 0x48}, + + // [cvbs_on] + {0xf0, 0x36}, + {0x11, 0x00}, + {0xf0, 0x01}, + {0x79, 0xf1}, + + // [cvbs_off] + {0xf0, 0x36}, + {0x11, 0x80}, + {0xf0, 0x01}, + {0x79, 0xc1}, +}; + +*/ \ No newline at end of file diff --git a/code/components/esp32-camera-master/sensors/private_include/sc101iot.h b/code/components/esp32-camera-master/sensors/private_include/sc101iot.h new file mode 100644 index 00000000..85858498 --- /dev/null +++ b/code/components/esp32-camera-master/sensors/private_include/sc101iot.h @@ -0,0 +1,31 @@ +/* + * + * SC101IOT DVP driver. + * + */ +#ifndef __SC101IOT_H__ +#define __SC101IOT_H__ + +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int sc101iot_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int sc101iot_init(sensor_t *sensor); + +#endif // __SC101IOT_H__ diff --git a/code/components/esp32-camera-master/sensors/private_include/sc101iot_settings.h b/code/components/esp32-camera-master/sensors/private_include/sc101iot_settings.h new file mode 100644 index 00000000..2eb14398 --- /dev/null +++ b/code/components/esp32-camera-master/sensors/private_include/sc101iot_settings.h @@ -0,0 +1,257 @@ +//Preview Type:0:DVP Raw 10 bit// 1:Raw 8 bit// 2:YUV422// 3:RAW16 +//Preview Type:4:RGB565// 5:Pixart SPI// 6:MIPI 10bit// 7:MIPI 12bit// 8: MTK SPI +//port 0:MIPI// 1:Parallel// 2:MTK// 3:SPI// 4:TEST// 5: HISPI// 6 : Z2P/Z4P +//I2C Mode :0:Normal 8Addr,8Data// 1:Samsung 8 Addr,8Data// 2:Micron 8 Addr,16Data +//I2C Mode :3:Stmicro 16Addr,8Data//4:Micron2 16 Addr,16Data +//Out Format :0:YCbYCr/RG_GB// 1:YCrYCb/GR_BG// 2:CbYCrY/GB_RG// 3:CrYCbY/BG_GR +//MCLK Speed :0:6M//1:8M//2:10M//3:11.4M//4:12M//5:12.5M//6:13.5M//7:15M//8:18M//9:24M +//pin :BIT0 pwdn// BIT1:reset +//avdd 0:2.8V// 1:2.5V// 2:1.8V +//dovdd 0:2.8V// 1:2.5V// 2:1.8V +//dvdd 0:1.8V// 1:1.5V// 2:1.2V +/* +[DataBase] +DBName=DemoSens + +[Vendor] +VendorName=SmartSens +I2C_CRC=0 + +[Sensor] +SensorName=SC101AP_raw +width=1280 +height=720 +port=1 +type=2 +pin=3 +SlaveID=0xd0 +mode=0 +FlagReg=0xf7 +FlagMask=0xff +FlagData=0xda +FlagReg1=0xf8 +FlagMask1=0xff +FlagData1=0x4a +outformat=0 +mclk=20 +avdd=2.800000 +dovdd=2.800000 +dvdd=1.200000 + +Ext0=0 +Ext1=0 +Ext2=0 +AFVCC=0.00 +VPP=0.000000 +*/ +#include + +static const uint8_t sc101iot_default_init_regs[][2] = { +#if CONFIG_SC101IOT_720P_15FPS_ENABLED // 720P+YUV422+15FPS sensor default regs +/* Here are some test results: +# size xclk fps pic pclk +# ------- ------- ------ --------- ------- --- --- --- --- --- +# 720p 4 3 err +# 720p 8 5 normal 15 +# 720p 10 7.8 normal 19 +# 720p 20 15 warning 37.5 +# VGA 8 6 normal +# VGA 20 16 normal + +*/ + {0xf0, 0x30}, + {0x01, 0xff}, + {0x02, 0xe0}, + {0x30, 0x10}, + {0x3f, 0x81}, + {0xf0, 0x00}, + {0x70, 0x6b}, + {0x72, 0x30}, + {0x84, 0xb4}, + {0x8b, 0x00}, + {0x8c, 0x20}, + {0x8d, 0x02}, + {0x8e, 0xec}, + {0x9e, 0x10}, + {0xb0, 0xc1}, + {0xc8, 0x10}, + {0xc9, 0x10}, + {0xc6, 0x00}, + {0xe0, 0x0f}, + {0xb5, 0xf0}, + {0xde, 0x80}, + {0xb5, 0xf0}, + {0xde, 0x80}, + {0xb2, 0x50}, + {0xb3, 0xfc}, + {0xb4, 0x40}, + {0xb5, 0xc0}, + {0xb6, 0x50}, + {0xb7, 0xfc}, + {0xb8, 0x40}, + {0xb9, 0xc0}, + {0xba, 0xff}, + {0xbb, 0xcc}, + {0xbc, 0xa9}, + {0xbd, 0x7d}, + {0xc1, 0x77}, + {0xf0, 0x01}, + {0x70, 0x02}, + {0x71, 0x02}, + {0x72, 0x50}, + {0x73, 0x02}, + {0x74, 0xd2}, + {0x75, 0x20}, + {0x76, 0x81}, + {0x77, 0x8c}, + {0x78, 0x81}, + {0xf4, 0x01}, + {0xf5, 0x00}, + {0xf6, 0x00}, + {0xf0, 0x36}, + {0x40, 0x03}, + {0x41, 0x01}, + {0xf0, 0x39}, + {0x02, 0x70}, + {0xf0, 0x32}, + {0x41, 0x00}, + {0x43, 0x01}, + {0x48, 0x02}, + {0xf0, 0x45}, + {0x09, 0x20}, + {0xf0, 0x33}, + {0x33, 0x10}, + {0xf0, 0x30}, + {0x38, 0x44}, + {0xf0, 0x39}, + {0x07, 0x00}, + {0x08, 0x19}, + {0x47, 0x00}, + {0x48, 0x00}, + {0xf0, 0x37}, + {0x24, 0x31}, + {0xf0, 0x34}, + {0x9f, 0x02}, + {0xa6, 0x51}, + {0xa7, 0x57}, + {0xe8, 0x5f}, + {0xa8, 0x50}, + {0xa9, 0x50}, + {0xe9, 0x50}, + {0xf0, 0x33}, + {0xb3, 0x58}, + {0xb2, 0x78}, + {0xf0, 0x34}, + {0x9f, 0x03}, + {0xa6, 0x51}, + {0xa7, 0x57}, + {0xaa, 0x01}, + {0xab, 0x28}, + {0xac, 0x01}, + {0xad, 0x38}, + {0xf0, 0x33}, + {0x0a, 0x01}, + {0x0b, 0x28}, + {0xf0, 0x33}, + {0x64, 0x0f}, + {0xec, 0x51}, + {0xed, 0x57}, + {0x06, 0x58}, + {0xe9, 0x58}, + {0xeb, 0x68}, + {0xf0, 0x33}, + {0x64, 0x0f}, + {0xf0, 0x36}, + {0x70, 0xdf}, + {0xb6, 0x40}, + {0xb7, 0x51}, + {0xb8, 0x53}, + {0xb9, 0x57}, + {0xba, 0x5f}, + {0xb0, 0x84}, + {0xb1, 0x82}, + {0xb2, 0x84}, + {0xb3, 0x88}, + {0xb4, 0x90}, + {0xb5, 0x90}, + {0xf0, 0x36}, + {0x7e, 0x50}, + {0x7f, 0x51}, + {0x77, 0x81}, + {0x78, 0x86}, + {0x79, 0x89}, + {0xf0, 0x36}, + {0x70, 0xdf}, + {0x9c, 0x51}, + {0x9d, 0x57}, + {0x90, 0x54}, + {0x91, 0x54}, + {0x92, 0x56}, + {0xf0, 0x36}, + {0xa0, 0x51}, + {0xa1, 0x57}, + {0x96, 0x33}, + {0x97, 0x43}, + {0x98, 0x43}, + {0xf0, 0x36}, + {0x70, 0xdf}, + {0x7c, 0x40}, + {0x7d, 0x53}, + {0x74, 0xd0}, + {0x75, 0xf0}, + {0x76, 0xf0}, + {0xf0, 0x37}, + {0x0f, 0xd5}, + {0x7a, 0x40}, + {0x7b, 0x57}, + {0x71, 0x09}, + {0x72, 0x09}, + {0x73, 0x05}, + {0xf0, 0x33}, + {0x01, 0x44}, + {0xf0, 0x36}, + {0x37, 0xfb}, + {0xf0, 0x36}, + {0x3c, 0x0d}, + {0xf0, 0x33}, + {0x14, 0x95}, + {0xf0, 0x33}, + {0x8f, 0x80}, + {0xf0, 0x37}, + {0x27, 0x14}, + {0x28, 0x03}, + {0xf0, 0x36}, + {0x37, 0xf4}, + {0xf0, 0x33}, + {0x01, 0x44}, + {0xf0, 0x36}, + {0x79, 0x89}, + {0xf0, 0x34}, + {0xac, 0x01}, + {0xad, 0x40}, + {0xf0, 0x33}, + {0xeb, 0x70}, + {0xf0, 0x34}, + {0xa8, 0x50}, + {0xa9, 0x50}, + {0xf0, 0x33}, + {0xb3, 0x58}, + {0xf0, 0x36}, + {0x11, 0x80}, + {0xf0, 0x36}, + {0x41, 0x51}, + {0xf0, 0x3f}, + {0x03, 0x09}, + {0xf0, 0x32}, + {0x0c, 0x06}, + {0x0d, 0x82}, + {0x0e, 0x02}, + {0x0f, 0xee}, + {0xf0, 0x36}, + {0xea, 0x09}, + {0xeb, 0xf5}, + {0xec, 0x11}, + {0xed, 0x27}, + {0xe9, 0x20}, +#endif +}; diff --git a/code/components/esp32-camera-master/sensors/sc030iot.c b/code/components/esp32-camera-master/sensors/sc030iot.c new file mode 100644 index 00000000..86f525f3 --- /dev/null +++ b/code/components/esp32-camera-master/sensors/sc030iot.c @@ -0,0 +1,335 @@ +/* + * SC030IOT driver. + * + * Copyright 2020-2022 Espressif Systems (Shanghai) PTE LTD + * + * 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. + * + */ +#include +#include +#include +#include +#include "sccb.h" +#include "xclk.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#include "sc030iot.h" +#include "sc030iot_settings.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char* TAG = "sc030"; +#endif + +#define SC030_SENSOR_ID_HIGH_REG 0XF7 +#define SC030_SENSOR_ID_LOW_REG 0XF8 +#define SC030_MAX_FRAME_WIDTH (640) +#define SC030_MAX_FRAME_HIGH (480) + +// sc030 use "i2c paging mode", so the high byte of the register needs to be written to the 0xf0 reg. +// For more information please refer to the Technical Reference Manual. +static int get_reg(sensor_t *sensor, int reg, int reg_value_mask) +{ + int ret = 0; + uint8_t reg_high = (reg>>8) & 0xFF; + uint8_t reg_low = reg & 0xFF; + + if(SCCB_Write(sensor->slv_addr, 0xf0, reg_high)) { + return -1; + } + + ret = SCCB_Read(sensor->slv_addr, reg_low); + if(ret > 0){ + ret &= reg_value_mask; + } + return ret; +} + +// sc030 use "i2c paging mode", so the high byte of the register needs to be written to the 0xf0 reg. +// For more information please refer to the Technical Reference Manual. +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0; + uint8_t reg_high = (reg>>8) & 0xFF; + uint8_t reg_low = reg & 0xFF; + + if(SCCB_Write(sensor->slv_addr, 0xf0, reg_high)) { + return -1; + } + + ret = SCCB_Write(sensor->slv_addr, reg_low, value & 0xFF); + return ret; +} + +static int set_regs(sensor_t *sensor, const uint8_t (*regs)[2], uint32_t regs_entry_len) +{ + int i=0, res = 0; + while (islv_addr, regs[i][0], regs[i][1]); + if (res) { + return res; + } + i++; + } + return res; +} + +static int set_reg_bits(sensor_t *sensor, int reg, uint8_t offset, uint8_t length, uint8_t value) +{ + int ret = 0; + ret = get_reg(sensor, reg, 0xff); + if(ret < 0){ + return ret; + } + uint8_t mask = ((1 << length) - 1) << offset; + value = (ret & ~mask) | ((value << offset) & mask); + ret = set_reg(sensor, reg & 0xFFFF, 0xFFFF, value); + return ret; +} + +#define WRITE_REGS_OR_RETURN(regs, regs_entry_len) ret = set_regs(sensor, regs, regs_entry_len); if(ret){return ret;} +#define WRITE_REG_OR_RETURN(reg, val) ret = set_reg(sensor, reg, 0xFF, val); if(ret){return ret;} +#define SET_REG_BITS_OR_RETURN(reg, offset, length, val) ret = set_reg_bits(sensor, reg, offset, length, val); if(ret){return ret;} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + if(enable) { + SET_REG_BITS_OR_RETURN(0x3221, 1, 2, 0x3); // mirror on + } else { + SET_REG_BITS_OR_RETURN(0x3221, 1, 2, 0x0); // mirror off + } + + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + if(enable) { + SET_REG_BITS_OR_RETURN(0x3221, 5, 2, 0x3); // flip on + } else { + SET_REG_BITS_OR_RETURN(0x3221, 5, 2, 0x0); // flip off + } + + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x0100, 7, 1, enable & 0xff); // enable test pattern mode + + return ret; +} + +static int set_sharpness(sensor_t *sensor, int level) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00e0, 1, 1, 1); // enable edge enhancement + WRITE_REG_OR_RETURN(0x00d0, level & 0xFF); // base value + WRITE_REG_OR_RETURN(0x00d2, (level >> 8) & 0xFF); // limit + + return ret; +} + +static int set_agc_gain(sensor_t *sensor, int gain) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x0070, 1, 1, 1); // enable auto agc control + WRITE_REG_OR_RETURN(0x0068, gain & 0xFF); // Window weight setting1 + WRITE_REG_OR_RETURN(0x0069, (gain >> 8) & 0xFF); // Window weight setting2 + WRITE_REG_OR_RETURN(0x006a, (gain >> 16) & 0xFF); // Window weight setting3 + WRITE_REG_OR_RETURN(0x006b, (gain >> 24) & 0xFF); // Window weight setting4 + + return ret; +} + +static int set_aec_value(sensor_t *sensor, int value) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x0070, 0, 1, 1); // enable auto aec control + WRITE_REG_OR_RETURN(0x0072, value & 0xFF); // AE target + + return ret; +} + +static int set_awb_gain(sensor_t *sensor, int value) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00b0, 0, 1, 1); // enable awb control + WRITE_REG_OR_RETURN(0x00c8, value & 0xFF); // blue gain + WRITE_REG_OR_RETURN(0x00c9, (value>>8) & 0XFF); // red gain + return ret; +} + +static int set_saturation(sensor_t *sensor, int level) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00f5, 5, 1, 0); // enable saturation control + WRITE_REG_OR_RETURN(0x0149, level & 0xFF); // blue saturation gain (/128) + WRITE_REG_OR_RETURN(0x014a, (level>>8) & 0XFF); // red saturation gain (/128) + return ret; +} + +static int set_contrast(sensor_t *sensor, int level) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00f5, 6, 1, 0); // enable contrast control + WRITE_REG_OR_RETURN(0x014b, level); // contrast coefficient(/64) + return ret; +} + +static int reset(sensor_t *sensor) +{ + int ret = set_regs(sensor, sc030iot_default_init_regs, sizeof(sc030iot_default_init_regs)/(sizeof(uint8_t) * 2)); + + // Delay + vTaskDelay(50 / portTICK_PERIOD_MS); + + // ESP_LOGI(TAG, "set_reg=%0x", set_reg(sensor, 0x0100, 0xffff, 0x00)); // write 0x80 to enter test mode if you want to test the sensor + // ESP_LOGI(TAG, "0x0100=%0x", get_reg(sensor, 0x0100, 0xffff)); + if (ret) { + ESP_LOGE(TAG, "reset fail"); + } + return ret; +} + +static int set_window(sensor_t *sensor, int offset_x, int offset_y, int w, int h) +{ + int ret = 0; + //sc:H_start={0x0172[1:0],0x0170},H_end={0x0172[5:4],0x0171}, + WRITE_REG_OR_RETURN(0x0170, offset_x & 0xff); + WRITE_REG_OR_RETURN(0x0171, (offset_x+w) & 0xff); + WRITE_REG_OR_RETURN(0x0172, ((offset_x>>8) & 0x03) | (((offset_x+w)>>4)&0x30)); + + //sc:V_start={0x0175[1:0],0x0173},H_end={0x0175[5:4],0x0174}, + WRITE_REG_OR_RETURN(0x0173, offset_y & 0xff); + WRITE_REG_OR_RETURN(0x0174, (offset_y+h) & 0xff); + WRITE_REG_OR_RETURN(0x0175, ((offset_y>>8) & 0x03) | (((offset_y+h)>>4)&0x30)); + + vTaskDelay(10 / portTICK_PERIOD_MS); + + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + if(w>SC030_MAX_FRAME_WIDTH || h > SC030_MAX_FRAME_HIGH) { + goto err; + } + + uint16_t offset_x = (640-w) /2; + uint16_t offset_y = (480-h) /2; + + if(set_window(sensor, offset_x, offset_y, w, h)) { + goto err; + } + + sensor->status.framesize = framesize; + return 0; +err: + ESP_LOGE(TAG, "frame size err"); + return -1; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret=0; + sensor->pixformat = pixformat; + + switch (pixformat) { + case PIXFORMAT_RGB565: + case PIXFORMAT_RAW: + case PIXFORMAT_GRAYSCALE: + ESP_LOGE(TAG, "Not support"); + break; + case PIXFORMAT_YUV422: // For now, sc030/sc031 sensor only support YUV422. + break; + default: + return -1; + } + + return ret; +} + +static int init_status(sensor_t *sensor) +{ + return 0; +} + +static int set_dummy(sensor_t *sensor, int val){ return -1; } + +static int set_xclk(sensor_t *sensor, int timer, int xclk) +{ + int ret = 0; + sensor->xclk_freq_hz = xclk * 1000000U; + ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); + return ret; +} + +int sc030iot_detect(int slv_addr, sensor_id_t *id) +{ + if (SC030IOT_SCCB_ADDR == slv_addr) { + uint8_t MIDL = SCCB_Read(slv_addr, SC030_SENSOR_ID_LOW_REG); + uint8_t MIDH = SCCB_Read(slv_addr, SC030_SENSOR_ID_HIGH_REG); + uint16_t PID = MIDH << 8 | MIDL; + if (SC030IOT_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int sc030iot_init(sensor_t *sensor) +{ + // Set function pointers + sensor->reset = reset; + sensor->init_status = init_status; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + + sensor->set_saturation= set_saturation; + sensor->set_colorbar = set_colorbar; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + sensor->set_sharpness = set_sharpness; + sensor->set_agc_gain = set_agc_gain; + sensor->set_aec_value = set_aec_value; + sensor->set_awb_gain = set_awb_gain; + sensor->set_contrast = set_contrast; + //not supported + sensor->set_denoise = set_dummy; + sensor->set_quality = set_dummy; + sensor->set_special_effect = set_dummy; + sensor->set_wb_mode = set_dummy; + sensor->set_ae_level = set_dummy; + + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_xclk = set_xclk; + + ESP_LOGD(TAG, "sc030iot Attached"); + + return 0; +} \ No newline at end of file diff --git a/code/components/esp32-camera-master/sensors/sc101iot.c b/code/components/esp32-camera-master/sensors/sc101iot.c new file mode 100644 index 00000000..310a0476 --- /dev/null +++ b/code/components/esp32-camera-master/sensors/sc101iot.c @@ -0,0 +1,342 @@ +/* + * SC101IOT driver. + * + * Copyright 2020-2022 Espressif Systems (Shanghai) PTE LTD + * + * 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. + * + */ +#include +#include +#include +#include +#include "sccb.h" +#include "xclk.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#include "sc101iot.h" +#include "sc101iot_settings.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char* TAG = "sc101"; +#endif + +#define SC101_SENSOR_ID_HIGH_REG 0XF7 +#define SC101_SENSOR_ID_LOW_REG 0XF8 +#define SC101_MAX_FRAME_WIDTH (1280) +#define SC101_MAX_FRAME_HIGH (720) + +// sc101 use "i2c paging mode", so the high byte of the register needs to be written to the 0xf0 reg. +// For more information please refer to the Technical Reference Manual. +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = 0; + uint8_t reg_high = (reg>>8) & 0xFF; + uint8_t reg_low = reg & 0xFF; + + if(SCCB_Write(sensor->slv_addr, 0xf0, reg_high)) { + return -1; + } + + ret = SCCB_Read(sensor->slv_addr, reg_low); + if(ret > 0){ + ret &= mask; + } + return ret; +} + +// sc101 use "i2c paging mode", so the high byte of the register needs to be written to the 0xf0 reg. +// For more information please refer to the Technical Reference Manual. +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0; + uint8_t reg_high = (reg>>8) & 0xFF; + uint8_t reg_low = reg & 0xFF; + + if(SCCB_Write(sensor->slv_addr, 0xf0, reg_high)) { + return -1; + } + + ret = SCCB_Write(sensor->slv_addr, reg_low, value & 0xFF); + return ret; +} + +static int set_regs(sensor_t *sensor, const uint8_t (*regs)[2], uint32_t regs_entry_len) +{ + int i=0, res = 0; + while (islv_addr, regs[i][0], regs[i][1]); + if (res) { + return res; + } + i++; + } + return res; +} + +static int set_reg_bits(sensor_t *sensor, int reg, uint8_t offset, uint8_t length, uint8_t value) +{ + int ret = 0; + ret = get_reg(sensor, reg, 0xff); + if(ret < 0){ + return ret; + } + uint8_t mask = ((1 << length) - 1) << offset; + value = (ret & ~mask) | ((value << offset) & mask); + ret = set_reg(sensor, reg & 0xFFFF, 0xFFFF, value); + return ret; +} + +#define WRITE_REGS_OR_RETURN(regs, regs_entry_len) ret = set_regs(sensor, regs, regs_entry_len); if(ret){return ret;} +#define WRITE_REG_OR_RETURN(reg, val) ret = set_reg(sensor, reg, 0xFF, val); if(ret){return ret;} +#define SET_REG_BITS_OR_RETURN(reg, offset, length, val) ret = set_reg_bits(sensor, reg, offset, length, val); if(ret){return ret;} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + if(enable) { + SET_REG_BITS_OR_RETURN(0x3221, 1, 2, 0x3); // enable mirror + } else { + SET_REG_BITS_OR_RETURN(0x3221, 1, 2, 0x0); // disable mirror + } + + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + if(enable) { + SET_REG_BITS_OR_RETURN(0x3221, 5, 2, 0x3); // flip on + } else { + SET_REG_BITS_OR_RETURN(0x3221, 5, 2, 0x0); // flip off + } + + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x0100, 7, 1, enable & 0xff); // enable colorbar mode + return ret; +} + +static int set_raw_gma(sensor_t *sensor, int enable) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00f5, 1, 1, enable & 0xff); // enable gamma compensation + + return ret; +} + +static int set_sharpness(sensor_t *sensor, int level) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00e0, 1, 1, 1); // enable edge enhancement + WRITE_REG_OR_RETURN(0x00d0, level & 0xFF); // base value + WRITE_REG_OR_RETURN(0x00d2, (level >> 8) & 0xFF); // limit + + return ret; +} + +static int set_agc_gain(sensor_t *sensor, int gain) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x0070, 1, 1, 1); // enable auto agc control + WRITE_REG_OR_RETURN(0x0068, gain & 0xFF); // Window weight setting1 + WRITE_REG_OR_RETURN(0x0069, (gain >> 8) & 0xFF); // Window weight setting2 + WRITE_REG_OR_RETURN(0x006a, (gain >> 16) & 0xFF); // Window weight setting3 + WRITE_REG_OR_RETURN(0x006b, (gain >> 24) & 0xFF); // Window weight setting4 + + return ret; +} + +static int set_aec_value(sensor_t *sensor, int value) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x0070, 0, 1, 1); // enable auto aec control + WRITE_REG_OR_RETURN(0x0072, value & 0xFF); // AE target + + return ret; +} + +static int set_awb_gain(sensor_t *sensor, int value) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00b0, 0, 1, 1); // enable awb control + WRITE_REG_OR_RETURN(0x00c8, value & 0xFF); // blue gain + WRITE_REG_OR_RETURN(0x00c9, (value>>8) & 0XFF); // red gain + return ret; +} + +static int set_saturation(sensor_t *sensor, int level) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00f5, 5, 1, 0); // enable saturation control + WRITE_REG_OR_RETURN(0x0149, level & 0xFF); // blue saturation gain (/128) + WRITE_REG_OR_RETURN(0x014a, (level>>8) & 0XFF); // red saturation gain (/128) + return ret; +} + +static int set_contrast(sensor_t *sensor, int level) +{ + int ret = 0; + SET_REG_BITS_OR_RETURN(0x00f5, 6, 1, 0); // enable contrast control + WRITE_REG_OR_RETURN(0x014b, level); // contrast coefficient(/64) + return ret; +} + +static int reset(sensor_t *sensor) +{ + int ret = set_regs(sensor, sc101iot_default_init_regs, sizeof(sc101iot_default_init_regs)/(sizeof(uint8_t) * 2)); + + // Delay + vTaskDelay(50 / portTICK_PERIOD_MS); + + // ESP_LOGI(TAG, "set_reg=%0x", set_reg(sensor, 0x0100, 0xffff, 0x00)); // write 0x80 to enter test mode if you want to test the sensor + // ESP_LOGI(TAG, "0x0100=%0x", get_reg(sensor, 0x0100, 0xffff)); + if (ret) { + ESP_LOGE(TAG, "reset fail"); + } + return ret; +} + +static int set_window(sensor_t *sensor, int offset_x, int offset_y, int w, int h) +{ + int ret = 0; + //sc:H_start={0x0172[3:0],0x0170},H_end={0x0172[7:4],0x0171}, + WRITE_REG_OR_RETURN(0x0170, offset_x & 0xff); + WRITE_REG_OR_RETURN(0x0171, (offset_x+w) & 0xff); + WRITE_REG_OR_RETURN(0x0172, ((offset_x>>8) & 0x0f) | (((offset_x+w)>>4)&0xf0)); + + //sc:V_start={0x0175[3:0],0x0173},H_end={0x0175[7:4],0x0174}, + WRITE_REG_OR_RETURN(0x0173, offset_y & 0xff); + WRITE_REG_OR_RETURN(0x0174, (offset_y+h) & 0xff); + WRITE_REG_OR_RETURN(0x0175, ((offset_y>>8) & 0x0f) | (((offset_y+h)>>4)&0xf0)); + + vTaskDelay(10 / portTICK_PERIOD_MS); + + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + if(w>SC101_MAX_FRAME_WIDTH || h > SC101_MAX_FRAME_HIGH) { + goto err; + } + + uint16_t offset_x = (SC101_MAX_FRAME_WIDTH-w) /2; + uint16_t offset_y = (SC101_MAX_FRAME_HIGH-h) /2; + + if(set_window(sensor, offset_x, offset_y, w, h)) { + goto err; + } + + sensor->status.framesize = framesize; + return 0; +err: + ESP_LOGE(TAG, "frame size err"); + return -1; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret=0; + sensor->pixformat = pixformat; + + switch (pixformat) { + case PIXFORMAT_RGB565: + case PIXFORMAT_RAW: + case PIXFORMAT_GRAYSCALE: + ESP_LOGE(TAG, "Not support"); + break; + case PIXFORMAT_YUV422: // For now, sc101 sensor only support YUV422. + break; + default: + ret = -1; + } + + return ret; +} + +static int init_status(sensor_t *sensor) +{ + return 0; +} + +static int set_dummy(sensor_t *sensor, int val){ return -1; } + +static int set_xclk(sensor_t *sensor, int timer, int xclk) +{ + int ret = 0; + sensor->xclk_freq_hz = xclk * 1000000U; + ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); + return ret; +} + +int sc101iot_detect(int slv_addr, sensor_id_t *id) +{ + if (SC101IOT_SCCB_ADDR == slv_addr) { + uint8_t MIDL = SCCB_Read(slv_addr, SC101_SENSOR_ID_LOW_REG); + uint8_t MIDH = SCCB_Read(slv_addr, SC101_SENSOR_ID_HIGH_REG); + uint16_t PID = MIDH << 8 | MIDL; + if (SC101IOT_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int sc101iot_init(sensor_t *sensor) +{ + // Set function pointers + sensor->reset = reset; + sensor->init_status = init_status; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + sensor->set_colorbar = set_colorbar; + sensor->set_raw_gma = set_raw_gma; + sensor->set_sharpness = set_sharpness; + sensor->set_agc_gain = set_agc_gain; + sensor->set_aec_value = set_aec_value; + sensor->set_awb_gain = set_awb_gain; + sensor->set_saturation= set_saturation; + sensor->set_contrast = set_contrast; + + sensor->set_denoise = set_dummy; + sensor->set_quality = set_dummy; + sensor->set_special_effect = set_dummy; + sensor->set_wb_mode = set_dummy; + sensor->set_ae_level = set_dummy; + + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_xclk = set_xclk; + + ESP_LOGD(TAG, "sc101iot Attached"); + + return 0; +} \ No newline at end of file diff --git a/code/components/esp32-camera-master/target/esp32/ll_cam.c b/code/components/esp32-camera-master/target/esp32/ll_cam.c index d0f0c862..ed7f9413 100644 --- a/code/components/esp32-camera-master/target/esp32/ll_cam.c +++ b/code/components/esp32-camera-master/target/esp32/ll_cam.c @@ -34,10 +34,14 @@ static inline int gpio_ll_get_level(gpio_dev_t *hw, int gpio_num) #include "xclk.h" #include "cam_hal.h" +#if (ESP_IDF_VERSION_MAJOR >= 4) && (ESP_IDF_VERSION_MINOR >= 3) +#include "esp_rom_gpio.h" +#endif + #if (ESP_IDF_VERSION_MAJOR >= 5) #define GPIO_PIN_INTR_POSEDGE GPIO_INTR_POSEDGE #define GPIO_PIN_INTR_NEGEDGE GPIO_INTR_NEGEDGE -#define gpio_matrix_in(a,b,c) gpio_iomux_in(a,b) +#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c) #endif static const char *TAG = "esp32 ll_cam"; @@ -233,7 +237,7 @@ static void IRAM_ATTR ll_cam_dma_isr(void *arg) //DBG_PIN_SET(0); } -bool ll_cam_stop(cam_obj_t *cam) +bool IRAM_ATTR ll_cam_stop(cam_obj_t *cam) { I2S0.conf.rx_start = 0; I2S_ISR_DISABLE(in_suc_eof); @@ -308,7 +312,7 @@ esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) I2S0.clkm_conf.clkm_div_a = 0; I2S0.clkm_conf.clkm_div_b = 0; I2S0.clkm_conf.clkm_div_num = 2; - + I2S0.fifo_conf.dscr_en = 1; I2S0.fifo_conf.rx_fifo_mod = sampling_mode; I2S0.fifo_conf.rx_fifo_mod_force_en = 1; @@ -442,9 +446,12 @@ static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ } // Calculate DMA size dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; - - ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u, dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u, image_size: %u", - node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node, dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item, image_size); + + ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u, dma_half_buffer_min: %5u, dma_half_buffer: %5u," + "lines_per_half_buffer: %2u, dma_buffer_size: %5u, image_size: %u", + (unsigned) (node_size * cam->dma_bytes_per_item), (unsigned) nodes_per_line, (unsigned) lines_per_node, + (unsigned) (dma_half_buffer_min * cam->dma_bytes_per_item), (unsigned) (dma_half_buffer * cam->dma_bytes_per_item), + (unsigned) (lines_per_half_buffer), (unsigned) (dma_buffer_size * cam->dma_bytes_per_item), (unsigned) image_size); cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; diff --git a/code/components/esp32-camera-master/target/esp32s2/ll_cam.c b/code/components/esp32-camera-master/target/esp32s2/ll_cam.c index e54b81f0..b6f0a92b 100644 --- a/code/components/esp32-camera-master/target/esp32s2/ll_cam.c +++ b/code/components/esp32-camera-master/target/esp32s2/ll_cam.c @@ -21,10 +21,15 @@ #include "xclk.h" #include "cam_hal.h" +#if (ESP_IDF_VERSION_MAJOR >= 4) && (ESP_IDF_VERSION_MINOR >= 3) +#include "esp_rom_gpio.h" +#endif + #if (ESP_IDF_VERSION_MAJOR >= 5) #define GPIO_PIN_INTR_POSEDGE GPIO_INTR_POSEDGE #define GPIO_PIN_INTR_NEGEDGE GPIO_INTR_NEGEDGE -#define gpio_matrix_in(a,b,c) gpio_iomux_in(a,b) +#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c) +#define ets_delay_us(a) esp_rom_delay_us(a) #endif static const char *TAG = "s2 ll_cam"; @@ -70,7 +75,7 @@ static void IRAM_ATTR ll_cam_dma_isr(void *arg) } } -bool ll_cam_stop(cam_obj_t *cam) +bool IRAM_ATTR ll_cam_stop(cam_obj_t *cam) { I2S0.conf.rx_start = 0; @@ -119,7 +124,7 @@ bool ll_cam_start(cam_obj_t *cam, int frame_pos) } else { I2S0.in_link.addr = ((uint32_t)&cam->frames[frame_pos].dma[0]) & 0xfffff; } - + I2S0.in_link.start = 1; I2S0.conf.rx_start = 1; return true; @@ -299,8 +304,8 @@ static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ } } - ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u", - node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node); + ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u", + (unsigned) (node_size * cam->dma_bytes_per_item), nodes_per_line, lines_per_node); cam->dma_node_buffer_size = node_size * cam->dma_bytes_per_item; @@ -332,9 +337,10 @@ static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ size_t dma_buffer_max = 2 * dma_half_buffer_max; size_t dma_buffer_size = dma_buffer_max; dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; - - ESP_LOGI(TAG, "dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u", - dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item); + + ESP_LOGI(TAG, "dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u", + (unsigned) (dma_half_buffer_min * cam->dma_bytes_per_item), (unsigned) (dma_half_buffer * cam->dma_bytes_per_item), + (unsigned) lines_per_half_buffer, (unsigned) (dma_buffer_size * cam->dma_bytes_per_item)); cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; diff --git a/code/components/esp32-camera-master/target/esp32s3/ll_cam.c b/code/components/esp32-camera-master/target/esp32s3/ll_cam.c index ce405d16..7520cac3 100644 --- a/code/components/esp32-camera-master/target/esp32s3/ll_cam.c +++ b/code/components/esp32-camera-master/target/esp32s3/ll_cam.c @@ -22,10 +22,15 @@ #include "soc/gdma_reg.h" #include "ll_cam.h" #include "cam_hal.h" +#include "esp_rom_gpio.h" #if (ESP_IDF_VERSION_MAJOR >= 5) -#define gpio_matrix_in(a,b,c) gpio_iomux_in(a,b) -#define gpio_matrix_out(a,b,c,d) gpio_iomux_out(a,b,c) +#include "soc/gpio_sig_map.h" +#include "soc/gpio_periph.h" +#include "soc/io_mux_reg.h" +#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c) +#define gpio_matrix_out(a,b,c,d) esp_rom_gpio_connect_out_signal(a,b,c,d) +#define ets_delay_us(a) esp_rom_delay_us(a) #endif static const char *TAG = "s3 ll_cam"; @@ -74,7 +79,7 @@ static void IRAM_ATTR ll_cam_dma_isr(void *arg) } } -bool ll_cam_stop(cam_obj_t *cam) +bool IRAM_ATTR ll_cam_stop(cam_obj_t *cam) { if (cam->jpeg_mode || !cam->psram_mode) { GDMA.channel[cam->dma_num].in.int_ena.in_suc_eof = 0; @@ -170,6 +175,7 @@ static esp_err_t ll_cam_dma_init(cam_obj_t *cam) } GDMA.channel[cam->dma_num].in.conf1.in_check_owner = 0; + // GDMA.channel[cam->dma_num].in.conf1.in_ext_mem_bk_size = 2; GDMA.channel[cam->dma_num].in.peri_sel.sel = 5; //GDMA.channel[cam->dma_num].in.pri.rx_pri = 1;//rx prio 0-15 @@ -178,8 +184,57 @@ static esp_err_t ll_cam_dma_init(cam_obj_t *cam) return ESP_OK; } +#if CONFIG_CAMERA_CONVERTER_ENABLED +static esp_err_t ll_cam_converter_config(cam_obj_t *cam, const camera_config_t *config) +{ + esp_err_t ret = ESP_OK; + + switch (config->conv_mode) { + case YUV422_TO_YUV420: + if (config->pixel_format != PIXFORMAT_YUV422) { + ret = ESP_FAIL; + } else { + ESP_LOGI(TAG, "YUV422 to YUV420 mode"); + LCD_CAM.cam_rgb_yuv.cam_conv_yuv2yuv_mode = 1; + LCD_CAM.cam_rgb_yuv.cam_conv_yuv_mode = 0; + LCD_CAM.cam_rgb_yuv.cam_conv_trans_mode = 1; + } + break; + case YUV422_TO_RGB565: + if (config->pixel_format != PIXFORMAT_YUV422) { + ret = ESP_FAIL; + } else { + ESP_LOGI(TAG, "YUV422 to RGB565 mode"); + LCD_CAM.cam_rgb_yuv.cam_conv_yuv2yuv_mode = 3; + LCD_CAM.cam_rgb_yuv.cam_conv_yuv_mode = 0; + LCD_CAM.cam_rgb_yuv.cam_conv_trans_mode = 0; + } + break; + default: + break; + } +#if CONFIG_LCD_CAM_CONV_BT709_ENABLED + LCD_CAM.cam_rgb_yuv.cam_conv_protocol_mode = 1; +#else + LCD_CAM.cam_rgb_yuv.cam_conv_protocol_mode = 0; +#endif +#if CONFIG_LCD_CAM_CONV_FULL_RANGE_ENABLED + LCD_CAM.cam_rgb_yuv.cam_conv_data_out_mode = 1; + LCD_CAM.cam_rgb_yuv.cam_conv_data_in_mode = 1; +#else + LCD_CAM.cam_rgb_yuv.cam_conv_data_out_mode = 0; + LCD_CAM.cam_rgb_yuv.cam_conv_data_in_mode = 0; +#endif + LCD_CAM.cam_rgb_yuv.cam_conv_mode_8bits_on = 1; + LCD_CAM.cam_rgb_yuv.cam_conv_bypass = 1; + cam->conv_mode = config->conv_mode; + return ret; +} +#endif + esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) { + esp_err_t ret = ESP_OK; if (REG_GET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN) == 0) { REG_CLR_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN); REG_SET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN); @@ -188,7 +243,7 @@ esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) } LCD_CAM.cam_ctrl.val = 0; - + LCD_CAM.cam_ctrl.cam_clkm_div_b = 0; LCD_CAM.cam_ctrl.cam_clkm_div_a = 0; LCD_CAM.cam_ctrl.cam_clkm_div_num = 160000000 / config->xclk_freq_hz; @@ -215,15 +270,21 @@ esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) LCD_CAM.cam_rgb_yuv.val = 0; +#if CONFIG_CAMERA_CONVERTER_ENABLED + if (config->conv_mode) { + ret = ll_cam_converter_config(cam, config); + if(ret != ESP_OK) { + return ret; + } + } +#endif + LCD_CAM.cam_ctrl.cam_update = 1; LCD_CAM.cam_ctrl1.cam_start = 1; - esp_err_t err = ll_cam_dma_init(cam); - if(err != ESP_OK) { - return err; - } - - return ESP_OK; + ret = ll_cam_dma_init(cam); + + return ret; } void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en) @@ -262,11 +323,12 @@ esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config) gpio_set_pull_mode(data_pins[i], GPIO_FLOATING); gpio_matrix_in(data_pins[i], CAM_DATA_IN0_IDX + i, false); } - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_xclk], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_xclk, GPIO_MODE_OUTPUT); - gpio_set_pull_mode(config->pin_xclk, GPIO_FLOATING); - gpio_matrix_out(config->pin_xclk, CAM_CLK_IDX, false, false); + if (config->pin_xclk >= 0) { + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_xclk], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_xclk, GPIO_MODE_OUTPUT); + gpio_set_pull_mode(config->pin_xclk, GPIO_FLOATING); + gpio_matrix_out(config->pin_xclk, CAM_CLK_IDX, false, false); + } return ESP_OK; } @@ -338,8 +400,8 @@ static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ } } - ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u", - node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node); + ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u", + (unsigned) (node_size * cam->dma_bytes_per_item), (unsigned) nodes_per_line, (unsigned) lines_per_node); cam->dma_node_buffer_size = node_size * cam->dma_bytes_per_item; @@ -371,9 +433,10 @@ static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ if (!cam->psram_mode) { dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; } - - ESP_LOGI(TAG, "dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u", - dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item); + + ESP_LOGI(TAG, "dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u", + (unsigned) (dma_half_buffer_min * cam->dma_bytes_per_item), (unsigned) (dma_half_buffer * cam->dma_bytes_per_item), + (unsigned) lines_per_half_buffer, (unsigned) (dma_buffer_size * cam->dma_bytes_per_item)); cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; @@ -382,7 +445,7 @@ static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ } bool ll_cam_dma_sizes(cam_obj_t *cam) -{ +{ cam->dma_bytes_per_item = 1; if (cam->jpeg_mode) { if (cam->psram_mode) { @@ -433,8 +496,22 @@ esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_ } cam->fb_bytes_per_pixel = 1; // frame buffer stores Y8 } else if (pix_format == PIXFORMAT_YUV422 || pix_format == PIXFORMAT_RGB565) { - cam->in_bytes_per_pixel = 2; // camera sends YU/YV +#if CONFIG_CAMERA_CONVERTER_ENABLED + switch (cam->conv_mode) { + case YUV422_TO_YUV420: + cam->in_bytes_per_pixel = 1.5; // for DMA receive + cam->fb_bytes_per_pixel = 1.5; // frame buffer stores YUV420 + break; + case YUV422_TO_RGB565: + default: + cam->in_bytes_per_pixel = 2; // for DMA receive cam->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565 + break; + } +#else + cam->in_bytes_per_pixel = 2; // for DMA receive + cam->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565 +#endif } else if (pix_format == PIXFORMAT_JPEG) { cam->in_bytes_per_pixel = 1; cam->fb_bytes_per_pixel = 1; diff --git a/code/components/esp32-camera-master/target/private_include/ll_cam.h b/code/components/esp32-camera-master/target/private_include/ll_cam.h index 7d30c370..34c8da36 100644 --- a/code/components/esp32-camera-master/target/private_include/ll_cam.h +++ b/code/components/esp32-camera-master/target/private_include/ll_cam.h @@ -101,7 +101,7 @@ typedef struct { QueueHandle_t frame_buffer_queue; TaskHandle_t task_handle; intr_handle_t cam_intr_handle; - + uint8_t dma_num;//ESP32-S3 intr_handle_t dma_intr_handle;//ESP32-S3 @@ -116,8 +116,14 @@ typedef struct { //for RGB/YUV modes uint16_t width; uint16_t height; +#if CONFIG_CAMERA_CONVERTER_ENABLED + float in_bytes_per_pixel; + float fb_bytes_per_pixel; + camera_conv_mode_t conv_mode; +#else uint8_t in_bytes_per_pixel; uint8_t fb_bytes_per_pixel; +#endif uint32_t fb_size; cam_state_t state; @@ -134,7 +140,7 @@ esp_err_t ll_cam_init_isr(cam_obj_t *cam); void ll_cam_do_vsync(cam_obj_t *cam); uint8_t ll_cam_get_dma_align(cam_obj_t *cam); bool ll_cam_dma_sizes(cam_obj_t *cam); -size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len); +size_t ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len); esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid); // implemented in cam_hal diff --git a/code/components/esp32-camera-master/test/test_camera.c b/code/components/esp32-camera-master/test/test_camera.c index 89ad0619..f03b7c6a 100644 --- a/code/components/esp32-camera-master/test/test_camera.c +++ b/code/components/esp32-camera-master/test/test_camera.c @@ -6,6 +6,7 @@ #include "unity.h" #include #include "esp_log.h" +#include "driver/i2c.h" #include "esp_camera.h" @@ -105,11 +106,16 @@ #endif +#define I2C_MASTER_SCL_IO 4 /*!< GPIO number used for I2C master clock */ +#define I2C_MASTER_SDA_IO 5 /*!< GPIO number used for I2C master data */ +#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ +#define I2C_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */ + static const char *TAG = "test camera"; typedef void (*decode_func_t)(uint8_t *jpegbuffer, uint32_t size, uint8_t *outbuffer); -static esp_err_t init_camera(uint32_t xclk_freq_hz, pixformat_t pixel_format, framesize_t frame_size, uint8_t fb_count) +static esp_err_t init_camera(uint32_t xclk_freq_hz, pixformat_t pixel_format, framesize_t frame_size, uint8_t fb_count, int sccb_sda_gpio_num, int sccb_port) { framesize_t size_bak = frame_size; if (PIXFORMAT_JPEG == pixel_format && FRAMESIZE_SVGA > frame_size) { @@ -119,8 +125,9 @@ static esp_err_t init_camera(uint32_t xclk_freq_hz, pixformat_t pixel_format, fr .pin_pwdn = PWDN_GPIO_NUM, .pin_reset = RESET_GPIO_NUM, .pin_xclk = XCLK_GPIO_NUM, - .pin_sscb_sda = SIOD_GPIO_NUM, - .pin_sscb_scl = SIOC_GPIO_NUM, + .pin_sccb_sda = sccb_sda_gpio_num, // If pin_sccb_sda is -1, sccb will use the already initialized i2c port specified by `sccb_i2c_port`. + .pin_sccb_scl = SIOC_GPIO_NUM, + .sccb_i2c_port = sccb_port, .pin_d7 = Y9_GPIO_NUM, .pin_d6 = Y8_GPIO_NUM, @@ -226,7 +233,7 @@ static void camera_performance_test(uint32_t xclk_freq, uint32_t pic_num) { esp_err_t ret = ESP_OK; //detect sensor information - TEST_ESP_OK(init_camera(20000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); + TEST_ESP_OK(init_camera(20000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2, SIOD_GPIO_NUM, -1)); sensor_t *s = esp_camera_sensor_get(); camera_sensor_info_t *info = esp_camera_sensor_get_info(&s->id); TEST_ASSERT_NOT_NULL(info); @@ -249,7 +256,7 @@ static void camera_performance_test(uint32_t xclk_freq, uint32_t pic_num) for (; format_s <= format_e; format_s++) { for (size_t i = 0; i <= max_size; i++) { ESP_LOGI(TAG, "\n\n===> Testing format:%s resolution: %d x %d <===", get_cam_format_name(*format_s), resolution[i].width, resolution[i].height); - ret = init_camera(xclk_freq, *format_s, i, 2); + ret = init_camera(xclk_freq, *format_s, i, 2, SIOD_GPIO_NUM, -1); vTaskDelay(100 / portTICK_RATE_MS); if (ESP_OK != ret) { ESP_LOGW(TAG, "Testing init failed :-(, skip this item"); @@ -276,7 +283,7 @@ static void camera_performance_test(uint32_t xclk_freq, uint32_t pic_num) TEST_CASE("Camera driver init, deinit test", "[camera]") { uint64_t t1 = esp_timer_get_time(); - TEST_ESP_OK(init_camera(20000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); + TEST_ESP_OK(init_camera(20000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2, SIOD_GPIO_NUM, -1)); uint64_t t2 = esp_timer_get_time(); ESP_LOGI(TAG, "Camera init time %llu ms", (t2 - t1) / 1000); @@ -285,7 +292,7 @@ TEST_CASE("Camera driver init, deinit test", "[camera]") TEST_CASE("Camera driver take RGB565 picture test", "[camera]") { - TEST_ESP_OK(init_camera(10000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); + TEST_ESP_OK(init_camera(10000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2, SIOD_GPIO_NUM, -1)); vTaskDelay(500 / portTICK_RATE_MS); ESP_LOGI(TAG, "Taking picture..."); camera_fb_t *pic = esp_camera_fb_get(); @@ -301,7 +308,7 @@ TEST_CASE("Camera driver take RGB565 picture test", "[camera]") TEST_CASE("Camera driver take YUV422 picture test", "[camera]") { - TEST_ESP_OK(init_camera(10000000, PIXFORMAT_YUV422, FRAMESIZE_QVGA, 2)); + TEST_ESP_OK(init_camera(10000000, PIXFORMAT_YUV422, FRAMESIZE_QVGA, 2, SIOD_GPIO_NUM, -1)); vTaskDelay(500 / portTICK_RATE_MS); ESP_LOGI(TAG, "Taking picture..."); camera_fb_t *pic = esp_camera_fb_get(); @@ -317,7 +324,7 @@ TEST_CASE("Camera driver take YUV422 picture test", "[camera]") TEST_CASE("Camera driver take JPEG picture test", "[camera]") { - TEST_ESP_OK(init_camera(20000000, PIXFORMAT_JPEG, FRAMESIZE_QVGA, 2)); + TEST_ESP_OK(init_camera(20000000, PIXFORMAT_JPEG, FRAMESIZE_QVGA, 2, SIOD_GPIO_NUM, -1)); vTaskDelay(500 / portTICK_RATE_MS); ESP_LOGI(TAG, "Taking picture..."); camera_fb_t *pic = esp_camera_fb_get(); @@ -484,6 +491,25 @@ static void img_jpeg_decode_test(uint16_t pic_index, uint16_t lib_index) jpg_decode_test(lib_index, DECODE_RGB565, imgs[pic_index].buf, imgs[pic_index].length, imgs[pic_index].w, imgs[pic_index].h, 16); } +/** + * @brief i2c master initialization + */ +static esp_err_t i2c_master_init(int i2c_port) +{ + i2c_config_t conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = I2C_MASTER_SDA_IO, + .scl_io_num = I2C_MASTER_SCL_IO, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .master.clk_speed = I2C_MASTER_FREQ_HZ, + }; + + i2c_param_config(i2c_port, &conf); + + return i2c_driver_install(i2c_port, conf.mode, 0, 0, 0); +} + TEST_CASE("Conversions image 227x149 jpeg decode test", "[camera]") { img_jpeg_decode_test(0, 0); @@ -498,3 +524,12 @@ TEST_CASE("Conversions image 480x320 jpeg decode test", "[camera]") { img_jpeg_decode_test(2, 0); } + +TEST_CASE("Camera driver uses an i2c port initialized by other devices test", "[camera]") +{ + TEST_ESP_OK(i2c_master_init(I2C_MASTER_NUM)); + TEST_ESP_OK(init_camera(20000000, PIXFORMAT_JPEG, FRAMESIZE_QVGA, 2, -1, I2C_MASTER_NUM)); + vTaskDelay(500 / portTICK_RATE_MS); + TEST_ESP_OK(esp_camera_deinit()); + TEST_ESP_OK(i2c_driver_delete(I2C_MASTER_NUM)); +} diff --git a/code/components/esp32-camera-master_20220924.zip b/code/components/esp32-camera-master_20220924.zip new file mode 100644 index 00000000..0ed83dd1 Binary files /dev/null and b/code/components/esp32-camera-master_20220924.zip differ diff --git a/code/components/tflite-lib/CMakeLists.txt b/code/components/tflite-lib/CMakeLists.txt index aaf56231..e09fd092 100644 --- a/code/components/tflite-lib/CMakeLists.txt +++ b/code/components/tflite-lib/CMakeLists.txt @@ -51,18 +51,28 @@ set(lib_srcs "${tflite_dir}/kernels/internal/quantization_util.cc" "${tflite_dir}/schema/schema_utils.cc") +set(priv_req esp-nn) + +# include component requirements which were introduced after IDF version 4.1 +if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.1") + list(APPEND priv_req esp_timer driver) +endif() + idf_component_register( SRCS "${lib_srcs}" INCLUDE_DIRS "." "third_party/gemmlowp" "third_party/flatbuffers/include" "third_party/ruy" "third_party/kissfft" - REQUIRES "esp-nn") + REQUIRES ${pub_req} + PRIV_REQUIRES ${priv_req}) # Reduce the level of paranoia to be able to compile TF sources target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-maybe-uninitialized -Wno-missing-field-initializers + -Wno-error=sign-compare + -Wno-error=double-promotion -DESP_NN # enables ESP-NN optimizations by Espressif -Wno-type-limits) diff --git a/code/components/tflite-lib/tensorflow/lite/builtin_ops.h b/code/components/tflite-lib/tensorflow/lite/builtin_ops.h index 01156c39..33707308 100644 --- a/code/components/tflite-lib/tensorflow/lite/builtin_ops.h +++ b/code/components/tflite-lib/tensorflow/lite/builtin_ops.h @@ -185,6 +185,7 @@ typedef enum { kTfLiteBuiltinUnsortedSegmentSum = 155, kTfLiteBuiltinAtan2 = 156, kTfLiteBuiltinUnsortedSegmentMin = 157, + kTfLiteBuiltinSign = 158, } TfLiteBuiltinOperator; #ifdef __cplusplus diff --git a/code/components/tflite-lib/tensorflow/lite/c/common.cc b/code/components/tflite-lib/tensorflow/lite/c/common.cc index ae5c44b5..f10d3bfe 100644 --- a/code/components/tflite-lib/tensorflow/lite/c/common.cc +++ b/code/components/tflite-lib/tensorflow/lite/c/common.cc @@ -283,4 +283,25 @@ const char* TfLiteTypeGetName(TfLiteType type) { TfLiteDelegate TfLiteDelegateCreate() { return TfLiteDelegate{}; } +struct TfLiteOpaqueDelegateStruct* TfLiteOpaqueDelegateCreate( + const TfLiteOpaqueDelegateBuilder* opaque_delegate_builder) { + if (!opaque_delegate_builder) return nullptr; + + TfLiteDelegate* result = new TfLiteDelegate{}; + result->opaque_delegate_builder = new TfLiteOpaqueDelegateBuilder{}; + *(result->opaque_delegate_builder) = *opaque_delegate_builder; + + return reinterpret_cast(result); +} + +void TfLiteOpaqueDelegateDelete( + const struct TfLiteOpaqueDelegateStruct* opaque_delegate) { + if (!opaque_delegate) return; + + const TfLiteDelegate* tflite_delegate = + reinterpret_cast(opaque_delegate); + delete tflite_delegate->opaque_delegate_builder; + delete tflite_delegate; +} + } // extern "C" diff --git a/code/components/tflite-lib/tensorflow/lite/c/common.h b/code/components/tflite-lib/tensorflow/lite/c/common.h index cc856f9a..f60b65ed 100644 --- a/code/components/tflite-lib/tensorflow/lite/c/common.h +++ b/code/components/tflite-lib/tensorflow/lite/c/common.h @@ -63,6 +63,8 @@ typedef enum TfLiteExternalContextType { struct TfLiteContext; struct TfLiteDelegate; struct TfLiteRegistration; +struct TfLiteOpaqueDelegateStruct; +struct TfLiteOpaqueDelegateBuilder; // An external context is a collection of information unrelated to the TF Lite // framework, but useful to a subset of the ops. TF Lite knows very little @@ -973,7 +975,7 @@ typedef enum TfLiteDelegateFlags { typedef struct TfLiteDelegate { // Data that delegate needs to identify itself. This data is owned by the // delegate. The delegate is owned in the user code, so the delegate is - // responsible for doing this when it is destroyed. + // responsible for deallocating this when it is destroyed. void* data_; // Invoked by ModifyGraphWithDelegate. This prepare is called, giving the @@ -1010,12 +1012,83 @@ typedef struct TfLiteDelegate { // Bitmask flags. See the comments in `TfLiteDelegateFlags`. int64_t flags; + + // The opaque delegate builder associated with this object. If set then the + // TF Lite runtime will give precedence to this field. E.g. instead of + // invoking 'Prepare' via the function pointer inside the 'TfLiteDelegate' + // object, the runtime will first check if the corresponding function + // pointer inside 'opaque_delegate_builder' is set and if so invoke that. + // + // If this field is non-null, then the 'Prepare' field (of the + // 'TfLiteDelegate') should be null. + struct TfLiteOpaqueDelegateBuilder* opaque_delegate_builder; } TfLiteDelegate; // Build a 'null' delegate, with all the fields properly set to their default // values. TfLiteDelegate TfLiteDelegateCreate(void); +// `TfLiteOpaqueDelegateBuilder` is used for constructing +// `TfLiteOpaqueDelegateStruct`, see `TfLiteOpaqueDelegateCreate` below. Note: +// This struct is not ABI stable. +// +// For forward source compatibility `TfLiteOpaqueDelegateBuilder` objects should +// be brace-initialized, so that all fields (including any that might be added +// in the future) get zero-initialized. The purpose of each field is exactly +// the same as with `TfLiteDelegate`. +// +// WARNING: This is an experimental interface that is subject to change. +typedef struct TfLiteOpaqueDelegateBuilder { + // Data that delegate needs to identify itself. This data is owned by the + // delegate. The delegate is owned in the user code, so the delegate is + // responsible for deallocating this when it is destroyed. + void* data; + // Invoked by ModifyGraphWithDelegate. This prepare is called, giving the + // delegate a view of the current graph through TfLiteContext*. It typically + // will look at the nodes and call ReplaceNodeSubsetsWithDelegateKernels() + // to ask the TensorFlow lite runtime to create macro-nodes to represent + // delegated subgraphs of the original graph. + TfLiteStatus (*Prepare)(TfLiteOpaqueContext* context, // NOLINT + struct TfLiteOpaqueDelegateStruct* delegate, + void* data); + // Copies the data from delegate buffer handle into raw memory of the given + // 'tensor'. Note that the delegate is allowed to allocate the raw bytes as + // long as it follows the rules for kTfLiteDynamic tensors, in which case this + // cannot be null. + TfLiteStatus (*CopyFromBufferHandle)( // NOLINT + TfLiteOpaqueContext* context, struct TfLiteOpaqueDelegateStruct* delegate, + void* data, TfLiteBufferHandle buffer_handle, TfLiteOpaqueTensor* tensor); + // Copies the data from raw memory of the given 'tensor' to delegate buffer + // handle. This can be null if the delegate doesn't use its own buffer. + TfLiteStatus (*CopyToBufferHandle)( // NOLINT + TfLiteOpaqueContext* context, struct TfLiteOpaqueDelegateStruct* delegate, + void* data, TfLiteBufferHandle buffer_handle, TfLiteOpaqueTensor* tensor); + // Frees the Delegate Buffer Handle. Note: This only frees the handle, but + // this doesn't release the underlying resource (e.g. textures). The + // resources are either owned by application layer or the delegate. + // This can be null if the delegate doesn't use its own buffer. + void (*FreeBufferHandle)(TfLiteOpaqueContext* context, // NOLINT + struct TfLiteOpaqueDelegateStruct* delegate, + void* data, TfLiteBufferHandle* handle); + // Bitmask flags. See the comments in `TfLiteDelegateFlags`. + int64_t flags; +} TfLiteOpaqueDelegateBuilder; + +// Creates an opaque delegate and returns its address. The opaque delegate will +// behave according to the provided 'opaque_delegate_builder'. The lifetime of +// the fields within the 'opaque_delegate_builder' must outlive any interaction +// between the runtime and the returned 'TfLiteOpaqueDelegateStruct'. The +// returned address should be passed to 'TfLiteOpaqueDelegateDelete' for +// deletion. If 'opaque_delegate_builder' is a null pointer, then a null +// pointer will be returned. +struct TfLiteOpaqueDelegateStruct* TfLiteOpaqueDelegateCreate( + const TfLiteOpaqueDelegateBuilder* opaque_delegate_builder); + +// Deletes the provided opaque 'delegate'. This function has no effect if the +// 'delegate' is a null pointer. +void TfLiteOpaqueDelegateDelete( + const struct TfLiteOpaqueDelegateStruct* delegate); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/code/components/tflite-lib/tensorflow/lite/context_util.h b/code/components/tflite-lib/tensorflow/lite/context_util.h index 7c8a5abd..ed42cc73 100644 --- a/code/components/tflite-lib/tensorflow/lite/context_util.h +++ b/code/components/tflite-lib/tensorflow/lite/context_util.h @@ -12,8 +12,9 @@ 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. ==============================================================================*/ -// This provides a few C++ helpers that are useful for manipulating C structures -// in C++. +/// \file +/// This provides a few C++ helpers that are useful for manipulating C +/// structures in C++. #ifndef TENSORFLOW_LITE_CONTEXT_UTIL_H_ #define TENSORFLOW_LITE_CONTEXT_UTIL_H_ @@ -23,13 +24,14 @@ limitations under the License. namespace tflite { -// Provide a range iterable wrapper for TfLiteIntArray* (C lists that TfLite -// C api uses. Can't use the google array_view, since we can't depend on even +/// Provides a range iterable wrapper for TfLiteIntArray* (C lists) that TfLite +/// C api uses. +// Can't use the google array_view, since we can't depend on even // absl for embedded device reasons. class TfLiteIntArrayView { public: - // Construct a view of a TfLiteIntArray*. Note, `int_array` should be non-null - // and this view does not take ownership of it. + /// Construct a view of a TfLiteIntArray*. Note, `int_array` should be + /// non-null and this view does not take ownership of it. explicit TfLiteIntArrayView(const TfLiteIntArray* int_array) : int_array_(int_array) {} diff --git a/code/components/tflite-lib/tensorflow/lite/core/api/flatbuffer_conversions.cc b/code/components/tflite-lib/tensorflow/lite/core/api/flatbuffer_conversions.cc index 1ecefa47..37d7661c 100644 --- a/code/components/tflite-lib/tensorflow/lite/core/api/flatbuffer_conversions.cc +++ b/code/components/tflite-lib/tensorflow/lite/core/api/flatbuffer_conversions.cc @@ -457,6 +457,10 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type, return ParseRsqrt(op, error_reporter, allocator, builtin_data); } + case BuiltinOperator_SELECT_V2: { + return ParseSelectV2(op, error_reporter, allocator, builtin_data); + } + case BuiltinOperator_SHAPE: { return ParseShape(op, error_reporter, allocator, builtin_data); } @@ -865,7 +869,6 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type, case BuiltinOperator_RELU_0_TO_1: case BuiltinOperator_SCATTER_ND: case BuiltinOperator_SELECT: - case BuiltinOperator_SELECT_V2: case BuiltinOperator_SLICE: case BuiltinOperator_TILE: case BuiltinOperator_TOPK_V2: @@ -881,6 +884,7 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type, case BuiltinOperator_UNSORTED_SEGMENT_PROD: case BuiltinOperator_UNSORTED_SEGMENT_SUM: case BuiltinOperator_ATAN2: + case BuiltinOperator_SIGN: case BuiltinOperator_WHERE: return kTfLiteOk; case BuiltinOperator_PLACEHOLDER_FOR_GREATER_OP_CODES: @@ -1982,6 +1986,14 @@ TfLiteStatus ParseRsqrt(const Operator*, ErrorReporter*, BuiltinDataAllocator*, return kTfLiteOk; } +// We have this parse function instead of directly returning kTfLiteOk from the +// switch-case in ParseOpData because this function is used as part of the +// selective registration for the OpResolver implementation in micro. +TfLiteStatus ParseSelectV2(const Operator*, ErrorReporter*, + BuiltinDataAllocator*, void**) { + return kTfLiteOk; +} + TfLiteStatus ParseShape(const Operator* op, ErrorReporter* error_reporter, BuiltinDataAllocator* allocator, void** builtin_data) { SafeBuiltinDataAllocator safe_allocator(allocator); diff --git a/code/components/tflite-lib/tensorflow/lite/core/api/flatbuffer_conversions.h b/code/components/tflite-lib/tensorflow/lite/core/api/flatbuffer_conversions.h index ed317b81..c7653f01 100644 --- a/code/components/tflite-lib/tensorflow/lite/core/api/flatbuffer_conversions.h +++ b/code/components/tflite-lib/tensorflow/lite/core/api/flatbuffer_conversions.h @@ -319,6 +319,10 @@ TfLiteStatus ParseRound(const Operator* op, ErrorReporter* error_reporter, TfLiteStatus ParseRsqrt(const Operator* op, ErrorReporter* error_reporter, BuiltinDataAllocator* allocator, void** builtin_data); +TfLiteStatus ParseSelectV2(const Operator* op, ErrorReporter* error_reporter, + BuiltinDataAllocator* allocator, + void** builtin_data); + TfLiteStatus ParseShape(const Operator* op, ErrorReporter* error_reporter, BuiltinDataAllocator* allocator, void** builtin_data); diff --git a/code/components/tflite-lib/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.cc b/code/components/tflite-lib/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.cc index 55457f4d..f1e781b2 100644 --- a/code/components/tflite-lib/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.cc +++ b/code/components/tflite-lib/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.cc @@ -1,3 +1,5 @@ +#include + #include "tensorflow/lite/experimental/microfrontend/lib/kiss_fft_common.h" #define FIXED_POINT 16 diff --git a/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/hard_swish.h b/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/hard_swish.h index d9fe32e9..81fcd63e 100644 --- a/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/hard_swish.h +++ b/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/hard_swish.h @@ -12,8 +12,8 @@ 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. ==============================================================================*/ -#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ACTIVATIONS_H_ -#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ACTIVATIONS_H_ +#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_HARD_SWISH_H_ +#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_HARD_SWISH_H_ #include @@ -165,4 +165,4 @@ inline void HardSwish(const HardSwishParams& params, } // namespace reference_ops } // namespace tflite -#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CONV_H_ +#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_HARD_SWISH_H_ diff --git a/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/mul.h b/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/mul.h index b977104c..53197732 100644 --- a/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/mul.h +++ b/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/mul.h @@ -16,6 +16,7 @@ limitations under the License. #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_MUL_H_ #include +#include #include "tensorflow/lite/kernels/internal/common.h" @@ -61,6 +62,20 @@ inline void Mul(const ArithmeticParams& params, } } +inline void Mul(const ArithmeticParams& params, + const RuntimeShape& input1_shape, + const std::complex* input1_data, + const RuntimeShape& input2_shape, + const std::complex* input2_data, + const RuntimeShape& output_shape, + std::complex* output_data) { + const int flat_size = + MatchingExtendedShapeFlatSize(input1_shape, input2_shape, output_shape); + for (int i = 0; i < flat_size; ++i) { + output_data[i] = input1_data[i] * input2_data[i]; + } +} + inline void Mul(const ArithmeticParams& params, const RuntimeShape& input1_shape, const uint8_t* input1_data, const RuntimeShape& input2_shape, const uint8_t* input2_data, @@ -162,6 +177,37 @@ void BroadcastMul4DSlow(const ArithmeticParams& params, } } +inline void BroadcastMul4DSlow(const ArithmeticParams& params, + const RuntimeShape& unextended_input1_shape, + const std::complex* input1_data, + const RuntimeShape& unextended_input2_shape, + const std::complex* input2_data, + const RuntimeShape& unextended_output_shape, + std::complex* output_data) { + TFLITE_DCHECK_LE(unextended_input1_shape.DimensionsCount(), 4); + TFLITE_DCHECK_LE(unextended_input2_shape.DimensionsCount(), 4); + TFLITE_DCHECK_LE(unextended_output_shape.DimensionsCount(), 4); + const RuntimeShape output_shape = + RuntimeShape::ExtendedShape(4, unextended_output_shape); + + NdArrayDesc<4> desc1; + NdArrayDesc<4> desc2; + NdArrayDescsForElementwiseBroadcast(unextended_input1_shape, + unextended_input2_shape, &desc1, &desc2); + + for (int b = 0; b < output_shape.Dims(0); ++b) { + for (int y = 0; y < output_shape.Dims(1); ++y) { + for (int x = 0; x < output_shape.Dims(2); ++x) { + for (int c = 0; c < output_shape.Dims(3); ++c) { + output_data[Offset(output_shape, b, y, x, c)] = + input1_data[SubscriptToIndex(desc1, b, y, x, c)] * + input2_data[SubscriptToIndex(desc2, b, y, x, c)]; + } + } + } + } +} + } // namespace reference_ops } // namespace tflite diff --git a/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/select.h b/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/select.h new file mode 100644 index 00000000..82b6097c --- /dev/null +++ b/code/components/tflite-lib/tensorflow/lite/kernels/internal/reference/select.h @@ -0,0 +1,151 @@ +/* Copyright 2022 The TensorFlow 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. +==============================================================================*/ +#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SELECT_H_ +#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SELECT_H_ + +#include + +#include "ruy/profiler/instrumentation.h" // from @ruy +#include "tensorflow/lite/kernels/internal/common.h" +#include "tensorflow/lite/kernels/internal/types.h" + +namespace tflite { +namespace reference_ops { + +template +void Select(const RuntimeShape& input_condition_shape, + const D* input_condition_data, const RuntimeShape& input_x_shape, + const T* input_x_data, const RuntimeShape& input_y_shape, + const T* input_y_data, const RuntimeShape& output_shape, + T* output_data) { + ruy::profiler::ScopeLabel label("Select"); + int64_t flatsize; + // Allow select operator executions on mixed scalar tensors and one element + // tensors. + if (input_condition_shape.FlatSize() == 1 && input_x_shape.FlatSize() == 1 && + input_y_shape.FlatSize() == 1 && output_shape.FlatSize() == 1) { + flatsize = 1; + } else { + flatsize = MatchingFlatSize(input_condition_shape, input_x_shape, + input_y_shape, output_shape); + } + for (int64_t i = 0; i < flatsize; ++i) { + output_data[i] = + input_condition_data[i] ? input_x_data[i] : input_y_data[i]; + } +} + +template +void RankOneSelect(const RuntimeShape& input_condition_shape, + const D* input_condition_data, + const RuntimeShape& input_x_shape, const T* input_x_data, + const RuntimeShape& input_y_shape, const T* input_y_data, + const RuntimeShape& output_shape, T* output_data) { + ruy::profiler::ScopeLabel label("Select/RankOneSelect"); + const int64_t outer_size = input_condition_shape.FlatSize(); + int64_t inner_size; + if (input_condition_shape.DimensionsCount() == 0) { + inner_size = MatchingFlatSize(input_x_shape, input_y_shape, output_shape); + } else { + TFLITE_DCHECK_EQ( + MatchingDim(input_x_shape, 0, input_y_shape, 0, output_shape, 0), + outer_size); + inner_size = + MatchingFlatSizeSkipDim(input_x_shape, 0, input_y_shape, output_shape); + } + + int64_t offset = 0; + for (int64_t i = 0; i < outer_size; i++) { + const T* input_data = input_condition_data[i] ? input_x_data : input_y_data; + memcpy(output_data + offset, input_data + offset, inner_size * sizeof(T)); + offset += inner_size; + } +} + +template +void BroadcastSelect5DSlow(const RuntimeShape& input_condition_shape, + const D* input_condition_data, + const RuntimeShape& input_x_shape, + const T* input_x_data, + const RuntimeShape& input_y_shape, + const T* input_y_data, + const RuntimeShape& output_shape, T* output_data) { + ruy::profiler::ScopeLabel label("Select/BroadcastSelectSlow"); + TFLITE_DCHECK_LE(input_condition_shape.DimensionsCount(), 5); + TFLITE_DCHECK_LE(input_x_shape.DimensionsCount(), 5); + TFLITE_DCHECK_LE(input_y_shape.DimensionsCount(), 5); + TFLITE_DCHECK_LE(output_shape.DimensionsCount(), 5); + + NdArrayDesc<5> desc_condition; + NdArrayDesc<5> desc_x; + NdArrayDesc<5> desc_y; + NdArrayDesc<5> desc_output; + const RuntimeShape extended_output_shape = + RuntimeShape::ExtendedShape(5, output_shape); + CopyDimsToDesc(extended_output_shape, &desc_output); + NdArrayDescsForElementwiseBroadcast(input_condition_shape, input_x_shape, + input_y_shape, &desc_condition, &desc_x, + &desc_y); + + // In Tensorflow, the dimensions are canonically named (batch_number, row, + // col, channel), with extents (batches, height, width, depth), with the + // trailing dimension changing most rapidly (channels has the smallest + // stride, typically 1 element). + // + // In generated C code, we store arrays with the dimensions reversed. The + // first dimension has smallest stride. + // + // We name our variables by their Tensorflow convention, but generate C code + // nesting loops such that the innermost loop has the smallest stride for + // the best cache behavior. + for (int n = 0; n < desc_output.extents[0]; ++n) { + int out_idx_n = desc_output.extents[1] * n; + int cond_idx_n = desc_condition.strides[0] * n; + int in_idx1_n = desc_x.strides[0] * n; + int in_idx2_n = desc_y.strides[0] * n; + for (int b = 0; b < desc_output.extents[1]; ++b) { + int out_idx_b = (out_idx_n + b) * desc_output.extents[2]; + int cond_idx_b = cond_idx_n + desc_condition.strides[1] * b; + int in_idx1_b = in_idx1_n + desc_x.strides[1] * b; + int in_idx2_b = in_idx2_n + desc_y.strides[1] * b; + for (int y = 0; y < desc_output.extents[2]; ++y) { + int out_idx_y = (out_idx_b + y) * desc_output.extents[3]; + int cond_idx_y = cond_idx_b + desc_condition.strides[2] * y; + int in_idx1_y = in_idx1_b + desc_x.strides[2] * y; + int in_idx2_y = in_idx2_b + desc_y.strides[2] * y; + for (int x = 0; x < desc_output.extents[3]; ++x) { + int out_idx = (out_idx_y + x) * desc_output.extents[4]; + int cond_idx = cond_idx_y + desc_condition.strides[3] * x; + int in_idx1 = in_idx1_y + desc_x.strides[3] * x; + int in_idx2 = in_idx2_y + desc_y.strides[3] * x; + for (int c = 0; c < desc_output.extents[4]; ++c) { + output_data[out_idx] = input_condition_data[cond_idx] + ? input_x_data[in_idx1] + : input_y_data[in_idx2]; + out_idx++; + cond_idx += desc_condition.strides[4]; + in_idx1 += desc_x.strides[4]; + in_idx2 += desc_y.strides[4]; + } + } + } + } + } +} + +} // namespace reference_ops +} // namespace tflite + +#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SELECT_H_ diff --git a/code/components/tflite-lib/tensorflow/lite/micro/all_ops_resolver.cc b/code/components/tflite-lib/tensorflow/lite/micro/all_ops_resolver.cc index abbe34e7..df792264 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/all_ops_resolver.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/all_ops_resolver.cc @@ -92,6 +92,7 @@ AllOpsResolver::AllOpsResolver() { AddResizeNearestNeighbor(); AddRound(); AddRsqrt(); + AddSelectV2(); AddShape(); AddSin(); AddSlice(); @@ -102,6 +103,7 @@ AllOpsResolver::AllOpsResolver() { AddSplitV(); AddSqrt(); AddSquare(); + AddSquaredDifference(); AddSqueeze(); AddStridedSlice(); AddSub(); @@ -110,6 +112,7 @@ AllOpsResolver::AllOpsResolver() { AddTanh(); AddTranspose(); AddTransposeConv(); + AddUnidirectionalSequenceLSTM(); AddUnpack(); AddVarHandle(); AddWhile(); diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/add.h b/code/components/tflite-lib/tensorflow/lite/micro/kernels/add.h index 88526153..e2e5d23b 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/add.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/add.h @@ -1,4 +1,4 @@ -/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. +/* Copyright 2022 The TensorFlow 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. @@ -59,6 +59,19 @@ TfLiteStatus CalculateOpDataAdd(TfLiteContext* context, TfLiteAddParams* params, TfLiteStatus AddPrepare(TfLiteContext* context, TfLiteNode* node); +// Generic must define registration function. +TfLiteRegistration Register_ADD(); + +#if defined(CMSIS_NN) +TfLiteRegistration Register_ADD_INT8(); + +TfLiteRegistration Register_ADD_INT16(); +#else +// Fallback registration +inline TfLiteRegistration Register_ADD_INT8() { return Register_ADD(); } + +inline TfLiteRegistration Register_ADD_INT16() { return Register_ADD(); } +#endif } // namespace tflite #endif // TENSORFLOW_LITE_MICRO_KERNELS_ADD_H_ diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/add_n.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/add_n.cc index ce064687..35336681 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/add_n.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/add_n.cc @@ -121,8 +121,8 @@ TfLiteStatus CalculateOpData(TfLiteContext* context, TfLiteNode* node) { context, kTfLiteActNone, output, &data->output_activation_min, &data->output_activation_max)); } else { - TF_LITE_KERNEL_LOG(context, "ADD_N only supports FLOAT32 and INT8, got %s.", - TfLiteTypeGetName(output->type)); + MicroPrintf("ADD_N only supports FLOAT32 and INT8, got %s.", + TfLiteTypeGetName(output->type)); return kTfLiteError; } @@ -198,8 +198,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { } else if (output->type == kTfLiteInt8) { EvalAddNQuantized(context, node, output); } else { - TF_LITE_KERNEL_LOG(context, "ADD_N only supports FLOAT32 and INT8, got %s.", - TfLiteTypeGetName(output->type)); + MicroPrintf("ADD_N only supports FLOAT32 and INT8, got %s.", + TfLiteTypeGetName(output->type)); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/arg_min_max.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/arg_min_max.cc index a8aa5a48..d06b94a6 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/arg_min_max.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/arg_min_max.cc @@ -70,21 +70,20 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node, bool is_arg_max) { TF_LITE_ARG_MIN_MAX(int8_t, int32_t, int32_t); break; default: - TF_LITE_KERNEL_LOG(context, - "Only float32, uint8_t and int8_t are " - "supported currently, got %s.", - TfLiteTypeGetName(input->type)); + MicroPrintf( + "Only float32, uint8_t and int8_t are " + "supported currently, got %s.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } } else { - TF_LITE_KERNEL_LOG(context, - "Only int32_t are supported currently, got %s.", - TfLiteTypeGetName(output->type)); + MicroPrintf("Only int32_t are supported currently, got %s.", + TfLiteTypeGetName(output->type)); return kTfLiteError; } } else { - TF_LITE_KERNEL_LOG(context, "Only int32_t are supported currently, got %s.", - TfLiteTypeGetName(axis->type)); + MicroPrintf("Only int32_t are supported currently, got %s.", + TfLiteTypeGetName(axis->type)); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/batch_to_space_nd.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/batch_to_space_nd.cc index be82d942..eebf7c68 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/batch_to_space_nd.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/batch_to_space_nd.cc @@ -95,8 +95,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorData(output)); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/circular_buffer.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/circular_buffer.cc index 399d1648..a45a8d26 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/circular_buffer.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/circular_buffer.cc @@ -90,7 +90,7 @@ TfLiteStatus CircularBufferEval(TfLiteContext* context, TfLiteNode* node) { EvalInt8(tflite::micro::GetTensorData(input), num_slots, depth, tflite::micro::GetTensorData(output)); } else { - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), input->type); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/comparisons.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/comparisons.cc index cff15e4d..409373fb 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/comparisons.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/comparisons.cc @@ -118,8 +118,8 @@ TfLiteStatus EqualEval(TfLiteContext* context, TfLiteNode* node) { output_data); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input1->type), input1->type); + MicroPrintf("Type %s (%d) not supported.", + TfLiteTypeGetName(input1->type), input1->type); return kTfLiteError; } return kTfLiteOk; @@ -210,8 +210,8 @@ TfLiteStatus NotEqualEval(TfLiteContext* context, TfLiteNode* node) { output_data); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input1->type), input1->type); + MicroPrintf("Type %s (%d) not supported.", + TfLiteTypeGetName(input1->type), input1->type); return kTfLiteError; } return kTfLiteOk; @@ -288,8 +288,8 @@ TfLiteStatus GreaterEval(TfLiteContext* context, TfLiteNode* node) { output_data); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input1->type), input1->type); + MicroPrintf("Type %s (%d) not supported.", + TfLiteTypeGetName(input1->type), input1->type); return kTfLiteError; } return kTfLiteOk; @@ -366,8 +366,8 @@ TfLiteStatus GreaterEqualEval(TfLiteContext* context, TfLiteNode* node) { output_data); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input1->type), input1->type); + MicroPrintf("Type %s (%d) not supported.", + TfLiteTypeGetName(input1->type), input1->type); return kTfLiteError; } return kTfLiteOk; @@ -444,8 +444,8 @@ TfLiteStatus LessEval(TfLiteContext* context, TfLiteNode* node) { output_data); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input1->type), input1->type); + MicroPrintf("Type %s (%d) not supported.", + TfLiteTypeGetName(input1->type), input1->type); return kTfLiteError; } return kTfLiteOk; @@ -522,8 +522,8 @@ TfLiteStatus LessEqualEval(TfLiteContext* context, TfLiteNode* node) { output_data); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input1->type), input1->type); + MicroPrintf("Type %s (%d) not supported.", + TfLiteTypeGetName(input1->type), input1->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/concatenation.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/concatenation.cc index 34622c22..8b4d68d9 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/concatenation.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/concatenation.cc @@ -133,7 +133,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE(context, input_type == kTfLiteFloat32 || input_type == kTfLiteInt8 || input_type == kTfLiteInt16 || input_type == kTfLiteInt32 || - input_type == kTfLiteInt64); + input_type == kTfLiteInt64 || input_type == kTfLiteBool); // Output type must match input type TF_LITE_ENSURE_EQ(context, output_type, input_type); @@ -149,8 +149,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { int num_dimensions = NumDimensions(input); if (num_dimensions > RuntimeShape::kMaxSmallSize) { - TF_LITE_KERNEL_LOG( - context, + MicroPrintf( "Op Concatenation does not currently support num dimensions > %d " "Tensor has %d dimensions.", RuntimeShape::kMaxSmallSize, num_dimensions); @@ -168,6 +167,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE(context, output != nullptr); switch (output_type) { // Already know in/outtypes are same. + case kTfLiteBool: case kTfLiteFloat32: case kTfLiteInt16: case kTfLiteInt32: @@ -205,9 +205,8 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { break; } default: - TF_LITE_KERNEL_LOG( - context, "Op Concatenation does not currently support Type '%s'.", - TfLiteTypeGetName(output_type)); + MicroPrintf("Op Concatenation does not currently support Type '%s'.", + TfLiteTypeGetName(output_type)); return kTfLiteError; } @@ -238,11 +237,13 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { case kTfLiteInt16: EvalUnquantized(context, node); break; + case kTfLiteBool: + EvalUnquantized(context, node); + break; default: - TF_LITE_KERNEL_LOG( - context, "Op Concatenation does not currently support Type '%s'.", - TfLiteTypeGetName(output_type)); + MicroPrintf("Op Concatenation does not currently support Type '%s'.", + TfLiteTypeGetName(output_type)); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/cumsum.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/cumsum.cc index eedc61fd..751654fe 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/cumsum.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/cumsum.cc @@ -123,7 +123,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { if (axis < 0) axis += input_shape.DimensionsCount(); if (axis < 0 || axis >= input_shape.DimensionsCount()) { - TF_LITE_KERNEL_LOG(context, "CUMSUM Invalid axis: %d", axis); + MicroPrintf("CUMSUM Invalid axis: %d", axis); return kTfLiteError; } @@ -156,9 +156,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { } break; default: { - TF_LITE_KERNEL_LOG(context, - "CUMSUM only supports FLOAT32 and INT8, got %s.", - TfLiteTypeGetName(output->type)); + MicroPrintf("CUMSUM only supports FLOAT32 and INT8, got %s.", + TfLiteTypeGetName(output->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/depth_to_space.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/depth_to_space.cc index ec000540..4dda7192 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/depth_to_space.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/depth_to_space.cc @@ -124,9 +124,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorData(output)); break; default: - TF_LITE_KERNEL_LOG( - context, "DEPTH_TO_SPACE only supports FLOAT32 and INT8, got %s.", - TfLiteTypeGetName(output->type)); + MicroPrintf("DEPTH_TO_SPACE only supports FLOAT32 and INT8, got %s.", + TfLiteTypeGetName(output->type)); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/depthwise_conv.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/depthwise_conv.cc index d2468ff9..c2ed8892 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/depthwise_conv.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/depthwise_conv.cc @@ -82,8 +82,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { break; } default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/div.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/div.cc index 099c0225..34bf6d7c 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/div.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/div.cc @@ -162,8 +162,7 @@ TfLiteStatus EvalQuantized(TfLiteContext* context, TfLiteNode* node, } #undef TF_LITE_DIV } else { - TF_LITE_KERNEL_LOG( - context, "Unsupported combination of input and output types in DIV."); + MicroPrintf("Unsupported combination of input and output types in DIV."); return kTfLiteError; } @@ -189,10 +188,10 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE_OK(context, EvalQuantized(context, node, params, data, input1, input2, output)); } else { - TF_LITE_KERNEL_LOG(context, - "DIV only supports FLOAT32, quantized INT8 " - "now, got type %s (%d).", - TfLiteTypeGetName(output->type), output->type); + MicroPrintf( + "DIV only supports FLOAT32, quantized INT8 " + "now, got type %s (%d).", + TfLiteTypeGetName(output->type), output->type); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/elementwise.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/elementwise.cc index b1cb1dcb..bb3c6545 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/elementwise.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/elementwise.cc @@ -90,8 +90,8 @@ TfLiteStatus GenericPrepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE(context, output != nullptr); TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type); if (!IsSupportedType(input->type)) { - TF_LITE_KERNEL_LOG(context, "Input data type %s (%d) is not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Input data type %s (%d) is not supported.", + TfLiteTypeGetName(input->type), input->type); return kTfLiteError; } @@ -112,8 +112,8 @@ TfLiteStatus PrepareAbsRsqrt(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE(context, output != nullptr); TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type); if (!IsSupportedType(input->type)) { - TF_LITE_KERNEL_LOG(context, "Input data type %s (%d) is not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Input data type %s (%d) is not supported.", + TfLiteTypeGetName(input->type), input->type); return kTfLiteError; } @@ -317,8 +317,8 @@ TfLiteStatus AbsEval(TfLiteContext* context, TfLiteNode* node) { type); break; default: - TF_LITE_KERNEL_LOG(context, "Current data type %s is not supported.", - TfLiteTypeGetName(type)); + MicroPrintf("Current data type %s is not supported.", + TfLiteTypeGetName(type)); return kTfLiteError; break; } @@ -355,8 +355,8 @@ TfLiteStatus RsqrtEval(TfLiteContext* context, TfLiteNode* node) { elementwise::validate_input_func, type); default: - TF_LITE_KERNEL_LOG(context, "Current data type %s is not supported.", - TfLiteTypeGetName(type)); + MicroPrintf("Current data type %s is not supported.", + TfLiteTypeGetName(type)); return kTfLiteError; } } @@ -426,4 +426,4 @@ TfLiteRegistration Register_LOGICAL_NOT() { } // namespace micro } // namespace ops -} // namespace tflite \ No newline at end of file +} // namespace tflite diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/elu.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/elu.cc index 0b64e89d..7d1169d1 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/elu.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/elu.cc @@ -25,7 +25,6 @@ limitations under the License. #include "tensorflow/lite/kernels/internal/types.h" #include "tensorflow/lite/kernels/kernel_util.h" #include "tensorflow/lite/micro/kernels/kernel_util.h" -#include "tensorflow/lite/micro/micro_error_reporter.h" namespace tflite { namespace { @@ -136,9 +135,8 @@ TfLiteStatus EluEval(TfLiteContext* context, TfLiteNode* node) { return kTfLiteOk; } default: - TF_LITE_KERNEL_LOG( - context, "ELU only supports float32 and int8 currently, got %s.", - TfLiteTypeGetName(input->type)); + MicroPrintf("ELU only supports float32 and int8 currently, got %s.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/conv.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/conv.cc index 919dd006..b442e8ed 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/conv.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/conv.cc @@ -26,7 +26,6 @@ limitations under the License. #include "tensorflow/lite/kernels/padding.h" #include "tensorflow/lite/micro/kernels/kernel_util.h" -#include "freertos/FreeRTOS.h" #include #if ESP_NN diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/depthwise_conv.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/depthwise_conv.cc index a2460248..41a2bff7 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/depthwise_conv.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/depthwise_conv.cc @@ -27,7 +27,6 @@ limitations under the License. #include "tensorflow/lite/kernels/padding.h" #include "tensorflow/lite/micro/kernels/kernel_util.h" -#include "freertos/FreeRTOS.h" #include #if ESP_NN diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/softmax.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/softmax.cc index 9a967839..df0da908 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/softmax.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/esp_nn/softmax.cc @@ -25,7 +25,6 @@ limitations under the License. #include "tensorflow/lite/kernels/op_macros.h" #include "tensorflow/lite/micro/kernels/kernel_util.h" -#include "freertos/FreeRTOS.h" #include #if ESP_NN diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/exp.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/exp.cc index ae26f636..64de090e 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/exp.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/exp.cc @@ -19,6 +19,7 @@ limitations under the License. #include "tensorflow/lite/kernels/internal/tensor_ctypes.h" #include "tensorflow/lite/kernels/kernel_util.h" #include "tensorflow/lite/micro/kernels/kernel_util.h" +#include "tensorflow/lite/micro/micro_error_reporter.h" namespace tflite { namespace { @@ -63,8 +64,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { static_cast(flat_size), tflite::micro::GetTensorData(output)); } else { - TF_LITE_KERNEL_LOG(context, "Type %s (%d) currently not supported by Exp.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) currently not supported by Exp.", + TfLiteTypeGetName(input->type), input->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/expand_dims.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/expand_dims.cc index 4b105bf6..85e3e37c 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/expand_dims.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/expand_dims.cc @@ -31,8 +31,7 @@ TfLiteStatus GetAxisValueFromTensor(TfLiteContext* context, int32_t* axis_value) { const int axis_dims = (tflite::GetTensorShape(axis)).DimensionsCount(); if (axis_dims > 1) { - TF_LITE_KERNEL_LOG(context, "Axis has only one element for Expand_Dims.", - axis_dims); + MicroPrintf("Axis has only one element for Expand_Dims.", axis_dims); return kTfLiteError; } @@ -41,9 +40,8 @@ TfLiteStatus GetAxisValueFromTensor(TfLiteContext* context, *axis_value = axis_ptr[0]; return kTfLiteOk; } else { - TF_LITE_KERNEL_LOG(context, - "Axis type %s (%d) not supported by Expand_Dims.", - TfLiteTypeGetName(axis->type), axis->type); + MicroPrintf("Axis type %s (%d) not supported by Expand_Dims.", + TfLiteTypeGetName(axis->type), axis->type); return kTfLiteError; } } @@ -99,8 +97,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE(context, output != nullptr); output->type = input->type; if (IsDynamicTensor(axis)) { - TF_LITE_KERNEL_LOG(context, - "DynamicTensor is not yet supported by Expand_Dims."); + MicroPrintf("DynamicTensor is not yet supported by Expand_Dims."); return kTfLiteError; } TF_LITE_ENSURE_OK(context, VerifyTensorDim(context, input, axis, output)); @@ -135,8 +132,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorData(input), flat_size); } break; default: - TF_LITE_KERNEL_LOG( - context, + MicroPrintf( "Expand_Dims only currently supports int8 and float32, got %d.", input->type); return kTfLiteError; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/fill.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/fill.cc index 9f438b89..1191eba8 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/fill.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/fill.cc @@ -53,9 +53,8 @@ TfLiteStatus EnsureEq(TfLiteContext* context, const TfLiteIntArray* array, case kTfLiteInt64: return EnsureEqImpl(context, array, tensor); default: - TF_LITE_KERNEL_LOG(context, - "cannot compare int array to tensor of type %d.", - tensor->type); + MicroPrintf("cannot compare int array to tensor of type %d.", + tensor->type); return kTfLiteError; } } @@ -123,9 +122,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { FillImpl(value, output); break; default: - TF_LITE_KERNEL_LOG( - context, "Fill only currently supports float32 for input 1, got %d.", - TfLiteTypeGetName(value->type)); + MicroPrintf("Fill only currently supports float32 for input 1, got %d.", + TfLiteTypeGetName(value->type)); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/floor_div.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/floor_div.cc index 333a1eba..d8a96734 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/floor_div.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/floor_div.cc @@ -74,7 +74,7 @@ TfLiteStatus EvalFloorDiv(TfLiteContext* context, // Validate the denominator. for (int i = 0; i < tflite::ElementCount(*input2->dims); ++i) { if (std::equal_to()(denominator_data[i], 0)) { - TF_LITE_KERNEL_LOG(context, "Division by 0"); + MicroPrintf("Division by 0"); return kTfLiteError; } } @@ -113,8 +113,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { return EvalFloorDiv(context, input1, input2, output); } default: { - TF_LITE_KERNEL_LOG(context, "Type '%s' is not supported by FLOOR_DIV.", - TfLiteTypeGetName(input1->type)); + MicroPrintf("Type '%s' is not supported by FLOOR_DIV.", + TfLiteTypeGetName(input1->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/floor_mod.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/floor_mod.cc index 9bb49497..ca12800c 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/floor_mod.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/floor_mod.cc @@ -111,8 +111,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { output); } default: { - TF_LITE_KERNEL_LOG(context, "Type '%s' is not supported by FLOOR_MOD.", - TfLiteTypeGetName(input1->type)); + MicroPrintf("Type '%s' is not supported by FLOOR_MOD.", + TfLiteTypeGetName(input1->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/fully_connected.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/fully_connected.cc index a083edd7..82d87284 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/fully_connected.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/fully_connected.cc @@ -141,8 +141,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { } default: { - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/gather.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/gather.cc index 6035efa7..ec4e2e5a 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/gather.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/gather.cc @@ -118,9 +118,8 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { case kTfLiteInt32: break; default: - TF_LITE_KERNEL_LOG(context, - "Positions of type '%s' are not supported by gather.", - TfLiteTypeGetName(coords->type)); + MicroPrintf("Positions of type '%s' are not supported by gather.", + TfLiteTypeGetName(coords->type)); return kTfLiteError; break; } @@ -134,8 +133,8 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { case kTfLiteInt8: break; default: - TF_LITE_KERNEL_LOG(context, "Type '%s' is not supported by gather.", - TfLiteTypeGetName(input->type)); + MicroPrintf("Type '%s' is not supported by gather.", + TfLiteTypeGetName(input->type)); return kTfLiteError; break; } @@ -207,8 +206,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { return Gather(params, input, coords, output); break; default: - TF_LITE_KERNEL_LOG(context, "Type '%s' is not supported by gather.", - TfLiteTypeGetName(input->type)); + MicroPrintf("Type '%s' is not supported by gather.", + TfLiteTypeGetName(input->type)); return kTfLiteError; break; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/gather_nd.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/gather_nd.cc index 4327177d..5bb4dd84 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/gather_nd.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/gather_nd.cc @@ -47,9 +47,8 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { case kTfLiteInt8: break; default: - TF_LITE_KERNEL_LOG(context, - "Params of type '%s' are not supported by gather_nd.", - TfLiteTypeGetName(params->type)); + MicroPrintf("Params of type '%s' are not supported by gather_nd.", + TfLiteTypeGetName(params->type)); return kTfLiteError; break; } @@ -57,9 +56,8 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { case kTfLiteInt32: break; default: - TF_LITE_KERNEL_LOG(context, - "Indices of type '%s' are not supported by gather_nd.", - TfLiteTypeGetName(indices->type)); + MicroPrintf("Indices of type '%s' are not supported by gather_nd.", + TfLiteTypeGetName(indices->type)); return kTfLiteError; } @@ -67,22 +65,20 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { const int indices_rank = NumDimensions(indices); const int indices_nd = SizeOfDimension(indices, indices_rank - 1); if (params_rank < 1) { - TF_LITE_KERNEL_LOG(context, "Params must be at least a vector."); + MicroPrintf("Params must be at least a vector."); return kTfLiteError; } if (indices_rank < 1) { - TF_LITE_KERNEL_LOG(context, "Indices must be at least a vector."); + MicroPrintf("Indices must be at least a vector."); return kTfLiteError; } if (indices_nd > params_rank) { - TF_LITE_KERNEL_LOG( - context, "Index innermost dimension length must be <= params rank."); + MicroPrintf("Index innermost dimension length must be <= params rank."); return kTfLiteError; } if (indices_nd > MAX_INDICES_ND) { - TF_LITE_KERNEL_LOG(context, - "Index innermost dimension length must not exceed %d.", - MAX_INDICES_ND); + MicroPrintf("Index innermost dimension length must not exceed %d.", + MAX_INDICES_ND); return kTfLiteError; } @@ -171,13 +167,12 @@ TfLiteStatus EvalGatherNd(TfLiteContext* context, status = GatherNd(params, indices, output); break; default: - TF_LITE_KERNEL_LOG(context, - "Params type '%s' are not supported by gather_nd.", - TfLiteTypeGetName(params->type)); + MicroPrintf("Params type '%s' are not supported by gather_nd.", + TfLiteTypeGetName(params->type)); return kTfLiteError; } if (status != kTfLiteOk) { - TF_LITE_KERNEL_LOG(context, "gather_nd index out of bounds"); + MicroPrintf("gather_nd index out of bounds"); } return status; } @@ -195,9 +190,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { return EvalGatherNd(context, params, indices, output); break; default: - TF_LITE_KERNEL_LOG(context, - "Indices of type '%s' are not supported by gather_nd.", - TfLiteTypeGetName(indices->type)); + MicroPrintf("Indices of type '%s' are not supported by gather_nd.", + TfLiteTypeGetName(indices->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_runner.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_runner.cc index dd4c14f4..7e61ef29 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_runner.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_runner.cc @@ -106,5 +106,17 @@ TfLiteStatus KernelRunner::Invoke() { return kTfLiteOk; } +TfLiteStatus KernelRunner::Free() { + tflite::micro::ClearBufferApi(&context_); + context_.GetScratchBuffer = MicroContextGetScratchBuffer; + + if (registration_.free == nullptr) { + MicroPrintf("TfLiteRegistration missing free function pointer!"); + return kTfLiteError; + } + + registration_.free(&context_, node_.user_data); + return kTfLiteOk; +} } // namespace micro -} // namespace tflite +} // namespace tflite \ No newline at end of file diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_runner.h b/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_runner.h index 4482b70e..c7d53c3a 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_runner.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_runner.h @@ -48,6 +48,11 @@ class KernelRunner { // passed into the constructor of this class. TfLiteStatus Invoke(); + // Calls Free on a given TfLiteRegistration pointer(if it's implemented). + // After successful Free, kTfLiteOk status will be returned. If Free is not + // implemented for a given kernel kTfLiteError will be returned. + TfLiteStatus Free(); + // Returns a pointer to the internal MockMicroGraph which KernelRunner uses // to stub out MicroGraph methods and track invocations on each subgraph. MockMicroGraph* GetMockGraph() { return &mock_micro_graph_; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_util.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_util.cc index 91c0bc91..a8e88d30 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_util.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_util.cc @@ -17,6 +17,7 @@ limitations under the License. #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/micro/memory_helpers.h" +#include "tensorflow/lite/micro/micro_error_reporter.h" namespace tflite { namespace micro { @@ -39,9 +40,10 @@ int ValidateTensorIndexing(const TfLiteContext* context, int index, TfLiteRegistration RegisterOp( void* (*init)(TfLiteContext* context, const char* buffer, size_t length), TfLiteStatus (*prepare)(TfLiteContext* context, TfLiteNode* node), - TfLiteStatus (*invoke)(TfLiteContext* context, TfLiteNode* node)) { + TfLiteStatus (*invoke)(TfLiteContext* context, TfLiteNode* node), + void (*free)(TfLiteContext* context, void* buffer)) { return {/*init=*/init, - /*free=*/nullptr, + /*free=*/free, /*prepare=*/prepare, /*invoke=*/invoke, /*profiling_string=*/nullptr, @@ -160,6 +162,46 @@ TfLiteStatus CopyOpInputsToOpOutputs(TfLiteContext* context, TfLiteNode* node) { return kTfLiteOk; } +// Args: +// 1. int8_t tensor_data - int8_t buffer of unknown size who's data you'd +// like +// to print +// 2. int n_btyes - a small int representing number of bytes you want to +// print +// to debug output. It should always be <= tensor_data's size. +// 3. prefix - optional message you'd like to print before printing bytes +// +// Purpose: +// Function takes in paramaters above and prints n_bytes bytes from the +// tensor_data buffer. This can be use to debug the output of a model and it's +// op. + +void PrintNBytes(const int8_t* tensor_data, int n_bytes, const char* prefix) { + if (prefix != nullptr) { + MicroPrintf("%s", prefix); + } + + for (int i = 0; i < n_bytes; ++i) { + MicroPrintf(" %x", tensor_data[i]); + } + MicroPrintf("\n"); +} + +// same as the PrintNBytes above but the buffer needs to be extracted out of the +// TfLiteEvalTensor* +void PrintNBytes(const TfLiteEvalTensor* tensor, int n_bytes, + const char* prefix) { + const int8_t* tensor_data = tflite::micro::GetTensorData(tensor); + PrintNBytes(tensor_data, n_bytes, prefix); +} + +// same as the PrintNBytes above but the buffer needs to be extracted out of the +// TfLiteEvalTensor* +void PrintNBytes(const TfLiteTensor* tensor, int n_bytes, const char* prefix) { + const int8_t* tensor_data = tflite::GetTensorData(tensor); + PrintNBytes(tensor_data, n_bytes, prefix); +} + TfLiteStatus CopyOpInputsToSubgraphInputs(TfLiteContext* context, TfLiteNode* node, MicroGraph* graph_info, diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_util.h b/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_util.h index d6f20c72..6ac1cb36 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_util.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/kernel_util.h @@ -21,8 +21,10 @@ limitations under the License. #include "tensorflow/lite/c/builtin_op_data.h" #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/kernels/internal/compatibility.h" +#include "tensorflow/lite/kernels/internal/tensor_ctypes.h" #include "tensorflow/lite/kernels/internal/types.h" #include "tensorflow/lite/micro/micro_context.h" +#include "tensorflow/lite/micro/micro_error_reporter.h" namespace tflite { namespace micro { @@ -30,7 +32,20 @@ namespace micro { TfLiteRegistration RegisterOp( void* (*init)(TfLiteContext* context, const char* buffer, size_t length), TfLiteStatus (*prepare)(TfLiteContext* context, TfLiteNode* node), - TfLiteStatus (*invoke)(TfLiteContext* context, TfLiteNode* node)); + TfLiteStatus (*invoke)(TfLiteContext* context, TfLiteNode* node), + void (*free)(TfLiteContext* context, void* buffer) = nullptr); + +// Prints out n bytes in a int8_t buffer as hex +void PrintNBytes(const int8_t* tensor_data, int n_bytes, + const char* prefix = nullptr); + +// Prints out the the n bytes in a TfLiteEvalTensor as hex +void PrintNBytes(const TfLiteEvalTensor* tensor, int n_bytes, + const char* prefix = nullptr); + +// Prints out the the n bytes in a TfLiteTensor as hex +void PrintNBytes(const TfLiteTensor* tensor, int n_bytes, + const char* prefix = nullptr); // Returns a mutable tensor for a given input index. is_variable must be checked // during prepare when the full TfLiteTensor is available. diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/l2_pool_2d.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/l2_pool_2d.cc index 2b2a27bf..fbba4e0b 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/l2_pool_2d.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/l2_pool_2d.cc @@ -125,9 +125,8 @@ TfLiteStatus L2Eval(TfLiteContext* context, TfLiteNode* node) { L2EvalFloat(*params, *input, &op_params, output); break; default: - TF_LITE_KERNEL_LOG(context, - "L2_POOL_2D only supports float32 currently, got %s.", - TfLiteTypeGetName(input->type)); + MicroPrintf("L2_POOL_2D only supports float32 currently, got %s.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/l2norm.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/l2norm.cc index 45858e78..e8ce4ec0 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/l2norm.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/l2norm.cc @@ -126,8 +126,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorData(input), tflite::micro::GetTensorData(output)); } else { - TF_LITE_KERNEL_LOG(context, "Output type is %s, requires float.", - TfLiteTypeGetName(output->type)); + MicroPrintf("Output type is %s, requires float.", + TfLiteTypeGetName(output->type)); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/log_softmax.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/log_softmax.cc index 5fd87612..5958319a 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/log_softmax.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/log_softmax.cc @@ -132,9 +132,8 @@ TfLiteStatus LogSoftmaxEval(TfLiteContext* context, TfLiteNode* node) { return kTfLiteOk; } default: - TF_LITE_KERNEL_LOG(context, - "LOG_SOFTMAX only supports float32, int8, got %s.", - TfLiteTypeGetName(input->type)); + MicroPrintf("LOG_SOFTMAX only supports float32, int8, got %s.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/lstm_eval.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/lstm_eval.cc index f157a8d0..58484638 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/lstm_eval.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/lstm_eval.cc @@ -22,6 +22,8 @@ limitations under the License. #include "tensorflow/lite/c/builtin_op_data.h" #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/kernels/internal/compatibility.h" +#include "tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h" +#include "tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h" #include "tensorflow/lite/kernels/internal/tensor_ctypes.h" #include "tensorflow/lite/kernels/op_macros.h" #include "tensorflow/lite/micro/kernels/kernel_util.h" @@ -530,11 +532,20 @@ void CalculateLstmGateInteger8x8_16( // Apply activation switch (activation) { case kTfLiteActSigmoid: - micro_tensor_utils::ApplySigmoid(gate, n_batch, n_cell, gate); - break; - case kTfLiteActTanh: - micro_tensor_utils::ApplyTanh(3, gate, n_batch, n_cell, gate); + + reference_integer_ops::Logistic( + 0 /*data->input_multiplier*/, 0 /*data->input_left_shift */, + n_batch * n_cell /*NumElements(input->dims)*/, + gate /* tflite::micro::GetTensorData(input) */, + gate /*tflite::micro::GetTensorData(output) */); + break; + case kTfLiteActTanh: { + int32_t dims_data = n_batch * n_cell; + RuntimeShape tanh_inp_shape = RuntimeShape(1, &dims_data); + reference_integer_ops::Tanh(0, 0, tanh_inp_shape, gate, tanh_inp_shape, + gate); + } break; default: // Only Sigmoid or Tanh is used. TFLITE_ASSERT_FALSE; @@ -599,7 +610,7 @@ void UpdateLstmCellInteger(int n_batch, int n_cell, int16_t* cell_state, // - scratch1: scratch area of size n_batch*n_cell // - scratch2: scratch area used by MatrixBatchVectorMultiplyAccumulate void CalculateLstmOutputInteger8x8_16( - int n_batch, int n_cell, int n_output, const int16_t* cell_state, + int n_batch, int n_cell, int n_output, int16_t* cell_state, int32_t cell_state_scale, const int16_t* output_gate, int32_t hidden_scale_a, int32_t hidden_scale_b, int32_t hidden_zp, const int8_t* projection_weights, int32_t proj_scale_a, @@ -607,8 +618,23 @@ void CalculateLstmOutputInteger8x8_16( int32_t output_state_zp, int8_t quantized_proj_clip, int8_t* output_state, int16_t* scratch0, int8_t* scratch1, int32_t* scratch2) { // Note: unlike float/hybrid, the activation is always Tanh. - micro_tensor_utils::ApplyTanh(15 + cell_state_scale, cell_state, n_batch, - n_cell, scratch0); + + { + int32_t tanh_input_left_shift = (15 + cell_state_scale) - 3; + int32_t dims_data = n_batch * n_cell; + if (tanh_input_left_shift < 0) /* handling negative shift value */ + { + int32_t i; + tanh_input_left_shift = -tanh_input_left_shift; + for (i = 0; i < dims_data; i++) { + cell_state[i] = cell_state[i] >> tanh_input_left_shift; + } + tanh_input_left_shift = 0; + } + RuntimeShape tanh_inp_shape = RuntimeShape(1, &dims_data); + reference_integer_ops::Tanh(0, tanh_input_left_shift, tanh_inp_shape, + cell_state, tanh_inp_shape, scratch0); + } micro_tensor_utils::CwiseMul(output_gate, scratch0, hidden_scale_a, hidden_scale_b, n_batch, n_cell, hidden_zp, scratch1); diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/maximum_minimum.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/maximum_minimum.cc index 7964f1e6..cb3cae24 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/maximum_minimum.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/maximum_minimum.cc @@ -98,15 +98,13 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { TFLiteOperation(context, node, op_context); break; default: - TF_LITE_KERNEL_LOG(context, - "Type %s (%d) is not supported by Maximum/Minimum.", - TfLiteTypeGetName(op_context.output->type), - op_context.output->type); + MicroPrintf("Type %s (%d) is not supported by Maximum/Minimum.", + TfLiteTypeGetName(op_context.output->type), + op_context.output->type); return kTfLiteError; } } else { - TF_LITE_KERNEL_LOG(context, - "Kernel type not supported by Maximum/Minimum."); + MicroPrintf("Kernel type not supported by Maximum/Minimum."); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/micro_ops.h b/code/components/tflite-lib/tensorflow/lite/micro/kernels/micro_ops.h index c4dec92d..68583f75 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/micro_ops.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/micro_ops.h @@ -72,6 +72,7 @@ TfLiteRegistration Register_READ_VARIABLE(); TfLiteRegistration Register_RELU(); TfLiteRegistration Register_RELU6(); TfLiteRegistration Register_RESIZE_BILINEAR(); +TfLiteRegistration Register_SELECT_V2(); TfLiteRegistration Register_SHAPE(); TfLiteRegistration Register_SLICE(); TfLiteRegistration Register_SPACE_TO_BATCH_ND(); @@ -79,6 +80,7 @@ TfLiteRegistration Register_SPACE_TO_DEPTH(); TfLiteRegistration Register_SQUARED_DIFFERENCE(); TfLiteRegistration Register_SQUEEZE(); TfLiteRegistration Register_SUB(); +TfLiteRegistration Register_SUM(); TfLiteRegistration Register_SVDF(); TfLiteRegistration Register_TRANSPOSE(); TfLiteRegistration Register_TRANSPOSE_CONV(); diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/micro_tensor_utils.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/micro_tensor_utils.cc index 88b097c7..32c68121 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/micro_tensor_utils.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/micro_tensor_utils.cc @@ -663,7 +663,7 @@ void PortableCwiseMul(const int16_t* input_1, const int16_t* input_2, const int16_t b = input_2[index]; int32_t value = static_cast(a) * static_cast(b); value = MultiplyByQuantizedMultiplier(value, multiplier, shift); - value -= output_zp; + value += output_zp; value = std::min(std::max(static_cast(-128), value), static_cast(127)); diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/mul.h b/code/components/tflite-lib/tensorflow/lite/micro/kernels/mul.h index e6d1a9b1..0c6379e1 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/mul.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/mul.h @@ -1,4 +1,4 @@ -/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. +/* Copyright 2022 The TensorFlow 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. @@ -60,6 +60,15 @@ void EvalMulFloatReference(TfLiteContext* context, TfLiteNode* node, const TfLiteEvalTensor* input2, TfLiteEvalTensor* output); +// Generic must define registration function. +TfLiteRegistration Register_MUL(); + +#if defined(CMSIS_NN) +TfLiteRegistration Register_MUL_INT8(); +#else +// Fallback registration +inline TfLiteRegistration Register_MUL_INT8() { return Register_MUL(); } +#endif } // namespace tflite #endif // TENSORFLOW_LITE_MICRO_KERNELS_MUL_H_ diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/neg.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/neg.cc index 59dd8cb8..03cbbb09 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/neg.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/neg.cc @@ -41,8 +41,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorData(output)); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/pack.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/pack.cc index 56f3b96e..01d62f77 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/pack.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/pack.cc @@ -95,8 +95,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { data->axis); } default: { - TF_LITE_KERNEL_LOG(context, "Type '%s' is not supported by pack.", - TfLiteTypeGetName(output->type)); + MicroPrintf("Type '%s' is not supported by pack.", + TfLiteTypeGetName(output->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/pad.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/pad.cc index b645f983..61c304bf 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/pad.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/pad.cc @@ -213,8 +213,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { } break; default: - TF_LITE_KERNEL_LOG(context, "Type %s not currently supported by Pad.", - TfLiteTypeGetName(input->type)); + MicroPrintf("Type %s not currently supported by Pad.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/pooling.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/pooling.cc index a2ef8b62..f32014e8 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/pooling.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/pooling.cc @@ -45,8 +45,8 @@ TfLiteStatus AverageEval(TfLiteContext* context, TfLiteNode* node) { AveragePoolingEvalQuantized(context, node, params, data, input, output); break; default: - TF_LITE_KERNEL_LOG(context, "Input type %s is not currently supported", - TfLiteTypeGetName(input->type)); + MicroPrintf("Input type %s is not currently supported", + TfLiteTypeGetName(input->type)); return kTfLiteError; } return kTfLiteOk; @@ -73,8 +73,8 @@ TfLiteStatus MaxEval(TfLiteContext* context, TfLiteNode* node) { MaxPoolingEvalQuantized(context, node, params, data, input, output); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s not currently supported.", - TfLiteTypeGetName(input->type)); + MicroPrintf("Type %s not currently supported.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/pooling.h b/code/components/tflite-lib/tensorflow/lite/micro/kernels/pooling.h index a80f1f59..493250ee 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/pooling.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/pooling.h @@ -1,4 +1,4 @@ -/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. +/* Copyright 2022 The TensorFlow 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. @@ -20,6 +20,7 @@ limitations under the License. #include "tensorflow/lite/c/builtin_op_data.h" #include "tensorflow/lite/c/common.h" +#include "tensorflow/lite/micro/kernels/micro_ops.h" namespace tflite { @@ -66,6 +67,19 @@ void MaxPoolingEvalQuantized(TfLiteContext* context, TfLiteNode* node, const TfLiteEvalTensor* input, TfLiteEvalTensor* output); +#if defined(CMSIS_NN) +TfLiteRegistration Register_AVERAGE_POOL_2D_INT8(); + +TfLiteRegistration Register_MAX_POOL_2D_INT8(); +#else +inline TfLiteRegistration Register_AVERAGE_POOL_2D_INT8() { + return tflite::Register_AVERAGE_POOL_2D(); +} + +inline TfLiteRegistration Register_MAX_POOL_2D_INT8() { + return tflite::Register_MAX_POOL_2D(); +} +#endif } // namespace tflite #endif // TENSORFLOW_LITE_MICRO_KERNELS_POOLING_H_ diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/prelu.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/prelu.cc index 54cc0e02..6c5a8a4f 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/prelu.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/prelu.cc @@ -61,9 +61,8 @@ TfLiteStatus PreluEval(TfLiteContext* context, TfLiteNode* node) { return kTfLiteOk; } break; default: - TF_LITE_KERNEL_LOG( - context, "Only float32 and uint8_t are supported currently, got %d.", - TfLiteTypeGetName(input->type)); + MicroPrintf("Only float32 and uint8_t are supported currently, got %d.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/reduce_common.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/reduce_common.cc index a6f940c6..b191ba21 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/reduce_common.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/reduce_common.cc @@ -28,7 +28,7 @@ limitations under the License. namespace tflite { -const int kMaxNumberOfAxis = 4; +const int kMaxNumberOfAxis = 5; const int kMaxNumberOfReducedAxis = 2; TfLiteStatus PrepareSimple(TfLiteContext* context, TfLiteNode* node, diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/resize_bilinear.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/resize_bilinear.cc index a90057b9..f2acd9f4 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/resize_bilinear.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/resize_bilinear.cc @@ -55,8 +55,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { auto* params = reinterpret_cast(node->builtin_data); if (params->half_pixel_centers && params->align_corners) { - TF_LITE_KERNEL_LOG( - context, "If half_pixel_centers is True, align_corners must be False."); + MicroPrintf("If half_pixel_centers is True, align_corners must be False."); return kTfLiteError; } @@ -100,8 +99,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorShape(output), tflite::micro::GetTensorData(output)); } else { - TF_LITE_KERNEL_LOG(context, "Output type is %d, requires float or int8.", - output->type); + MicroPrintf("Output type is %d, requires float or int8.", output->type); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/resize_nearest_neighbor.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/resize_nearest_neighbor.cc index ce507445..aa3b8fa1 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/resize_nearest_neighbor.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/resize_nearest_neighbor.cc @@ -21,7 +21,6 @@ limitations under the License. #include "tensorflow/lite/kernels/kernel_util.h" #include "tensorflow/lite/kernels/op_macros.h" #include "tensorflow/lite/micro/kernels/kernel_util.h" -#include "tensorflow/lite/micro/micro_error_reporter.h" namespace tflite { namespace ops { @@ -55,7 +54,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { output->type = input->type; if (!IsConstantTensor(size)) { - TF_LITE_KERNEL_LOG(context, "Dynamic tensors are unsupported in tfmicro."); + MicroPrintf("Dynamic tensors are unsupported in tfmicro."); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/select.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/select.cc new file mode 100644 index 00000000..0bcbfbea --- /dev/null +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/select.cc @@ -0,0 +1,196 @@ +/* Copyright 2022 The TensorFlow 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. +==============================================================================*/ +#include "tensorflow/lite/kernels/internal/reference/select.h" + +#include +#include + +#include "tensorflow/lite/c/common.h" +#include "tensorflow/lite/kernels/internal/tensor_ctypes.h" +#include "tensorflow/lite/kernels/kernel_util.h" +#include "tensorflow/lite/micro/kernels/kernel_util.h" + +namespace tflite { + +constexpr int kInputTensorCondition = 0; +constexpr int kInputTensorX = 1; +constexpr int kInputTensorY = 2; +constexpr int kOutputTensor = 0; + +struct OpData { + bool requires_broadcast; + // True if input condition is scalar or input condition has rank one and + // matches the first dimension of other inputs. + bool has_low_rank_input_condition; +}; + +void* SelectInit(TfLiteContext* context, const char* buffer, size_t length) { + TFLITE_DCHECK(context->AllocatePersistentBuffer != nullptr); + auto* data = static_cast( + context->AllocatePersistentBuffer(context, sizeof(OpData))); + data->requires_broadcast = false; + data->has_low_rank_input_condition = false; + return data; +} + +TfLiteStatus CheckBroadcastShape(TfLiteContext* context, + const TfLiteTensor* input1, + const TfLiteTensor* input2, + const TfLiteTensor* input3, + const TfLiteIntArray* output_shape) { + const int dims1 = NumDimensions(input1); + const int dims2 = NumDimensions(input2); + const int dims3 = NumDimensions(input3); + const int out_dims = std::max(std::max(dims1, dims2), dims3); + TF_LITE_ENSURE_EQ(context, out_dims, output_shape->size); + + for (int i = 0; i < out_dims; ++i) { + const int d1 = i >= dims1 ? 1 : SizeOfDimension(input1, dims1 - i - 1); + const int d2 = i >= dims2 ? 1 : SizeOfDimension(input2, dims2 - i - 1); + const int d3 = i >= dims3 ? 1 : SizeOfDimension(input3, dims3 - i - 1); + const int min_value = std::min(std::min(d1, d2), d3); + int max_value = std::max(std::max(d1, d2), d3); + // If one dimention is 0, others must be 0 or 1. + if (min_value == 0) max_value = 0; + if (!(d1 == 1 || d1 == max_value) || !(d2 == 1 || d2 == max_value) || + !(d3 == 1 || d3 == max_value)) { + MicroPrintf("Given shapes are not broadcastable."); + return kTfLiteError; + } + TF_LITE_ENSURE_EQ(context, output_shape->data[out_dims - i - 1], max_value); + } + return kTfLiteOk; +} + +TfLiteStatus SelectPrepare(TfLiteContext* context, TfLiteNode* node) { + OpData* data = reinterpret_cast(node->user_data); + + TF_LITE_ENSURE_EQ(context, NumInputs(node), 3); + TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); + + MicroContext* micro_context = GetMicroContext(context); + TfLiteTensor* input_condition = + micro_context->AllocateTempInputTensor(node, kInputTensorCondition); + + TfLiteTensor* input_x = + micro_context->AllocateTempInputTensor(node, kInputTensorX); + + TfLiteTensor* input_y = + micro_context->AllocateTempInputTensor(node, kInputTensorY); + + TfLiteTensor* output = + micro_context->AllocateTempOutputTensor(node, kOutputTensor); + + // Input must be bool. + TF_LITE_ENSURE_TYPES_EQ(context, input_condition->type, kTfLiteBool); + TF_LITE_ENSURE_TYPES_EQ(context, input_x->type, input_y->type); + output->type = input_x->type; + + // Respect the original output shape when there are mixed shapes to represent + // a scalar data. + if (GetTensorShape(input_condition).FlatSize() == 1 && + GetTensorShape(input_x).FlatSize() == 1 && + GetTensorShape(input_y).FlatSize() == 1 && + GetTensorShape(output).FlatSize() == 1) { + return kTfLiteOk; + } + + bool same_shape = HaveSameShapes(input_condition, input_x) && + HaveSameShapes(input_x, input_y); + if (!same_shape) { + TF_LITE_ENSURE_OK( + context, CheckBroadcastShape(context, input_condition, input_x, input_y, + output->dims)); + data->requires_broadcast = true; + } + + micro_context->DeallocateTempTfLiteTensor(input_condition); + micro_context->DeallocateTempTfLiteTensor(input_x); + micro_context->DeallocateTempTfLiteTensor(input_y); + micro_context->DeallocateTempTfLiteTensor(output); + + return kTfLiteOk; +} + +TfLiteStatus SelectEval(TfLiteContext* context, TfLiteNode* node) { + OpData* data = static_cast(node->user_data); + MicroContext* micro_context = GetMicroContext(context); + + TfLiteTensor* input_condition = + micro_context->AllocateTempInputTensor(node, kInputTensorCondition); + + TfLiteTensor* input_x = + micro_context->AllocateTempInputTensor(node, kInputTensorX); + + TfLiteTensor* input_y = + micro_context->AllocateTempInputTensor(node, kInputTensorY); + + TfLiteTensor* output = + micro_context->AllocateTempOutputTensor(node, kOutputTensor); + +#define TF_LITE_SELECT(type, op) \ + reference_ops::op(GetTensorShape(input_condition), \ + GetTensorData(input_condition), \ + GetTensorShape(input_x), GetTensorData(input_x), \ + GetTensorShape(input_y), GetTensorData(input_y), \ + GetTensorShape(output), GetTensorData(output)); + +#define TF_LITE_SWITCH(type, op) \ + switch (type) { \ + case kTfLiteFloat32: \ + TF_LITE_SELECT(float, op); \ + break; \ + case kTfLiteInt8: \ + TF_LITE_SELECT(int8_t, op); \ + break; \ + case kTfLiteInt16: \ + TF_LITE_SELECT(int16_t, op); \ + break; \ + default: \ + MicroPrintf("Does not support type other than %s, but got %s", \ + "int8|int16|float32", TfLiteTypeGetName(type)); \ + return kTfLiteError; \ + } + + if (data->has_low_rank_input_condition) { + MicroPrintf("Not yet implemented."); + return kTfLiteError; + } else if (data->requires_broadcast) { + TF_LITE_SWITCH(input_x->type, BroadcastSelect5DSlow); + } else { + TF_LITE_SWITCH(input_x->type, Select); + } + +#undef TF_LITE_SELECT +#undef TF_LITE_SWITCH + micro_context->DeallocateTempTfLiteTensor(input_condition); + micro_context->DeallocateTempTfLiteTensor(input_x); + micro_context->DeallocateTempTfLiteTensor(input_y); + micro_context->DeallocateTempTfLiteTensor(output); + + return kTfLiteOk; +} + +// SelectV2 op selects values of 'x' if the corresponding value of 'condition' +// is true or the value of 'y' if false. There are valid condition input sizes: +// +// 1. Either the same shape (in which case the select is elementwise), or +// 2. Broadcastable shapes between 'condition', 'x' and 'y'. +TfLiteRegistration Register_SELECT_V2() { + return tflite::micro::RegisterOp(tflite::SelectInit, tflite::SelectPrepare, + tflite::SelectEval); +} + +} // namespace tflite diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/shape.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/shape.cc index 02f663a8..b8bd5544 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/shape.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/shape.cc @@ -47,8 +47,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { TfLiteEvalTensor* output = tflite::micro::GetEvalOutput(context, node, kOutputTensor); if (output->type != kTfLiteInt32) { - TF_LITE_KERNEL_LOG(context, "Output type %s (%d) not supported.", - TfLiteTypeGetName(output->type), output->type); + MicroPrintf("Output type %s (%d) not supported.", + TfLiteTypeGetName(output->type), output->type); return kTfLiteError; } else { ExtractShape(input, tflite::micro::GetTensorData(output)); diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/slice.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/slice.cc index 212cf47f..a6ecd935 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/slice.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/slice.cc @@ -106,8 +106,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { GetBeginAndSizeVectors(input->dims->size, begin, size, op_params.begin, op_params.size); } else { - TF_LITE_KERNEL_LOG(context, "Begin tensor type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Begin tensor type %s (%d) not supported.", + TfLiteTypeGetName(input->type), input->type); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/softmax.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/softmax.cc index c2cee3c5..1ad5be0c 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/softmax.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/softmax.cc @@ -75,8 +75,8 @@ TfLiteStatus SoftmaxEval(TfLiteContext* context, TfLiteNode* node) { return kTfLiteOk; } default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/space_to_batch_nd.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/space_to_batch_nd.cc index 21f81312..7a7f61e9 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/space_to_batch_nd.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/space_to_batch_nd.cc @@ -104,8 +104,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorData(output)); break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/space_to_depth.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/space_to_depth.cc index 30519b27..b8635de8 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/space_to_depth.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/space_to_depth.cc @@ -109,9 +109,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { micro::GetTensorData(output)); break; default: - TF_LITE_KERNEL_LOG( - context, "SPACE_TO_DEPTH only supports FLOAT32 and INT8, got %s.", - TfLiteTypeGetName(input->type)); + MicroPrintf("SPACE_TO_DEPTH only supports FLOAT32 and INT8, got %s.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/split_v.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/split_v.cc index 3ea35130..959796c3 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/split_v.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/split_v.cc @@ -111,8 +111,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { return SplitImpl(context, node, input, axis_value); } default: - TF_LITE_KERNEL_LOG(context, "Type %s currently not supported.", - TfLiteTypeGetName(input->type)); + MicroPrintf("Type %s currently not supported.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/squeeze.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/squeeze.cc index e81b5b56..86841753 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/squeeze.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/squeeze.cc @@ -90,8 +90,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteEvalTensor* input = tflite::micro::GetEvalInput(context, node, 0); if (input->type == kTfLiteString) { - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/strided_slice.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/strided_slice.cc index 832e2ccd..344698d6 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/strided_slice.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/strided_slice.cc @@ -183,9 +183,16 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorShape(output), tflite::micro::GetTensorData(output)); break; + case kTfLiteBool: + reference_ops::StridedSlice(op_params, + tflite::micro::GetTensorShape(input), + tflite::micro::GetTensorData(input), + tflite::micro::GetTensorShape(output), + tflite::micro::GetTensorData(output)); + break; default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/svdf.h b/code/components/tflite-lib/tensorflow/lite/micro/kernels/svdf.h index 7a04a5c6..0915c9fd 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/svdf.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/svdf.h @@ -1,4 +1,4 @@ -/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. +/* Copyright 2022 The TensorFlow 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. @@ -82,7 +82,7 @@ TfLiteStatus PrepareSvdf(TfLiteContext* context, TfLiteNode* node); // (reference or optimized) must define this function. TfLiteRegistration Register_SVDF(); -#if defined(HEXAGON) +#if defined(HEXAGON) || defined(CMSIS_NN) TfLiteRegistration Register_SVDF_INT8(); #else diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/tanh.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/tanh.cc index e97a9035..bb4133bf 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/tanh.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/tanh.cc @@ -185,9 +185,9 @@ TfLiteStatus TanhEval(TfLiteContext* context, TfLiteNode* node) { return kTfLiteOk; } break; default: - TF_LITE_KERNEL_LOG(context, "Input %s, output %s not supported.", - TfLiteTypeGetName(input->type), - TfLiteTypeGetName(output->type)); + MicroPrintf("Input %s, output %s not supported.", + TfLiteTypeGetName(input->type), + TfLiteTypeGetName(output->type), context); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/transpose.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/transpose.cc index 9f77e04d..740ef5f9 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/transpose.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/transpose.cc @@ -103,10 +103,10 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { tflite::micro::GetTensorData(output)); break; default: - TF_LITE_KERNEL_LOG(context, - "Type %s is currently not supported by Transpose. " - "Only float32 and int8 is supported", - TfLiteTypeGetName(input->type)); + MicroPrintf( + "Type %s is currently not supported by Transpose. " + "Only float32 and int8 is supported", + TfLiteTypeGetName(input->type)); return kTfLiteError; } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/transpose_conv.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/transpose_conv.cc index 0b2afd5b..1b1e8b3b 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/transpose_conv.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/transpose_conv.cc @@ -327,8 +327,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { break; } default: - TF_LITE_KERNEL_LOG(context, "Type %s (%d) not supported.", - TfLiteTypeGetName(input->type), input->type); + MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), + input->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm_test_config.h b/code/components/tflite-lib/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm_test_config.h index e37c0efd..24c838fa 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm_test_config.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm_test_config.h @@ -24,7 +24,7 @@ namespace testing { // kernel is reconciled with reference kernel #if !defined(XTENSA) -typedef struct LstmIntegerTestConfig { +struct LstmIntegerTestConfig { const int n_batch; const int n_input; const int n_cell; @@ -100,9 +100,9 @@ typedef struct LstmIntegerTestConfig { bool asymmetric_quantize_inputs; const float ranges[25][2]; -} LstmIntegerTestConfig; +}; -typedef struct LstmFloatTestConfig { +struct LstmFloatTestConfig { const int n_batch; const int n_input; const int n_cell; @@ -153,9 +153,9 @@ typedef struct LstmFloatTestConfig { float* output; const float* expected_output_original; float* expected_output; -} LstmFloatTestConfig; +}; -typedef struct LstmWeightQuantizationBuffers { +struct LstmWeightQuantizationBuffers { int8_t* lstm_i2i_quant; float* lstm_i2i_scale; int* lstm_i2i_zp; @@ -215,7 +215,7 @@ typedef struct LstmWeightQuantizationBuffers { float* lstm_proj_w_scale; int* lstm_proj_w_zp; TfLiteAffineQuantization* lstm_proj_w_qparam; -} LstmWeightQuantizationBuffers; +}; extern LstmIntegerTestConfig lstm_integer_no_peephole_config; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/unpack.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/unpack.cc index d199add0..9a0ef177 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/unpack.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/unpack.cc @@ -91,8 +91,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { return UnpackImpl(context, node, input, data->num, data->axis); } default: { - TF_LITE_KERNEL_LOG(context, "Type '%s' is not supported by unpack.", - TfLiteTypeGetName(input->type)); + MicroPrintf("Type '%s' is not supported by unpack.", + TfLiteTypeGetName(input->type)); return kTfLiteError; } } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/kernels/zeros_like.cc b/code/components/tflite-lib/tensorflow/lite/micro/kernels/zeros_like.cc index fd6e6612..9c77e7ad 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/kernels/zeros_like.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/kernels/zeros_like.cc @@ -70,10 +70,10 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { resetZeros(tflite::micro::GetTensorData(output), flat_size); break; default: - TF_LITE_KERNEL_LOG(context, - "ZerosLike only currently supports int64, int32, " - "and float32, got %d.", - input->type); + MicroPrintf( + "ZerosLike only currently supports int64, int32, " + "and float32, got %d.", + input->type); return kTfLiteError; } return kTfLiteOk; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/micro_allocation_info.cc b/code/components/tflite-lib/tensorflow/lite/micro/micro_allocation_info.cc index edab2b83..c1ebac3f 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/micro_allocation_info.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/micro_allocation_info.cc @@ -323,8 +323,12 @@ TfLiteStatus AllocationInfoBuilder::GetOfflinePlannedOffsets( if (model_->metadata()) { for (size_t i = 0; i < model_->metadata()->size(); ++i) { auto metadata = model_->metadata()->Get(i); - if (strncmp(metadata->name()->c_str(), kOfflineMemAllocMetadata, - strlen(kOfflineMemAllocMetadata)) == 0) { + const size_t metadata_name_size = (size_t)metadata->name()->size(); + + if ((strncmp(metadata->name()->c_str(), kOfflineMemAllocMetadata, + std::min(metadata_name_size, + strlen(kOfflineMemAllocMetadata))) == 0) && + metadata_name_size == strlen(kOfflineMemAllocMetadata)) { const flatbuffers::Vector>* buffers = model_->buffers(); auto* buffer = (*buffers)[metadata->buffer()]; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/micro_allocator.cc b/code/components/tflite-lib/tensorflow/lite/micro/micro_allocator.cc index 6b78fdc0..707f2e83 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/micro_allocator.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/micro_allocator.cc @@ -509,14 +509,15 @@ TfLiteStatus MicroAllocator::FinishModelAllocation( return kTfLiteError; } - // Allocate scratch buffer metadata and buffers for variable tensors. + // Allocate scratch buffer metadata. + TF_LITE_ENSURE_STATUS(AllocateScratchBufferHandles( + scratch_buffer_handles, scratch_buffer_request_count_)); + + // Allocate buffers for variable tensors. for (size_t subgraph_idx = 0; subgraph_idx < model->subgraphs()->size(); subgraph_idx++) { const SubGraph* subgraph = model->subgraphs()->Get(subgraph_idx); TFLITE_DCHECK(subgraph != nullptr); - - TF_LITE_ENSURE_STATUS(AllocateScratchBufferHandles( - scratch_buffer_handles, scratch_buffer_request_count_)); TF_LITE_ENSURE_STATUS(AllocateVariables( subgraph, subgraph_allocations[subgraph_idx].tensors)); } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/micro_allocator.h b/code/components/tflite-lib/tensorflow/lite/micro/micro_allocator.h index 7381489d..f9bd8b75 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/micro_allocator.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/micro_allocator.h @@ -54,7 +54,7 @@ TfLiteStatus InitializeTfLiteTensorFromFlatbuffer( // of a sequential, array of ScratchBufferHandle allocations in the tail // section. These allocations are indexed by the request API defined in the // TfLiteContext struct. -typedef struct { +struct ScratchBufferRequest { // Number of bytes required by the buffer. The actual allocated size might be // greater than `bytes` due to buffer alignment. size_t bytes; @@ -63,29 +63,29 @@ typedef struct { // have `before` = node_idx and `after` = node_idx. int node_idx; int subgraph_idx; -} ScratchBufferRequest; +}; } // namespace internal -typedef struct { +struct NodeAndRegistration { TfLiteNode node; const TfLiteRegistration* registration; -} NodeAndRegistration; +}; // Holds a pointer to a buffer for a scratch buffer requested by a kernel during // the model prepare stage. This struct is allocated in-place and allows for // quick pointer-indexed lookup for speed during model inference. -typedef struct { +struct ScratchBufferHandle { // Pointer to location of the scratch buffer: uint8_t* data; -} ScratchBufferHandle; +}; // Stores all per-subgraph allocations. This includes the node and registration -// array, tensor list and scratch buffer handles for each subgraph. -typedef struct { +// array, and tensor list for each subgraph. +struct SubgraphAllocations { NodeAndRegistration* node_and_registrations; TfLiteEvalTensor* tensors; -} SubgraphAllocations; +}; // Allocator responsible for allocating memory for all intermediate tensors // necessary to invoke a model. diff --git a/code/components/tflite-lib/tensorflow/lite/micro/micro_interpreter.cc b/code/components/tflite-lib/tensorflow/lite/micro/micro_interpreter.cc index f726a5f3..50fe7911 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/micro_interpreter.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/micro_interpreter.cc @@ -317,7 +317,17 @@ TfLiteTensor* MicroInterpreter::output(size_t index) { } return output_tensors_[index]; } +// Repurposing free subgraphs to reset state for some ops for now +// will reset api is made. See b/220940833#comment25 for more context. +TfLiteStatus MicroInterpreter::Reset() { + TfLiteStatus status = graph_.FreeSubgraphs(); + if (status != kTfLiteOk) { + return status; + } + return graph_.ResetVariableTensors(); +} +// TODO: remove this API completely in favor of MicroInterpreter::Reset TfLiteStatus MicroInterpreter::ResetVariableTensors() { return graph_.ResetVariableTensors(); } diff --git a/code/components/tflite-lib/tensorflow/lite/micro/micro_interpreter.h b/code/components/tflite-lib/tensorflow/lite/micro/micro_interpreter.h index aa409386..285a890f 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/micro_interpreter.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/micro_interpreter.h @@ -31,7 +31,7 @@ limitations under the License. #include "tensorflow/lite/portable_type_to_tflitetype.h" #include "tensorflow/lite/schema/schema_generated.h" -// Copied from tensorflow/lite/version.h to avoid a dependency chain into +/// Copied from tensorflow/lite/version.h to avoid a dependency chain into // tensorflow/core. #define TFLITE_SCHEMA_VERSION (3) @@ -116,6 +116,11 @@ class MicroInterpreter { return nullptr; } + // Reset the state to be what you would expect when the interpreter is first + // created. i.e. after Init and Prepare is called for the very first time. + TfLiteStatus Reset(); + + // TODO(b/244457206): remove this in favor of Reset() // Reset all variable tensors to the default value. TfLiteStatus ResetVariableTensors(); diff --git a/code/components/tflite-lib/tensorflow/lite/micro/micro_mutable_op_resolver.h b/code/components/tflite-lib/tensorflow/lite/micro/micro_mutable_op_resolver.h index 4b273417..738cd4fb 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/micro_mutable_op_resolver.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/micro_mutable_op_resolver.h @@ -24,11 +24,13 @@ limitations under the License. #include "tensorflow/lite/kernels/internal/compatibility.h" #include "tensorflow/lite/kernels/op_macros.h" #include "tensorflow/lite/micro/compatibility.h" +#include "tensorflow/lite/micro/kernels/add.h" #include "tensorflow/lite/micro/kernels/conv.h" #include "tensorflow/lite/micro/kernels/depthwise_conv.h" #include "tensorflow/lite/micro/kernels/ethosu.h" #include "tensorflow/lite/micro/kernels/fully_connected.h" #include "tensorflow/lite/micro/kernels/micro_ops.h" +#include "tensorflow/lite/micro/kernels/pooling.h" #include "tensorflow/lite/micro/kernels/reduce.h" #include "tensorflow/lite/micro/kernels/softmax.h" #include "tensorflow/lite/micro/micro_error_reporter.h" @@ -140,9 +142,9 @@ class MicroMutableOpResolver : public MicroOpResolver { tflite::Register_ASSIGN_VARIABLE(), ParseAssignVariable); } - TfLiteStatus AddAveragePool2D() { - return AddBuiltin(BuiltinOperator_AVERAGE_POOL_2D, - tflite::Register_AVERAGE_POOL_2D(), ParsePool); + TfLiteStatus AddAveragePool2D( + const TfLiteRegistration& registration = Register_AVERAGE_POOL_2D()) { + return AddBuiltin(BuiltinOperator_AVERAGE_POOL_2D, registration, ParsePool); } TfLiteStatus AddBatchToSpaceNd() { @@ -363,9 +365,9 @@ class MicroMutableOpResolver : public MicroOpResolver { tflite::ops::micro::Register_MAXIMUM(), ParseMaximum); } - TfLiteStatus AddMaxPool2D() { - return AddBuiltin(BuiltinOperator_MAX_POOL_2D, - tflite::Register_MAX_POOL_2D(), ParsePool); + TfLiteStatus AddMaxPool2D( + const TfLiteRegistration& registration = Register_MAX_POOL_2D()) { + return AddBuiltin(BuiltinOperator_MAX_POOL_2D, registration, ParsePool); } TfLiteStatus AddMirrorPad() { @@ -382,8 +384,8 @@ class MicroMutableOpResolver : public MicroOpResolver { tflite::ops::micro::Register_MINIMUM(), ParseMinimum); } - TfLiteStatus AddMul() { - return AddBuiltin(BuiltinOperator_MUL, tflite::Register_MUL(), ParseMul); + TfLiteStatus AddMul(const TfLiteRegistration& registration = Register_MUL()) { + return AddBuiltin(BuiltinOperator_MUL, registration, ParseMul); } TfLiteStatus AddNeg() { @@ -466,6 +468,11 @@ class MicroMutableOpResolver : public MicroOpResolver { tflite::ops::micro::Register_RSQRT(), ParseRsqrt); } + TfLiteStatus AddSelectV2() { + return AddBuiltin(BuiltinOperator_SELECT_V2, Register_SELECT_V2(), + ParseSelectV2); + } + TfLiteStatus AddShape() { return AddBuiltin(BuiltinOperator_SHAPE, Register_SHAPE(), ParseShape); } @@ -519,6 +526,12 @@ class MicroMutableOpResolver : public MicroOpResolver { tflite::ops::micro::Register_SQUARE(), ParseSquare); } + TfLiteStatus AddSquaredDifference() { + return AddBuiltin(BuiltinOperator_SQUARED_DIFFERENCE, + tflite::Register_SQUARED_DIFFERENCE(), + ParseSquaredDifference); + } + TfLiteStatus AddStridedSlice() { return AddBuiltin(BuiltinOperator_STRIDED_SLICE, tflite::ops::micro::Register_STRIDED_SLICE(), diff --git a/code/components/tflite-lib/tensorflow/lite/micro/micro_profiler.cc b/code/components/tflite-lib/tensorflow/lite/micro/micro_profiler.cc index 72f3d37f..86b1ebbb 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/micro_profiler.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/micro_profiler.cc @@ -16,6 +16,7 @@ limitations under the License. #include #include +#include #include "tensorflow/lite/kernels/internal/compatibility.h" #include "tensorflow/lite/micro/micro_error_reporter.h" @@ -67,4 +68,48 @@ void MicroProfiler::LogCsv() const { #endif } +void MicroProfiler::LogTicksPerTagCsv() { +#if !defined(TF_LITE_STRIP_ERROR_STRINGS) + MicroPrintf( + "\"Unique Tag\",\"Total ticks across all events with that tag.\""); + int total_ticks = 0; + for (int i = 0; i < num_events_; ++i) { + uint32_t ticks = end_ticks_[i] - start_ticks_[i]; + TFLITE_DCHECK(tags_[i] != nullptr); + int position = FindExistingOrNextPosition(tags_[i]); + TFLITE_DCHECK(position >= 0); + total_ticks_per_tag[position].tag = tags_[i]; + total_ticks_per_tag[position].ticks = + total_ticks_per_tag[position].ticks + ticks; + total_ticks += ticks; + } + + for (int i = 0; i < num_events_; ++i) { + TicksPerTag each_tag_entry = total_ticks_per_tag[i]; + if (each_tag_entry.tag == nullptr) { + break; + } + MicroPrintf("%s, %d", each_tag_entry.tag, each_tag_entry.ticks); + } + MicroPrintf("total number of ticks, %d", total_ticks); +#endif +} + +// This method finds a particular array element in the total_ticks_per_tag array +// with the matching tag_name passed in the method. If it can find a +// matching array element that has the same tag_name, then it will return the +// position of the matching element. But if it unable to find a matching element +// with the given tag_name, it will return the next available empty position +// from the array. +int MicroProfiler::FindExistingOrNextPosition(const char* tag_name) { + int pos = 0; + for (; pos < num_events_; pos++) { + TicksPerTag each_tag_entry = total_ticks_per_tag[pos]; + if (each_tag_entry.tag == nullptr || + strcmp(each_tag_entry.tag, tag_name) == 0) { + return pos; + } + } + return pos < num_events_ ? pos : -1; +} } // namespace tflite diff --git a/code/components/tflite-lib/tensorflow/lite/micro/micro_profiler.h b/code/components/tflite-lib/tensorflow/lite/micro/micro_profiler.h index 41f41a35..c37978a0 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/micro_profiler.h +++ b/code/components/tflite-lib/tensorflow/lite/micro/micro_profiler.h @@ -61,6 +61,11 @@ class MicroProfiler { // Separated Value) form. void LogCsv() const; + // Prints total ticks for each unique tag in CSV format. + // Output will have one row for each unique tag along with the + // total ticks summed across all events with that particular tag. + void LogTicksPerTagCsv(); + private: // Maximum number of events that this class can keep track of. If we call // AddEvent more than kMaxEvents number of times, then the oldest event's @@ -72,6 +77,17 @@ class MicroProfiler { uint32_t end_ticks_[kMaxEvents]; int num_events_ = 0; + struct TicksPerTag { + const char* tag; + uint32_t ticks; + }; + // In practice, the number of tags will be much lower than the number of + // events. But it is theoretically possible that each event to be unique and + // hence we allow total_ticks_per_tag to have kMaxEvents entries. + TicksPerTag total_ticks_per_tag[kMaxEvents] = {}; + + int FindExistingOrNextPosition(const char* tag_name); + TF_LITE_REMOVE_VIRTUAL_DELETE; }; diff --git a/code/components/tflite-lib/tensorflow/lite/micro/recording_micro_allocator.cc b/code/components/tflite-lib/tensorflow/lite/micro/recording_micro_allocator.cc index 61f7816a..cdfcc272 100644 --- a/code/components/tflite-lib/tensorflow/lite/micro/recording_micro_allocator.cc +++ b/code/components/tflite-lib/tensorflow/lite/micro/recording_micro_allocator.cc @@ -163,10 +163,12 @@ TfLiteStatus RecordingMicroAllocator::AllocateNodeAndRegistrations( TfLiteStatus status = MicroAllocator::AllocateNodeAndRegistrations(model, subgraph_allocations); + + RecordAllocationUsage(allocations, + recorded_node_and_registration_array_data_); + for (size_t subgraph_idx = 0; subgraph_idx < model->subgraphs()->size(); subgraph_idx++) { - RecordAllocationUsage(allocations, - recorded_node_and_registration_array_data_); // The allocation count in SingleArenaBufferAllocator will only be 1. To // provide better logging, decrement by 1 and add in the actual number of // operators used in the graph: The allocation for this recording will @@ -176,8 +178,12 @@ TfLiteStatus RecordingMicroAllocator::AllocateNodeAndRegistrations( // potential for fragmentation, manually adjust the accounting by // decrementing by 1 and adding the actual number of nodes used in the // graph: - recorded_node_and_registration_array_data_.count += - model->subgraphs()->Get(subgraph_idx)->operators()->size() - 1; + if (model->subgraphs()->Get(subgraph_idx)->operators()) { + recorded_node_and_registration_array_data_.count += + model->subgraphs()->Get(subgraph_idx)->operators()->size() - 1; + } else { + recorded_node_and_registration_array_data_.count -= 1; + } } return status; } @@ -188,9 +194,11 @@ TfLiteStatus RecordingMicroAllocator::AllocateTfLiteEvalTensors( TfLiteStatus status = MicroAllocator::AllocateTfLiteEvalTensors(model, subgraph_allocations); + + RecordAllocationUsage(allocations, recorded_tflite_eval_tensor_data_); + for (size_t subgraph_idx = 0; subgraph_idx < model->subgraphs()->size(); subgraph_idx++) { - RecordAllocationUsage(allocations, recorded_tflite_eval_tensor_data_); // The allocation for this recording will always be 1. This is because the // parent class mallocs one large allocation for the number of tensors in // the graph (e.g. sizeof(TfLiteEvalTensor) * num_tensors). To prevent extra diff --git a/code/components/tflite-lib/tensorflow/lite/schema/schema_generated.h b/code/components/tflite-lib/tensorflow/lite/schema/schema_generated.h index 5d1cee85..b3a6831a 100644 --- a/code/components/tflite-lib/tensorflow/lite/schema/schema_generated.h +++ b/code/components/tflite-lib/tensorflow/lite/schema/schema_generated.h @@ -6,6 +6,13 @@ #include "flatbuffers/flatbuffers.h" +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 2 && + FLATBUFFERS_VERSION_MINOR == 0 && + FLATBUFFERS_VERSION_REVISION == 6, + "Non-compatible flatbuffers version included"); + namespace tflite { struct CustomQuantization; @@ -36,6 +43,10 @@ struct SparsityParameters; struct SparsityParametersBuilder; struct SparsityParametersT; +struct VariantSubType; +struct VariantSubTypeBuilder; +struct VariantSubTypeT; + struct Tensor; struct TensorBuilder; struct TensorT; @@ -528,6 +539,10 @@ struct UnsortedSegmentMinOptions; struct UnsortedSegmentMinOptionsBuilder; struct UnsortedSegmentMinOptionsT; +struct SignOptions; +struct SignOptionsBuilder; +struct SignOptionsT; + struct OperatorCode; struct OperatorCodeBuilder; struct OperatorCodeT; @@ -560,7 +575,7 @@ struct Model; struct ModelBuilder; struct ModelT; -enum TensorType { +enum TensorType : int8_t { TensorType_FLOAT32 = 0, TensorType_FLOAT16 = 1, TensorType_INT32 = 2, @@ -635,7 +650,7 @@ inline const char *EnumNameTensorType(TensorType e) { return EnumNamesTensorType()[index]; } -enum QuantizationDetails { +enum QuantizationDetails : uint8_t { QuantizationDetails_NONE = 0, QuantizationDetails_CustomQuantization = 1, QuantizationDetails_MIN = QuantizationDetails_NONE, @@ -673,6 +688,14 @@ template<> struct QuantizationDetailsTraits { static const QuantizationDetails enum_value = QuantizationDetails_CustomQuantization; }; +template struct QuantizationDetailsUnionTraits { + static const QuantizationDetails enum_value = QuantizationDetails_NONE; +}; + +template<> struct QuantizationDetailsUnionTraits { + static const QuantizationDetails enum_value = QuantizationDetails_CustomQuantization; +}; + struct QuantizationDetailsUnion { QuantizationDetails type; void *value; @@ -690,17 +713,15 @@ struct QuantizationDetailsUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { - using RT = typename std::remove_reference::type; + typedef typename std::remove_reference::type RT; Reset(); - type = QuantizationDetailsTraits::enum_value; + type = QuantizationDetailsUnionTraits::enum_value; if (type != QuantizationDetails_NONE) { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, QuantizationDetails type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; @@ -718,7 +739,7 @@ struct QuantizationDetailsUnion { bool VerifyQuantizationDetails(flatbuffers::Verifier &verifier, const void *obj, QuantizationDetails type); bool VerifyQuantizationDetailsVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); -enum DimensionType { +enum DimensionType : int8_t { DimensionType_DENSE = 0, DimensionType_SPARSE_CSR = 1, DimensionType_MIN = DimensionType_DENSE, @@ -748,7 +769,7 @@ inline const char *EnumNameDimensionType(DimensionType e) { return EnumNamesDimensionType()[index]; } -enum SparseIndexVector { +enum SparseIndexVector : uint8_t { SparseIndexVector_NONE = 0, SparseIndexVector_Int32Vector = 1, SparseIndexVector_Uint16Vector = 2, @@ -800,6 +821,22 @@ template<> struct SparseIndexVectorTraits { static const SparseIndexVector enum_value = SparseIndexVector_Uint8Vector; }; +template struct SparseIndexVectorUnionTraits { + static const SparseIndexVector enum_value = SparseIndexVector_NONE; +}; + +template<> struct SparseIndexVectorUnionTraits { + static const SparseIndexVector enum_value = SparseIndexVector_Int32Vector; +}; + +template<> struct SparseIndexVectorUnionTraits { + static const SparseIndexVector enum_value = SparseIndexVector_Uint16Vector; +}; + +template<> struct SparseIndexVectorUnionTraits { + static const SparseIndexVector enum_value = SparseIndexVector_Uint8Vector; +}; + struct SparseIndexVectorUnion { SparseIndexVector type; void *value; @@ -817,17 +854,15 @@ struct SparseIndexVectorUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { - using RT = typename std::remove_reference::type; + typedef typename std::remove_reference::type RT; Reset(); - type = SparseIndexVectorTraits::enum_value; + type = SparseIndexVectorUnionTraits::enum_value; if (type != SparseIndexVector_NONE) { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, SparseIndexVector type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; @@ -861,7 +896,7 @@ struct SparseIndexVectorUnion { bool VerifySparseIndexVector(flatbuffers::Verifier &verifier, const void *obj, SparseIndexVector type); bool VerifySparseIndexVectorVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); -enum BuiltinOperator { +enum BuiltinOperator : int32_t { BuiltinOperator_ADD = 0, BuiltinOperator_AVERAGE_POOL_2D = 1, BuiltinOperator_CONCATENATION = 2, @@ -1020,11 +1055,12 @@ enum BuiltinOperator { BuiltinOperator_UNSORTED_SEGMENT_SUM = 155, BuiltinOperator_ATAN2 = 156, BuiltinOperator_UNSORTED_SEGMENT_MIN = 157, + BuiltinOperator_SIGN = 158, BuiltinOperator_MIN = BuiltinOperator_ADD, - BuiltinOperator_MAX = BuiltinOperator_UNSORTED_SEGMENT_MIN + BuiltinOperator_MAX = BuiltinOperator_SIGN }; -inline const BuiltinOperator (&EnumValuesBuiltinOperator())[158] { +inline const BuiltinOperator (&EnumValuesBuiltinOperator())[159] { static const BuiltinOperator values[] = { BuiltinOperator_ADD, BuiltinOperator_AVERAGE_POOL_2D, @@ -1183,13 +1219,14 @@ inline const BuiltinOperator (&EnumValuesBuiltinOperator())[158] { BuiltinOperator_UNSORTED_SEGMENT_MAX, BuiltinOperator_UNSORTED_SEGMENT_SUM, BuiltinOperator_ATAN2, - BuiltinOperator_UNSORTED_SEGMENT_MIN + BuiltinOperator_UNSORTED_SEGMENT_MIN, + BuiltinOperator_SIGN }; return values; } inline const char * const *EnumNamesBuiltinOperator() { - static const char * const names[159] = { + static const char * const names[160] = { "ADD", "AVERAGE_POOL_2D", "CONCATENATION", @@ -1348,18 +1385,19 @@ inline const char * const *EnumNamesBuiltinOperator() { "UNSORTED_SEGMENT_SUM", "ATAN2", "UNSORTED_SEGMENT_MIN", + "SIGN", nullptr }; return names; } inline const char *EnumNameBuiltinOperator(BuiltinOperator e) { - if (flatbuffers::IsOutRange(e, BuiltinOperator_ADD, BuiltinOperator_UNSORTED_SEGMENT_MIN)) return ""; + if (flatbuffers::IsOutRange(e, BuiltinOperator_ADD, BuiltinOperator_SIGN)) return ""; const size_t index = static_cast(e); return EnumNamesBuiltinOperator()[index]; } -enum BuiltinOptions { +enum BuiltinOptions : uint8_t { BuiltinOptions_NONE = 0, BuiltinOptions_Conv2DOptions = 1, BuiltinOptions_DepthwiseConv2DOptions = 2, @@ -1483,11 +1521,12 @@ enum BuiltinOptions { BuiltinOptions_UnsortedSegmentMinOptions = 120, BuiltinOptions_UnsortedSegmentSumOptions = 121, BuiltinOptions_ATan2Options = 122, + BuiltinOptions_SignOptions = 123, BuiltinOptions_MIN = BuiltinOptions_NONE, - BuiltinOptions_MAX = BuiltinOptions_ATan2Options + BuiltinOptions_MAX = BuiltinOptions_SignOptions }; -inline const BuiltinOptions (&EnumValuesBuiltinOptions())[123] { +inline const BuiltinOptions (&EnumValuesBuiltinOptions())[124] { static const BuiltinOptions values[] = { BuiltinOptions_NONE, BuiltinOptions_Conv2DOptions, @@ -1611,13 +1650,14 @@ inline const BuiltinOptions (&EnumValuesBuiltinOptions())[123] { BuiltinOptions_UnsortedSegmentMaxOptions, BuiltinOptions_UnsortedSegmentMinOptions, BuiltinOptions_UnsortedSegmentSumOptions, - BuiltinOptions_ATan2Options + BuiltinOptions_ATan2Options, + BuiltinOptions_SignOptions }; return values; } inline const char * const *EnumNamesBuiltinOptions() { - static const char * const names[124] = { + static const char * const names[125] = { "NONE", "Conv2DOptions", "DepthwiseConv2DOptions", @@ -1741,13 +1781,14 @@ inline const char * const *EnumNamesBuiltinOptions() { "UnsortedSegmentMinOptions", "UnsortedSegmentSumOptions", "ATan2Options", + "SignOptions", nullptr }; return names; } inline const char *EnumNameBuiltinOptions(BuiltinOptions e) { - if (flatbuffers::IsOutRange(e, BuiltinOptions_NONE, BuiltinOptions_ATan2Options)) return ""; + if (flatbuffers::IsOutRange(e, BuiltinOptions_NONE, BuiltinOptions_SignOptions)) return ""; const size_t index = static_cast(e); return EnumNamesBuiltinOptions()[index]; } @@ -2244,6 +2285,506 @@ template<> struct BuiltinOptionsTraits { static const BuiltinOptions enum_value = BuiltinOptions_ATan2Options; }; +template<> struct BuiltinOptionsTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SignOptions; +}; + +template struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_NONE; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_Conv2DOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_DepthwiseConv2DOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ConcatEmbeddingsOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LSHProjectionOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_Pool2DOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SVDFOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_RNNOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_FullyConnectedOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SoftmaxOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ConcatenationOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_AddOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_L2NormOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LocalResponseNormalizationOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LSTMOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ResizeBilinearOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_CallOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ReshapeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SkipGramOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SpaceToDepthOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_EmbeddingLookupSparseOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_MulOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_PadOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_GatherOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_BatchToSpaceNDOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SpaceToBatchNDOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_TransposeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ReducerOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SubOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_DivOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SqueezeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SequenceRNNOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_StridedSliceOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ExpOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_TopKV2Options; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SplitOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LogSoftmaxOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_CastOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_DequantizeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_MaximumMinimumOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ArgMaxOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LessOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_NegOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_PadV2Options; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_GreaterOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_GreaterEqualOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LessEqualOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SelectOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SliceOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_TransposeConvOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SparseToDenseOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_TileOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ExpandDimsOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_EqualOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_NotEqualOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ShapeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_PowOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ArgMinOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_FakeQuantOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_PackOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LogicalOrOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_OneHotOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LogicalAndOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LogicalNotOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_UnpackOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_FloorDivOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SquareOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ZerosLikeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_FillOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_BidirectionalSequenceLSTMOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_BidirectionalSequenceRNNOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_UnidirectionalSequenceLSTMOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_FloorModOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_RangeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ResizeNearestNeighborOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_LeakyReluOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SquaredDifferenceOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_MirrorPadOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_AbsOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SplitVOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_UniqueOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ReverseV2Options; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_AddNOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_GatherNdOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_CosOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_WhereOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_RankOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ReverseSequenceOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_MatrixDiagOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_QuantizeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_MatrixSetDiagOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_HardSwishOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_IfOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_WhileOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_DepthToSpaceOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_NonMaxSuppressionV4Options; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_NonMaxSuppressionV5Options; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ScatterNdOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SelectV2Options; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_DensifyOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SegmentSumOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_BatchMatMulOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_CumsumOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_CallOnceOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_BroadcastToOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_Rfft2dOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_Conv3DOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_HashtableOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_HashtableFindOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_HashtableImportOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_HashtableSizeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_VarHandleOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ReadVariableOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_AssignVariableOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_RandomOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_BucketizeOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_GeluOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_DynamicUpdateSliceOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_UnsortedSegmentProdOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_UnsortedSegmentMaxOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_UnsortedSegmentMinOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_UnsortedSegmentSumOptions; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_ATan2Options; +}; + +template<> struct BuiltinOptionsUnionTraits { + static const BuiltinOptions enum_value = BuiltinOptions_SignOptions; +}; + struct BuiltinOptionsUnion { BuiltinOptions type; void *value; @@ -2261,17 +2802,15 @@ struct BuiltinOptionsUnion { void Reset(); -#ifndef FLATBUFFERS_CPP98_STL template void Set(T&& val) { - using RT = typename std::remove_reference::type; + typedef typename std::remove_reference::type RT; Reset(); - type = BuiltinOptionsTraits::enum_value; + type = BuiltinOptionsUnionTraits::enum_value; if (type != BuiltinOptions_NONE) { value = new RT(std::forward(val)); } } -#endif // FLATBUFFERS_CPP98_STL static void *UnPack(const void *obj, BuiltinOptions type, const flatbuffers::resolver_function_t *resolver); flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher = nullptr) const; @@ -3252,12 +3791,20 @@ struct BuiltinOptionsUnion { return type == BuiltinOptions_ATan2Options ? reinterpret_cast(value) : nullptr; } + tflite::SignOptionsT *AsSignOptions() { + return type == BuiltinOptions_SignOptions ? + reinterpret_cast(value) : nullptr; + } + const tflite::SignOptionsT *AsSignOptions() const { + return type == BuiltinOptions_SignOptions ? + reinterpret_cast(value) : nullptr; + } }; bool VerifyBuiltinOptions(flatbuffers::Verifier &verifier, const void *obj, BuiltinOptions type); bool VerifyBuiltinOptionsVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); -enum Padding { +enum Padding : int8_t { Padding_SAME = 0, Padding_VALID = 1, Padding_MIN = Padding_SAME, @@ -3287,7 +3834,7 @@ inline const char *EnumNamePadding(Padding e) { return EnumNamesPadding()[index]; } -enum ActivationFunctionType { +enum ActivationFunctionType : int8_t { ActivationFunctionType_NONE = 0, ActivationFunctionType_RELU = 1, ActivationFunctionType_RELU_N1_TO_1 = 2, @@ -3329,7 +3876,7 @@ inline const char *EnumNameActivationFunctionType(ActivationFunctionType e) { return EnumNamesActivationFunctionType()[index]; } -enum LSHProjectionType { +enum LSHProjectionType : int8_t { LSHProjectionType_UNKNOWN = 0, LSHProjectionType_SPARSE = 1, LSHProjectionType_DENSE = 2, @@ -3362,7 +3909,7 @@ inline const char *EnumNameLSHProjectionType(LSHProjectionType e) { return EnumNamesLSHProjectionType()[index]; } -enum FullyConnectedOptionsWeightsFormat { +enum FullyConnectedOptionsWeightsFormat : int8_t { FullyConnectedOptionsWeightsFormat_DEFAULT = 0, FullyConnectedOptionsWeightsFormat_SHUFFLED4x16INT8 = 1, FullyConnectedOptionsWeightsFormat_MIN = FullyConnectedOptionsWeightsFormat_DEFAULT, @@ -3392,7 +3939,7 @@ inline const char *EnumNameFullyConnectedOptionsWeightsFormat(FullyConnectedOpti return EnumNamesFullyConnectedOptionsWeightsFormat()[index]; } -enum LSTMKernelType { +enum LSTMKernelType : int8_t { LSTMKernelType_FULL = 0, LSTMKernelType_BASIC = 1, LSTMKernelType_MIN = LSTMKernelType_FULL, @@ -3422,7 +3969,7 @@ inline const char *EnumNameLSTMKernelType(LSTMKernelType e) { return EnumNamesLSTMKernelType()[index]; } -enum CombinerType { +enum CombinerType : int8_t { CombinerType_SUM = 0, CombinerType_MEAN = 1, CombinerType_SQRTN = 2, @@ -3455,7 +4002,7 @@ inline const char *EnumNameCombinerType(CombinerType e) { return EnumNamesCombinerType()[index]; } -enum MirrorPadMode { +enum MirrorPadMode : int8_t { MirrorPadMode_REFLECT = 0, MirrorPadMode_SYMMETRIC = 1, MirrorPadMode_MIN = MirrorPadMode_REFLECT, @@ -3485,7 +4032,7 @@ inline const char *EnumNameMirrorPadMode(MirrorPadMode e) { return EnumNamesMirrorPadMode()[index]; } -enum CustomOptionsFormat { +enum CustomOptionsFormat : int8_t { CustomOptionsFormat_FLEXBUFFERS = 0, CustomOptionsFormat_MIN = CustomOptionsFormat_FLEXBUFFERS, CustomOptionsFormat_MAX = CustomOptionsFormat_FLEXBUFFERS @@ -3514,9 +4061,7 @@ inline const char *EnumNameCustomOptionsFormat(CustomOptionsFormat e) { struct CustomQuantizationT : public flatbuffers::NativeTable { typedef CustomQuantization TableType; - std::vector custom; - CustomQuantizationT() { - } + std::vector custom{}; }; struct CustomQuantization FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -3550,7 +4095,6 @@ struct CustomQuantizationBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - CustomQuantizationBuilder &operator=(const CustomQuantizationBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -3580,15 +4124,12 @@ flatbuffers::Offset CreateCustomQuantization(flatbuffers::Fl struct QuantizationParametersT : public flatbuffers::NativeTable { typedef QuantizationParameters TableType; - std::vector min; - std::vector max; - std::vector scale; - std::vector zero_point; - tflite::QuantizationDetailsUnion details; - int32_t quantized_dimension; - QuantizationParametersT() - : quantized_dimension(0) { - } + std::vector min{}; + std::vector max{}; + std::vector scale{}; + std::vector zero_point{}; + tflite::QuantizationDetailsUnion details{}; + int32_t quantized_dimension = 0; }; struct QuantizationParameters FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -3638,10 +4179,10 @@ struct QuantizationParameters FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tab verifier.VerifyVector(scale()) && VerifyOffset(verifier, VT_ZERO_POINT) && verifier.VerifyVector(zero_point()) && - VerifyField(verifier, VT_DETAILS_TYPE) && + VerifyField(verifier, VT_DETAILS_TYPE, 1) && VerifyOffset(verifier, VT_DETAILS) && VerifyQuantizationDetails(verifier, details(), details_type()) && - VerifyField(verifier, VT_QUANTIZED_DIMENSION) && + VerifyField(verifier, VT_QUANTIZED_DIMENSION, 4) && verifier.EndTable(); } QuantizationParametersT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -3682,7 +4223,6 @@ struct QuantizationParametersBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - QuantizationParametersBuilder &operator=(const QuantizationParametersBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -3738,9 +4278,7 @@ flatbuffers::Offset CreateQuantizationParameters(flatbuf struct Int32VectorT : public flatbuffers::NativeTable { typedef Int32Vector TableType; - std::vector values; - Int32VectorT() { - } + std::vector values{}; }; struct Int32Vector FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -3774,7 +4312,6 @@ struct Int32VectorBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Int32VectorBuilder &operator=(const Int32VectorBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -3803,9 +4340,7 @@ flatbuffers::Offset CreateInt32Vector(flatbuffers::FlatBufferBuilde struct Uint16VectorT : public flatbuffers::NativeTable { typedef Uint16Vector TableType; - std::vector values; - Uint16VectorT() { - } + std::vector values{}; }; struct Uint16Vector FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -3839,7 +4374,6 @@ struct Uint16VectorBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Uint16VectorBuilder &operator=(const Uint16VectorBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -3869,9 +4403,7 @@ flatbuffers::Offset CreateUint16Vector(flatbuffers::FlatBufferBuil struct Uint8VectorT : public flatbuffers::NativeTable { typedef Uint8Vector TableType; - std::vector values; - Uint8VectorT() { - } + std::vector values{}; }; struct Uint8Vector FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -3905,7 +4437,6 @@ struct Uint8VectorBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Uint8VectorBuilder &operator=(const Uint8VectorBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -3935,14 +4466,10 @@ flatbuffers::Offset CreateUint8Vector(flatbuffers::FlatBufferBuilde struct DimensionMetadataT : public flatbuffers::NativeTable { typedef DimensionMetadata TableType; - tflite::DimensionType format; - int32_t dense_size; - tflite::SparseIndexVectorUnion array_segments; - tflite::SparseIndexVectorUnion array_indices; - DimensionMetadataT() - : format(tflite::DimensionType_DENSE), - dense_size(0) { - } + tflite::DimensionType format = tflite::DimensionType_DENSE; + int32_t dense_size = 0; + tflite::SparseIndexVectorUnion array_segments{}; + tflite::SparseIndexVectorUnion array_indices{}; }; struct DimensionMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -3996,12 +4523,12 @@ struct DimensionMetadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FORMAT) && - VerifyField(verifier, VT_DENSE_SIZE) && - VerifyField(verifier, VT_ARRAY_SEGMENTS_TYPE) && + VerifyField(verifier, VT_FORMAT, 1) && + VerifyField(verifier, VT_DENSE_SIZE, 4) && + VerifyField(verifier, VT_ARRAY_SEGMENTS_TYPE, 1) && VerifyOffset(verifier, VT_ARRAY_SEGMENTS) && VerifySparseIndexVector(verifier, array_segments(), array_segments_type()) && - VerifyField(verifier, VT_ARRAY_INDICES_TYPE) && + VerifyField(verifier, VT_ARRAY_INDICES_TYPE, 1) && VerifyOffset(verifier, VT_ARRAY_INDICES) && VerifySparseIndexVector(verifier, array_indices(), array_indices_type()) && verifier.EndTable(); @@ -4061,7 +4588,6 @@ struct DimensionMetadataBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - DimensionMetadataBuilder &operator=(const DimensionMetadataBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -4091,11 +4617,13 @@ flatbuffers::Offset CreateDimensionMetadata(flatbuffers::Flat struct SparsityParametersT : public flatbuffers::NativeTable { typedef SparsityParameters TableType; - std::vector traversal_order; - std::vector block_map; - std::vector> dim_metadata; - SparsityParametersT() { - } + std::vector traversal_order{}; + std::vector block_map{}; + std::vector> dim_metadata{}; + SparsityParametersT() = default; + SparsityParametersT(const SparsityParametersT &o); + SparsityParametersT(SparsityParametersT&&) FLATBUFFERS_NOEXCEPT = default; + SparsityParametersT &operator=(SparsityParametersT o) FLATBUFFERS_NOEXCEPT; }; struct SparsityParameters FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -4148,7 +4676,6 @@ struct SparsityParametersBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SparsityParametersBuilder &operator=(const SparsityParametersBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -4185,23 +4712,110 @@ inline flatbuffers::Offset CreateSparsityParametersDirect( flatbuffers::Offset CreateSparsityParameters(flatbuffers::FlatBufferBuilder &_fbb, const SparsityParametersT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +struct VariantSubTypeT : public flatbuffers::NativeTable { + typedef VariantSubType TableType; + std::vector shape{}; + tflite::TensorType type = tflite::TensorType_FLOAT32; + bool has_rank = false; +}; + +struct VariantSubType FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef VariantSubTypeT NativeTableType; + typedef VariantSubTypeBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_SHAPE = 4, + VT_TYPE = 6, + VT_HAS_RANK = 8 + }; + const flatbuffers::Vector *shape() const { + return GetPointer *>(VT_SHAPE); + } + tflite::TensorType type() const { + return static_cast(GetField(VT_TYPE, 0)); + } + bool has_rank() const { + return GetField(VT_HAS_RANK, 0) != 0; + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_SHAPE) && + verifier.VerifyVector(shape()) && + VerifyField(verifier, VT_TYPE, 1) && + VerifyField(verifier, VT_HAS_RANK, 1) && + verifier.EndTable(); + } + VariantSubTypeT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(VariantSubTypeT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const VariantSubTypeT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct VariantSubTypeBuilder { + typedef VariantSubType Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_shape(flatbuffers::Offset> shape) { + fbb_.AddOffset(VariantSubType::VT_SHAPE, shape); + } + void add_type(tflite::TensorType type) { + fbb_.AddElement(VariantSubType::VT_TYPE, static_cast(type), 0); + } + void add_has_rank(bool has_rank) { + fbb_.AddElement(VariantSubType::VT_HAS_RANK, static_cast(has_rank), 0); + } + explicit VariantSubTypeBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateVariantSubType( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset> shape = 0, + tflite::TensorType type = tflite::TensorType_FLOAT32, + bool has_rank = false) { + VariantSubTypeBuilder builder_(_fbb); + builder_.add_shape(shape); + builder_.add_has_rank(has_rank); + builder_.add_type(type); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateVariantSubTypeDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const std::vector *shape = nullptr, + tflite::TensorType type = tflite::TensorType_FLOAT32, + bool has_rank = false) { + auto shape__ = shape ? _fbb.CreateVector(*shape) : 0; + return tflite::CreateVariantSubType( + _fbb, + shape__, + type, + has_rank); +} + +flatbuffers::Offset CreateVariantSubType(flatbuffers::FlatBufferBuilder &_fbb, const VariantSubTypeT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + struct TensorT : public flatbuffers::NativeTable { typedef Tensor TableType; - std::vector shape; - tflite::TensorType type; - uint32_t buffer; - std::string name; - std::unique_ptr quantization; - bool is_variable; - std::unique_ptr sparsity; - std::vector shape_signature; - bool has_rank; - TensorT() - : type(tflite::TensorType_FLOAT32), - buffer(0), - is_variable(false), - has_rank(false) { - } + std::vector shape{}; + tflite::TensorType type = tflite::TensorType_FLOAT32; + uint32_t buffer = 0; + std::string name{}; + std::unique_ptr quantization{}; + bool is_variable = false; + std::unique_ptr sparsity{}; + std::vector shape_signature{}; + bool has_rank = false; + std::vector> variant_tensors{}; + TensorT() = default; + TensorT(const TensorT &o); + TensorT(TensorT&&) FLATBUFFERS_NOEXCEPT = default; + TensorT &operator=(TensorT o) FLATBUFFERS_NOEXCEPT; }; struct Tensor FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -4216,7 +4830,8 @@ struct Tensor FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { VT_IS_VARIABLE = 14, VT_SPARSITY = 16, VT_SHAPE_SIGNATURE = 18, - VT_HAS_RANK = 20 + VT_HAS_RANK = 20, + VT_VARIANT_TENSORS = 22 }; const flatbuffers::Vector *shape() const { return GetPointer *>(VT_SHAPE); @@ -4245,22 +4860,28 @@ struct Tensor FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { bool has_rank() const { return GetField(VT_HAS_RANK, 0) != 0; } + const flatbuffers::Vector> *variant_tensors() const { + return GetPointer> *>(VT_VARIANT_TENSORS); + } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_SHAPE) && verifier.VerifyVector(shape()) && - VerifyField(verifier, VT_TYPE) && - VerifyField(verifier, VT_BUFFER) && + VerifyField(verifier, VT_TYPE, 1) && + VerifyField(verifier, VT_BUFFER, 4) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && VerifyOffset(verifier, VT_QUANTIZATION) && verifier.VerifyTable(quantization()) && - VerifyField(verifier, VT_IS_VARIABLE) && + VerifyField(verifier, VT_IS_VARIABLE, 1) && VerifyOffset(verifier, VT_SPARSITY) && verifier.VerifyTable(sparsity()) && VerifyOffset(verifier, VT_SHAPE_SIGNATURE) && verifier.VerifyVector(shape_signature()) && - VerifyField(verifier, VT_HAS_RANK) && + VerifyField(verifier, VT_HAS_RANK, 1) && + VerifyOffset(verifier, VT_VARIANT_TENSORS) && + verifier.VerifyVector(variant_tensors()) && + verifier.VerifyVectorOfTables(variant_tensors()) && verifier.EndTable(); } TensorT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -4299,11 +4920,13 @@ struct TensorBuilder { void add_has_rank(bool has_rank) { fbb_.AddElement(Tensor::VT_HAS_RANK, static_cast(has_rank), 0); } + void add_variant_tensors(flatbuffers::Offset>> variant_tensors) { + fbb_.AddOffset(Tensor::VT_VARIANT_TENSORS, variant_tensors); + } explicit TensorBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TensorBuilder &operator=(const TensorBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -4321,8 +4944,10 @@ inline flatbuffers::Offset CreateTensor( bool is_variable = false, flatbuffers::Offset sparsity = 0, flatbuffers::Offset> shape_signature = 0, - bool has_rank = false) { + bool has_rank = false, + flatbuffers::Offset>> variant_tensors = 0) { TensorBuilder builder_(_fbb); + builder_.add_variant_tensors(variant_tensors); builder_.add_shape_signature(shape_signature); builder_.add_sparsity(sparsity); builder_.add_quantization(quantization); @@ -4345,10 +4970,12 @@ inline flatbuffers::Offset CreateTensorDirect( bool is_variable = false, flatbuffers::Offset sparsity = 0, const std::vector *shape_signature = nullptr, - bool has_rank = false) { + bool has_rank = false, + const std::vector> *variant_tensors = nullptr) { auto shape__ = shape ? _fbb.CreateVector(*shape) : 0; auto name__ = name ? _fbb.CreateString(name) : 0; auto shape_signature__ = shape_signature ? _fbb.CreateVector(*shape_signature) : 0; + auto variant_tensors__ = variant_tensors ? _fbb.CreateVector>(*variant_tensors) : 0; return tflite::CreateTensor( _fbb, shape__, @@ -4359,27 +4986,20 @@ inline flatbuffers::Offset CreateTensorDirect( is_variable, sparsity, shape_signature__, - has_rank); + has_rank, + variant_tensors__); } flatbuffers::Offset CreateTensor(flatbuffers::FlatBufferBuilder &_fbb, const TensorT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); struct Conv2DOptionsT : public flatbuffers::NativeTable { typedef Conv2DOptions TableType; - tflite::Padding padding; - int32_t stride_w; - int32_t stride_h; - tflite::ActivationFunctionType fused_activation_function; - int32_t dilation_w_factor; - int32_t dilation_h_factor; - Conv2DOptionsT() - : padding(tflite::Padding_SAME), - stride_w(0), - stride_h(0), - fused_activation_function(tflite::ActivationFunctionType_NONE), - dilation_w_factor(1), - dilation_h_factor(1) { - } + tflite::Padding padding = tflite::Padding_SAME; + int32_t stride_w = 0; + int32_t stride_h = 0; + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + int32_t dilation_w_factor = 1; + int32_t dilation_h_factor = 1; }; struct Conv2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -4413,12 +5033,12 @@ struct Conv2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_PADDING) && - VerifyField(verifier, VT_STRIDE_W) && - VerifyField(verifier, VT_STRIDE_H) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_DILATION_W_FACTOR) && - VerifyField(verifier, VT_DILATION_H_FACTOR) && + VerifyField(verifier, VT_PADDING, 1) && + VerifyField(verifier, VT_STRIDE_W, 4) && + VerifyField(verifier, VT_STRIDE_H, 4) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_DILATION_W_FACTOR, 4) && + VerifyField(verifier, VT_DILATION_H_FACTOR, 4) && verifier.EndTable(); } Conv2DOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -4452,7 +5072,6 @@ struct Conv2DOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Conv2DOptionsBuilder &operator=(const Conv2DOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -4482,24 +5101,14 @@ flatbuffers::Offset CreateConv2DOptions(flatbuffers::FlatBufferBu struct Conv3DOptionsT : public flatbuffers::NativeTable { typedef Conv3DOptions TableType; - tflite::Padding padding; - int32_t stride_d; - int32_t stride_w; - int32_t stride_h; - tflite::ActivationFunctionType fused_activation_function; - int32_t dilation_d_factor; - int32_t dilation_w_factor; - int32_t dilation_h_factor; - Conv3DOptionsT() - : padding(tflite::Padding_SAME), - stride_d(0), - stride_w(0), - stride_h(0), - fused_activation_function(tflite::ActivationFunctionType_NONE), - dilation_d_factor(1), - dilation_w_factor(1), - dilation_h_factor(1) { - } + tflite::Padding padding = tflite::Padding_SAME; + int32_t stride_d = 0; + int32_t stride_w = 0; + int32_t stride_h = 0; + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + int32_t dilation_d_factor = 1; + int32_t dilation_w_factor = 1; + int32_t dilation_h_factor = 1; }; struct Conv3DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -4541,14 +5150,14 @@ struct Conv3DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_PADDING) && - VerifyField(verifier, VT_STRIDE_D) && - VerifyField(verifier, VT_STRIDE_W) && - VerifyField(verifier, VT_STRIDE_H) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_DILATION_D_FACTOR) && - VerifyField(verifier, VT_DILATION_W_FACTOR) && - VerifyField(verifier, VT_DILATION_H_FACTOR) && + VerifyField(verifier, VT_PADDING, 1) && + VerifyField(verifier, VT_STRIDE_D, 4) && + VerifyField(verifier, VT_STRIDE_W, 4) && + VerifyField(verifier, VT_STRIDE_H, 4) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_DILATION_D_FACTOR, 4) && + VerifyField(verifier, VT_DILATION_W_FACTOR, 4) && + VerifyField(verifier, VT_DILATION_H_FACTOR, 4) && verifier.EndTable(); } Conv3DOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -4588,7 +5197,6 @@ struct Conv3DOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Conv3DOptionsBuilder &operator=(const Conv3DOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -4622,20 +5230,12 @@ flatbuffers::Offset CreateConv3DOptions(flatbuffers::FlatBufferBu struct Pool2DOptionsT : public flatbuffers::NativeTable { typedef Pool2DOptions TableType; - tflite::Padding padding; - int32_t stride_w; - int32_t stride_h; - int32_t filter_width; - int32_t filter_height; - tflite::ActivationFunctionType fused_activation_function; - Pool2DOptionsT() - : padding(tflite::Padding_SAME), - stride_w(0), - stride_h(0), - filter_width(0), - filter_height(0), - fused_activation_function(tflite::ActivationFunctionType_NONE) { - } + tflite::Padding padding = tflite::Padding_SAME; + int32_t stride_w = 0; + int32_t stride_h = 0; + int32_t filter_width = 0; + int32_t filter_height = 0; + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; }; struct Pool2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -4669,12 +5269,12 @@ struct Pool2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_PADDING) && - VerifyField(verifier, VT_STRIDE_W) && - VerifyField(verifier, VT_STRIDE_H) && - VerifyField(verifier, VT_FILTER_WIDTH) && - VerifyField(verifier, VT_FILTER_HEIGHT) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && + VerifyField(verifier, VT_PADDING, 1) && + VerifyField(verifier, VT_STRIDE_W, 4) && + VerifyField(verifier, VT_STRIDE_H, 4) && + VerifyField(verifier, VT_FILTER_WIDTH, 4) && + VerifyField(verifier, VT_FILTER_HEIGHT, 4) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && verifier.EndTable(); } Pool2DOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -4708,7 +5308,6 @@ struct Pool2DOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Pool2DOptionsBuilder &operator=(const Pool2DOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -4738,22 +5337,13 @@ flatbuffers::Offset CreatePool2DOptions(flatbuffers::FlatBufferBu struct DepthwiseConv2DOptionsT : public flatbuffers::NativeTable { typedef DepthwiseConv2DOptions TableType; - tflite::Padding padding; - int32_t stride_w; - int32_t stride_h; - int32_t depth_multiplier; - tflite::ActivationFunctionType fused_activation_function; - int32_t dilation_w_factor; - int32_t dilation_h_factor; - DepthwiseConv2DOptionsT() - : padding(tflite::Padding_SAME), - stride_w(0), - stride_h(0), - depth_multiplier(0), - fused_activation_function(tflite::ActivationFunctionType_NONE), - dilation_w_factor(1), - dilation_h_factor(1) { - } + tflite::Padding padding = tflite::Padding_SAME; + int32_t stride_w = 0; + int32_t stride_h = 0; + int32_t depth_multiplier = 0; + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + int32_t dilation_w_factor = 1; + int32_t dilation_h_factor = 1; }; struct DepthwiseConv2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -4791,13 +5381,13 @@ struct DepthwiseConv2DOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tab } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_PADDING) && - VerifyField(verifier, VT_STRIDE_W) && - VerifyField(verifier, VT_STRIDE_H) && - VerifyField(verifier, VT_DEPTH_MULTIPLIER) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_DILATION_W_FACTOR) && - VerifyField(verifier, VT_DILATION_H_FACTOR) && + VerifyField(verifier, VT_PADDING, 1) && + VerifyField(verifier, VT_STRIDE_W, 4) && + VerifyField(verifier, VT_STRIDE_H, 4) && + VerifyField(verifier, VT_DEPTH_MULTIPLIER, 4) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_DILATION_W_FACTOR, 4) && + VerifyField(verifier, VT_DILATION_H_FACTOR, 4) && verifier.EndTable(); } DepthwiseConv2DOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -4834,7 +5424,6 @@ struct DepthwiseConv2DOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - DepthwiseConv2DOptionsBuilder &operator=(const DepthwiseConv2DOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -4866,12 +5455,9 @@ flatbuffers::Offset CreateDepthwiseConv2DOptions(flatbuf struct ConcatEmbeddingsOptionsT : public flatbuffers::NativeTable { typedef ConcatEmbeddingsOptions TableType; - int32_t num_channels; - std::vector num_columns_per_channel; - std::vector embedding_dim_per_channel; - ConcatEmbeddingsOptionsT() - : num_channels(0) { - } + int32_t num_channels = 0; + std::vector num_columns_per_channel{}; + std::vector embedding_dim_per_channel{}; }; struct ConcatEmbeddingsOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -4893,7 +5479,7 @@ struct ConcatEmbeddingsOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Ta } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_NUM_CHANNELS) && + VerifyField(verifier, VT_NUM_CHANNELS, 4) && VerifyOffset(verifier, VT_NUM_COLUMNS_PER_CHANNEL) && verifier.VerifyVector(num_columns_per_channel()) && VerifyOffset(verifier, VT_EMBEDDING_DIM_PER_CHANNEL) && @@ -4922,7 +5508,6 @@ struct ConcatEmbeddingsOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ConcatEmbeddingsOptionsBuilder &operator=(const ConcatEmbeddingsOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -4960,10 +5545,7 @@ flatbuffers::Offset CreateConcatEmbeddingsOptions(flatb struct LSHProjectionOptionsT : public flatbuffers::NativeTable { typedef LSHProjectionOptions TableType; - tflite::LSHProjectionType type; - LSHProjectionOptionsT() - : type(tflite::LSHProjectionType_UNKNOWN) { - } + tflite::LSHProjectionType type = tflite::LSHProjectionType_UNKNOWN; }; struct LSHProjectionOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -4977,7 +5559,7 @@ struct LSHProjectionOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_TYPE) && + VerifyField(verifier, VT_TYPE, 1) && verifier.EndTable(); } LSHProjectionOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -4996,7 +5578,6 @@ struct LSHProjectionOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LSHProjectionOptionsBuilder &operator=(const LSHProjectionOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5016,14 +5597,9 @@ flatbuffers::Offset CreateLSHProjectionOptions(flatbuffers struct SVDFOptionsT : public flatbuffers::NativeTable { typedef SVDFOptions TableType; - int32_t rank; - tflite::ActivationFunctionType fused_activation_function; - bool asymmetric_quantize_inputs; - SVDFOptionsT() - : rank(0), - fused_activation_function(tflite::ActivationFunctionType_NONE), - asymmetric_quantize_inputs(false) { - } + int32_t rank = 0; + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + bool asymmetric_quantize_inputs = false; }; struct SVDFOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5045,9 +5621,9 @@ struct SVDFOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_RANK) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_RANK, 4) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } SVDFOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5072,7 +5648,6 @@ struct SVDFOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SVDFOptionsBuilder &operator=(const SVDFOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5096,12 +5671,8 @@ flatbuffers::Offset CreateSVDFOptions(flatbuffers::FlatBufferBuilde struct RNNOptionsT : public flatbuffers::NativeTable { typedef RNNOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - bool asymmetric_quantize_inputs; - RNNOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE), - asymmetric_quantize_inputs(false) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + bool asymmetric_quantize_inputs = false; }; struct RNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5119,8 +5690,8 @@ struct RNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } RNNOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5142,7 +5713,6 @@ struct RNNOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - RNNOptionsBuilder &operator=(const RNNOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5164,14 +5734,9 @@ flatbuffers::Offset CreateRNNOptions(flatbuffers::FlatBufferBuilder struct SequenceRNNOptionsT : public flatbuffers::NativeTable { typedef SequenceRNNOptions TableType; - bool time_major; - tflite::ActivationFunctionType fused_activation_function; - bool asymmetric_quantize_inputs; - SequenceRNNOptionsT() - : time_major(false), - fused_activation_function(tflite::ActivationFunctionType_NONE), - asymmetric_quantize_inputs(false) { - } + bool time_major = false; + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + bool asymmetric_quantize_inputs = false; }; struct SequenceRNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5193,9 +5758,9 @@ struct SequenceRNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_TIME_MAJOR) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_TIME_MAJOR, 1) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } SequenceRNNOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5220,7 +5785,6 @@ struct SequenceRNNOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SequenceRNNOptionsBuilder &operator=(const SequenceRNNOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5244,16 +5808,10 @@ flatbuffers::Offset CreateSequenceRNNOptions(flatbuffers::Fl struct BidirectionalSequenceRNNOptionsT : public flatbuffers::NativeTable { typedef BidirectionalSequenceRNNOptions TableType; - bool time_major; - tflite::ActivationFunctionType fused_activation_function; - bool merge_outputs; - bool asymmetric_quantize_inputs; - BidirectionalSequenceRNNOptionsT() - : time_major(false), - fused_activation_function(tflite::ActivationFunctionType_NONE), - merge_outputs(false), - asymmetric_quantize_inputs(false) { - } + bool time_major = false; + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + bool merge_outputs = false; + bool asymmetric_quantize_inputs = false; }; struct BidirectionalSequenceRNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5279,10 +5837,10 @@ struct BidirectionalSequenceRNNOptions FLATBUFFERS_FINAL_CLASS : private flatbuf } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_TIME_MAJOR) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_MERGE_OUTPUTS) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_TIME_MAJOR, 1) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_MERGE_OUTPUTS, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } BidirectionalSequenceRNNOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5310,7 +5868,6 @@ struct BidirectionalSequenceRNNOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BidirectionalSequenceRNNOptionsBuilder &operator=(const BidirectionalSequenceRNNOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5336,16 +5893,10 @@ flatbuffers::Offset CreateBidirectionalSequence struct FullyConnectedOptionsT : public flatbuffers::NativeTable { typedef FullyConnectedOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - tflite::FullyConnectedOptionsWeightsFormat weights_format; - bool keep_num_dims; - bool asymmetric_quantize_inputs; - FullyConnectedOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE), - weights_format(tflite::FullyConnectedOptionsWeightsFormat_DEFAULT), - keep_num_dims(false), - asymmetric_quantize_inputs(false) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + tflite::FullyConnectedOptionsWeightsFormat weights_format = tflite::FullyConnectedOptionsWeightsFormat_DEFAULT; + bool keep_num_dims = false; + bool asymmetric_quantize_inputs = false; }; struct FullyConnectedOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5371,10 +5922,10 @@ struct FullyConnectedOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tabl } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_WEIGHTS_FORMAT) && - VerifyField(verifier, VT_KEEP_NUM_DIMS) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_WEIGHTS_FORMAT, 1) && + VerifyField(verifier, VT_KEEP_NUM_DIMS, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } FullyConnectedOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5402,7 +5953,6 @@ struct FullyConnectedOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - FullyConnectedOptionsBuilder &operator=(const FullyConnectedOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5428,10 +5978,7 @@ flatbuffers::Offset CreateFullyConnectedOptions(flatbuffe struct SoftmaxOptionsT : public flatbuffers::NativeTable { typedef SoftmaxOptions TableType; - float beta; - SoftmaxOptionsT() - : beta(0.0f) { - } + float beta = 0.0f; }; struct SoftmaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5445,7 +5992,7 @@ struct SoftmaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_BETA) && + VerifyField(verifier, VT_BETA, 4) && verifier.EndTable(); } SoftmaxOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5464,7 +6011,6 @@ struct SoftmaxOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SoftmaxOptionsBuilder &operator=(const SoftmaxOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5484,12 +6030,8 @@ flatbuffers::Offset CreateSoftmaxOptions(flatbuffers::FlatBuffer struct ConcatenationOptionsT : public flatbuffers::NativeTable { typedef ConcatenationOptions TableType; - int32_t axis; - tflite::ActivationFunctionType fused_activation_function; - ConcatenationOptionsT() - : axis(0), - fused_activation_function(tflite::ActivationFunctionType_NONE) { - } + int32_t axis = 0; + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; }; struct ConcatenationOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5507,8 +6049,8 @@ struct ConcatenationOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_AXIS) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && + VerifyField(verifier, VT_AXIS, 4) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && verifier.EndTable(); } ConcatenationOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5530,7 +6072,6 @@ struct ConcatenationOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ConcatenationOptionsBuilder &operator=(const ConcatenationOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5552,12 +6093,8 @@ flatbuffers::Offset CreateConcatenationOptions(flatbuffers struct AddOptionsT : public flatbuffers::NativeTable { typedef AddOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - bool pot_scale_int16; - AddOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE), - pot_scale_int16(true) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + bool pot_scale_int16 = true; }; struct AddOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5575,8 +6112,8 @@ struct AddOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_POT_SCALE_INT16) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_POT_SCALE_INT16, 1) && verifier.EndTable(); } AddOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5598,7 +6135,6 @@ struct AddOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - AddOptionsBuilder &operator=(const AddOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5620,10 +6156,7 @@ flatbuffers::Offset CreateAddOptions(flatbuffers::FlatBufferBuilder struct MulOptionsT : public flatbuffers::NativeTable { typedef MulOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - MulOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; }; struct MulOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5637,7 +6170,7 @@ struct MulOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && verifier.EndTable(); } MulOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5656,7 +6189,6 @@ struct MulOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - MulOptionsBuilder &operator=(const MulOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5676,10 +6208,7 @@ flatbuffers::Offset CreateMulOptions(flatbuffers::FlatBufferBuilder struct L2NormOptionsT : public flatbuffers::NativeTable { typedef L2NormOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - L2NormOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; }; struct L2NormOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5693,7 +6222,7 @@ struct L2NormOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && verifier.EndTable(); } L2NormOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5712,7 +6241,6 @@ struct L2NormOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - L2NormOptionsBuilder &operator=(const L2NormOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5732,16 +6260,10 @@ flatbuffers::Offset CreateL2NormOptions(flatbuffers::FlatBufferBu struct LocalResponseNormalizationOptionsT : public flatbuffers::NativeTable { typedef LocalResponseNormalizationOptions TableType; - int32_t radius; - float bias; - float alpha; - float beta; - LocalResponseNormalizationOptionsT() - : radius(0), - bias(0.0f), - alpha(0.0f), - beta(0.0f) { - } + int32_t radius = 0; + float bias = 0.0f; + float alpha = 0.0f; + float beta = 0.0f; }; struct LocalResponseNormalizationOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5767,10 +6289,10 @@ struct LocalResponseNormalizationOptions FLATBUFFERS_FINAL_CLASS : private flatb } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_RADIUS) && - VerifyField(verifier, VT_BIAS) && - VerifyField(verifier, VT_ALPHA) && - VerifyField(verifier, VT_BETA) && + VerifyField(verifier, VT_RADIUS, 4) && + VerifyField(verifier, VT_BIAS, 4) && + VerifyField(verifier, VT_ALPHA, 4) && + VerifyField(verifier, VT_BETA, 4) && verifier.EndTable(); } LocalResponseNormalizationOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5798,7 +6320,6 @@ struct LocalResponseNormalizationOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LocalResponseNormalizationOptionsBuilder &operator=(const LocalResponseNormalizationOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5824,18 +6345,11 @@ flatbuffers::Offset CreateLocalResponseNormal struct LSTMOptionsT : public flatbuffers::NativeTable { typedef LSTMOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - float cell_clip; - float proj_clip; - tflite::LSTMKernelType kernel_type; - bool asymmetric_quantize_inputs; - LSTMOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE), - cell_clip(0.0f), - proj_clip(0.0f), - kernel_type(tflite::LSTMKernelType_FULL), - asymmetric_quantize_inputs(false) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + float cell_clip = 0.0f; + float proj_clip = 0.0f; + tflite::LSTMKernelType kernel_type = tflite::LSTMKernelType_FULL; + bool asymmetric_quantize_inputs = false; }; struct LSTMOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5865,11 +6379,11 @@ struct LSTMOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_CELL_CLIP) && - VerifyField(verifier, VT_PROJ_CLIP) && - VerifyField(verifier, VT_KERNEL_TYPE) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_CELL_CLIP, 4) && + VerifyField(verifier, VT_PROJ_CLIP, 4) && + VerifyField(verifier, VT_KERNEL_TYPE, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } LSTMOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -5900,7 +6414,6 @@ struct LSTMOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LSTMOptionsBuilder &operator=(const LSTMOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -5928,18 +6441,11 @@ flatbuffers::Offset CreateLSTMOptions(flatbuffers::FlatBufferBuilde struct UnidirectionalSequenceLSTMOptionsT : public flatbuffers::NativeTable { typedef UnidirectionalSequenceLSTMOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - float cell_clip; - float proj_clip; - bool time_major; - bool asymmetric_quantize_inputs; - UnidirectionalSequenceLSTMOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE), - cell_clip(0.0f), - proj_clip(0.0f), - time_major(false), - asymmetric_quantize_inputs(false) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + float cell_clip = 0.0f; + float proj_clip = 0.0f; + bool time_major = false; + bool asymmetric_quantize_inputs = false; }; struct UnidirectionalSequenceLSTMOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -5969,11 +6475,11 @@ struct UnidirectionalSequenceLSTMOptions FLATBUFFERS_FINAL_CLASS : private flatb } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_CELL_CLIP) && - VerifyField(verifier, VT_PROJ_CLIP) && - VerifyField(verifier, VT_TIME_MAJOR) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_CELL_CLIP, 4) && + VerifyField(verifier, VT_PROJ_CLIP, 4) && + VerifyField(verifier, VT_TIME_MAJOR, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } UnidirectionalSequenceLSTMOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6004,7 +6510,6 @@ struct UnidirectionalSequenceLSTMOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - UnidirectionalSequenceLSTMOptionsBuilder &operator=(const UnidirectionalSequenceLSTMOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6032,20 +6537,12 @@ flatbuffers::Offset CreateUnidirectionalSeque struct BidirectionalSequenceLSTMOptionsT : public flatbuffers::NativeTable { typedef BidirectionalSequenceLSTMOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - float cell_clip; - float proj_clip; - bool merge_outputs; - bool time_major; - bool asymmetric_quantize_inputs; - BidirectionalSequenceLSTMOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE), - cell_clip(0.0f), - proj_clip(0.0f), - merge_outputs(false), - time_major(true), - asymmetric_quantize_inputs(false) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + float cell_clip = 0.0f; + float proj_clip = 0.0f; + bool merge_outputs = false; + bool time_major = true; + bool asymmetric_quantize_inputs = false; }; struct BidirectionalSequenceLSTMOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6079,12 +6576,12 @@ struct BidirectionalSequenceLSTMOptions FLATBUFFERS_FINAL_CLASS : private flatbu } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_CELL_CLIP) && - VerifyField(verifier, VT_PROJ_CLIP) && - VerifyField(verifier, VT_MERGE_OUTPUTS) && - VerifyField(verifier, VT_TIME_MAJOR) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_CELL_CLIP, 4) && + VerifyField(verifier, VT_PROJ_CLIP, 4) && + VerifyField(verifier, VT_MERGE_OUTPUTS, 1) && + VerifyField(verifier, VT_TIME_MAJOR, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } BidirectionalSequenceLSTMOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6118,7 +6615,6 @@ struct BidirectionalSequenceLSTMOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BidirectionalSequenceLSTMOptionsBuilder &operator=(const BidirectionalSequenceLSTMOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6148,12 +6644,8 @@ flatbuffers::Offset CreateBidirectionalSequenc struct ResizeBilinearOptionsT : public flatbuffers::NativeTable { typedef ResizeBilinearOptions TableType; - bool align_corners; - bool half_pixel_centers; - ResizeBilinearOptionsT() - : align_corners(false), - half_pixel_centers(false) { - } + bool align_corners = false; + bool half_pixel_centers = false; }; struct ResizeBilinearOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6171,8 +6663,8 @@ struct ResizeBilinearOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tabl } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_ALIGN_CORNERS) && - VerifyField(verifier, VT_HALF_PIXEL_CENTERS) && + VerifyField(verifier, VT_ALIGN_CORNERS, 1) && + VerifyField(verifier, VT_HALF_PIXEL_CENTERS, 1) && verifier.EndTable(); } ResizeBilinearOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6194,7 +6686,6 @@ struct ResizeBilinearOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ResizeBilinearOptionsBuilder &operator=(const ResizeBilinearOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6216,12 +6707,8 @@ flatbuffers::Offset CreateResizeBilinearOptions(flatbuffe struct ResizeNearestNeighborOptionsT : public flatbuffers::NativeTable { typedef ResizeNearestNeighborOptions TableType; - bool align_corners; - bool half_pixel_centers; - ResizeNearestNeighborOptionsT() - : align_corners(false), - half_pixel_centers(false) { - } + bool align_corners = false; + bool half_pixel_centers = false; }; struct ResizeNearestNeighborOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6239,8 +6726,8 @@ struct ResizeNearestNeighborOptions FLATBUFFERS_FINAL_CLASS : private flatbuffer } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_ALIGN_CORNERS) && - VerifyField(verifier, VT_HALF_PIXEL_CENTERS) && + VerifyField(verifier, VT_ALIGN_CORNERS, 1) && + VerifyField(verifier, VT_HALF_PIXEL_CENTERS, 1) && verifier.EndTable(); } ResizeNearestNeighborOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6262,7 +6749,6 @@ struct ResizeNearestNeighborOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ResizeNearestNeighborOptionsBuilder &operator=(const ResizeNearestNeighborOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6284,10 +6770,7 @@ flatbuffers::Offset CreateResizeNearestNeighborOpt struct CallOptionsT : public flatbuffers::NativeTable { typedef CallOptions TableType; - uint32_t subgraph; - CallOptionsT() - : subgraph(0) { - } + uint32_t subgraph = 0; }; struct CallOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6301,7 +6784,7 @@ struct CallOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_SUBGRAPH) && + VerifyField(verifier, VT_SUBGRAPH, 4) && verifier.EndTable(); } CallOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6320,7 +6803,6 @@ struct CallOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - CallOptionsBuilder &operator=(const CallOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6340,8 +6822,6 @@ flatbuffers::Offset CreateCallOptions(flatbuffers::FlatBufferBuilde struct PadOptionsT : public flatbuffers::NativeTable { typedef PadOptions TableType; - PadOptionsT() { - } }; struct PadOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6364,7 +6844,6 @@ struct PadOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - PadOptionsBuilder &operator=(const PadOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6382,8 +6861,6 @@ flatbuffers::Offset CreatePadOptions(flatbuffers::FlatBufferBuilder struct PadV2OptionsT : public flatbuffers::NativeTable { typedef PadV2Options TableType; - PadV2OptionsT() { - } }; struct PadV2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6406,7 +6883,6 @@ struct PadV2OptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - PadV2OptionsBuilder &operator=(const PadV2OptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6424,9 +6900,7 @@ flatbuffers::Offset CreatePadV2Options(flatbuffers::FlatBufferBuil struct ReshapeOptionsT : public flatbuffers::NativeTable { typedef ReshapeOptions TableType; - std::vector new_shape; - ReshapeOptionsT() { - } + std::vector new_shape{}; }; struct ReshapeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6460,7 +6934,6 @@ struct ReshapeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ReshapeOptionsBuilder &operator=(const ReshapeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6489,8 +6962,6 @@ flatbuffers::Offset CreateReshapeOptions(flatbuffers::FlatBuffer struct SpaceToBatchNDOptionsT : public flatbuffers::NativeTable { typedef SpaceToBatchNDOptions TableType; - SpaceToBatchNDOptionsT() { - } }; struct SpaceToBatchNDOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6513,7 +6984,6 @@ struct SpaceToBatchNDOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SpaceToBatchNDOptionsBuilder &operator=(const SpaceToBatchNDOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6531,8 +7001,6 @@ flatbuffers::Offset CreateSpaceToBatchNDOptions(flatbuffe struct BatchToSpaceNDOptionsT : public flatbuffers::NativeTable { typedef BatchToSpaceNDOptions TableType; - BatchToSpaceNDOptionsT() { - } }; struct BatchToSpaceNDOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6555,7 +7023,6 @@ struct BatchToSpaceNDOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BatchToSpaceNDOptionsBuilder &operator=(const BatchToSpaceNDOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6573,14 +7040,9 @@ flatbuffers::Offset CreateBatchToSpaceNDOptions(flatbuffe struct SkipGramOptionsT : public flatbuffers::NativeTable { typedef SkipGramOptions TableType; - int32_t ngram_size; - int32_t max_skip_size; - bool include_all_ngrams; - SkipGramOptionsT() - : ngram_size(0), - max_skip_size(0), - include_all_ngrams(false) { - } + int32_t ngram_size = 0; + int32_t max_skip_size = 0; + bool include_all_ngrams = false; }; struct SkipGramOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6602,9 +7064,9 @@ struct SkipGramOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_NGRAM_SIZE) && - VerifyField(verifier, VT_MAX_SKIP_SIZE) && - VerifyField(verifier, VT_INCLUDE_ALL_NGRAMS) && + VerifyField(verifier, VT_NGRAM_SIZE, 4) && + VerifyField(verifier, VT_MAX_SKIP_SIZE, 4) && + VerifyField(verifier, VT_INCLUDE_ALL_NGRAMS, 1) && verifier.EndTable(); } SkipGramOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6629,7 +7091,6 @@ struct SkipGramOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SkipGramOptionsBuilder &operator=(const SkipGramOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6653,10 +7114,7 @@ flatbuffers::Offset CreateSkipGramOptions(flatbuffers::FlatBuff struct SpaceToDepthOptionsT : public flatbuffers::NativeTable { typedef SpaceToDepthOptions TableType; - int32_t block_size; - SpaceToDepthOptionsT() - : block_size(0) { - } + int32_t block_size = 0; }; struct SpaceToDepthOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6670,7 +7128,7 @@ struct SpaceToDepthOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_BLOCK_SIZE) && + VerifyField(verifier, VT_BLOCK_SIZE, 4) && verifier.EndTable(); } SpaceToDepthOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6689,7 +7147,6 @@ struct SpaceToDepthOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SpaceToDepthOptionsBuilder &operator=(const SpaceToDepthOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6709,10 +7166,7 @@ flatbuffers::Offset CreateSpaceToDepthOptions(flatbuffers:: struct DepthToSpaceOptionsT : public flatbuffers::NativeTable { typedef DepthToSpaceOptions TableType; - int32_t block_size; - DepthToSpaceOptionsT() - : block_size(0) { - } + int32_t block_size = 0; }; struct DepthToSpaceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6726,7 +7180,7 @@ struct DepthToSpaceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_BLOCK_SIZE) && + VerifyField(verifier, VT_BLOCK_SIZE, 4) && verifier.EndTable(); } DepthToSpaceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6745,7 +7199,6 @@ struct DepthToSpaceOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - DepthToSpaceOptionsBuilder &operator=(const DepthToSpaceOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6765,12 +7218,8 @@ flatbuffers::Offset CreateDepthToSpaceOptions(flatbuffers:: struct SubOptionsT : public flatbuffers::NativeTable { typedef SubOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - bool pot_scale_int16; - SubOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE), - pot_scale_int16(true) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; + bool pot_scale_int16 = true; }; struct SubOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6788,8 +7237,8 @@ struct SubOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && - VerifyField(verifier, VT_POT_SCALE_INT16) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && + VerifyField(verifier, VT_POT_SCALE_INT16, 1) && verifier.EndTable(); } SubOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6811,7 +7260,6 @@ struct SubOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SubOptionsBuilder &operator=(const SubOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6833,10 +7281,7 @@ flatbuffers::Offset CreateSubOptions(flatbuffers::FlatBufferBuilder struct DivOptionsT : public flatbuffers::NativeTable { typedef DivOptions TableType; - tflite::ActivationFunctionType fused_activation_function; - DivOptionsT() - : fused_activation_function(tflite::ActivationFunctionType_NONE) { - } + tflite::ActivationFunctionType fused_activation_function = tflite::ActivationFunctionType_NONE; }; struct DivOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6850,7 +7295,7 @@ struct DivOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION) && + VerifyField(verifier, VT_FUSED_ACTIVATION_FUNCTION, 1) && verifier.EndTable(); } DivOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6869,7 +7314,6 @@ struct DivOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - DivOptionsBuilder &operator=(const DivOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6889,8 +7333,6 @@ flatbuffers::Offset CreateDivOptions(flatbuffers::FlatBufferBuilder struct TopKV2OptionsT : public flatbuffers::NativeTable { typedef TopKV2Options TableType; - TopKV2OptionsT() { - } }; struct TopKV2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6913,7 +7355,6 @@ struct TopKV2OptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TopKV2OptionsBuilder &operator=(const TopKV2OptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6931,10 +7372,7 @@ flatbuffers::Offset CreateTopKV2Options(flatbuffers::FlatBufferBu struct EmbeddingLookupSparseOptionsT : public flatbuffers::NativeTable { typedef EmbeddingLookupSparseOptions TableType; - tflite::CombinerType combiner; - EmbeddingLookupSparseOptionsT() - : combiner(tflite::CombinerType_SUM) { - } + tflite::CombinerType combiner = tflite::CombinerType_SUM; }; struct EmbeddingLookupSparseOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -6948,7 +7386,7 @@ struct EmbeddingLookupSparseOptions FLATBUFFERS_FINAL_CLASS : private flatbuffer } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_COMBINER) && + VerifyField(verifier, VT_COMBINER, 1) && verifier.EndTable(); } EmbeddingLookupSparseOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -6967,7 +7405,6 @@ struct EmbeddingLookupSparseOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - EmbeddingLookupSparseOptionsBuilder &operator=(const EmbeddingLookupSparseOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -6987,12 +7424,8 @@ flatbuffers::Offset CreateEmbeddingLookupSparseOpt struct GatherOptionsT : public flatbuffers::NativeTable { typedef GatherOptions TableType; - int32_t axis; - int32_t batch_dims; - GatherOptionsT() - : axis(0), - batch_dims(0) { - } + int32_t axis = 0; + int32_t batch_dims = 0; }; struct GatherOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7010,8 +7443,8 @@ struct GatherOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_AXIS) && - VerifyField(verifier, VT_BATCH_DIMS) && + VerifyField(verifier, VT_AXIS, 4) && + VerifyField(verifier, VT_BATCH_DIMS, 4) && verifier.EndTable(); } GatherOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -7033,7 +7466,6 @@ struct GatherOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - GatherOptionsBuilder &operator=(const GatherOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7055,8 +7487,6 @@ flatbuffers::Offset CreateGatherOptions(flatbuffers::FlatBufferBu struct TransposeOptionsT : public flatbuffers::NativeTable { typedef TransposeOptions TableType; - TransposeOptionsT() { - } }; struct TransposeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7079,7 +7509,6 @@ struct TransposeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TransposeOptionsBuilder &operator=(const TransposeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7097,8 +7526,6 @@ flatbuffers::Offset CreateTransposeOptions(flatbuffers::FlatBu struct ExpOptionsT : public flatbuffers::NativeTable { typedef ExpOptions TableType; - ExpOptionsT() { - } }; struct ExpOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7121,7 +7548,6 @@ struct ExpOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ExpOptionsBuilder &operator=(const ExpOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7139,8 +7565,6 @@ flatbuffers::Offset CreateExpOptions(flatbuffers::FlatBufferBuilder struct CosOptionsT : public flatbuffers::NativeTable { typedef CosOptions TableType; - CosOptionsT() { - } }; struct CosOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7163,7 +7587,6 @@ struct CosOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - CosOptionsBuilder &operator=(const CosOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7181,10 +7604,7 @@ flatbuffers::Offset CreateCosOptions(flatbuffers::FlatBufferBuilder struct ReducerOptionsT : public flatbuffers::NativeTable { typedef ReducerOptions TableType; - bool keep_dims; - ReducerOptionsT() - : keep_dims(false) { - } + bool keep_dims = false; }; struct ReducerOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7198,7 +7618,7 @@ struct ReducerOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_KEEP_DIMS) && + VerifyField(verifier, VT_KEEP_DIMS, 1) && verifier.EndTable(); } ReducerOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -7217,7 +7637,6 @@ struct ReducerOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ReducerOptionsBuilder &operator=(const ReducerOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7237,9 +7656,7 @@ flatbuffers::Offset CreateReducerOptions(flatbuffers::FlatBuffer struct SqueezeOptionsT : public flatbuffers::NativeTable { typedef SqueezeOptions TableType; - std::vector squeeze_dims; - SqueezeOptionsT() { - } + std::vector squeeze_dims{}; }; struct SqueezeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7273,7 +7690,6 @@ struct SqueezeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SqueezeOptionsBuilder &operator=(const SqueezeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7302,10 +7718,7 @@ flatbuffers::Offset CreateSqueezeOptions(flatbuffers::FlatBuffer struct SplitOptionsT : public flatbuffers::NativeTable { typedef SplitOptions TableType; - int32_t num_splits; - SplitOptionsT() - : num_splits(0) { - } + int32_t num_splits = 0; }; struct SplitOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7319,7 +7732,7 @@ struct SplitOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_NUM_SPLITS) && + VerifyField(verifier, VT_NUM_SPLITS, 4) && verifier.EndTable(); } SplitOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -7338,7 +7751,6 @@ struct SplitOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SplitOptionsBuilder &operator=(const SplitOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7358,10 +7770,7 @@ flatbuffers::Offset CreateSplitOptions(flatbuffers::FlatBufferBuil struct SplitVOptionsT : public flatbuffers::NativeTable { typedef SplitVOptions TableType; - int32_t num_splits; - SplitVOptionsT() - : num_splits(0) { - } + int32_t num_splits = 0; }; struct SplitVOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7375,7 +7784,7 @@ struct SplitVOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_NUM_SPLITS) && + VerifyField(verifier, VT_NUM_SPLITS, 4) && verifier.EndTable(); } SplitVOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -7394,7 +7803,6 @@ struct SplitVOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SplitVOptionsBuilder &operator=(const SplitVOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7414,18 +7822,11 @@ flatbuffers::Offset CreateSplitVOptions(flatbuffers::FlatBufferBu struct StridedSliceOptionsT : public flatbuffers::NativeTable { typedef StridedSliceOptions TableType; - int32_t begin_mask; - int32_t end_mask; - int32_t ellipsis_mask; - int32_t new_axis_mask; - int32_t shrink_axis_mask; - StridedSliceOptionsT() - : begin_mask(0), - end_mask(0), - ellipsis_mask(0), - new_axis_mask(0), - shrink_axis_mask(0) { - } + int32_t begin_mask = 0; + int32_t end_mask = 0; + int32_t ellipsis_mask = 0; + int32_t new_axis_mask = 0; + int32_t shrink_axis_mask = 0; }; struct StridedSliceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7455,11 +7856,11 @@ struct StridedSliceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_BEGIN_MASK) && - VerifyField(verifier, VT_END_MASK) && - VerifyField(verifier, VT_ELLIPSIS_MASK) && - VerifyField(verifier, VT_NEW_AXIS_MASK) && - VerifyField(verifier, VT_SHRINK_AXIS_MASK) && + VerifyField(verifier, VT_BEGIN_MASK, 4) && + VerifyField(verifier, VT_END_MASK, 4) && + VerifyField(verifier, VT_ELLIPSIS_MASK, 4) && + VerifyField(verifier, VT_NEW_AXIS_MASK, 4) && + VerifyField(verifier, VT_SHRINK_AXIS_MASK, 4) && verifier.EndTable(); } StridedSliceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -7490,7 +7891,6 @@ struct StridedSliceOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - StridedSliceOptionsBuilder &operator=(const StridedSliceOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7518,8 +7918,6 @@ flatbuffers::Offset CreateStridedSliceOptions(flatbuffers:: struct LogSoftmaxOptionsT : public flatbuffers::NativeTable { typedef LogSoftmaxOptions TableType; - LogSoftmaxOptionsT() { - } }; struct LogSoftmaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7542,7 +7940,6 @@ struct LogSoftmaxOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LogSoftmaxOptionsBuilder &operator=(const LogSoftmaxOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7560,12 +7957,8 @@ flatbuffers::Offset CreateLogSoftmaxOptions(flatbuffers::Flat struct CastOptionsT : public flatbuffers::NativeTable { typedef CastOptions TableType; - tflite::TensorType in_data_type; - tflite::TensorType out_data_type; - CastOptionsT() - : in_data_type(tflite::TensorType_FLOAT32), - out_data_type(tflite::TensorType_FLOAT32) { - } + tflite::TensorType in_data_type = tflite::TensorType_FLOAT32; + tflite::TensorType out_data_type = tflite::TensorType_FLOAT32; }; struct CastOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7583,8 +7976,8 @@ struct CastOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_IN_DATA_TYPE) && - VerifyField(verifier, VT_OUT_DATA_TYPE) && + VerifyField(verifier, VT_IN_DATA_TYPE, 1) && + VerifyField(verifier, VT_OUT_DATA_TYPE, 1) && verifier.EndTable(); } CastOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -7606,7 +7999,6 @@ struct CastOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - CastOptionsBuilder &operator=(const CastOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7628,8 +8020,6 @@ flatbuffers::Offset CreateCastOptions(flatbuffers::FlatBufferBuilde struct DequantizeOptionsT : public flatbuffers::NativeTable { typedef DequantizeOptions TableType; - DequantizeOptionsT() { - } }; struct DequantizeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7652,7 +8042,6 @@ struct DequantizeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - DequantizeOptionsBuilder &operator=(const DequantizeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7670,8 +8059,6 @@ flatbuffers::Offset CreateDequantizeOptions(flatbuffers::Flat struct MaximumMinimumOptionsT : public flatbuffers::NativeTable { typedef MaximumMinimumOptions TableType; - MaximumMinimumOptionsT() { - } }; struct MaximumMinimumOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7694,7 +8081,6 @@ struct MaximumMinimumOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - MaximumMinimumOptionsBuilder &operator=(const MaximumMinimumOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7712,8 +8098,6 @@ flatbuffers::Offset CreateMaximumMinimumOptions(flatbuffe struct TileOptionsT : public flatbuffers::NativeTable { typedef TileOptions TableType; - TileOptionsT() { - } }; struct TileOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7736,7 +8120,6 @@ struct TileOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TileOptionsBuilder &operator=(const TileOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7754,10 +8137,7 @@ flatbuffers::Offset CreateTileOptions(flatbuffers::FlatBufferBuilde struct ArgMaxOptionsT : public flatbuffers::NativeTable { typedef ArgMaxOptions TableType; - tflite::TensorType output_type; - ArgMaxOptionsT() - : output_type(tflite::TensorType_FLOAT32) { - } + tflite::TensorType output_type = tflite::TensorType_FLOAT32; }; struct ArgMaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7771,7 +8151,7 @@ struct ArgMaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_OUTPUT_TYPE) && + VerifyField(verifier, VT_OUTPUT_TYPE, 1) && verifier.EndTable(); } ArgMaxOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -7790,7 +8170,6 @@ struct ArgMaxOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ArgMaxOptionsBuilder &operator=(const ArgMaxOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7810,10 +8189,7 @@ flatbuffers::Offset CreateArgMaxOptions(flatbuffers::FlatBufferBu struct ArgMinOptionsT : public flatbuffers::NativeTable { typedef ArgMinOptions TableType; - tflite::TensorType output_type; - ArgMinOptionsT() - : output_type(tflite::TensorType_FLOAT32) { - } + tflite::TensorType output_type = tflite::TensorType_FLOAT32; }; struct ArgMinOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7827,7 +8203,7 @@ struct ArgMinOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_OUTPUT_TYPE) && + VerifyField(verifier, VT_OUTPUT_TYPE, 1) && verifier.EndTable(); } ArgMinOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -7846,7 +8222,6 @@ struct ArgMinOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ArgMinOptionsBuilder &operator=(const ArgMinOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7866,8 +8241,6 @@ flatbuffers::Offset CreateArgMinOptions(flatbuffers::FlatBufferBu struct GreaterOptionsT : public flatbuffers::NativeTable { typedef GreaterOptions TableType; - GreaterOptionsT() { - } }; struct GreaterOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7890,7 +8263,6 @@ struct GreaterOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - GreaterOptionsBuilder &operator=(const GreaterOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7908,8 +8280,6 @@ flatbuffers::Offset CreateGreaterOptions(flatbuffers::FlatBuffer struct GreaterEqualOptionsT : public flatbuffers::NativeTable { typedef GreaterEqualOptions TableType; - GreaterEqualOptionsT() { - } }; struct GreaterEqualOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7932,7 +8302,6 @@ struct GreaterEqualOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - GreaterEqualOptionsBuilder &operator=(const GreaterEqualOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7950,8 +8319,6 @@ flatbuffers::Offset CreateGreaterEqualOptions(flatbuffers:: struct LessOptionsT : public flatbuffers::NativeTable { typedef LessOptions TableType; - LessOptionsT() { - } }; struct LessOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -7974,7 +8341,6 @@ struct LessOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LessOptionsBuilder &operator=(const LessOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -7992,8 +8358,6 @@ flatbuffers::Offset CreateLessOptions(flatbuffers::FlatBufferBuilde struct LessEqualOptionsT : public flatbuffers::NativeTable { typedef LessEqualOptions TableType; - LessEqualOptionsT() { - } }; struct LessEqualOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8016,7 +8380,6 @@ struct LessEqualOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LessEqualOptionsBuilder &operator=(const LessEqualOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8034,8 +8397,6 @@ flatbuffers::Offset CreateLessEqualOptions(flatbuffers::FlatBu struct NegOptionsT : public flatbuffers::NativeTable { typedef NegOptions TableType; - NegOptionsT() { - } }; struct NegOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8058,7 +8419,6 @@ struct NegOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - NegOptionsBuilder &operator=(const NegOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8076,8 +8436,6 @@ flatbuffers::Offset CreateNegOptions(flatbuffers::FlatBufferBuilder struct SelectOptionsT : public flatbuffers::NativeTable { typedef SelectOptions TableType; - SelectOptionsT() { - } }; struct SelectOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8100,7 +8458,6 @@ struct SelectOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SelectOptionsBuilder &operator=(const SelectOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8118,8 +8475,6 @@ flatbuffers::Offset CreateSelectOptions(flatbuffers::FlatBufferBu struct SliceOptionsT : public flatbuffers::NativeTable { typedef SliceOptions TableType; - SliceOptionsT() { - } }; struct SliceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8142,7 +8497,6 @@ struct SliceOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SliceOptionsBuilder &operator=(const SliceOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8160,14 +8514,9 @@ flatbuffers::Offset CreateSliceOptions(flatbuffers::FlatBufferBuil struct TransposeConvOptionsT : public flatbuffers::NativeTable { typedef TransposeConvOptions TableType; - tflite::Padding padding; - int32_t stride_w; - int32_t stride_h; - TransposeConvOptionsT() - : padding(tflite::Padding_SAME), - stride_w(0), - stride_h(0) { - } + tflite::Padding padding = tflite::Padding_SAME; + int32_t stride_w = 0; + int32_t stride_h = 0; }; struct TransposeConvOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8189,9 +8538,9 @@ struct TransposeConvOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_PADDING) && - VerifyField(verifier, VT_STRIDE_W) && - VerifyField(verifier, VT_STRIDE_H) && + VerifyField(verifier, VT_PADDING, 1) && + VerifyField(verifier, VT_STRIDE_W, 4) && + VerifyField(verifier, VT_STRIDE_H, 4) && verifier.EndTable(); } TransposeConvOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -8216,7 +8565,6 @@ struct TransposeConvOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TransposeConvOptionsBuilder &operator=(const TransposeConvOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8240,8 +8588,6 @@ flatbuffers::Offset CreateTransposeConvOptions(flatbuffers struct ExpandDimsOptionsT : public flatbuffers::NativeTable { typedef ExpandDimsOptions TableType; - ExpandDimsOptionsT() { - } }; struct ExpandDimsOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8264,7 +8610,6 @@ struct ExpandDimsOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ExpandDimsOptionsBuilder &operator=(const ExpandDimsOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8282,10 +8627,7 @@ flatbuffers::Offset CreateExpandDimsOptions(flatbuffers::Flat struct SparseToDenseOptionsT : public flatbuffers::NativeTable { typedef SparseToDenseOptions TableType; - bool validate_indices; - SparseToDenseOptionsT() - : validate_indices(false) { - } + bool validate_indices = false; }; struct SparseToDenseOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8299,7 +8641,7 @@ struct SparseToDenseOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALIDATE_INDICES) && + VerifyField(verifier, VT_VALIDATE_INDICES, 1) && verifier.EndTable(); } SparseToDenseOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -8318,7 +8660,6 @@ struct SparseToDenseOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SparseToDenseOptionsBuilder &operator=(const SparseToDenseOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8338,8 +8679,6 @@ flatbuffers::Offset CreateSparseToDenseOptions(flatbuffers struct EqualOptionsT : public flatbuffers::NativeTable { typedef EqualOptions TableType; - EqualOptionsT() { - } }; struct EqualOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8362,7 +8701,6 @@ struct EqualOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - EqualOptionsBuilder &operator=(const EqualOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8380,8 +8718,6 @@ flatbuffers::Offset CreateEqualOptions(flatbuffers::FlatBufferBuil struct NotEqualOptionsT : public flatbuffers::NativeTable { typedef NotEqualOptions TableType; - NotEqualOptionsT() { - } }; struct NotEqualOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8404,7 +8740,6 @@ struct NotEqualOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - NotEqualOptionsBuilder &operator=(const NotEqualOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8422,10 +8757,7 @@ flatbuffers::Offset CreateNotEqualOptions(flatbuffers::FlatBuff struct ShapeOptionsT : public flatbuffers::NativeTable { typedef ShapeOptions TableType; - tflite::TensorType out_type; - ShapeOptionsT() - : out_type(tflite::TensorType_FLOAT32) { - } + tflite::TensorType out_type = tflite::TensorType_FLOAT32; }; struct ShapeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8439,7 +8771,7 @@ struct ShapeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_OUT_TYPE) && + VerifyField(verifier, VT_OUT_TYPE, 1) && verifier.EndTable(); } ShapeOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -8458,7 +8790,6 @@ struct ShapeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ShapeOptionsBuilder &operator=(const ShapeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8478,8 +8809,6 @@ flatbuffers::Offset CreateShapeOptions(flatbuffers::FlatBufferBuil struct RankOptionsT : public flatbuffers::NativeTable { typedef RankOptions TableType; - RankOptionsT() { - } }; struct RankOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8502,7 +8831,6 @@ struct RankOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - RankOptionsBuilder &operator=(const RankOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8520,8 +8848,6 @@ flatbuffers::Offset CreateRankOptions(flatbuffers::FlatBufferBuilde struct PowOptionsT : public flatbuffers::NativeTable { typedef PowOptions TableType; - PowOptionsT() { - } }; struct PowOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8544,7 +8870,6 @@ struct PowOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - PowOptionsBuilder &operator=(const PowOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8562,16 +8887,10 @@ flatbuffers::Offset CreatePowOptions(flatbuffers::FlatBufferBuilder struct FakeQuantOptionsT : public flatbuffers::NativeTable { typedef FakeQuantOptions TableType; - float min; - float max; - int32_t num_bits; - bool narrow_range; - FakeQuantOptionsT() - : min(0.0f), - max(0.0f), - num_bits(0), - narrow_range(false) { - } + float min = 0.0f; + float max = 0.0f; + int32_t num_bits = 0; + bool narrow_range = false; }; struct FakeQuantOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8597,10 +8916,10 @@ struct FakeQuantOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_MIN) && - VerifyField(verifier, VT_MAX) && - VerifyField(verifier, VT_NUM_BITS) && - VerifyField(verifier, VT_NARROW_RANGE) && + VerifyField(verifier, VT_MIN, 4) && + VerifyField(verifier, VT_MAX, 4) && + VerifyField(verifier, VT_NUM_BITS, 4) && + VerifyField(verifier, VT_NARROW_RANGE, 1) && verifier.EndTable(); } FakeQuantOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -8628,7 +8947,6 @@ struct FakeQuantOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - FakeQuantOptionsBuilder &operator=(const FakeQuantOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8654,12 +8972,8 @@ flatbuffers::Offset CreateFakeQuantOptions(flatbuffers::FlatBu struct PackOptionsT : public flatbuffers::NativeTable { typedef PackOptions TableType; - int32_t values_count; - int32_t axis; - PackOptionsT() - : values_count(0), - axis(0) { - } + int32_t values_count = 0; + int32_t axis = 0; }; struct PackOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8677,8 +8991,8 @@ struct PackOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VALUES_COUNT) && - VerifyField(verifier, VT_AXIS) && + VerifyField(verifier, VT_VALUES_COUNT, 4) && + VerifyField(verifier, VT_AXIS, 4) && verifier.EndTable(); } PackOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -8700,7 +9014,6 @@ struct PackOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - PackOptionsBuilder &operator=(const PackOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8722,8 +9035,6 @@ flatbuffers::Offset CreatePackOptions(flatbuffers::FlatBufferBuilde struct LogicalOrOptionsT : public flatbuffers::NativeTable { typedef LogicalOrOptions TableType; - LogicalOrOptionsT() { - } }; struct LogicalOrOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8746,7 +9057,6 @@ struct LogicalOrOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LogicalOrOptionsBuilder &operator=(const LogicalOrOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8764,10 +9074,7 @@ flatbuffers::Offset CreateLogicalOrOptions(flatbuffers::FlatBu struct OneHotOptionsT : public flatbuffers::NativeTable { typedef OneHotOptions TableType; - int32_t axis; - OneHotOptionsT() - : axis(0) { - } + int32_t axis = 0; }; struct OneHotOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8781,7 +9088,7 @@ struct OneHotOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_AXIS) && + VerifyField(verifier, VT_AXIS, 4) && verifier.EndTable(); } OneHotOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -8800,7 +9107,6 @@ struct OneHotOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - OneHotOptionsBuilder &operator=(const OneHotOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8820,8 +9126,6 @@ flatbuffers::Offset CreateOneHotOptions(flatbuffers::FlatBufferBu struct AbsOptionsT : public flatbuffers::NativeTable { typedef AbsOptions TableType; - AbsOptionsT() { - } }; struct AbsOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8844,7 +9148,6 @@ struct AbsOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - AbsOptionsBuilder &operator=(const AbsOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8862,8 +9165,6 @@ flatbuffers::Offset CreateAbsOptions(flatbuffers::FlatBufferBuilder struct HardSwishOptionsT : public flatbuffers::NativeTable { typedef HardSwishOptions TableType; - HardSwishOptionsT() { - } }; struct HardSwishOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8886,7 +9187,6 @@ struct HardSwishOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - HardSwishOptionsBuilder &operator=(const HardSwishOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8904,8 +9204,6 @@ flatbuffers::Offset CreateHardSwishOptions(flatbuffers::FlatBu struct LogicalAndOptionsT : public flatbuffers::NativeTable { typedef LogicalAndOptions TableType; - LogicalAndOptionsT() { - } }; struct LogicalAndOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8928,7 +9226,6 @@ struct LogicalAndOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LogicalAndOptionsBuilder &operator=(const LogicalAndOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8946,8 +9243,6 @@ flatbuffers::Offset CreateLogicalAndOptions(flatbuffers::Flat struct LogicalNotOptionsT : public flatbuffers::NativeTable { typedef LogicalNotOptions TableType; - LogicalNotOptionsT() { - } }; struct LogicalNotOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -8970,7 +9265,6 @@ struct LogicalNotOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LogicalNotOptionsBuilder &operator=(const LogicalNotOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -8988,12 +9282,8 @@ flatbuffers::Offset CreateLogicalNotOptions(flatbuffers::Flat struct UnpackOptionsT : public flatbuffers::NativeTable { typedef UnpackOptions TableType; - int32_t num; - int32_t axis; - UnpackOptionsT() - : num(0), - axis(0) { - } + int32_t num = 0; + int32_t axis = 0; }; struct UnpackOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9011,8 +9301,8 @@ struct UnpackOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_NUM) && - VerifyField(verifier, VT_AXIS) && + VerifyField(verifier, VT_NUM, 4) && + VerifyField(verifier, VT_AXIS, 4) && verifier.EndTable(); } UnpackOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -9034,7 +9324,6 @@ struct UnpackOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - UnpackOptionsBuilder &operator=(const UnpackOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9056,8 +9345,6 @@ flatbuffers::Offset CreateUnpackOptions(flatbuffers::FlatBufferBu struct FloorDivOptionsT : public flatbuffers::NativeTable { typedef FloorDivOptions TableType; - FloorDivOptionsT() { - } }; struct FloorDivOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9080,7 +9367,6 @@ struct FloorDivOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - FloorDivOptionsBuilder &operator=(const FloorDivOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9098,8 +9384,6 @@ flatbuffers::Offset CreateFloorDivOptions(flatbuffers::FlatBuff struct SquareOptionsT : public flatbuffers::NativeTable { typedef SquareOptions TableType; - SquareOptionsT() { - } }; struct SquareOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9122,7 +9406,6 @@ struct SquareOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SquareOptionsBuilder &operator=(const SquareOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9140,8 +9423,6 @@ flatbuffers::Offset CreateSquareOptions(flatbuffers::FlatBufferBu struct ZerosLikeOptionsT : public flatbuffers::NativeTable { typedef ZerosLikeOptions TableType; - ZerosLikeOptionsT() { - } }; struct ZerosLikeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9164,7 +9445,6 @@ struct ZerosLikeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ZerosLikeOptionsBuilder &operator=(const ZerosLikeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9182,8 +9462,6 @@ flatbuffers::Offset CreateZerosLikeOptions(flatbuffers::FlatBu struct FillOptionsT : public flatbuffers::NativeTable { typedef FillOptions TableType; - FillOptionsT() { - } }; struct FillOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9206,7 +9484,6 @@ struct FillOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - FillOptionsBuilder &operator=(const FillOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9224,8 +9501,6 @@ flatbuffers::Offset CreateFillOptions(flatbuffers::FlatBufferBuilde struct FloorModOptionsT : public flatbuffers::NativeTable { typedef FloorModOptions TableType; - FloorModOptionsT() { - } }; struct FloorModOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9248,7 +9523,6 @@ struct FloorModOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - FloorModOptionsBuilder &operator=(const FloorModOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9266,8 +9540,6 @@ flatbuffers::Offset CreateFloorModOptions(flatbuffers::FlatBuff struct RangeOptionsT : public flatbuffers::NativeTable { typedef RangeOptions TableType; - RangeOptionsT() { - } }; struct RangeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9290,7 +9562,6 @@ struct RangeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - RangeOptionsBuilder &operator=(const RangeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9308,10 +9579,7 @@ flatbuffers::Offset CreateRangeOptions(flatbuffers::FlatBufferBuil struct LeakyReluOptionsT : public flatbuffers::NativeTable { typedef LeakyReluOptions TableType; - float alpha; - LeakyReluOptionsT() - : alpha(0.0f) { - } + float alpha = 0.0f; }; struct LeakyReluOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9325,7 +9593,7 @@ struct LeakyReluOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_ALPHA) && + VerifyField(verifier, VT_ALPHA, 4) && verifier.EndTable(); } LeakyReluOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -9344,7 +9612,6 @@ struct LeakyReluOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - LeakyReluOptionsBuilder &operator=(const LeakyReluOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9364,8 +9631,6 @@ flatbuffers::Offset CreateLeakyReluOptions(flatbuffers::FlatBu struct SquaredDifferenceOptionsT : public flatbuffers::NativeTable { typedef SquaredDifferenceOptions TableType; - SquaredDifferenceOptionsT() { - } }; struct SquaredDifferenceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9388,7 +9653,6 @@ struct SquaredDifferenceOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SquaredDifferenceOptionsBuilder &operator=(const SquaredDifferenceOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9406,10 +9670,7 @@ flatbuffers::Offset CreateSquaredDifferenceOptions(fla struct MirrorPadOptionsT : public flatbuffers::NativeTable { typedef MirrorPadOptions TableType; - tflite::MirrorPadMode mode; - MirrorPadOptionsT() - : mode(tflite::MirrorPadMode_REFLECT) { - } + tflite::MirrorPadMode mode = tflite::MirrorPadMode_REFLECT; }; struct MirrorPadOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9423,7 +9684,7 @@ struct MirrorPadOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_MODE) && + VerifyField(verifier, VT_MODE, 1) && verifier.EndTable(); } MirrorPadOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -9442,7 +9703,6 @@ struct MirrorPadOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - MirrorPadOptionsBuilder &operator=(const MirrorPadOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9462,10 +9722,7 @@ flatbuffers::Offset CreateMirrorPadOptions(flatbuffers::FlatBu struct UniqueOptionsT : public flatbuffers::NativeTable { typedef UniqueOptions TableType; - tflite::TensorType idx_out_type; - UniqueOptionsT() - : idx_out_type(tflite::TensorType_INT32) { - } + tflite::TensorType idx_out_type = tflite::TensorType_INT32; }; struct UniqueOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9479,7 +9736,7 @@ struct UniqueOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_IDX_OUT_TYPE) && + VerifyField(verifier, VT_IDX_OUT_TYPE, 1) && verifier.EndTable(); } UniqueOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -9498,7 +9755,6 @@ struct UniqueOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - UniqueOptionsBuilder &operator=(const UniqueOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9518,8 +9774,6 @@ flatbuffers::Offset CreateUniqueOptions(flatbuffers::FlatBufferBu struct ReverseV2OptionsT : public flatbuffers::NativeTable { typedef ReverseV2Options TableType; - ReverseV2OptionsT() { - } }; struct ReverseV2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9542,7 +9796,6 @@ struct ReverseV2OptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ReverseV2OptionsBuilder &operator=(const ReverseV2OptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9560,8 +9813,6 @@ flatbuffers::Offset CreateReverseV2Options(flatbuffers::FlatBu struct AddNOptionsT : public flatbuffers::NativeTable { typedef AddNOptions TableType; - AddNOptionsT() { - } }; struct AddNOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9584,7 +9835,6 @@ struct AddNOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - AddNOptionsBuilder &operator=(const AddNOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9602,8 +9852,6 @@ flatbuffers::Offset CreateAddNOptions(flatbuffers::FlatBufferBuilde struct GatherNdOptionsT : public flatbuffers::NativeTable { typedef GatherNdOptions TableType; - GatherNdOptionsT() { - } }; struct GatherNdOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9626,7 +9874,6 @@ struct GatherNdOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - GatherNdOptionsBuilder &operator=(const GatherNdOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9644,8 +9891,6 @@ flatbuffers::Offset CreateGatherNdOptions(flatbuffers::FlatBuff struct WhereOptionsT : public flatbuffers::NativeTable { typedef WhereOptions TableType; - WhereOptionsT() { - } }; struct WhereOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9668,7 +9913,6 @@ struct WhereOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - WhereOptionsBuilder &operator=(const WhereOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9686,12 +9930,8 @@ flatbuffers::Offset CreateWhereOptions(flatbuffers::FlatBufferBuil struct ReverseSequenceOptionsT : public flatbuffers::NativeTable { typedef ReverseSequenceOptions TableType; - int32_t seq_dim; - int32_t batch_dim; - ReverseSequenceOptionsT() - : seq_dim(0), - batch_dim(0) { - } + int32_t seq_dim = 0; + int32_t batch_dim = 0; }; struct ReverseSequenceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9709,8 +9949,8 @@ struct ReverseSequenceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tab } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_SEQ_DIM) && - VerifyField(verifier, VT_BATCH_DIM) && + VerifyField(verifier, VT_SEQ_DIM, 4) && + VerifyField(verifier, VT_BATCH_DIM, 4) && verifier.EndTable(); } ReverseSequenceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -9732,7 +9972,6 @@ struct ReverseSequenceOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ReverseSequenceOptionsBuilder &operator=(const ReverseSequenceOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9754,8 +9993,6 @@ flatbuffers::Offset CreateReverseSequenceOptions(flatbuf struct MatrixDiagOptionsT : public flatbuffers::NativeTable { typedef MatrixDiagOptions TableType; - MatrixDiagOptionsT() { - } }; struct MatrixDiagOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9778,7 +10015,6 @@ struct MatrixDiagOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - MatrixDiagOptionsBuilder &operator=(const MatrixDiagOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9796,8 +10032,6 @@ flatbuffers::Offset CreateMatrixDiagOptions(flatbuffers::Flat struct QuantizeOptionsT : public flatbuffers::NativeTable { typedef QuantizeOptions TableType; - QuantizeOptionsT() { - } }; struct QuantizeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9820,7 +10054,6 @@ struct QuantizeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - QuantizeOptionsBuilder &operator=(const QuantizeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9838,8 +10071,6 @@ flatbuffers::Offset CreateQuantizeOptions(flatbuffers::FlatBuff struct MatrixSetDiagOptionsT : public flatbuffers::NativeTable { typedef MatrixSetDiagOptions TableType; - MatrixSetDiagOptionsT() { - } }; struct MatrixSetDiagOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9862,7 +10093,6 @@ struct MatrixSetDiagOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - MatrixSetDiagOptionsBuilder &operator=(const MatrixSetDiagOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9880,12 +10110,8 @@ flatbuffers::Offset CreateMatrixSetDiagOptions(flatbuffers struct IfOptionsT : public flatbuffers::NativeTable { typedef IfOptions TableType; - int32_t then_subgraph_index; - int32_t else_subgraph_index; - IfOptionsT() - : then_subgraph_index(0), - else_subgraph_index(0) { - } + int32_t then_subgraph_index = 0; + int32_t else_subgraph_index = 0; }; struct IfOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9903,8 +10129,8 @@ struct IfOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_THEN_SUBGRAPH_INDEX) && - VerifyField(verifier, VT_ELSE_SUBGRAPH_INDEX) && + VerifyField(verifier, VT_THEN_SUBGRAPH_INDEX, 4) && + VerifyField(verifier, VT_ELSE_SUBGRAPH_INDEX, 4) && verifier.EndTable(); } IfOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -9926,7 +10152,6 @@ struct IfOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - IfOptionsBuilder &operator=(const IfOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -9948,10 +10173,7 @@ flatbuffers::Offset CreateIfOptions(flatbuffers::FlatBufferBuilder &_ struct CallOnceOptionsT : public flatbuffers::NativeTable { typedef CallOnceOptions TableType; - int32_t init_subgraph_index; - CallOnceOptionsT() - : init_subgraph_index(0) { - } + int32_t init_subgraph_index = 0; }; struct CallOnceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -9965,7 +10187,7 @@ struct CallOnceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_INIT_SUBGRAPH_INDEX) && + VerifyField(verifier, VT_INIT_SUBGRAPH_INDEX, 4) && verifier.EndTable(); } CallOnceOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -9984,7 +10206,6 @@ struct CallOnceOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - CallOnceOptionsBuilder &operator=(const CallOnceOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10004,12 +10225,8 @@ flatbuffers::Offset CreateCallOnceOptions(flatbuffers::FlatBuff struct WhileOptionsT : public flatbuffers::NativeTable { typedef WhileOptions TableType; - int32_t cond_subgraph_index; - int32_t body_subgraph_index; - WhileOptionsT() - : cond_subgraph_index(0), - body_subgraph_index(0) { - } + int32_t cond_subgraph_index = 0; + int32_t body_subgraph_index = 0; }; struct WhileOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10027,8 +10244,8 @@ struct WhileOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_COND_SUBGRAPH_INDEX) && - VerifyField(verifier, VT_BODY_SUBGRAPH_INDEX) && + VerifyField(verifier, VT_COND_SUBGRAPH_INDEX, 4) && + VerifyField(verifier, VT_BODY_SUBGRAPH_INDEX, 4) && verifier.EndTable(); } WhileOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -10050,7 +10267,6 @@ struct WhileOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - WhileOptionsBuilder &operator=(const WhileOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10072,8 +10288,6 @@ flatbuffers::Offset CreateWhileOptions(flatbuffers::FlatBufferBuil struct NonMaxSuppressionV4OptionsT : public flatbuffers::NativeTable { typedef NonMaxSuppressionV4Options TableType; - NonMaxSuppressionV4OptionsT() { - } }; struct NonMaxSuppressionV4Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10096,7 +10310,6 @@ struct NonMaxSuppressionV4OptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - NonMaxSuppressionV4OptionsBuilder &operator=(const NonMaxSuppressionV4OptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10114,8 +10327,6 @@ flatbuffers::Offset CreateNonMaxSuppressionV4Options struct NonMaxSuppressionV5OptionsT : public flatbuffers::NativeTable { typedef NonMaxSuppressionV5Options TableType; - NonMaxSuppressionV5OptionsT() { - } }; struct NonMaxSuppressionV5Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10138,7 +10349,6 @@ struct NonMaxSuppressionV5OptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - NonMaxSuppressionV5OptionsBuilder &operator=(const NonMaxSuppressionV5OptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10156,8 +10366,6 @@ flatbuffers::Offset CreateNonMaxSuppressionV5Options struct ScatterNdOptionsT : public flatbuffers::NativeTable { typedef ScatterNdOptions TableType; - ScatterNdOptionsT() { - } }; struct ScatterNdOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10180,7 +10388,6 @@ struct ScatterNdOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ScatterNdOptionsBuilder &operator=(const ScatterNdOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10198,8 +10405,6 @@ flatbuffers::Offset CreateScatterNdOptions(flatbuffers::FlatBu struct SelectV2OptionsT : public flatbuffers::NativeTable { typedef SelectV2Options TableType; - SelectV2OptionsT() { - } }; struct SelectV2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10222,7 +10427,6 @@ struct SelectV2OptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SelectV2OptionsBuilder &operator=(const SelectV2OptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10240,8 +10444,6 @@ flatbuffers::Offset CreateSelectV2Options(flatbuffers::FlatBuff struct DensifyOptionsT : public flatbuffers::NativeTable { typedef DensifyOptions TableType; - DensifyOptionsT() { - } }; struct DensifyOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10264,7 +10466,6 @@ struct DensifyOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - DensifyOptionsBuilder &operator=(const DensifyOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10282,8 +10483,6 @@ flatbuffers::Offset CreateDensifyOptions(flatbuffers::FlatBuffer struct SegmentSumOptionsT : public flatbuffers::NativeTable { typedef SegmentSumOptions TableType; - SegmentSumOptionsT() { - } }; struct SegmentSumOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10306,7 +10505,6 @@ struct SegmentSumOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SegmentSumOptionsBuilder &operator=(const SegmentSumOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10324,14 +10522,9 @@ flatbuffers::Offset CreateSegmentSumOptions(flatbuffers::Flat struct BatchMatMulOptionsT : public flatbuffers::NativeTable { typedef BatchMatMulOptions TableType; - bool adj_x; - bool adj_y; - bool asymmetric_quantize_inputs; - BatchMatMulOptionsT() - : adj_x(false), - adj_y(false), - asymmetric_quantize_inputs(false) { - } + bool adj_x = false; + bool adj_y = false; + bool asymmetric_quantize_inputs = false; }; struct BatchMatMulOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10353,9 +10546,9 @@ struct BatchMatMulOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_ADJ_X) && - VerifyField(verifier, VT_ADJ_Y) && - VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS) && + VerifyField(verifier, VT_ADJ_X, 1) && + VerifyField(verifier, VT_ADJ_Y, 1) && + VerifyField(verifier, VT_ASYMMETRIC_QUANTIZE_INPUTS, 1) && verifier.EndTable(); } BatchMatMulOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -10380,7 +10573,6 @@ struct BatchMatMulOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BatchMatMulOptionsBuilder &operator=(const BatchMatMulOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10404,12 +10596,8 @@ flatbuffers::Offset CreateBatchMatMulOptions(flatbuffers::Fl struct CumsumOptionsT : public flatbuffers::NativeTable { typedef CumsumOptions TableType; - bool exclusive; - bool reverse; - CumsumOptionsT() - : exclusive(false), - reverse(false) { - } + bool exclusive = false; + bool reverse = false; }; struct CumsumOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10427,8 +10615,8 @@ struct CumsumOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_EXCLUSIVE) && - VerifyField(verifier, VT_REVERSE) && + VerifyField(verifier, VT_EXCLUSIVE, 1) && + VerifyField(verifier, VT_REVERSE, 1) && verifier.EndTable(); } CumsumOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -10450,7 +10638,6 @@ struct CumsumOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - CumsumOptionsBuilder &operator=(const CumsumOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10472,8 +10659,6 @@ flatbuffers::Offset CreateCumsumOptions(flatbuffers::FlatBufferBu struct BroadcastToOptionsT : public flatbuffers::NativeTable { typedef BroadcastToOptions TableType; - BroadcastToOptionsT() { - } }; struct BroadcastToOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10496,7 +10681,6 @@ struct BroadcastToOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BroadcastToOptionsBuilder &operator=(const BroadcastToOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10514,8 +10698,6 @@ flatbuffers::Offset CreateBroadcastToOptions(flatbuffers::Fl struct Rfft2dOptionsT : public flatbuffers::NativeTable { typedef Rfft2dOptions TableType; - Rfft2dOptionsT() { - } }; struct Rfft2dOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10538,7 +10720,6 @@ struct Rfft2dOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Rfft2dOptionsBuilder &operator=(const Rfft2dOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10556,14 +10737,9 @@ flatbuffers::Offset CreateRfft2dOptions(flatbuffers::FlatBufferBu struct HashtableOptionsT : public flatbuffers::NativeTable { typedef HashtableOptions TableType; - int32_t table_id; - tflite::TensorType key_dtype; - tflite::TensorType value_dtype; - HashtableOptionsT() - : table_id(0), - key_dtype(tflite::TensorType_FLOAT32), - value_dtype(tflite::TensorType_FLOAT32) { - } + int32_t table_id = 0; + tflite::TensorType key_dtype = tflite::TensorType_FLOAT32; + tflite::TensorType value_dtype = tflite::TensorType_FLOAT32; }; struct HashtableOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10585,9 +10761,9 @@ struct HashtableOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_TABLE_ID) && - VerifyField(verifier, VT_KEY_DTYPE) && - VerifyField(verifier, VT_VALUE_DTYPE) && + VerifyField(verifier, VT_TABLE_ID, 4) && + VerifyField(verifier, VT_KEY_DTYPE, 1) && + VerifyField(verifier, VT_VALUE_DTYPE, 1) && verifier.EndTable(); } HashtableOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -10612,7 +10788,6 @@ struct HashtableOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - HashtableOptionsBuilder &operator=(const HashtableOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10636,8 +10811,6 @@ flatbuffers::Offset CreateHashtableOptions(flatbuffers::FlatBu struct HashtableFindOptionsT : public flatbuffers::NativeTable { typedef HashtableFindOptions TableType; - HashtableFindOptionsT() { - } }; struct HashtableFindOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10660,7 +10833,6 @@ struct HashtableFindOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - HashtableFindOptionsBuilder &operator=(const HashtableFindOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10678,8 +10850,6 @@ flatbuffers::Offset CreateHashtableFindOptions(flatbuffers struct HashtableImportOptionsT : public flatbuffers::NativeTable { typedef HashtableImportOptions TableType; - HashtableImportOptionsT() { - } }; struct HashtableImportOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10702,7 +10872,6 @@ struct HashtableImportOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - HashtableImportOptionsBuilder &operator=(const HashtableImportOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10720,8 +10889,6 @@ flatbuffers::Offset CreateHashtableImportOptions(flatbuf struct HashtableSizeOptionsT : public flatbuffers::NativeTable { typedef HashtableSizeOptions TableType; - HashtableSizeOptionsT() { - } }; struct HashtableSizeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10744,7 +10911,6 @@ struct HashtableSizeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - HashtableSizeOptionsBuilder &operator=(const HashtableSizeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10762,10 +10928,8 @@ flatbuffers::Offset CreateHashtableSizeOptions(flatbuffers struct VarHandleOptionsT : public flatbuffers::NativeTable { typedef VarHandleOptions TableType; - std::string container; - std::string shared_name; - VarHandleOptionsT() { - } + std::string container{}; + std::string shared_name{}; }; struct VarHandleOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10808,7 +10972,6 @@ struct VarHandleOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - VarHandleOptionsBuilder &operator=(const VarHandleOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10842,8 +11005,6 @@ flatbuffers::Offset CreateVarHandleOptions(flatbuffers::FlatBu struct ReadVariableOptionsT : public flatbuffers::NativeTable { typedef ReadVariableOptions TableType; - ReadVariableOptionsT() { - } }; struct ReadVariableOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10866,7 +11027,6 @@ struct ReadVariableOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ReadVariableOptionsBuilder &operator=(const ReadVariableOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10884,8 +11044,6 @@ flatbuffers::Offset CreateReadVariableOptions(flatbuffers:: struct AssignVariableOptionsT : public flatbuffers::NativeTable { typedef AssignVariableOptions TableType; - AssignVariableOptionsT() { - } }; struct AssignVariableOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10908,7 +11066,6 @@ struct AssignVariableOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - AssignVariableOptionsBuilder &operator=(const AssignVariableOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10926,12 +11083,8 @@ flatbuffers::Offset CreateAssignVariableOptions(flatbuffe struct RandomOptionsT : public flatbuffers::NativeTable { typedef RandomOptions TableType; - int64_t seed; - int64_t seed2; - RandomOptionsT() - : seed(0), - seed2(0) { - } + int64_t seed = 0; + int64_t seed2 = 0; }; struct RandomOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -10949,8 +11102,8 @@ struct RandomOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_SEED) && - VerifyField(verifier, VT_SEED2) && + VerifyField(verifier, VT_SEED, 8) && + VerifyField(verifier, VT_SEED2, 8) && verifier.EndTable(); } RandomOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -10972,7 +11125,6 @@ struct RandomOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - RandomOptionsBuilder &operator=(const RandomOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -10994,9 +11146,7 @@ flatbuffers::Offset CreateRandomOptions(flatbuffers::FlatBufferBu struct BucketizeOptionsT : public flatbuffers::NativeTable { typedef BucketizeOptions TableType; - std::vector boundaries; - BucketizeOptionsT() { - } + std::vector boundaries{}; }; struct BucketizeOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11030,7 +11180,6 @@ struct BucketizeOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BucketizeOptionsBuilder &operator=(const BucketizeOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11059,10 +11208,7 @@ flatbuffers::Offset CreateBucketizeOptions(flatbuffers::FlatBu struct GeluOptionsT : public flatbuffers::NativeTable { typedef GeluOptions TableType; - bool approximate; - GeluOptionsT() - : approximate(false) { - } + bool approximate = false; }; struct GeluOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11076,7 +11222,7 @@ struct GeluOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_APPROXIMATE) && + VerifyField(verifier, VT_APPROXIMATE, 1) && verifier.EndTable(); } GeluOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -11095,7 +11241,6 @@ struct GeluOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - GeluOptionsBuilder &operator=(const GeluOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11115,8 +11260,6 @@ flatbuffers::Offset CreateGeluOptions(flatbuffers::FlatBufferBuilde struct DynamicUpdateSliceOptionsT : public flatbuffers::NativeTable { typedef DynamicUpdateSliceOptions TableType; - DynamicUpdateSliceOptionsT() { - } }; struct DynamicUpdateSliceOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11139,7 +11282,6 @@ struct DynamicUpdateSliceOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - DynamicUpdateSliceOptionsBuilder &operator=(const DynamicUpdateSliceOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11157,8 +11299,6 @@ flatbuffers::Offset CreateDynamicUpdateSliceOptions(f struct UnsortedSegmentProdOptionsT : public flatbuffers::NativeTable { typedef UnsortedSegmentProdOptions TableType; - UnsortedSegmentProdOptionsT() { - } }; struct UnsortedSegmentProdOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11181,7 +11321,6 @@ struct UnsortedSegmentProdOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - UnsortedSegmentProdOptionsBuilder &operator=(const UnsortedSegmentProdOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11199,8 +11338,6 @@ flatbuffers::Offset CreateUnsortedSegmentProdOptions struct UnsortedSegmentMaxOptionsT : public flatbuffers::NativeTable { typedef UnsortedSegmentMaxOptions TableType; - UnsortedSegmentMaxOptionsT() { - } }; struct UnsortedSegmentMaxOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11223,7 +11360,6 @@ struct UnsortedSegmentMaxOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - UnsortedSegmentMaxOptionsBuilder &operator=(const UnsortedSegmentMaxOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11241,8 +11377,6 @@ flatbuffers::Offset CreateUnsortedSegmentMaxOptions(f struct UnsortedSegmentSumOptionsT : public flatbuffers::NativeTable { typedef UnsortedSegmentSumOptions TableType; - UnsortedSegmentSumOptionsT() { - } }; struct UnsortedSegmentSumOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11265,7 +11399,6 @@ struct UnsortedSegmentSumOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - UnsortedSegmentSumOptionsBuilder &operator=(const UnsortedSegmentSumOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11283,8 +11416,6 @@ flatbuffers::Offset CreateUnsortedSegmentSumOptions(f struct ATan2OptionsT : public flatbuffers::NativeTable { typedef ATan2Options TableType; - ATan2OptionsT() { - } }; struct ATan2Options FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11307,7 +11438,6 @@ struct ATan2OptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ATan2OptionsBuilder &operator=(const ATan2OptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11325,8 +11455,6 @@ flatbuffers::Offset CreateATan2Options(flatbuffers::FlatBufferBuil struct UnsortedSegmentMinOptionsT : public flatbuffers::NativeTable { typedef UnsortedSegmentMinOptions TableType; - UnsortedSegmentMinOptionsT() { - } }; struct UnsortedSegmentMinOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11349,7 +11477,6 @@ struct UnsortedSegmentMinOptionsBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - UnsortedSegmentMinOptionsBuilder &operator=(const UnsortedSegmentMinOptionsBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11365,17 +11492,51 @@ inline flatbuffers::Offset CreateUnsortedSegmentMinOp flatbuffers::Offset CreateUnsortedSegmentMinOptions(flatbuffers::FlatBufferBuilder &_fbb, const UnsortedSegmentMinOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +struct SignOptionsT : public flatbuffers::NativeTable { + typedef SignOptions TableType; +}; + +struct SignOptions FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef SignOptionsT NativeTableType; + typedef SignOptionsBuilder Builder; + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + verifier.EndTable(); + } + SignOptionsT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; + void UnPackTo(SignOptionsT *_o, const flatbuffers::resolver_function_t *_resolver = nullptr) const; + static flatbuffers::Offset Pack(flatbuffers::FlatBufferBuilder &_fbb, const SignOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); +}; + +struct SignOptionsBuilder { + typedef SignOptions Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + explicit SignOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateSignOptions( + flatbuffers::FlatBufferBuilder &_fbb) { + SignOptionsBuilder builder_(_fbb); + return builder_.Finish(); +} + +flatbuffers::Offset CreateSignOptions(flatbuffers::FlatBufferBuilder &_fbb, const SignOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); + struct OperatorCodeT : public flatbuffers::NativeTable { typedef OperatorCode TableType; - int8_t deprecated_builtin_code; - std::string custom_code; - int32_t version; - tflite::BuiltinOperator builtin_code; - OperatorCodeT() - : deprecated_builtin_code(0), - version(1), - builtin_code(tflite::BuiltinOperator_ADD) { - } + int8_t deprecated_builtin_code = 0; + std::string custom_code{}; + int32_t version = 1; + tflite::BuiltinOperator builtin_code = tflite::BuiltinOperator_ADD; }; struct OperatorCode FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11401,11 +11562,11 @@ struct OperatorCode FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_DEPRECATED_BUILTIN_CODE) && + VerifyField(verifier, VT_DEPRECATED_BUILTIN_CODE, 1) && VerifyOffset(verifier, VT_CUSTOM_CODE) && verifier.VerifyString(custom_code()) && - VerifyField(verifier, VT_VERSION) && - VerifyField(verifier, VT_BUILTIN_CODE) && + VerifyField(verifier, VT_VERSION, 4) && + VerifyField(verifier, VT_BUILTIN_CODE, 4) && verifier.EndTable(); } OperatorCodeT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -11433,7 +11594,6 @@ struct OperatorCodeBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - OperatorCodeBuilder &operator=(const OperatorCodeBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -11474,18 +11634,14 @@ flatbuffers::Offset CreateOperatorCode(flatbuffers::FlatBufferBuil struct OperatorT : public flatbuffers::NativeTable { typedef Operator TableType; - uint32_t opcode_index; - std::vector inputs; - std::vector outputs; - tflite::BuiltinOptionsUnion builtin_options; - std::vector custom_options; - tflite::CustomOptionsFormat custom_options_format; - std::vector mutating_variable_inputs; - std::vector intermediates; - OperatorT() - : opcode_index(0), - custom_options_format(tflite::CustomOptionsFormat_FLEXBUFFERS) { - } + uint32_t opcode_index = 0; + std::vector inputs{}; + std::vector outputs{}; + tflite::BuiltinOptionsUnion builtin_options{}; + std::vector custom_options{}; + tflite::CustomOptionsFormat custom_options_format = tflite::CustomOptionsFormat_FLEXBUFFERS; + std::vector mutating_variable_inputs{}; + std::vector intermediates{}; }; struct Operator FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -11884,6 +12040,9 @@ struct Operator FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const tflite::ATan2Options *builtin_options_as_ATan2Options() const { return builtin_options_type() == tflite::BuiltinOptions_ATan2Options ? static_cast(builtin_options()) : nullptr; } + const tflite::SignOptions *builtin_options_as_SignOptions() const { + return builtin_options_type() == tflite::BuiltinOptions_SignOptions ? static_cast(builtin_options()) : nullptr; + } const flatbuffers::Vector *custom_options() const { return GetPointer *>(VT_CUSTOM_OPTIONS); } @@ -11898,17 +12057,17 @@ struct Operator FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_OPCODE_INDEX) && + VerifyField(verifier, VT_OPCODE_INDEX, 4) && VerifyOffset(verifier, VT_INPUTS) && verifier.VerifyVector(inputs()) && VerifyOffset(verifier, VT_OUTPUTS) && verifier.VerifyVector(outputs()) && - VerifyField(verifier, VT_BUILTIN_OPTIONS_TYPE) && + VerifyField(verifier, VT_BUILTIN_OPTIONS_TYPE, 1) && VerifyOffset(verifier, VT_BUILTIN_OPTIONS) && VerifyBuiltinOptions(verifier, builtin_options(), builtin_options_type()) && VerifyOffset(verifier, VT_CUSTOM_OPTIONS) && verifier.VerifyVector(custom_options()) && - VerifyField(verifier, VT_CUSTOM_OPTIONS_FORMAT) && + VerifyField(verifier, VT_CUSTOM_OPTIONS_FORMAT, 1) && VerifyOffset(verifier, VT_MUTATING_VARIABLE_INPUTS) && verifier.VerifyVector(mutating_variable_inputs()) && VerifyOffset(verifier, VT_INTERMEDIATES) && @@ -12408,6 +12567,10 @@ template<> inline const tflite::ATan2Options *Operator::builtin_options_as inline const tflite::SignOptions *Operator::builtin_options_as() const { + return builtin_options_as_SignOptions(); +} + struct OperatorBuilder { typedef Operator Table; flatbuffers::FlatBufferBuilder &fbb_; @@ -12443,7 +12606,6 @@ struct OperatorBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - OperatorBuilder &operator=(const OperatorBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -12508,13 +12670,15 @@ flatbuffers::Offset CreateOperator(flatbuffers::FlatBufferBuilder &_fb struct SubGraphT : public flatbuffers::NativeTable { typedef SubGraph TableType; - std::vector> tensors; - std::vector inputs; - std::vector outputs; - std::vector> operators; - std::string name; - SubGraphT() { - } + std::vector> tensors{}; + std::vector inputs{}; + std::vector outputs{}; + std::vector> operators{}; + std::string name{}; + SubGraphT() = default; + SubGraphT(const SubGraphT &o); + SubGraphT(SubGraphT&&) FLATBUFFERS_NOEXCEPT = default; + SubGraphT &operator=(SubGraphT o) FLATBUFFERS_NOEXCEPT; }; struct SubGraph FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -12586,7 +12750,6 @@ struct SubGraphBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SubGraphBuilder &operator=(const SubGraphBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -12635,9 +12798,7 @@ flatbuffers::Offset CreateSubGraph(flatbuffers::FlatBufferBuilder &_fb struct BufferT : public flatbuffers::NativeTable { typedef Buffer TableType; - std::vector data; - BufferT() { - } + std::vector data{}; }; struct Buffer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -12671,7 +12832,6 @@ struct BufferBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - BufferBuilder &operator=(const BufferBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -12701,11 +12861,8 @@ flatbuffers::Offset CreateBuffer(flatbuffers::FlatBufferBuilder &_fbb, c struct MetadataT : public flatbuffers::NativeTable { typedef Metadata TableType; - std::string name; - uint32_t buffer; - MetadataT() - : buffer(0) { - } + std::string name{}; + uint32_t buffer = 0; }; struct Metadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -12725,7 +12882,7 @@ struct Metadata FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && - VerifyField(verifier, VT_BUFFER) && + VerifyField(verifier, VT_BUFFER, 4) && verifier.EndTable(); } MetadataT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -12747,7 +12904,6 @@ struct MetadataBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - MetadataBuilder &operator=(const MetadataBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -12780,11 +12936,8 @@ flatbuffers::Offset CreateMetadata(flatbuffers::FlatBufferBuilder &_fb struct TensorMapT : public flatbuffers::NativeTable { typedef TensorMap TableType; - std::string name; - uint32_t tensor_index; - TensorMapT() - : tensor_index(0) { - } + std::string name{}; + uint32_t tensor_index = 0; }; struct TensorMap FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -12804,7 +12957,7 @@ struct TensorMap FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_NAME) && verifier.VerifyString(name()) && - VerifyField(verifier, VT_TENSOR_INDEX) && + VerifyField(verifier, VT_TENSOR_INDEX, 4) && verifier.EndTable(); } TensorMapT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -12826,7 +12979,6 @@ struct TensorMapBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TensorMapBuilder &operator=(const TensorMapBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -12859,13 +13011,14 @@ flatbuffers::Offset CreateTensorMap(flatbuffers::FlatBufferBuilder &_ struct SignatureDefT : public flatbuffers::NativeTable { typedef SignatureDef TableType; - std::vector> inputs; - std::vector> outputs; - std::string signature_key; - uint32_t subgraph_index; - SignatureDefT() - : subgraph_index(0) { - } + std::vector> inputs{}; + std::vector> outputs{}; + std::string signature_key{}; + uint32_t subgraph_index = 0; + SignatureDefT() = default; + SignatureDefT(const SignatureDefT &o); + SignatureDefT(SignatureDefT&&) FLATBUFFERS_NOEXCEPT = default; + SignatureDefT &operator=(SignatureDefT o) FLATBUFFERS_NOEXCEPT; }; struct SignatureDef FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -12899,7 +13052,7 @@ struct SignatureDef FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { verifier.VerifyVectorOfTables(outputs()) && VerifyOffset(verifier, VT_SIGNATURE_KEY) && verifier.VerifyString(signature_key()) && - VerifyField(verifier, VT_SUBGRAPH_INDEX) && + VerifyField(verifier, VT_SUBGRAPH_INDEX, 4) && verifier.EndTable(); } SignatureDefT *UnPack(const flatbuffers::resolver_function_t *_resolver = nullptr) const; @@ -12927,7 +13080,6 @@ struct SignatureDefBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - SignatureDefBuilder &operator=(const SignatureDefBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -12970,17 +13122,18 @@ flatbuffers::Offset CreateSignatureDef(flatbuffers::FlatBufferBuil struct ModelT : public flatbuffers::NativeTable { typedef Model TableType; - uint32_t version; - std::vector> operator_codes; - std::vector> subgraphs; - std::string description; - std::vector> buffers; - std::vector metadata_buffer; - std::vector> metadata; - std::vector> signature_defs; - ModelT() - : version(0) { - } + uint32_t version = 0; + std::vector> operator_codes{}; + std::vector> subgraphs{}; + std::string description{}; + std::vector> buffers{}; + std::vector metadata_buffer{}; + std::vector> metadata{}; + std::vector> signature_defs{}; + ModelT() = default; + ModelT(const ModelT &o); + ModelT(ModelT&&) FLATBUFFERS_NOEXCEPT = default; + ModelT &operator=(ModelT o) FLATBUFFERS_NOEXCEPT; }; struct Model FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -13022,7 +13175,7 @@ struct Model FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, VT_VERSION) && + VerifyField(verifier, VT_VERSION, 4) && VerifyOffset(verifier, VT_OPERATOR_CODES) && verifier.VerifyVector(operator_codes()) && verifier.VerifyVectorOfTables(operator_codes()) && @@ -13081,7 +13234,6 @@ struct ModelBuilder { : fbb_(_fbb) { start_ = fbb_.StartTable(); } - ModelBuilder &operator=(const ModelBuilder &); flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); auto o = flatbuffers::Offset(end); @@ -13143,7 +13295,7 @@ inline flatbuffers::Offset CreateModelDirect( flatbuffers::Offset CreateModel(flatbuffers::FlatBufferBuilder &_fbb, const ModelT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr); inline CustomQuantizationT *CustomQuantization::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new CustomQuantizationT()); + auto _o = std::unique_ptr(new CustomQuantizationT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13151,7 +13303,7 @@ inline CustomQuantizationT *CustomQuantization::UnPack(const flatbuffers::resolv inline void CustomQuantization::UnPackTo(CustomQuantizationT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = custom(); if (_e) { _o->custom.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->custom[_i] = _e->Get(_i); } } } + { auto _e = custom(); if (_e) { _o->custom.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->custom.begin()); } } } inline flatbuffers::Offset CustomQuantization::Pack(flatbuffers::FlatBufferBuilder &_fbb, const CustomQuantizationT* _o, const flatbuffers::rehasher_function_t *_rehasher) { @@ -13170,7 +13322,7 @@ inline flatbuffers::Offset CreateCustomQuantization(flatbuff } inline QuantizationParametersT *QuantizationParameters::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new QuantizationParametersT()); + auto _o = std::unique_ptr(new QuantizationParametersT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13214,7 +13366,7 @@ inline flatbuffers::Offset CreateQuantizationParameters( } inline Int32VectorT *Int32Vector::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new Int32VectorT()); + auto _o = std::unique_ptr(new Int32VectorT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13240,7 +13392,7 @@ inline flatbuffers::Offset CreateInt32Vector(flatbuffers::FlatBuffe } inline Uint16VectorT *Uint16Vector::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new Uint16VectorT()); + auto _o = std::unique_ptr(new Uint16VectorT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13267,7 +13419,7 @@ inline flatbuffers::Offset CreateUint16Vector(flatbuffers::FlatBuf } inline Uint8VectorT *Uint8Vector::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new Uint8VectorT()); + auto _o = std::unique_ptr(new Uint8VectorT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13275,7 +13427,7 @@ inline Uint8VectorT *Uint8Vector::UnPack(const flatbuffers::resolver_function_t inline void Uint8Vector::UnPackTo(Uint8VectorT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = values(); if (_e) { _o->values.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->values[_i] = _e->Get(_i); } } } + { auto _e = values(); if (_e) { _o->values.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->values.begin()); } } } inline flatbuffers::Offset Uint8Vector::Pack(flatbuffers::FlatBufferBuilder &_fbb, const Uint8VectorT* _o, const flatbuffers::rehasher_function_t *_rehasher) { @@ -13294,7 +13446,7 @@ inline flatbuffers::Offset CreateUint8Vector(flatbuffers::FlatBuffe } inline DimensionMetadataT *DimensionMetadata::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new DimensionMetadataT()); + auto _o = std::unique_ptr(new DimensionMetadataT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13334,8 +13486,22 @@ inline flatbuffers::Offset CreateDimensionMetadata(flatbuffer _array_indices); } +inline SparsityParametersT::SparsityParametersT(const SparsityParametersT &o) + : traversal_order(o.traversal_order), + block_map(o.block_map) { + dim_metadata.reserve(o.dim_metadata.size()); + for (const auto &dim_metadata_ : o.dim_metadata) { dim_metadata.emplace_back((dim_metadata_) ? new tflite::DimensionMetadataT(*dim_metadata_) : nullptr); } +} + +inline SparsityParametersT &SparsityParametersT::operator=(SparsityParametersT o) FLATBUFFERS_NOEXCEPT { + std::swap(traversal_order, o.traversal_order); + std::swap(block_map, o.block_map); + std::swap(dim_metadata, o.dim_metadata); + return *this; +} + inline SparsityParametersT *SparsityParameters::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SparsityParametersT()); + auto _o = std::unique_ptr(new SparsityParametersT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13345,7 +13511,7 @@ inline void SparsityParameters::UnPackTo(SparsityParametersT *_o, const flatbuff (void)_resolver; { auto _e = traversal_order(); if (_e) { _o->traversal_order.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->traversal_order[_i] = _e->Get(_i); } } } { auto _e = block_map(); if (_e) { _o->block_map.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->block_map[_i] = _e->Get(_i); } } } - { auto _e = dim_metadata(); if (_e) { _o->dim_metadata.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->dim_metadata[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } + { auto _e = dim_metadata(); if (_e) { _o->dim_metadata.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->dim_metadata[_i]) { _e->Get(_i)->UnPackTo(_o->dim_metadata[_i].get(), _resolver); } else { _o->dim_metadata[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } } inline flatbuffers::Offset SparsityParameters::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SparsityParametersT* _o, const flatbuffers::rehasher_function_t *_rehasher) { @@ -13366,8 +13532,68 @@ inline flatbuffers::Offset CreateSparsityParameters(flatbuff _dim_metadata); } +inline VariantSubTypeT *VariantSubType::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = std::unique_ptr(new VariantSubTypeT()); + UnPackTo(_o.get(), _resolver); + return _o.release(); +} + +inline void VariantSubType::UnPackTo(VariantSubTypeT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; + { auto _e = shape(); if (_e) { _o->shape.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->shape[_i] = _e->Get(_i); } } } + { auto _e = type(); _o->type = _e; } + { auto _e = has_rank(); _o->has_rank = _e; } +} + +inline flatbuffers::Offset VariantSubType::Pack(flatbuffers::FlatBufferBuilder &_fbb, const VariantSubTypeT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateVariantSubType(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateVariantSubType(flatbuffers::FlatBufferBuilder &_fbb, const VariantSubTypeT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const VariantSubTypeT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + auto _shape = _o->shape.size() ? _fbb.CreateVector(_o->shape) : 0; + auto _type = _o->type; + auto _has_rank = _o->has_rank; + return tflite::CreateVariantSubType( + _fbb, + _shape, + _type, + _has_rank); +} + +inline TensorT::TensorT(const TensorT &o) + : shape(o.shape), + type(o.type), + buffer(o.buffer), + name(o.name), + quantization((o.quantization) ? new tflite::QuantizationParametersT(*o.quantization) : nullptr), + is_variable(o.is_variable), + sparsity((o.sparsity) ? new tflite::SparsityParametersT(*o.sparsity) : nullptr), + shape_signature(o.shape_signature), + has_rank(o.has_rank) { + variant_tensors.reserve(o.variant_tensors.size()); + for (const auto &variant_tensors_ : o.variant_tensors) { variant_tensors.emplace_back((variant_tensors_) ? new tflite::VariantSubTypeT(*variant_tensors_) : nullptr); } +} + +inline TensorT &TensorT::operator=(TensorT o) FLATBUFFERS_NOEXCEPT { + std::swap(shape, o.shape); + std::swap(type, o.type); + std::swap(buffer, o.buffer); + std::swap(name, o.name); + std::swap(quantization, o.quantization); + std::swap(is_variable, o.is_variable); + std::swap(sparsity, o.sparsity); + std::swap(shape_signature, o.shape_signature); + std::swap(has_rank, o.has_rank); + std::swap(variant_tensors, o.variant_tensors); + return *this; +} + inline TensorT *Tensor::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new TensorT()); + auto _o = std::unique_ptr(new TensorT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13379,11 +13605,12 @@ inline void Tensor::UnPackTo(TensorT *_o, const flatbuffers::resolver_function_t { auto _e = type(); _o->type = _e; } { auto _e = buffer(); _o->buffer = _e; } { auto _e = name(); if (_e) _o->name = _e->str(); } - { auto _e = quantization(); if (_e) _o->quantization = std::unique_ptr(_e->UnPack(_resolver)); } + { auto _e = quantization(); if (_e) { if(_o->quantization) { _e->UnPackTo(_o->quantization.get(), _resolver); } else { _o->quantization = std::unique_ptr(_e->UnPack(_resolver)); } } } { auto _e = is_variable(); _o->is_variable = _e; } - { auto _e = sparsity(); if (_e) _o->sparsity = std::unique_ptr(_e->UnPack(_resolver)); } + { auto _e = sparsity(); if (_e) { if(_o->sparsity) { _e->UnPackTo(_o->sparsity.get(), _resolver); } else { _o->sparsity = std::unique_ptr(_e->UnPack(_resolver)); } } } { auto _e = shape_signature(); if (_e) { _o->shape_signature.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->shape_signature[_i] = _e->Get(_i); } } } { auto _e = has_rank(); _o->has_rank = _e; } + { auto _e = variant_tensors(); if (_e) { _o->variant_tensors.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->variant_tensors[_i]) { _e->Get(_i)->UnPackTo(_o->variant_tensors[_i].get(), _resolver); } else { _o->variant_tensors[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } } inline flatbuffers::Offset Tensor::Pack(flatbuffers::FlatBufferBuilder &_fbb, const TensorT* _o, const flatbuffers::rehasher_function_t *_rehasher) { @@ -13403,6 +13630,7 @@ inline flatbuffers::Offset CreateTensor(flatbuffers::FlatBufferBuilder & auto _sparsity = _o->sparsity ? CreateSparsityParameters(_fbb, _o->sparsity.get(), _rehasher) : 0; auto _shape_signature = _o->shape_signature.size() ? _fbb.CreateVector(_o->shape_signature) : 0; auto _has_rank = _o->has_rank; + auto _variant_tensors = _o->variant_tensors.size() ? _fbb.CreateVector> (_o->variant_tensors.size(), [](size_t i, _VectorArgs *__va) { return CreateVariantSubType(*__va->__fbb, __va->__o->variant_tensors[i].get(), __va->__rehasher); }, &_va ) : 0; return tflite::CreateTensor( _fbb, _shape, @@ -13413,11 +13641,12 @@ inline flatbuffers::Offset CreateTensor(flatbuffers::FlatBufferBuilder & _is_variable, _sparsity, _shape_signature, - _has_rank); + _has_rank, + _variant_tensors); } inline Conv2DOptionsT *Conv2DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new Conv2DOptionsT()); + auto _o = std::unique_ptr(new Conv2DOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13458,7 +13687,7 @@ inline flatbuffers::Offset CreateConv2DOptions(flatbuffers::FlatB } inline Conv3DOptionsT *Conv3DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new Conv3DOptionsT()); + auto _o = std::unique_ptr(new Conv3DOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13505,7 +13734,7 @@ inline flatbuffers::Offset CreateConv3DOptions(flatbuffers::FlatB } inline Pool2DOptionsT *Pool2DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new Pool2DOptionsT()); + auto _o = std::unique_ptr(new Pool2DOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13546,7 +13775,7 @@ inline flatbuffers::Offset CreatePool2DOptions(flatbuffers::FlatB } inline DepthwiseConv2DOptionsT *DepthwiseConv2DOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new DepthwiseConv2DOptionsT()); + auto _o = std::unique_ptr(new DepthwiseConv2DOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13590,7 +13819,7 @@ inline flatbuffers::Offset CreateDepthwiseConv2DOptions( } inline ConcatEmbeddingsOptionsT *ConcatEmbeddingsOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ConcatEmbeddingsOptionsT()); + auto _o = std::unique_ptr(new ConcatEmbeddingsOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13622,7 +13851,7 @@ inline flatbuffers::Offset CreateConcatEmbeddingsOption } inline LSHProjectionOptionsT *LSHProjectionOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LSHProjectionOptionsT()); + auto _o = std::unique_ptr(new LSHProjectionOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13648,7 +13877,7 @@ inline flatbuffers::Offset CreateLSHProjectionOptions(flat } inline SVDFOptionsT *SVDFOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SVDFOptionsT()); + auto _o = std::unique_ptr(new SVDFOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13680,7 +13909,7 @@ inline flatbuffers::Offset CreateSVDFOptions(flatbuffers::FlatBuffe } inline RNNOptionsT *RNNOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new RNNOptionsT()); + auto _o = std::unique_ptr(new RNNOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13709,7 +13938,7 @@ inline flatbuffers::Offset CreateRNNOptions(flatbuffers::FlatBufferB } inline SequenceRNNOptionsT *SequenceRNNOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SequenceRNNOptionsT()); + auto _o = std::unique_ptr(new SequenceRNNOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13741,7 +13970,7 @@ inline flatbuffers::Offset CreateSequenceRNNOptions(flatbuff } inline BidirectionalSequenceRNNOptionsT *BidirectionalSequenceRNNOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new BidirectionalSequenceRNNOptionsT()); + auto _o = std::unique_ptr(new BidirectionalSequenceRNNOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13776,7 +14005,7 @@ inline flatbuffers::Offset CreateBidirectionalS } inline FullyConnectedOptionsT *FullyConnectedOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new FullyConnectedOptionsT()); + auto _o = std::unique_ptr(new FullyConnectedOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13811,7 +14040,7 @@ inline flatbuffers::Offset CreateFullyConnectedOptions(fl } inline SoftmaxOptionsT *SoftmaxOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SoftmaxOptionsT()); + auto _o = std::unique_ptr(new SoftmaxOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13837,7 +14066,7 @@ inline flatbuffers::Offset CreateSoftmaxOptions(flatbuffers::Fla } inline ConcatenationOptionsT *ConcatenationOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ConcatenationOptionsT()); + auto _o = std::unique_ptr(new ConcatenationOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13866,7 +14095,7 @@ inline flatbuffers::Offset CreateConcatenationOptions(flat } inline AddOptionsT *AddOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new AddOptionsT()); + auto _o = std::unique_ptr(new AddOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13895,7 +14124,7 @@ inline flatbuffers::Offset CreateAddOptions(flatbuffers::FlatBufferB } inline MulOptionsT *MulOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new MulOptionsT()); + auto _o = std::unique_ptr(new MulOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13921,7 +14150,7 @@ inline flatbuffers::Offset CreateMulOptions(flatbuffers::FlatBufferB } inline L2NormOptionsT *L2NormOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new L2NormOptionsT()); + auto _o = std::unique_ptr(new L2NormOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13947,7 +14176,7 @@ inline flatbuffers::Offset CreateL2NormOptions(flatbuffers::FlatB } inline LocalResponseNormalizationOptionsT *LocalResponseNormalizationOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LocalResponseNormalizationOptionsT()); + auto _o = std::unique_ptr(new LocalResponseNormalizationOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -13982,7 +14211,7 @@ inline flatbuffers::Offset CreateLocalRespons } inline LSTMOptionsT *LSTMOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LSTMOptionsT()); + auto _o = std::unique_ptr(new LSTMOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14020,7 +14249,7 @@ inline flatbuffers::Offset CreateLSTMOptions(flatbuffers::FlatBuffe } inline UnidirectionalSequenceLSTMOptionsT *UnidirectionalSequenceLSTMOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new UnidirectionalSequenceLSTMOptionsT()); + auto _o = std::unique_ptr(new UnidirectionalSequenceLSTMOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14058,7 +14287,7 @@ inline flatbuffers::Offset CreateUnidirection } inline BidirectionalSequenceLSTMOptionsT *BidirectionalSequenceLSTMOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new BidirectionalSequenceLSTMOptionsT()); + auto _o = std::unique_ptr(new BidirectionalSequenceLSTMOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14099,7 +14328,7 @@ inline flatbuffers::Offset CreateBidirectional } inline ResizeBilinearOptionsT *ResizeBilinearOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ResizeBilinearOptionsT()); + auto _o = std::unique_ptr(new ResizeBilinearOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14128,7 +14357,7 @@ inline flatbuffers::Offset CreateResizeBilinearOptions(fl } inline ResizeNearestNeighborOptionsT *ResizeNearestNeighborOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ResizeNearestNeighborOptionsT()); + auto _o = std::unique_ptr(new ResizeNearestNeighborOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14157,7 +14386,7 @@ inline flatbuffers::Offset CreateResizeNearestNeig } inline CallOptionsT *CallOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new CallOptionsT()); + auto _o = std::unique_ptr(new CallOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14183,7 +14412,7 @@ inline flatbuffers::Offset CreateCallOptions(flatbuffers::FlatBuffe } inline PadOptionsT *PadOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new PadOptionsT()); + auto _o = std::unique_ptr(new PadOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14206,7 +14435,7 @@ inline flatbuffers::Offset CreatePadOptions(flatbuffers::FlatBufferB } inline PadV2OptionsT *PadV2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new PadV2OptionsT()); + auto _o = std::unique_ptr(new PadV2OptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14229,7 +14458,7 @@ inline flatbuffers::Offset CreatePadV2Options(flatbuffers::FlatBuf } inline ReshapeOptionsT *ReshapeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ReshapeOptionsT()); + auto _o = std::unique_ptr(new ReshapeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14255,7 +14484,7 @@ inline flatbuffers::Offset CreateReshapeOptions(flatbuffers::Fla } inline SpaceToBatchNDOptionsT *SpaceToBatchNDOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SpaceToBatchNDOptionsT()); + auto _o = std::unique_ptr(new SpaceToBatchNDOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14278,7 +14507,7 @@ inline flatbuffers::Offset CreateSpaceToBatchNDOptions(fl } inline BatchToSpaceNDOptionsT *BatchToSpaceNDOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new BatchToSpaceNDOptionsT()); + auto _o = std::unique_ptr(new BatchToSpaceNDOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14301,7 +14530,7 @@ inline flatbuffers::Offset CreateBatchToSpaceNDOptions(fl } inline SkipGramOptionsT *SkipGramOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SkipGramOptionsT()); + auto _o = std::unique_ptr(new SkipGramOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14333,7 +14562,7 @@ inline flatbuffers::Offset CreateSkipGramOptions(flatbuffers::F } inline SpaceToDepthOptionsT *SpaceToDepthOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SpaceToDepthOptionsT()); + auto _o = std::unique_ptr(new SpaceToDepthOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14359,7 +14588,7 @@ inline flatbuffers::Offset CreateSpaceToDepthOptions(flatbu } inline DepthToSpaceOptionsT *DepthToSpaceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new DepthToSpaceOptionsT()); + auto _o = std::unique_ptr(new DepthToSpaceOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14385,7 +14614,7 @@ inline flatbuffers::Offset CreateDepthToSpaceOptions(flatbu } inline SubOptionsT *SubOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SubOptionsT()); + auto _o = std::unique_ptr(new SubOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14414,7 +14643,7 @@ inline flatbuffers::Offset CreateSubOptions(flatbuffers::FlatBufferB } inline DivOptionsT *DivOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new DivOptionsT()); + auto _o = std::unique_ptr(new DivOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14440,7 +14669,7 @@ inline flatbuffers::Offset CreateDivOptions(flatbuffers::FlatBufferB } inline TopKV2OptionsT *TopKV2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new TopKV2OptionsT()); + auto _o = std::unique_ptr(new TopKV2OptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14463,7 +14692,7 @@ inline flatbuffers::Offset CreateTopKV2Options(flatbuffers::FlatB } inline EmbeddingLookupSparseOptionsT *EmbeddingLookupSparseOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new EmbeddingLookupSparseOptionsT()); + auto _o = std::unique_ptr(new EmbeddingLookupSparseOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14489,7 +14718,7 @@ inline flatbuffers::Offset CreateEmbeddingLookupSp } inline GatherOptionsT *GatherOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new GatherOptionsT()); + auto _o = std::unique_ptr(new GatherOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14518,7 +14747,7 @@ inline flatbuffers::Offset CreateGatherOptions(flatbuffers::FlatB } inline TransposeOptionsT *TransposeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new TransposeOptionsT()); + auto _o = std::unique_ptr(new TransposeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14541,7 +14770,7 @@ inline flatbuffers::Offset CreateTransposeOptions(flatbuffers: } inline ExpOptionsT *ExpOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ExpOptionsT()); + auto _o = std::unique_ptr(new ExpOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14564,7 +14793,7 @@ inline flatbuffers::Offset CreateExpOptions(flatbuffers::FlatBufferB } inline CosOptionsT *CosOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new CosOptionsT()); + auto _o = std::unique_ptr(new CosOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14587,7 +14816,7 @@ inline flatbuffers::Offset CreateCosOptions(flatbuffers::FlatBufferB } inline ReducerOptionsT *ReducerOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ReducerOptionsT()); + auto _o = std::unique_ptr(new ReducerOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14613,7 +14842,7 @@ inline flatbuffers::Offset CreateReducerOptions(flatbuffers::Fla } inline SqueezeOptionsT *SqueezeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SqueezeOptionsT()); + auto _o = std::unique_ptr(new SqueezeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14639,7 +14868,7 @@ inline flatbuffers::Offset CreateSqueezeOptions(flatbuffers::Fla } inline SplitOptionsT *SplitOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SplitOptionsT()); + auto _o = std::unique_ptr(new SplitOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14665,7 +14894,7 @@ inline flatbuffers::Offset CreateSplitOptions(flatbuffers::FlatBuf } inline SplitVOptionsT *SplitVOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SplitVOptionsT()); + auto _o = std::unique_ptr(new SplitVOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14691,7 +14920,7 @@ inline flatbuffers::Offset CreateSplitVOptions(flatbuffers::FlatB } inline StridedSliceOptionsT *StridedSliceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new StridedSliceOptionsT()); + auto _o = std::unique_ptr(new StridedSliceOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14729,7 +14958,7 @@ inline flatbuffers::Offset CreateStridedSliceOptions(flatbu } inline LogSoftmaxOptionsT *LogSoftmaxOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LogSoftmaxOptionsT()); + auto _o = std::unique_ptr(new LogSoftmaxOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14752,7 +14981,7 @@ inline flatbuffers::Offset CreateLogSoftmaxOptions(flatbuffer } inline CastOptionsT *CastOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new CastOptionsT()); + auto _o = std::unique_ptr(new CastOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14781,7 +15010,7 @@ inline flatbuffers::Offset CreateCastOptions(flatbuffers::FlatBuffe } inline DequantizeOptionsT *DequantizeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new DequantizeOptionsT()); + auto _o = std::unique_ptr(new DequantizeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14804,7 +15033,7 @@ inline flatbuffers::Offset CreateDequantizeOptions(flatbuffer } inline MaximumMinimumOptionsT *MaximumMinimumOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new MaximumMinimumOptionsT()); + auto _o = std::unique_ptr(new MaximumMinimumOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14827,7 +15056,7 @@ inline flatbuffers::Offset CreateMaximumMinimumOptions(fl } inline TileOptionsT *TileOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new TileOptionsT()); + auto _o = std::unique_ptr(new TileOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14850,7 +15079,7 @@ inline flatbuffers::Offset CreateTileOptions(flatbuffers::FlatBuffe } inline ArgMaxOptionsT *ArgMaxOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ArgMaxOptionsT()); + auto _o = std::unique_ptr(new ArgMaxOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14876,7 +15105,7 @@ inline flatbuffers::Offset CreateArgMaxOptions(flatbuffers::FlatB } inline ArgMinOptionsT *ArgMinOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ArgMinOptionsT()); + auto _o = std::unique_ptr(new ArgMinOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14902,7 +15131,7 @@ inline flatbuffers::Offset CreateArgMinOptions(flatbuffers::FlatB } inline GreaterOptionsT *GreaterOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new GreaterOptionsT()); + auto _o = std::unique_ptr(new GreaterOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14925,7 +15154,7 @@ inline flatbuffers::Offset CreateGreaterOptions(flatbuffers::Fla } inline GreaterEqualOptionsT *GreaterEqualOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new GreaterEqualOptionsT()); + auto _o = std::unique_ptr(new GreaterEqualOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14948,7 +15177,7 @@ inline flatbuffers::Offset CreateGreaterEqualOptions(flatbu } inline LessOptionsT *LessOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LessOptionsT()); + auto _o = std::unique_ptr(new LessOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14971,7 +15200,7 @@ inline flatbuffers::Offset CreateLessOptions(flatbuffers::FlatBuffe } inline LessEqualOptionsT *LessEqualOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LessEqualOptionsT()); + auto _o = std::unique_ptr(new LessEqualOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -14994,7 +15223,7 @@ inline flatbuffers::Offset CreateLessEqualOptions(flatbuffers: } inline NegOptionsT *NegOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new NegOptionsT()); + auto _o = std::unique_ptr(new NegOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15017,7 +15246,7 @@ inline flatbuffers::Offset CreateNegOptions(flatbuffers::FlatBufferB } inline SelectOptionsT *SelectOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SelectOptionsT()); + auto _o = std::unique_ptr(new SelectOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15040,7 +15269,7 @@ inline flatbuffers::Offset CreateSelectOptions(flatbuffers::FlatB } inline SliceOptionsT *SliceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SliceOptionsT()); + auto _o = std::unique_ptr(new SliceOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15063,7 +15292,7 @@ inline flatbuffers::Offset CreateSliceOptions(flatbuffers::FlatBuf } inline TransposeConvOptionsT *TransposeConvOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new TransposeConvOptionsT()); + auto _o = std::unique_ptr(new TransposeConvOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15095,7 +15324,7 @@ inline flatbuffers::Offset CreateTransposeConvOptions(flat } inline ExpandDimsOptionsT *ExpandDimsOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ExpandDimsOptionsT()); + auto _o = std::unique_ptr(new ExpandDimsOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15118,7 +15347,7 @@ inline flatbuffers::Offset CreateExpandDimsOptions(flatbuffer } inline SparseToDenseOptionsT *SparseToDenseOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SparseToDenseOptionsT()); + auto _o = std::unique_ptr(new SparseToDenseOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15144,7 +15373,7 @@ inline flatbuffers::Offset CreateSparseToDenseOptions(flat } inline EqualOptionsT *EqualOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new EqualOptionsT()); + auto _o = std::unique_ptr(new EqualOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15167,7 +15396,7 @@ inline flatbuffers::Offset CreateEqualOptions(flatbuffers::FlatBuf } inline NotEqualOptionsT *NotEqualOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new NotEqualOptionsT()); + auto _o = std::unique_ptr(new NotEqualOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15190,7 +15419,7 @@ inline flatbuffers::Offset CreateNotEqualOptions(flatbuffers::F } inline ShapeOptionsT *ShapeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ShapeOptionsT()); + auto _o = std::unique_ptr(new ShapeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15216,7 +15445,7 @@ inline flatbuffers::Offset CreateShapeOptions(flatbuffers::FlatBuf } inline RankOptionsT *RankOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new RankOptionsT()); + auto _o = std::unique_ptr(new RankOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15239,7 +15468,7 @@ inline flatbuffers::Offset CreateRankOptions(flatbuffers::FlatBuffe } inline PowOptionsT *PowOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new PowOptionsT()); + auto _o = std::unique_ptr(new PowOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15262,7 +15491,7 @@ inline flatbuffers::Offset CreatePowOptions(flatbuffers::FlatBufferB } inline FakeQuantOptionsT *FakeQuantOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new FakeQuantOptionsT()); + auto _o = std::unique_ptr(new FakeQuantOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15297,7 +15526,7 @@ inline flatbuffers::Offset CreateFakeQuantOptions(flatbuffers: } inline PackOptionsT *PackOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new PackOptionsT()); + auto _o = std::unique_ptr(new PackOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15326,7 +15555,7 @@ inline flatbuffers::Offset CreatePackOptions(flatbuffers::FlatBuffe } inline LogicalOrOptionsT *LogicalOrOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LogicalOrOptionsT()); + auto _o = std::unique_ptr(new LogicalOrOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15349,7 +15578,7 @@ inline flatbuffers::Offset CreateLogicalOrOptions(flatbuffers: } inline OneHotOptionsT *OneHotOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new OneHotOptionsT()); + auto _o = std::unique_ptr(new OneHotOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15375,7 +15604,7 @@ inline flatbuffers::Offset CreateOneHotOptions(flatbuffers::FlatB } inline AbsOptionsT *AbsOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new AbsOptionsT()); + auto _o = std::unique_ptr(new AbsOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15398,7 +15627,7 @@ inline flatbuffers::Offset CreateAbsOptions(flatbuffers::FlatBufferB } inline HardSwishOptionsT *HardSwishOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new HardSwishOptionsT()); + auto _o = std::unique_ptr(new HardSwishOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15421,7 +15650,7 @@ inline flatbuffers::Offset CreateHardSwishOptions(flatbuffers: } inline LogicalAndOptionsT *LogicalAndOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LogicalAndOptionsT()); + auto _o = std::unique_ptr(new LogicalAndOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15444,7 +15673,7 @@ inline flatbuffers::Offset CreateLogicalAndOptions(flatbuffer } inline LogicalNotOptionsT *LogicalNotOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LogicalNotOptionsT()); + auto _o = std::unique_ptr(new LogicalNotOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15467,7 +15696,7 @@ inline flatbuffers::Offset CreateLogicalNotOptions(flatbuffer } inline UnpackOptionsT *UnpackOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new UnpackOptionsT()); + auto _o = std::unique_ptr(new UnpackOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15496,7 +15725,7 @@ inline flatbuffers::Offset CreateUnpackOptions(flatbuffers::FlatB } inline FloorDivOptionsT *FloorDivOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new FloorDivOptionsT()); + auto _o = std::unique_ptr(new FloorDivOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15519,7 +15748,7 @@ inline flatbuffers::Offset CreateFloorDivOptions(flatbuffers::F } inline SquareOptionsT *SquareOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SquareOptionsT()); + auto _o = std::unique_ptr(new SquareOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15542,7 +15771,7 @@ inline flatbuffers::Offset CreateSquareOptions(flatbuffers::FlatB } inline ZerosLikeOptionsT *ZerosLikeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ZerosLikeOptionsT()); + auto _o = std::unique_ptr(new ZerosLikeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15565,7 +15794,7 @@ inline flatbuffers::Offset CreateZerosLikeOptions(flatbuffers: } inline FillOptionsT *FillOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new FillOptionsT()); + auto _o = std::unique_ptr(new FillOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15588,7 +15817,7 @@ inline flatbuffers::Offset CreateFillOptions(flatbuffers::FlatBuffe } inline FloorModOptionsT *FloorModOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new FloorModOptionsT()); + auto _o = std::unique_ptr(new FloorModOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15611,7 +15840,7 @@ inline flatbuffers::Offset CreateFloorModOptions(flatbuffers::F } inline RangeOptionsT *RangeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new RangeOptionsT()); + auto _o = std::unique_ptr(new RangeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15634,7 +15863,7 @@ inline flatbuffers::Offset CreateRangeOptions(flatbuffers::FlatBuf } inline LeakyReluOptionsT *LeakyReluOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new LeakyReluOptionsT()); + auto _o = std::unique_ptr(new LeakyReluOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15660,7 +15889,7 @@ inline flatbuffers::Offset CreateLeakyReluOptions(flatbuffers: } inline SquaredDifferenceOptionsT *SquaredDifferenceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SquaredDifferenceOptionsT()); + auto _o = std::unique_ptr(new SquaredDifferenceOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15683,7 +15912,7 @@ inline flatbuffers::Offset CreateSquaredDifferenceOpti } inline MirrorPadOptionsT *MirrorPadOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new MirrorPadOptionsT()); + auto _o = std::unique_ptr(new MirrorPadOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15709,7 +15938,7 @@ inline flatbuffers::Offset CreateMirrorPadOptions(flatbuffers: } inline UniqueOptionsT *UniqueOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new UniqueOptionsT()); + auto _o = std::unique_ptr(new UniqueOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15735,7 +15964,7 @@ inline flatbuffers::Offset CreateUniqueOptions(flatbuffers::FlatB } inline ReverseV2OptionsT *ReverseV2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ReverseV2OptionsT()); + auto _o = std::unique_ptr(new ReverseV2OptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15758,7 +15987,7 @@ inline flatbuffers::Offset CreateReverseV2Options(flatbuffers: } inline AddNOptionsT *AddNOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new AddNOptionsT()); + auto _o = std::unique_ptr(new AddNOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15781,7 +16010,7 @@ inline flatbuffers::Offset CreateAddNOptions(flatbuffers::FlatBuffe } inline GatherNdOptionsT *GatherNdOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new GatherNdOptionsT()); + auto _o = std::unique_ptr(new GatherNdOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15804,7 +16033,7 @@ inline flatbuffers::Offset CreateGatherNdOptions(flatbuffers::F } inline WhereOptionsT *WhereOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new WhereOptionsT()); + auto _o = std::unique_ptr(new WhereOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15827,7 +16056,7 @@ inline flatbuffers::Offset CreateWhereOptions(flatbuffers::FlatBuf } inline ReverseSequenceOptionsT *ReverseSequenceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ReverseSequenceOptionsT()); + auto _o = std::unique_ptr(new ReverseSequenceOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15856,7 +16085,7 @@ inline flatbuffers::Offset CreateReverseSequenceOptions( } inline MatrixDiagOptionsT *MatrixDiagOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new MatrixDiagOptionsT()); + auto _o = std::unique_ptr(new MatrixDiagOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15879,7 +16108,7 @@ inline flatbuffers::Offset CreateMatrixDiagOptions(flatbuffer } inline QuantizeOptionsT *QuantizeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new QuantizeOptionsT()); + auto _o = std::unique_ptr(new QuantizeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15902,7 +16131,7 @@ inline flatbuffers::Offset CreateQuantizeOptions(flatbuffers::F } inline MatrixSetDiagOptionsT *MatrixSetDiagOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new MatrixSetDiagOptionsT()); + auto _o = std::unique_ptr(new MatrixSetDiagOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15925,7 +16154,7 @@ inline flatbuffers::Offset CreateMatrixSetDiagOptions(flat } inline IfOptionsT *IfOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new IfOptionsT()); + auto _o = std::unique_ptr(new IfOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15954,7 +16183,7 @@ inline flatbuffers::Offset CreateIfOptions(flatbuffers::FlatBufferBui } inline CallOnceOptionsT *CallOnceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new CallOnceOptionsT()); + auto _o = std::unique_ptr(new CallOnceOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -15980,7 +16209,7 @@ inline flatbuffers::Offset CreateCallOnceOptions(flatbuffers::F } inline WhileOptionsT *WhileOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new WhileOptionsT()); + auto _o = std::unique_ptr(new WhileOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16009,7 +16238,7 @@ inline flatbuffers::Offset CreateWhileOptions(flatbuffers::FlatBuf } inline NonMaxSuppressionV4OptionsT *NonMaxSuppressionV4Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new NonMaxSuppressionV4OptionsT()); + auto _o = std::unique_ptr(new NonMaxSuppressionV4OptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16032,7 +16261,7 @@ inline flatbuffers::Offset CreateNonMaxSuppressionV4 } inline NonMaxSuppressionV5OptionsT *NonMaxSuppressionV5Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new NonMaxSuppressionV5OptionsT()); + auto _o = std::unique_ptr(new NonMaxSuppressionV5OptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16055,7 +16284,7 @@ inline flatbuffers::Offset CreateNonMaxSuppressionV5 } inline ScatterNdOptionsT *ScatterNdOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ScatterNdOptionsT()); + auto _o = std::unique_ptr(new ScatterNdOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16078,7 +16307,7 @@ inline flatbuffers::Offset CreateScatterNdOptions(flatbuffers: } inline SelectV2OptionsT *SelectV2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SelectV2OptionsT()); + auto _o = std::unique_ptr(new SelectV2OptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16101,7 +16330,7 @@ inline flatbuffers::Offset CreateSelectV2Options(flatbuffers::F } inline DensifyOptionsT *DensifyOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new DensifyOptionsT()); + auto _o = std::unique_ptr(new DensifyOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16124,7 +16353,7 @@ inline flatbuffers::Offset CreateDensifyOptions(flatbuffers::Fla } inline SegmentSumOptionsT *SegmentSumOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SegmentSumOptionsT()); + auto _o = std::unique_ptr(new SegmentSumOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16147,7 +16376,7 @@ inline flatbuffers::Offset CreateSegmentSumOptions(flatbuffer } inline BatchMatMulOptionsT *BatchMatMulOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new BatchMatMulOptionsT()); + auto _o = std::unique_ptr(new BatchMatMulOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16179,7 +16408,7 @@ inline flatbuffers::Offset CreateBatchMatMulOptions(flatbuff } inline CumsumOptionsT *CumsumOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new CumsumOptionsT()); + auto _o = std::unique_ptr(new CumsumOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16208,7 +16437,7 @@ inline flatbuffers::Offset CreateCumsumOptions(flatbuffers::FlatB } inline BroadcastToOptionsT *BroadcastToOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new BroadcastToOptionsT()); + auto _o = std::unique_ptr(new BroadcastToOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16231,7 +16460,7 @@ inline flatbuffers::Offset CreateBroadcastToOptions(flatbuff } inline Rfft2dOptionsT *Rfft2dOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new Rfft2dOptionsT()); + auto _o = std::unique_ptr(new Rfft2dOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16254,7 +16483,7 @@ inline flatbuffers::Offset CreateRfft2dOptions(flatbuffers::FlatB } inline HashtableOptionsT *HashtableOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new HashtableOptionsT()); + auto _o = std::unique_ptr(new HashtableOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16286,7 +16515,7 @@ inline flatbuffers::Offset CreateHashtableOptions(flatbuffers: } inline HashtableFindOptionsT *HashtableFindOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new HashtableFindOptionsT()); + auto _o = std::unique_ptr(new HashtableFindOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16309,7 +16538,7 @@ inline flatbuffers::Offset CreateHashtableFindOptions(flat } inline HashtableImportOptionsT *HashtableImportOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new HashtableImportOptionsT()); + auto _o = std::unique_ptr(new HashtableImportOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16332,7 +16561,7 @@ inline flatbuffers::Offset CreateHashtableImportOptions( } inline HashtableSizeOptionsT *HashtableSizeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new HashtableSizeOptionsT()); + auto _o = std::unique_ptr(new HashtableSizeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16355,7 +16584,7 @@ inline flatbuffers::Offset CreateHashtableSizeOptions(flat } inline VarHandleOptionsT *VarHandleOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new VarHandleOptionsT()); + auto _o = std::unique_ptr(new VarHandleOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16384,7 +16613,7 @@ inline flatbuffers::Offset CreateVarHandleOptions(flatbuffers: } inline ReadVariableOptionsT *ReadVariableOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ReadVariableOptionsT()); + auto _o = std::unique_ptr(new ReadVariableOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16407,7 +16636,7 @@ inline flatbuffers::Offset CreateReadVariableOptions(flatbu } inline AssignVariableOptionsT *AssignVariableOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new AssignVariableOptionsT()); + auto _o = std::unique_ptr(new AssignVariableOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16430,7 +16659,7 @@ inline flatbuffers::Offset CreateAssignVariableOptions(fl } inline RandomOptionsT *RandomOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new RandomOptionsT()); + auto _o = std::unique_ptr(new RandomOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16459,7 +16688,7 @@ inline flatbuffers::Offset CreateRandomOptions(flatbuffers::FlatB } inline BucketizeOptionsT *BucketizeOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new BucketizeOptionsT()); + auto _o = std::unique_ptr(new BucketizeOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16485,7 +16714,7 @@ inline flatbuffers::Offset CreateBucketizeOptions(flatbuffers: } inline GeluOptionsT *GeluOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new GeluOptionsT()); + auto _o = std::unique_ptr(new GeluOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16511,7 +16740,7 @@ inline flatbuffers::Offset CreateGeluOptions(flatbuffers::FlatBuffe } inline DynamicUpdateSliceOptionsT *DynamicUpdateSliceOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new DynamicUpdateSliceOptionsT()); + auto _o = std::unique_ptr(new DynamicUpdateSliceOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16534,7 +16763,7 @@ inline flatbuffers::Offset CreateDynamicUpdateSliceOp } inline UnsortedSegmentProdOptionsT *UnsortedSegmentProdOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new UnsortedSegmentProdOptionsT()); + auto _o = std::unique_ptr(new UnsortedSegmentProdOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16557,7 +16786,7 @@ inline flatbuffers::Offset CreateUnsortedSegmentProd } inline UnsortedSegmentMaxOptionsT *UnsortedSegmentMaxOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new UnsortedSegmentMaxOptionsT()); + auto _o = std::unique_ptr(new UnsortedSegmentMaxOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16580,7 +16809,7 @@ inline flatbuffers::Offset CreateUnsortedSegmentMaxOp } inline UnsortedSegmentSumOptionsT *UnsortedSegmentSumOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new UnsortedSegmentSumOptionsT()); + auto _o = std::unique_ptr(new UnsortedSegmentSumOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16603,7 +16832,7 @@ inline flatbuffers::Offset CreateUnsortedSegmentSumOp } inline ATan2OptionsT *ATan2Options::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ATan2OptionsT()); + auto _o = std::unique_ptr(new ATan2OptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16626,7 +16855,7 @@ inline flatbuffers::Offset CreateATan2Options(flatbuffers::FlatBuf } inline UnsortedSegmentMinOptionsT *UnsortedSegmentMinOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new UnsortedSegmentMinOptionsT()); + auto _o = std::unique_ptr(new UnsortedSegmentMinOptionsT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16648,8 +16877,31 @@ inline flatbuffers::Offset CreateUnsortedSegmentMinOp _fbb); } +inline SignOptionsT *SignOptions::UnPack(const flatbuffers::resolver_function_t *_resolver) const { + auto _o = std::unique_ptr(new SignOptionsT()); + UnPackTo(_o.get(), _resolver); + return _o.release(); +} + +inline void SignOptions::UnPackTo(SignOptionsT *_o, const flatbuffers::resolver_function_t *_resolver) const { + (void)_o; + (void)_resolver; +} + +inline flatbuffers::Offset SignOptions::Pack(flatbuffers::FlatBufferBuilder &_fbb, const SignOptionsT* _o, const flatbuffers::rehasher_function_t *_rehasher) { + return CreateSignOptions(_fbb, _o, _rehasher); +} + +inline flatbuffers::Offset CreateSignOptions(flatbuffers::FlatBufferBuilder &_fbb, const SignOptionsT *_o, const flatbuffers::rehasher_function_t *_rehasher) { + (void)_rehasher; + (void)_o; + struct _VectorArgs { flatbuffers::FlatBufferBuilder *__fbb; const SignOptionsT* __o; const flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va; + return tflite::CreateSignOptions( + _fbb); +} + inline OperatorCodeT *OperatorCode::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new OperatorCodeT()); + auto _o = std::unique_ptr(new OperatorCodeT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16684,7 +16936,7 @@ inline flatbuffers::Offset CreateOperatorCode(flatbuffers::FlatBuf } inline OperatorT *Operator::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new OperatorT()); + auto _o = std::unique_ptr(new OperatorT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16697,7 +16949,7 @@ inline void Operator::UnPackTo(OperatorT *_o, const flatbuffers::resolver_functi { auto _e = outputs(); if (_e) { _o->outputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->outputs[_i] = _e->Get(_i); } } } { auto _e = builtin_options_type(); _o->builtin_options.type = _e; } { auto _e = builtin_options(); if (_e) _o->builtin_options.value = tflite::BuiltinOptionsUnion::UnPack(_e, builtin_options_type(), _resolver); } - { auto _e = custom_options(); if (_e) { _o->custom_options.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->custom_options[_i] = _e->Get(_i); } } } + { auto _e = custom_options(); if (_e) { _o->custom_options.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->custom_options.begin()); } } { auto _e = custom_options_format(); _o->custom_options_format = _e; } { auto _e = mutating_variable_inputs(); if (_e) { _o->mutating_variable_inputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->mutating_variable_inputs[_i] = _e->Get(_i) != 0; } } } { auto _e = intermediates(); if (_e) { _o->intermediates.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->intermediates[_i] = _e->Get(_i); } } } @@ -16733,8 +16985,27 @@ inline flatbuffers::Offset CreateOperator(flatbuffers::FlatBufferBuild _intermediates); } +inline SubGraphT::SubGraphT(const SubGraphT &o) + : inputs(o.inputs), + outputs(o.outputs), + name(o.name) { + tensors.reserve(o.tensors.size()); + for (const auto &tensors_ : o.tensors) { tensors.emplace_back((tensors_) ? new tflite::TensorT(*tensors_) : nullptr); } + operators.reserve(o.operators.size()); + for (const auto &operators_ : o.operators) { operators.emplace_back((operators_) ? new tflite::OperatorT(*operators_) : nullptr); } +} + +inline SubGraphT &SubGraphT::operator=(SubGraphT o) FLATBUFFERS_NOEXCEPT { + std::swap(tensors, o.tensors); + std::swap(inputs, o.inputs); + std::swap(outputs, o.outputs); + std::swap(operators, o.operators); + std::swap(name, o.name); + return *this; +} + inline SubGraphT *SubGraph::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SubGraphT()); + auto _o = std::unique_ptr(new SubGraphT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16742,10 +17013,10 @@ inline SubGraphT *SubGraph::UnPack(const flatbuffers::resolver_function_t *_reso inline void SubGraph::UnPackTo(SubGraphT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = tensors(); if (_e) { _o->tensors.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->tensors[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } + { auto _e = tensors(); if (_e) { _o->tensors.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->tensors[_i]) { _e->Get(_i)->UnPackTo(_o->tensors[_i].get(), _resolver); } else { _o->tensors[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } { auto _e = inputs(); if (_e) { _o->inputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inputs[_i] = _e->Get(_i); } } } { auto _e = outputs(); if (_e) { _o->outputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->outputs[_i] = _e->Get(_i); } } } - { auto _e = operators(); if (_e) { _o->operators.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->operators[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } + { auto _e = operators(); if (_e) { _o->operators.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->operators[_i]) { _e->Get(_i)->UnPackTo(_o->operators[_i].get(), _resolver); } else { _o->operators[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } { auto _e = name(); if (_e) _o->name = _e->str(); } } @@ -16772,7 +17043,7 @@ inline flatbuffers::Offset CreateSubGraph(flatbuffers::FlatBufferBuild } inline BufferT *Buffer::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new BufferT()); + auto _o = std::unique_ptr(new BufferT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16780,7 +17051,7 @@ inline BufferT *Buffer::UnPack(const flatbuffers::resolver_function_t *_resolver inline void Buffer::UnPackTo(BufferT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = data(); if (_e) { _o->data.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->data[_i] = _e->Get(_i); } } } + { auto _e = data(); if (_e) { _o->data.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->data.begin()); } } } inline flatbuffers::Offset Buffer::Pack(flatbuffers::FlatBufferBuilder &_fbb, const BufferT* _o, const flatbuffers::rehasher_function_t *_rehasher) { @@ -16799,7 +17070,7 @@ inline flatbuffers::Offset CreateBuffer(flatbuffers::FlatBufferBuilder & } inline MetadataT *Metadata::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new MetadataT()); + auto _o = std::unique_ptr(new MetadataT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16828,7 +17099,7 @@ inline flatbuffers::Offset CreateMetadata(flatbuffers::FlatBufferBuild } inline TensorMapT *TensorMap::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new TensorMapT()); + auto _o = std::unique_ptr(new TensorMapT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16856,8 +17127,25 @@ inline flatbuffers::Offset CreateTensorMap(flatbuffers::FlatBufferBui _tensor_index); } +inline SignatureDefT::SignatureDefT(const SignatureDefT &o) + : signature_key(o.signature_key), + subgraph_index(o.subgraph_index) { + inputs.reserve(o.inputs.size()); + for (const auto &inputs_ : o.inputs) { inputs.emplace_back((inputs_) ? new tflite::TensorMapT(*inputs_) : nullptr); } + outputs.reserve(o.outputs.size()); + for (const auto &outputs_ : o.outputs) { outputs.emplace_back((outputs_) ? new tflite::TensorMapT(*outputs_) : nullptr); } +} + +inline SignatureDefT &SignatureDefT::operator=(SignatureDefT o) FLATBUFFERS_NOEXCEPT { + std::swap(inputs, o.inputs); + std::swap(outputs, o.outputs); + std::swap(signature_key, o.signature_key); + std::swap(subgraph_index, o.subgraph_index); + return *this; +} + inline SignatureDefT *SignatureDef::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new SignatureDefT()); + auto _o = std::unique_ptr(new SignatureDefT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16865,8 +17153,8 @@ inline SignatureDefT *SignatureDef::UnPack(const flatbuffers::resolver_function_ inline void SignatureDef::UnPackTo(SignatureDefT *_o, const flatbuffers::resolver_function_t *_resolver) const { (void)_o; (void)_resolver; - { auto _e = inputs(); if (_e) { _o->inputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->inputs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } - { auto _e = outputs(); if (_e) { _o->outputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->outputs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } + { auto _e = inputs(); if (_e) { _o->inputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->inputs[_i]) { _e->Get(_i)->UnPackTo(_o->inputs[_i].get(), _resolver); } else { _o->inputs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } + { auto _e = outputs(); if (_e) { _o->outputs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->outputs[_i]) { _e->Get(_i)->UnPackTo(_o->outputs[_i].get(), _resolver); } else { _o->outputs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } { auto _e = signature_key(); if (_e) _o->signature_key = _e->str(); } { auto _e = subgraph_index(); _o->subgraph_index = _e; } } @@ -16891,8 +17179,36 @@ inline flatbuffers::Offset CreateSignatureDef(flatbuffers::FlatBuf _subgraph_index); } +inline ModelT::ModelT(const ModelT &o) + : version(o.version), + description(o.description), + metadata_buffer(o.metadata_buffer) { + operator_codes.reserve(o.operator_codes.size()); + for (const auto &operator_codes_ : o.operator_codes) { operator_codes.emplace_back((operator_codes_) ? new tflite::OperatorCodeT(*operator_codes_) : nullptr); } + subgraphs.reserve(o.subgraphs.size()); + for (const auto &subgraphs_ : o.subgraphs) { subgraphs.emplace_back((subgraphs_) ? new tflite::SubGraphT(*subgraphs_) : nullptr); } + buffers.reserve(o.buffers.size()); + for (const auto &buffers_ : o.buffers) { buffers.emplace_back((buffers_) ? new tflite::BufferT(*buffers_) : nullptr); } + metadata.reserve(o.metadata.size()); + for (const auto &metadata_ : o.metadata) { metadata.emplace_back((metadata_) ? new tflite::MetadataT(*metadata_) : nullptr); } + signature_defs.reserve(o.signature_defs.size()); + for (const auto &signature_defs_ : o.signature_defs) { signature_defs.emplace_back((signature_defs_) ? new tflite::SignatureDefT(*signature_defs_) : nullptr); } +} + +inline ModelT &ModelT::operator=(ModelT o) FLATBUFFERS_NOEXCEPT { + std::swap(version, o.version); + std::swap(operator_codes, o.operator_codes); + std::swap(subgraphs, o.subgraphs); + std::swap(description, o.description); + std::swap(buffers, o.buffers); + std::swap(metadata_buffer, o.metadata_buffer); + std::swap(metadata, o.metadata); + std::swap(signature_defs, o.signature_defs); + return *this; +} + inline ModelT *Model::UnPack(const flatbuffers::resolver_function_t *_resolver) const { - std::unique_ptr _o = std::unique_ptr(new ModelT()); + auto _o = std::unique_ptr(new ModelT()); UnPackTo(_o.get(), _resolver); return _o.release(); } @@ -16901,13 +17217,13 @@ inline void Model::UnPackTo(ModelT *_o, const flatbuffers::resolver_function_t * (void)_o; (void)_resolver; { auto _e = version(); _o->version = _e; } - { auto _e = operator_codes(); if (_e) { _o->operator_codes.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->operator_codes[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } - { auto _e = subgraphs(); if (_e) { _o->subgraphs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->subgraphs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } + { auto _e = operator_codes(); if (_e) { _o->operator_codes.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->operator_codes[_i]) { _e->Get(_i)->UnPackTo(_o->operator_codes[_i].get(), _resolver); } else { _o->operator_codes[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } + { auto _e = subgraphs(); if (_e) { _o->subgraphs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->subgraphs[_i]) { _e->Get(_i)->UnPackTo(_o->subgraphs[_i].get(), _resolver); } else { _o->subgraphs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } { auto _e = description(); if (_e) _o->description = _e->str(); } - { auto _e = buffers(); if (_e) { _o->buffers.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->buffers[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } + { auto _e = buffers(); if (_e) { _o->buffers.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->buffers[_i]) { _e->Get(_i)->UnPackTo(_o->buffers[_i].get(), _resolver); } else { _o->buffers[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } { auto _e = metadata_buffer(); if (_e) { _o->metadata_buffer.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->metadata_buffer[_i] = _e->Get(_i); } } } - { auto _e = metadata(); if (_e) { _o->metadata.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->metadata[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } - { auto _e = signature_defs(); if (_e) { _o->signature_defs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->signature_defs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); } } } + { auto _e = metadata(); if (_e) { _o->metadata.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->metadata[_i]) { _e->Get(_i)->UnPackTo(_o->metadata[_i].get(), _resolver); } else { _o->metadata[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } + { auto _e = signature_defs(); if (_e) { _o->signature_defs.resize(_e->size()); for (flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->signature_defs[_i]) { _e->Get(_i)->UnPackTo(_o->signature_defs[_i].get(), _resolver); } else { _o->signature_defs[_i] = std::unique_ptr(_e->Get(_i)->UnPack(_resolver)); }; } } } } inline flatbuffers::Offset Model::Pack(flatbuffers::FlatBufferBuilder &_fbb, const ModelT* _o, const flatbuffers::rehasher_function_t *_rehasher) { @@ -16964,6 +17280,7 @@ inline bool VerifyQuantizationDetailsVector(flatbuffers::Verifier &verifier, con } inline void *QuantizationDetailsUnion::UnPack(const void *obj, QuantizationDetails type, const flatbuffers::resolver_function_t *resolver) { + (void)resolver; switch (type) { case QuantizationDetails_CustomQuantization: { auto ptr = reinterpret_cast(obj); @@ -16974,6 +17291,7 @@ inline void *QuantizationDetailsUnion::UnPack(const void *obj, QuantizationDetai } inline flatbuffers::Offset QuantizationDetailsUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const { + (void)_rehasher; switch (type) { case QuantizationDetails_CustomQuantization: { auto ptr = reinterpret_cast(value); @@ -17041,6 +17359,7 @@ inline bool VerifySparseIndexVectorVector(flatbuffers::Verifier &verifier, const } inline void *SparseIndexVectorUnion::UnPack(const void *obj, SparseIndexVector type, const flatbuffers::resolver_function_t *resolver) { + (void)resolver; switch (type) { case SparseIndexVector_Int32Vector: { auto ptr = reinterpret_cast(obj); @@ -17059,6 +17378,7 @@ inline void *SparseIndexVectorUnion::UnPack(const void *obj, SparseIndexVector t } inline flatbuffers::Offset SparseIndexVectorUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const { + (void)_rehasher; switch (type) { case SparseIndexVector_Int32Vector: { auto ptr = reinterpret_cast(value); @@ -17611,6 +17931,10 @@ inline bool VerifyBuiltinOptions(flatbuffers::Verifier &verifier, const void *ob auto ptr = reinterpret_cast(obj); return verifier.VerifyTable(ptr); } + case BuiltinOptions_SignOptions: { + auto ptr = reinterpret_cast(obj); + return verifier.VerifyTable(ptr); + } default: return true; } } @@ -17628,6 +17952,7 @@ inline bool VerifyBuiltinOptionsVector(flatbuffers::Verifier &verifier, const fl } inline void *BuiltinOptionsUnion::UnPack(const void *obj, BuiltinOptions type, const flatbuffers::resolver_function_t *resolver) { + (void)resolver; switch (type) { case BuiltinOptions_Conv2DOptions: { auto ptr = reinterpret_cast(obj); @@ -18117,11 +18442,16 @@ inline void *BuiltinOptionsUnion::UnPack(const void *obj, BuiltinOptions type, c auto ptr = reinterpret_cast(obj); return ptr->UnPack(resolver); } + case BuiltinOptions_SignOptions: { + auto ptr = reinterpret_cast(obj); + return ptr->UnPack(resolver); + } default: return nullptr; } } inline flatbuffers::Offset BuiltinOptionsUnion::Pack(flatbuffers::FlatBufferBuilder &_fbb, const flatbuffers::rehasher_function_t *_rehasher) const { + (void)_rehasher; switch (type) { case BuiltinOptions_Conv2DOptions: { auto ptr = reinterpret_cast(value); @@ -18611,6 +18941,10 @@ inline flatbuffers::Offset BuiltinOptionsUnion::Pack(flatbuffers::FlatBuff auto ptr = reinterpret_cast(value); return CreateATan2Options(_fbb, ptr, _rehasher).Union(); } + case BuiltinOptions_SignOptions: { + auto ptr = reinterpret_cast(value); + return CreateSignOptions(_fbb, ptr, _rehasher).Union(); + } default: return 0; } } @@ -19105,6 +19439,10 @@ inline BuiltinOptionsUnion::BuiltinOptionsUnion(const BuiltinOptionsUnion &u) : value = new tflite::ATan2OptionsT(*reinterpret_cast(u.value)); break; } + case BuiltinOptions_SignOptions: { + value = new tflite::SignOptionsT(*reinterpret_cast(u.value)); + break; + } default: break; } @@ -19722,6 +20060,11 @@ inline void BuiltinOptionsUnion::Reset() { delete ptr; break; } + case BuiltinOptions_SignOptions: { + auto ptr = reinterpret_cast(value); + delete ptr; + break; + } default: break; } value = nullptr; @@ -19745,6 +20088,11 @@ inline bool ModelBufferHasIdentifier(const void *buf) { buf, ModelIdentifier()); } +inline bool SizePrefixedModelBufferHasIdentifier(const void *buf) { + return flatbuffers::BufferHasIdentifier( + buf, ModelIdentifier(), true); +} + inline bool VerifyModelBuffer( flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer(ModelIdentifier()); diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/base.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/base.h index 371b6fdb..5f2158e0 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/base.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/base.h @@ -150,7 +150,7 @@ #define FLATBUFFERS_VERSION_MAJOR 2 #define FLATBUFFERS_VERSION_MINOR 0 -#define FLATBUFFERS_VERSION_REVISION 5 +#define FLATBUFFERS_VERSION_REVISION 6 #define FLATBUFFERS_STRING_EXPAND(X) #X #define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X) namespace flatbuffers { @@ -270,9 +270,12 @@ namespace flatbuffers { #endif // !FLATBUFFERS_HAS_NEW_STRTOD #ifndef FLATBUFFERS_LOCALE_INDEPENDENT - // Enable locale independent functions {strtof_l, strtod_l,strtoll_l, strtoull_l}. - #if ((defined(_MSC_VER) && _MSC_VER >= 1800) || \ - (defined(_XOPEN_VERSION) && (_XOPEN_VERSION>=700)) && (!defined(__ANDROID_API__) || (defined(__ANDROID_API__) && (__ANDROID_API__>=21)))) + // Enable locale independent functions {strtof_l, strtod_l,strtoll_l, + // strtoull_l}. + #if (defined(_MSC_VER) && _MSC_VER >= 1800) || \ + (defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \ + (defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \ + (!defined(__Fuchsia__) && !defined(__ANDROID_API__)) #define FLATBUFFERS_LOCALE_INDEPENDENT 1 #else #define FLATBUFFERS_LOCALE_INDEPENDENT 0 @@ -338,8 +341,17 @@ typedef uintmax_t largest_scalar_t; // In 32bits, this evaluates to 2GB - 1 #define FLATBUFFERS_MAX_BUFFER_SIZE ((1ULL << (sizeof(::flatbuffers::soffset_t) * 8 - 1)) - 1) +// The minimum size buffer that can be a valid flatbuffer. +// Includes the offset to the root table (uoffset_t), the offset to the vtable +// of the root table (soffset_t), the size of the vtable (uint16_t), and the +// size of the referring table (uint16_t). +#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(uoffset_t) + sizeof(soffset_t) + \ + sizeof(uint16_t) + sizeof(uint16_t) + // We support aligning the contents of buffers up to this size. -#define FLATBUFFERS_MAX_ALIGNMENT 16 +#ifndef FLATBUFFERS_MAX_ALIGNMENT + #define FLATBUFFERS_MAX_ALIGNMENT 32 +#endif /// @brief The length of a FlatBuffer file header. static const size_t kFileIdentifierLength = 4; diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flatbuffer_builder.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flatbuffer_builder.h index 8be4efbe..aa02f50d 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flatbuffer_builder.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flatbuffer_builder.h @@ -18,6 +18,7 @@ #define FLATBUFFERS_FLATBUFFER_BUILDER_H_ #include +#include #include "flatbuffers/allocator.h" #include "flatbuffers/array.h" @@ -42,14 +43,15 @@ inline voffset_t FieldIndexToOffset(voffset_t field_id) { return static_cast((field_id + fixed_fields) * sizeof(voffset_t)); } -template +template> const T *data(const std::vector &v) { // Eventually the returned pointer gets passed down to memcpy, so // we need it to be non-null to avoid undefined behavior. static uint8_t t; return v.empty() ? reinterpret_cast(&t) : &v.front(); } -template T *data(std::vector &v) { +template> +T *data(std::vector &v) { // Eventually the returned pointer gets passed down to memcpy, so // we need it to be non-null to avoid undefined behavior. static uint8_t t; @@ -285,9 +287,7 @@ class FlatBufferBuilder { FieldLoc fl = { off, field }; buf_.scratch_push_small(fl); num_field_loc++; - if (field > max_voffset_) { - max_voffset_ = field; - } + if (field > max_voffset_) { max_voffset_ = field; } } // Like PushElement, but additionally tracks the field this represents. @@ -443,6 +443,7 @@ class FlatBufferBuilder { // Aligns such that when "len" bytes are written, an object can be written // after it with "alignment" without padding. void PreAlign(size_t len, size_t alignment) { + if (len == 0) return; TrackMinAlign(alignment); buf_.fill(PaddingBytes(GetSize() + len, alignment)); } @@ -601,12 +602,14 @@ class FlatBufferBuilder { // This is useful when storing a nested_flatbuffer in a vector of bytes, // or when storing SIMD floats, etc. void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) { + if (len == 0) return; FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); PreAlign(len * elemsize, alignment); } // Similar to ForceVectorAlignment but for String fields. void ForceStringAlignment(size_t len, size_t alignment) { + if (len == 0) return; FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment)); PreAlign((len + 1) * sizeof(char), alignment); } @@ -642,6 +645,27 @@ class FlatBufferBuilder { return Offset>(EndVector(len)); } + /// @brief Serialize an array like object into a FlatBuffer `vector`. + /// @tparam T The data type of the array elements. + /// @tparam C The type of the array. + /// @param[in] array A reference to an array like object of type `T` to + /// serialize into the buffer as a `vector`. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template Offset> CreateVector(const C &array) { + return CreateVector(array.data(), array.size()); + } + + /// @brief Serialize an initializer list into a FlatBuffer `vector`. + /// @tparam T The data type of the initializer list elements. + /// @param[in] v The value of the initializer list. + /// @return Returns a typed `Offset` into the serialized data indicating + /// where the vector is stored. + template + Offset> CreateVector(std::initializer_list v) { + return CreateVector(v.begin(), v.size()); + } + template Offset>> CreateVector(const Offset *v, size_t len) { StartVector(len, sizeof(Offset)); @@ -655,7 +679,7 @@ class FlatBufferBuilder { /// buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template + template> Offset> CreateVector(const std::vector &v) { return CreateVector(data(v), v.size()); } @@ -706,15 +730,18 @@ class FlatBufferBuilder { return CreateVector(elems); } - /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. + /// @brief Serialize a `std::vector` into a FlatBuffer `vector`. + /// whereas StringType is any type that is accepted by the CreateString() + /// overloads. /// This is a convenience function for a common case. /// @param v A const reference to the `std::vector` to serialize into the /// buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template + template> Offset>> CreateVectorOfStrings( - const std::vector &v) { + const std::vector &v) { return CreateVectorOfStrings(v.cbegin(), v.cend()); } @@ -841,7 +868,7 @@ class FlatBufferBuilder { /// serialize into the buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template + template> Offset> CreateVectorOfStructs( const std::vector &v) { return CreateVectorOfStructs(data(v), v.size()); @@ -857,7 +884,7 @@ class FlatBufferBuilder { /// to the FlatBuffer struct. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template + template> Offset> CreateVectorOfNativeStructs( const std::vector &v, T (*const pack_func)(const S &)) { return CreateVectorOfNativeStructs(data(v), v.size(), pack_func); @@ -871,7 +898,7 @@ class FlatBufferBuilder { /// serialize into the buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template + template> Offset> CreateVectorOfNativeStructs( const std::vector &v) { return CreateVectorOfNativeStructs(data(v), v.size()); @@ -892,7 +919,7 @@ class FlatBufferBuilder { /// serialize into the buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template + template> Offset> CreateVectorOfSortedStructs( std::vector *v) { return CreateVectorOfSortedStructs(data(*v), v->size()); @@ -906,7 +933,7 @@ class FlatBufferBuilder { /// serialize into the buffer as a `vector`. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template + template> Offset> CreateVectorOfSortedNativeStructs( std::vector *v) { return CreateVectorOfSortedNativeStructs(data(*v), v->size()); @@ -922,7 +949,7 @@ class FlatBufferBuilder { /// where the vector is stored. template Offset> CreateVectorOfSortedStructs(T *v, size_t len) { - std::sort(v, v + len, StructKeyComparator()); + std::stable_sort(v, v + len, StructKeyComparator()); return CreateVectorOfStructs(v, len); } @@ -941,7 +968,7 @@ class FlatBufferBuilder { extern T Pack(const S &); auto structs = StartVectorOfStructs(len); for (size_t i = 0; i < len; i++) { structs[i] = Pack(v[i]); } - std::sort(structs, structs + len, StructKeyComparator()); + std::stable_sort(structs, structs + len, StructKeyComparator()); return EndVectorOfStructs(len); } @@ -973,7 +1000,7 @@ class FlatBufferBuilder { template Offset>> CreateVectorOfSortedTables(Offset *v, size_t len) { - std::sort(v, v + len, TableKeyComparator(buf_)); + std::stable_sort(v, v + len, TableKeyComparator(buf_)); return CreateVector(v, len); } @@ -984,7 +1011,7 @@ class FlatBufferBuilder { /// offsets to store in the buffer in sorted order. /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. - template + template> Offset>> CreateVectorOfSortedTables( std::vector, Alloc> *v) { return CreateVectorOfSortedTables(data(*v), v->size()); @@ -1074,7 +1101,7 @@ class FlatBufferBuilder { void SwapBufAllocator(FlatBufferBuilder &other) { buf_.swap_allocator(other.buf_); } - + /// @brief The length of a FlatBuffer file header. static const size_t kFileIdentifierLength = ::flatbuffers::kFileIdentifierLength; diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flatbuffers.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flatbuffers.h index c903d646..64217889 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flatbuffers.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flatbuffers.h @@ -226,27 +226,13 @@ struct TypeTable { }; // String which identifies the current version of FlatBuffers. -// flatbuffer_version_string is used by Google developers to identify which -// applications uploaded to Google Play are using this library. This allows -// the development team at Google to determine the popularity of the library. -// How it works: Applications that are uploaded to the Google Play Store are -// scanned for this version string. We track which applications are using it -// to measure popularity. You are free to remove it (of course) but we would -// appreciate if you left it in. +inline const char *flatbuffers_version_string() { + return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "." + FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "." + FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION); +} -// Weak linkage is culled by VS & doesn't work on cygwin. // clang-format off -#if !defined(_WIN32) && !defined(__CYGWIN__) - -extern volatile __attribute__((weak)) const char *flatbuffer_version_string; -volatile __attribute__((weak)) const char *flatbuffer_version_string = - "FlatBuffers " - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "." - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "." - FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION); - -#endif // !defined(_WIN32) && !defined(__CYGWIN__) - #define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\ inline E operator | (E lhs, E rhs){\ return E(T(lhs) | T(rhs));\ diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flexbuffers.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flexbuffers.h index a51fcc92..1a109bbd 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flexbuffers.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/flexbuffers.h @@ -156,6 +156,7 @@ inline uint64_t ReadUInt64(const uint8_t *data, uint8_t byte_width) { // TODO: GCC apparently replaces memcpy by a rep movsb, but only if count is a // constant, which here it isn't. Test if memcpy is still faster than // the conditionals in ReadSizedScalar. Can also use inline asm. + // clang-format off #if defined(_MSC_VER) && defined(_M_X64) && !defined(_M_ARM64EC) // This is 64-bit Windows only, __movsb does not work on 32-bit Windows. @@ -371,10 +372,7 @@ void AppendToString(std::string &s, T &&v, bool keys_quoted) { class Reference { public: Reference() - : data_(nullptr), - parent_width_(0), - byte_width_(0), - type_(FBT_NULL) {} + : data_(nullptr), parent_width_(0), byte_width_(0), type_(FBT_NULL) {} Reference(const uint8_t *data, uint8_t parent_width, uint8_t byte_width, Type type) @@ -590,7 +588,23 @@ class Reference { auto keys = m.Keys(); auto vals = m.Values(); for (size_t i = 0; i < keys.size(); i++) { - keys[i].ToString(true, keys_quoted, s); + bool kq = keys_quoted; + if (!kq) { + // FlexBuffers keys may contain arbitrary characters, only allow + // unquoted if it looks like an "identifier": + const char *p = keys[i].AsKey(); + if (!flatbuffers::is_alpha(*p) && *p != '_') { + kq = true; + } else { + while (*++p) { + if (!flatbuffers::is_alnum(*p) && *p != '_') { + kq = true; + break; + } + } + } + } + keys[i].ToString(true, kq, s); s += ": "; vals[i].ToString(true, keys_quoted, s); if (i < keys.size() - 1) s += ", "; @@ -1424,10 +1438,12 @@ class Builder FLATBUFFERS_FINAL_CLASS { template static Type GetScalarType() { static_assert(flatbuffers::is_scalar::value, "Unrelated types"); - return flatbuffers::is_floating_point::value ? FBT_FLOAT - : flatbuffers::is_same::value - ? FBT_BOOL - : (flatbuffers::is_unsigned::value ? FBT_UINT : FBT_INT); + return flatbuffers::is_floating_point::value + ? FBT_FLOAT + : flatbuffers::is_same::value + ? FBT_BOOL + : (flatbuffers::is_unsigned::value ? FBT_UINT + : FBT_INT); } public: @@ -1660,8 +1676,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS { // comes at the cost of using additional memory the same size of // the buffer being verified, so it is by default off. std::vector *reuse_tracker = nullptr, - bool _check_alignment = true, - size_t max_depth = 64) + bool _check_alignment = true, size_t max_depth = 64) : buf_(buf), size_(buf_len), depth_(0), @@ -1704,18 +1719,16 @@ class Verifier FLATBUFFERS_FINAL_CLASS { auto o = static_cast(p - buf_); return VerifyBefore(o, len); } - + bool VerifyByteWidth(size_t width) { return Check(width == 1 || width == 2 || width == 4 || width == 8); } - bool VerifyType(int type) { - return Check(type >= 0 && type < FBT_MAX_TYPE); - } + bool VerifyType(int type) { return Check(type >= 0 && type < FBT_MAX_TYPE); } bool VerifyOffset(uint64_t off, const uint8_t *p) { return Check(off <= static_cast(size_)) && - off <= static_cast(p - buf_); + off <= static_cast(p - buf_); } bool VerifyAlignment(const uint8_t *p, size_t size) const { @@ -1723,16 +1736,16 @@ class Verifier FLATBUFFERS_FINAL_CLASS { return Check((o & (size - 1)) == 0 || !check_alignment_); } - // Macro, since we want to escape from parent function & use lazy args. - #define FLEX_CHECK_VERIFIED(P, PACKED_TYPE) \ - if (reuse_tracker_) { \ - auto packed_type = PACKED_TYPE; \ - auto existing = (*reuse_tracker_)[P - buf_]; \ - if (existing == packed_type) return true; \ - /* Fail verification if already set with different type! */ \ - if (!Check(existing == 0)) return false; \ - (*reuse_tracker_)[P - buf_] = packed_type; \ - } +// Macro, since we want to escape from parent function & use lazy args. +#define FLEX_CHECK_VERIFIED(P, PACKED_TYPE) \ + if (reuse_tracker_) { \ + auto packed_type = PACKED_TYPE; \ + auto existing = (*reuse_tracker_)[P - buf_]; \ + if (existing == packed_type) return true; \ + /* Fail verification if already set with different type! */ \ + if (!Check(existing == 0)) return false; \ + (*reuse_tracker_)[P - buf_] = packed_type; \ + } bool VerifyVector(Reference r, const uint8_t *p, Type elem_type) { // Any kind of nesting goes thru this function, so guard against that @@ -1742,19 +1755,19 @@ class Verifier FLATBUFFERS_FINAL_CLASS { if (!Check(depth_ <= max_depth_ && num_vectors_ <= max_vectors_)) return false; auto size_byte_width = r.byte_width_; - FLEX_CHECK_VERIFIED(p, PackedType(Builder::WidthB(size_byte_width), r.type_)); - if (!VerifyBeforePointer(p, size_byte_width)) - return false; + if (!VerifyBeforePointer(p, size_byte_width)) return false; + FLEX_CHECK_VERIFIED(p - size_byte_width, + PackedType(Builder::WidthB(size_byte_width), r.type_)); auto sized = Sized(p, size_byte_width); auto num_elems = sized.size(); - auto elem_byte_width = - r.type_ == FBT_STRING || r.type_ == FBT_BLOB ? uint8_t(1) : r.byte_width_; + auto elem_byte_width = r.type_ == FBT_STRING || r.type_ == FBT_BLOB + ? uint8_t(1) + : r.byte_width_; auto max_elems = SIZE_MAX / elem_byte_width; if (!Check(num_elems < max_elems)) return false; // Protect against byte_size overflowing. auto byte_size = num_elems * elem_byte_width; - if (!VerifyFromPointer(p, byte_size)) - return false; + if (!VerifyFromPointer(p, byte_size)) return false; if (elem_type == FBT_NULL) { // Verify type bytes after the vector. if (!VerifyFromPointer(p + byte_size, num_elems)) return false; @@ -1775,28 +1788,25 @@ class Verifier FLATBUFFERS_FINAL_CLASS { bool VerifyKeys(const uint8_t *p, uint8_t byte_width) { // The vector part of the map has already been verified. const size_t num_prefixed_fields = 3; - if (!VerifyBeforePointer(p, byte_width * num_prefixed_fields)) - return false; + if (!VerifyBeforePointer(p, byte_width * num_prefixed_fields)) return false; p -= byte_width * num_prefixed_fields; auto off = ReadUInt64(p, byte_width); - if (!VerifyOffset(off, p)) - return false; + if (!VerifyOffset(off, p)) return false; auto key_byte_with = - static_cast(ReadUInt64(p + byte_width, byte_width)); - if (!VerifyByteWidth(key_byte_with)) - return false; + static_cast(ReadUInt64(p + byte_width, byte_width)); + if (!VerifyByteWidth(key_byte_with)) return false; return VerifyVector(Reference(p, byte_width, key_byte_with, FBT_VECTOR_KEY), p - off, FBT_KEY); } - bool VerifyKey(const uint8_t* p) { + bool VerifyKey(const uint8_t *p) { FLEX_CHECK_VERIFIED(p, PackedType(BIT_WIDTH_8, FBT_KEY)); while (p < buf_ + size_) if (*p++) return true; return false; } - #undef FLEX_CHECK_VERIFIED +#undef FLEX_CHECK_VERIFIED bool VerifyTerminator(const String &s) { return VerifyFromPointer(reinterpret_cast(s.c_str()), @@ -1814,37 +1824,26 @@ class Verifier FLATBUFFERS_FINAL_CLASS { } // All remaining types are an offset. auto off = ReadUInt64(r.data_, r.parent_width_); - if (!VerifyOffset(off, r.data_)) - return false; + if (!VerifyOffset(off, r.data_)) return false; auto p = r.Indirect(); - if (!VerifyAlignment(p, r.byte_width_)) - return false; + if (!VerifyAlignment(p, r.byte_width_)) return false; switch (r.type_) { case FBT_INDIRECT_INT: case FBT_INDIRECT_UINT: - case FBT_INDIRECT_FLOAT: - return VerifyFromPointer(p, r.byte_width_); - case FBT_KEY: - return VerifyKey(p); + case FBT_INDIRECT_FLOAT: return VerifyFromPointer(p, r.byte_width_); + case FBT_KEY: return VerifyKey(p); case FBT_MAP: - return VerifyVector(r, p, FBT_NULL) && - VerifyKeys(p, r.byte_width_); - case FBT_VECTOR: - return VerifyVector(r, p, FBT_NULL); - case FBT_VECTOR_INT: - return VerifyVector(r, p, FBT_INT); + return VerifyVector(r, p, FBT_NULL) && VerifyKeys(p, r.byte_width_); + case FBT_VECTOR: return VerifyVector(r, p, FBT_NULL); + case FBT_VECTOR_INT: return VerifyVector(r, p, FBT_INT); case FBT_VECTOR_BOOL: - case FBT_VECTOR_UINT: - return VerifyVector(r, p, FBT_UINT); - case FBT_VECTOR_FLOAT: - return VerifyVector(r, p, FBT_FLOAT); - case FBT_VECTOR_KEY: - return VerifyVector(r, p, FBT_KEY); + case FBT_VECTOR_UINT: return VerifyVector(r, p, FBT_UINT); + case FBT_VECTOR_FLOAT: return VerifyVector(r, p, FBT_FLOAT); + case FBT_VECTOR_KEY: return VerifyVector(r, p, FBT_KEY); case FBT_VECTOR_STRING_DEPRECATED: // Use of FBT_KEY here intentional, see elsewhere. return VerifyVector(r, p, FBT_KEY); - case FBT_BLOB: - return VerifyVector(r, p, FBT_UINT); + case FBT_BLOB: return VerifyVector(r, p, FBT_UINT); case FBT_STRING: return VerifyVector(r, p, FBT_UINT) && VerifyTerminator(String(p, r.byte_width_)); @@ -1859,12 +1858,10 @@ class Verifier FLATBUFFERS_FINAL_CLASS { case FBT_VECTOR_FLOAT4: { uint8_t len = 0; auto vtype = ToFixedTypedVectorElementType(r.type_, &len); - if (!VerifyType(vtype)) - return false; + if (!VerifyType(vtype)) return false; return VerifyFromPointer(p, r.byte_width_ * len); } - default: - return false; + default: return false; } } @@ -1874,8 +1871,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS { auto end = buf_ + size_; auto byte_width = *--end; auto packed_type = *--end; - return VerifyByteWidth(byte_width) && - Check(end - buf_ >= byte_width) && + return VerifyByteWidth(byte_width) && Check(end - buf_ >= byte_width) && VerifyRef(Reference(end - byte_width, byte_width, packed_type)); } @@ -1890,27 +1886,14 @@ class Verifier FLATBUFFERS_FINAL_CLASS { std::vector *reuse_tracker_; }; -// Utility function that contructs the Verifier for you, see above for parameters. +// Utility function that contructs the Verifier for you, see above for +// parameters. inline bool VerifyBuffer(const uint8_t *buf, size_t buf_len, std::vector *reuse_tracker = nullptr) { Verifier verifier(buf, buf_len, reuse_tracker); return verifier.VerifyBuffer(); } - -#ifdef FLATBUFFERS_H_ -// This is a verifier utility function that works together with the -// FlatBuffers verifier, which should only be present if flatbuffer.h -// has been included (which it typically is in generated code). -inline bool VerifyNestedFlexBuffer(const flatbuffers::Vector *nv, - flatbuffers::Verifier &verifier) { - if (!nv) return true; - return verifier.Check( - flexbuffers::VerifyBuffer(nv->data(), nv->size(), - verifier.GetFlexReuseTracker())); -} -#endif - } // namespace flexbuffers #if defined(_MSC_VER) diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/stl_emulation.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/stl_emulation.h index 75d13b29..97652b17 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/stl_emulation.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/stl_emulation.h @@ -26,16 +26,20 @@ #include #include -// Detect C++17 compatible compiler. -// __cplusplus >= 201703L - a compiler has support of 'static inline' variables. -#if defined(FLATBUFFERS_USE_STD_OPTIONAL) \ - || (defined(__cplusplus) && __cplusplus >= 201703L) \ - || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)) +#ifndef FLATBUFFERS_USE_STD_OPTIONAL + // Detect C++17 compatible compiler. + // __cplusplus >= 201703L - a compiler has support of 'static inline' variables. + #if (defined(__cplusplus) && __cplusplus >= 201703L) \ + || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) + #define FLATBUFFERS_USE_STD_OPTIONAL 1 + #else + #define FLATBUFFERS_USE_STD_OPTIONAL 0 + #endif // (defined(__cplusplus) && __cplusplus >= 201703L) ... +#endif // FLATBUFFERS_USE_STD_OPTIONAL + +#if FLATBUFFERS_USE_STD_OPTIONAL #include - #ifndef FLATBUFFERS_USE_STD_OPTIONAL - #define FLATBUFFERS_USE_STD_OPTIONAL - #endif -#endif // defined(FLATBUFFERS_USE_STD_OPTIONAL) ... +#endif // The __cpp_lib_span is the predefined feature macro. #if defined(FLATBUFFERS_USE_STD_SPAN) @@ -128,7 +132,7 @@ namespace flatbuffers { }; #endif // defined(FLATBUFFERS_TEMPLATES_ALIASES) -#ifdef FLATBUFFERS_USE_STD_OPTIONAL +#if FLATBUFFERS_USE_STD_OPTIONAL template using Optional = std::optional; using nullopt_t = std::nullopt_t; @@ -284,13 +288,13 @@ FLATBUFFERS_CONSTEXPR std::size_t dynamic_extent = static_cast(-1); namespace internal { // This is SFINAE helper class for checking of a common condition: // > This overload only participates in overload resolution - // > Check whether a pointer to an array of U can be converted - // > to a pointer to an array of E. - // This helper is used for checking of 'U -> const U'. - template + // > Check whether a pointer to an array of From can be converted + // > to a pointer to an array of To. + // This helper is used for checking of 'From -> const From'. + template struct is_span_convertable { using type = - typename std::conditional::value + typename std::conditional::value && (Extent == dynamic_extent || N == Extent), int, void>::type; }; @@ -362,13 +366,9 @@ class span FLATBUFFERS_FINAL_CLASS { #if !defined(FLATBUFFERS_SPAN_MINIMAL) using Iterator = internal::SpanIterator; - using ConstIterator = internal::SpanIterator; Iterator begin() const { return Iterator(data()); } Iterator end() const { return Iterator(data() + size()); } - - ConstIterator cbegin() const { return ConstIterator(data()); } - ConstIterator cend() const { return ConstIterator(data() + size()); } #endif // Returns a reference to the idx-th element of the sequence. @@ -462,45 +462,45 @@ class span FLATBUFFERS_FINAL_CLASS { private: // This is a naive implementation with 'count_' member even if (Extent != dynamic_extent). pointer const data_; - const size_type count_; + size_type count_; }; #endif // defined(FLATBUFFERS_USE_STD_SPAN) #if !defined(FLATBUFFERS_SPAN_MINIMAL) -template +template FLATBUFFERS_CONSTEXPR_CPP11 -flatbuffers::span make_span(U(&arr)[N]) FLATBUFFERS_NOEXCEPT { - return span(arr); +flatbuffers::span make_span(ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT { + return span(arr); } -template +template FLATBUFFERS_CONSTEXPR_CPP11 -flatbuffers::span make_span(const U(&arr)[N]) FLATBUFFERS_NOEXCEPT { - return span(arr); +flatbuffers::span make_span(const ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT { + return span(arr); } -template +template FLATBUFFERS_CONSTEXPR_CPP11 -flatbuffers::span make_span(std::array &arr) FLATBUFFERS_NOEXCEPT { - return span(arr); +flatbuffers::span make_span(std::array &arr) FLATBUFFERS_NOEXCEPT { + return span(arr); } -template +template FLATBUFFERS_CONSTEXPR_CPP11 -flatbuffers::span make_span(const std::array &arr) FLATBUFFERS_NOEXCEPT { - return span(arr); +flatbuffers::span make_span(const std::array &arr) FLATBUFFERS_NOEXCEPT { + return span(arr); } -template +template FLATBUFFERS_CONSTEXPR_CPP11 -flatbuffers::span make_span(U *first, std::size_t count) FLATBUFFERS_NOEXCEPT { - return span(first, count); +flatbuffers::span make_span(ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT { + return span(first, count); } -template +template FLATBUFFERS_CONSTEXPR_CPP11 -flatbuffers::span make_span(const U *first, std::size_t count) FLATBUFFERS_NOEXCEPT { - return span(first, count); +flatbuffers::span make_span(const ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT { + return span(first, count); } #endif // !defined(FLATBUFFERS_SPAN_MINIMAL) diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/table.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/table.h index 42470693..11b29247 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/table.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/table.h @@ -112,20 +112,22 @@ class Table { // Verify a particular field. template - bool VerifyField(const Verifier &verifier, voffset_t field) const { + bool VerifyField(const Verifier &verifier, voffset_t field, + size_t align) const { // Calling GetOptionalFieldOffset should be safe now thanks to // VerifyTable(). auto field_offset = GetOptionalFieldOffset(field); // Check the actual field. - return !field_offset || verifier.Verify(data_, field_offset); + return !field_offset || verifier.VerifyField(data_, field_offset, align); } // VerifyField for required fields. template - bool VerifyFieldRequired(const Verifier &verifier, voffset_t field) const { + bool VerifyFieldRequired(const Verifier &verifier, voffset_t field, + size_t align) const { auto field_offset = GetOptionalFieldOffset(field); return verifier.Check(field_offset != 0) && - verifier.Verify(data_, field_offset); + verifier.VerifyField(data_, field_offset, align); } // Versions for offsets. @@ -163,4 +165,4 @@ inline flatbuffers::Optional Table::GetOptional( } // namespace flatbuffers -#endif // FLATBUFFERS_TABLE_H_ \ No newline at end of file +#endif // FLATBUFFERS_TABLE_H_ diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/util.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/util.h index e0392a95..5a4bfe52 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/util.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/util.h @@ -17,8 +17,8 @@ #ifndef FLATBUFFERS_UTIL_H_ #define FLATBUFFERS_UTIL_H_ -#include #include +#include #include "flatbuffers/base.h" #include "flatbuffers/stl_emulation.h" @@ -30,8 +30,8 @@ #endif #ifndef FLATBUFFERS_PREFER_PRINTF -# include # include +# include #else // FLATBUFFERS_PREFER_PRINTF # include # include @@ -454,6 +454,9 @@ std::string StripPath(const std::string &filepath); // Strip the last component of the path + separator. std::string StripFileName(const std::string &filepath); +std::string StripPrefix(const std::string &filepath, + const std::string &prefix_to_remove); + // Concatenates a path with a filename, regardless of whether the path // ends in a separator or not. std::string ConCatPathFileName(const std::string &path, @@ -691,6 +694,32 @@ bool ReadEnvironmentVariable(const char *var_name, // MSVC specific: Send all assert reports to STDOUT to prevent CI hangs. void SetupDefaultCRTReportMode(); +enum class Case { + kUnknown = 0, + // TheQuickBrownFox + kUpperCamel = 1, + // theQuickBrownFox + kLowerCamel = 2, + // the_quick_brown_fox + kSnake = 3, + // THE_QUICK_BROWN_FOX + kScreamingSnake = 4, + // THEQUICKBROWNFOX + kAllUpper = 5, + // thequickbrownfox + kAllLower = 6, + // the-quick-brown-fox + kDasher = 7, + // THEQuiCKBr_ownFox (or whatever you want, we won't change it) + kKeep = 8, + // the_quick_brown_fox123 (as opposed to the_quick_brown_fox_123) + kSnake2 = 9, +}; + +// Convert the `input` string of case `input_case` to the specified `output_case`. +std::string ConvertCase(const std::string &input, Case output_case, + Case input_case = Case::kSnake); + } // namespace flatbuffers #endif // FLATBUFFERS_UTIL_H_ diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/vector.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/vector.h index f8a5d88e..6bcdfe26 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/vector.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/vector.h @@ -19,6 +19,7 @@ #include "flatbuffers/base.h" #include "flatbuffers/buffer.h" +#include "flatbuffers/stl_emulation.h" namespace flatbuffers { @@ -326,6 +327,24 @@ FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_bytes_span( return span(vec.Data(), vec.size() * sizeof(U)); } +// Convenient helper functions to get a span of any vector, regardless +// of whether it is null or not (the field is not set). +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_span(Vector *ptr) + FLATBUFFERS_NOEXCEPT { + static_assert(Vector::is_span_observable, + "wrong type U, only LE-scalar, or byte types are allowed"); + return ptr ? make_span(*ptr) : span(); +} + +template +FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span make_span( + const Vector *ptr) FLATBUFFERS_NOEXCEPT { + static_assert(Vector::is_span_observable, + "wrong type U, only LE-scalar, or byte types are allowed"); + return ptr ? make_span(*ptr) : span(); +} + // Represent a vector much like the template above, but in this case we // don't know what the element types are (used with reflection.h). class VectorOfAny { diff --git a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/verifier.h b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/verifier.h index dfa3da8a..0241223e 100644 --- a/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/verifier.h +++ b/code/components/tflite-lib/third_party/flatbuffers/include/flatbuffers/verifier.h @@ -18,7 +18,6 @@ #define FLATBUFFERS_VERIFIER_H_ #include "flatbuffers/base.h" -#include "flatbuffers/util.h" #include "flatbuffers/vector.h" namespace flatbuffers { @@ -26,22 +25,24 @@ namespace flatbuffers { // Helper class to verify the integrity of a FlatBuffer class Verifier FLATBUFFERS_FINAL_CLASS { public: - Verifier(const uint8_t *buf, size_t buf_len, uoffset_t _max_depth = 64, - uoffset_t _max_tables = 1000000, bool _check_alignment = true) + Verifier(const uint8_t *const buf, const size_t buf_len, + const uoffset_t _max_depth = 64, + const uoffset_t _max_tables = 1000000, + const bool _check_alignment = true) : buf_(buf), size_(buf_len), - depth_(0), max_depth_(_max_depth), - num_tables_(0), max_tables_(_max_tables), - upper_bound_(0), check_alignment_(_check_alignment), + upper_bound_(0), + depth_(0), + num_tables_(0), flex_reuse_tracker_(nullptr) { FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE); } // Central location where any verification failures register. - bool Check(bool ok) const { + bool Check(const bool ok) const { // clang-format off #ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE FLATBUFFERS_ASSERT(ok); @@ -55,7 +56,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS { } // Verify any range within the buffer. - bool Verify(size_t elem, size_t elem_len) const { + bool Verify(const size_t elem, const size_t elem_len) const { // clang-format off #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE auto upper_bound = elem + elem_len; @@ -66,48 +67,52 @@ class Verifier FLATBUFFERS_FINAL_CLASS { return Check(elem_len < size_ && elem <= size_ - elem_len); } - template bool VerifyAlignment(size_t elem) const { - return Check((elem & (sizeof(T) - 1)) == 0 || !check_alignment_); + bool VerifyAlignment(const size_t elem, const size_t align) const { + return Check((elem & (align - 1)) == 0 || !check_alignment_); } // Verify a range indicated by sizeof(T). - template bool Verify(size_t elem) const { - return VerifyAlignment(elem) && Verify(elem, sizeof(T)); + template bool Verify(const size_t elem) const { + return VerifyAlignment(elem, sizeof(T)) && Verify(elem, sizeof(T)); } - bool VerifyFromPointer(const uint8_t *p, size_t len) { - auto o = static_cast(p - buf_); - return Verify(o, len); + bool VerifyFromPointer(const uint8_t *const p, const size_t len) { + return Verify(static_cast(p - buf_), len); } // Verify relative to a known-good base pointer. - bool Verify(const uint8_t *base, voffset_t elem_off, size_t elem_len) const { - return Verify(static_cast(base - buf_) + elem_off, elem_len); + bool VerifyFieldStruct(const uint8_t *const base, const voffset_t elem_off, + const size_t elem_len, const size_t align) const { + const auto f = static_cast(base - buf_) + elem_off; + return VerifyAlignment(f, align) && Verify(f, elem_len); } template - bool Verify(const uint8_t *base, voffset_t elem_off) const { - return Verify(static_cast(base - buf_) + elem_off, sizeof(T)); + bool VerifyField(const uint8_t *const base, const voffset_t elem_off, + const size_t align) const { + const auto f = static_cast(base - buf_) + elem_off; + return VerifyAlignment(f, align) && Verify(f, sizeof(T)); } // Verify a pointer (may be NULL) of a table type. - template bool VerifyTable(const T *table) { + template bool VerifyTable(const T *const table) { return !table || table->Verify(*this); } // Verify a pointer (may be NULL) of any vector type. - template bool VerifyVector(const Vector *vec) const { + template bool VerifyVector(const Vector *const vec) const { return !vec || VerifyVectorOrString(reinterpret_cast(vec), sizeof(T)); } // Verify a pointer (may be NULL) of a vector to struct. - template bool VerifyVector(const Vector *vec) const { + template + bool VerifyVector(const Vector *const vec) const { return VerifyVector(reinterpret_cast *>(vec)); } // Verify a pointer (may be NULL) to string. - bool VerifyString(const String *str) const { + bool VerifyString(const String *const str) const { size_t end; return !str || (VerifyVectorOrString(reinterpret_cast(str), 1, &end) && @@ -116,24 +121,24 @@ class Verifier FLATBUFFERS_FINAL_CLASS { } // Common code between vectors and strings. - bool VerifyVectorOrString(const uint8_t *vec, size_t elem_size, - size_t *end = nullptr) const { - auto veco = static_cast(vec - buf_); + bool VerifyVectorOrString(const uint8_t *const vec, const size_t elem_size, + size_t *const end = nullptr) const { + const auto veco = static_cast(vec - buf_); // Check we can read the size field. if (!Verify(veco)) return false; // Check the whole array. If this is a string, the byte past the array // must be 0. - auto size = ReadScalar(vec); - auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size; + const auto size = ReadScalar(vec); + const auto max_elems = FLATBUFFERS_MAX_BUFFER_SIZE / elem_size; if (!Check(size < max_elems)) return false; // Protect against byte_size overflowing. - auto byte_size = sizeof(size) + elem_size * size; + const auto byte_size = sizeof(size) + elem_size * size; if (end) *end = veco + byte_size; return Verify(veco, byte_size); } // Special case for string contents, after the above has been called. - bool VerifyVectorOfStrings(const Vector> *vec) const { + bool VerifyVectorOfStrings(const Vector> *const vec) const { if (vec) { for (uoffset_t i = 0; i < vec->size(); i++) { if (!VerifyString(vec->Get(i))) return false; @@ -143,7 +148,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS { } // Special case for table contents, after the above has been called. - template bool VerifyVectorOfTables(const Vector> *vec) { + template + bool VerifyVectorOfTables(const Vector> *const vec) { if (vec) { for (uoffset_t i = 0; i < vec->size(); i++) { if (!vec->Get(i)->Verify(*this)) return false; @@ -153,29 +159,40 @@ class Verifier FLATBUFFERS_FINAL_CLASS { } __supress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart( - const uint8_t *table) { + const uint8_t *const table) { // Check the vtable offset. - auto tableo = static_cast(table - buf_); + const auto tableo = static_cast(table - buf_); if (!Verify(tableo)) return false; // This offset may be signed, but doing the subtraction unsigned always // gives the result we want. - auto vtableo = tableo - static_cast(ReadScalar(table)); + const auto vtableo = + tableo - static_cast(ReadScalar(table)); // Check the vtable size field, then check vtable fits in its entirety. - return VerifyComplexity() && Verify(vtableo) && - VerifyAlignment(ReadScalar(buf_ + vtableo)) && - Verify(vtableo, ReadScalar(buf_ + vtableo)); + if (!(VerifyComplexity() && Verify(vtableo) && + VerifyAlignment(ReadScalar(buf_ + vtableo), + sizeof(voffset_t)))) + return false; + const auto vsize = ReadScalar(buf_ + vtableo); + return Check((vsize & 1) == 0) && Verify(vtableo, vsize); } template - bool VerifyBufferFromStart(const char *identifier, size_t start) { + bool VerifyBufferFromStart(const char *const identifier, const size_t start) { + // Buffers have to be of some size to be valid. The reason it is a runtime + // check instead of static_assert, is that nested flatbuffers go through + // this call and their size is determined at runtime. + if (!Check(size_ >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false; + + // If an identifier is provided, check that we have a buffer if (identifier && !Check((size_ >= 2 * sizeof(flatbuffers::uoffset_t) && BufferHasIdentifier(buf_ + start, identifier)))) { return false; } // Call T::Verify, which must be in the generated code for this type. - auto o = VerifyOffset(start); - return o && reinterpret_cast(buf_ + start + o)->Verify(*this) + const auto o = VerifyOffset(start); + return Check(o != 0) && + reinterpret_cast(buf_ + start + o)->Verify(*this) // clang-format off #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE && GetComputedSize() @@ -185,9 +202,14 @@ class Verifier FLATBUFFERS_FINAL_CLASS { } template - bool VerifyNestedFlatBuffer(const Vector *buf, - const char *identifier) { + bool VerifyNestedFlatBuffer(const Vector *const buf, + const char *const identifier) { + // An empty buffer is OK as it indicates not present. if (!buf) return true; + + // If there is a nested buffer, it must be greater than the min size. + if(!Check(buf->size() >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false; + Verifier nested_verifier(buf->data(), buf->size()); return nested_verifier.VerifyBuffer(identifier); } @@ -195,19 +217,20 @@ class Verifier FLATBUFFERS_FINAL_CLASS { // Verify this whole buffer, starting with root type T. template bool VerifyBuffer() { return VerifyBuffer(nullptr); } - template bool VerifyBuffer(const char *identifier) { + template bool VerifyBuffer(const char *const identifier) { return VerifyBufferFromStart(identifier, 0); } - template bool VerifySizePrefixedBuffer(const char *identifier) { + template + bool VerifySizePrefixedBuffer(const char *const identifier) { return Verify(0U) && - ReadScalar(buf_) == size_ - sizeof(uoffset_t) && + Check(ReadScalar(buf_) == size_ - sizeof(uoffset_t)) && VerifyBufferFromStart(identifier, sizeof(uoffset_t)); } - uoffset_t VerifyOffset(size_t start) const { + uoffset_t VerifyOffset(const size_t start) const { if (!Verify(start)) return 0; - auto o = ReadScalar(buf_ + start); + const auto o = ReadScalar(buf_ + start); // May not point to itself. if (!Check(o != 0)) return 0; // Can't wrap around / buffers are max 2GB. @@ -218,7 +241,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS { return o; } - uoffset_t VerifyOffset(const uint8_t *base, voffset_t start) const { + uoffset_t VerifyOffset(const uint8_t *const base, + const voffset_t start) const { return VerifyOffset(static_cast(base - buf_) + start); } @@ -255,23 +279,23 @@ class Verifier FLATBUFFERS_FINAL_CLASS { // clang-format on } - std::vector *GetFlexReuseTracker() { - return flex_reuse_tracker_; - } + std::vector *GetFlexReuseTracker() { return flex_reuse_tracker_; } - void SetFlexReuseTracker(std::vector *rt) { + void SetFlexReuseTracker(std::vector *const rt) { flex_reuse_tracker_ = rt; } private: const uint8_t *buf_; - size_t size_; - uoffset_t depth_; - uoffset_t max_depth_; - uoffset_t num_tables_; - uoffset_t max_tables_; + const size_t size_; + const uoffset_t max_depth_; + const uoffset_t max_tables_; + const bool check_alignment_; + mutable size_t upper_bound_; - bool check_alignment_; + + uoffset_t depth_; + uoffset_t num_tables_; std::vector *flex_reuse_tracker_; }; diff --git a/code/components/tflite-lib_20220924.zip b/code/components/tflite-lib_20220924.zip new file mode 100644 index 00000000..06592987 Binary files /dev/null and b/code/components/tflite-lib_20220924.zip differ diff --git a/code/sdkconfig.esp32cam b/code/sdkconfig.esp32cam index 5510ad43..99f689a4 100644 --- a/code/sdkconfig.esp32cam +++ b/code/sdkconfig.esp32cam @@ -1233,9 +1233,13 @@ CONFIG_OV2640_SUPPORT=y # CONFIG_GC032A_SUPPORT is not set # CONFIG_GC0308_SUPPORT is not set # CONFIG_BF3005_SUPPORT is not set +CONFIG_BF20A6_SUPPORT=y +# CONFIG_SC101IOT_SUPPORT is not set +CONFIG_SC030IOT_SUPPORT=y # CONFIG_SCCB_HARDWARE_I2C_PORT0 is not set CONFIG_SCCB_HARDWARE_I2C_PORT1=y CONFIG_SCCB_CLK_FREQ=100000 +CONFIG_CAMERA_TASK_STACK_SIZE=2048 CONFIG_CAMERA_CORE0=y # CONFIG_CAMERA_CORE1 is not set # CONFIG_CAMERA_NO_AFFINITY is not set