Verified Commit a051757b authored by Vincent Coubard's avatar Vincent Coubard
Browse files

Version 0.7:


- README improvements:
  * Add link to external source code
  * Add link to application README
  * Explain how to stop the AMI
  * Various clarifications
- CLI improvement: Add a centralized ats.sh script that is used to
bootstrap, build and run.
- Fix warnings
- Fix Keil MDK project.
Signed-off-by: Vincent Coubard's avatarVincent Coubard <vincent.coubard@arm.com>
parent c65d6797
......@@ -17,6 +17,7 @@ cmake_build*/
*.pyc
Objects/
RTE/
downloads
# TF-Fuzz build artifacts
*.o
......
......@@ -8,13 +8,13 @@ This repo contains Arm's first [IoT Total Solution](https://www.arm.com/solution
The software supports multiple configurations of the Arm Corstone™-300 subsystem, incorporating the Cortex-M55 processor and Arm Ethos™-U55 microNPU. This total solution provides the complex, non differentiated secure platform software on behalf of the ecosystem, thus enabling you to focus on your next killer app.
This repo also supports a GitHub runner CI/CD workflow right out of the box which leverages [Arm Virtual Hardware](https://www.arm.com/virtual-hardware), a simulation environment that enables software development without the need of physical SoCs. The source code in this repo supports several configurations of the software, all of which are AWS IoT Core (OTA, etc.) enabled right out of the box. Instructions for using non-default configurations are coming soon!
This repo also supports a GitHub runner CI/CD workflow right out of the box which leverages [Arm Virtual Hardware](https://www.arm.com/virtual-hardware), a simulation environment that enables software development without the need of physical SoCs.
## Keyword detection application
The keyword detection application runs the DS-CNN model on top of [AWS FreeRTOS](https://docs.aws.amazon.com/freertos/). It detects keywords and inform the user of which keyword has been spotted. The audio data to process are injected at run time using the [Arm Virtual Hardware](https://www.arm.com/virtual-hardware) audio driver.
The Keyword application connects to [AWS IoT](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html) cloud to publish recognised keywords. AWS IoT cloud is also used for OTA firmware updates. These firmware updates are securely applied using [Trusted Firmware-M](https://tf-m-user-guide.trustedfirmware.org/).
The Keyword application connects to [AWS IoT](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html) cloud to publish recognised keywords. AWS IoT cloud is also used for OTA firmware updates. These firmware updates are securely applied using [Trusted Firmware-M](https://tf-m-user-guide.trustedfirmware.org/). For more information, refer to the keyword detection [Readme](./kws/README.md).
![Key word detection architecture overview](./resources/Keyword-detection-overview.png)
......@@ -111,7 +111,7 @@ git clone https://github.com/ARM-software/ATS-Keyword && cd ATS-Keyword
Synchronize git submodules, setup ML and apply required patches:
```sh
./bootstrap.sh
./ats.sh bootstrap
```
Install additional python dependencies required to run tests and sign binaries:
......@@ -123,12 +123,12 @@ pip3 install click imgtool pytest
Build the kws application:
```sh
./build.sh kws
./ats.sh build kws
```
Run the kws application:
```sh
./run.sh kws
./ats.sh run kws
```
Launch the kws integration tests:
......@@ -174,7 +174,7 @@ rm -rf ATS-Keyword
To utilize the Arm Virtual Hardware, you will need to create an AWS Account if you don’t already have one.
```sh
./scripts/vht_cli.py -k <key pair name> start
./scripts/vht_cli.py -k <key pair> start
```
3. Launch GitHub Self-Hosted Runner
......@@ -308,6 +308,19 @@ Upon completion of the build and sign process the signature string will be echoe
17. Click next
18. Click next, your update job is ready and running - next time your application connects it will perform the update.
# Terminating AMI Instance at the end of the day
## Stopping the instance in EC2 [(AWS on getting started)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html)
1. Go to [EC2](https://console.aws.amazon.com/ec2/v2/) in the AWS Web Console.
2. Select the instance to stop.
3. Click on `Instance state` and select `Stop Instance` in the drop down menu.
## Stopping the instance using a local terminal
```sh
./scripts/vht_cli.py -k MyKeyPair stop
```
# Source code overview
- `bsp`: Arm Corstone™-300 subsystem platform code and AWS configurations.
......@@ -354,6 +367,12 @@ Pre-integrated source code is available from the `ML Embedded Eval Kit` and can
Integrating a new model means integrating its source code and requires update of the build files.
# ML Embedded Eval Kit
The Arm ML Embedded Evaluation Kit , is an open-source repository enabling users to quickly build and deploy embedded machine learning applications for Arm Cortex-M55 CPU and Arm Ethos-U55 NPU.
With ML Eval Kit you can run inferences on either a custom neural network on Ethos-U microNPU or using availble ML applications such as [Image classification](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit/+/c930ad9dc189d831ac77f716df288f70178d4c10/docs/use_cases/img_class.md), [Keyword spotting (KWS)](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit/+/c930ad9dc189d831ac77f716df288f70178d4c10/docs/use_cases/kws.md), [Automated Speech Recognition (ASR)](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit/+/c930ad9dc189d831ac77f716df288f70178d4c10/docs/use_cases/asr.md), [Anomaly Detection](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit/+/c930ad9dc189d831ac77f716df288f70178d4c10/docs/use_cases/ad.md), and [Person Detection](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit/+/HEAD/docs/use_cases/visual_wake_word.md) all using Arm Fixed Virtual Platform (FVP) available in Arm Virtual Hardware.
# Known limitations
- Arm compiler 6 is the only compiler supported.
......@@ -374,13 +393,19 @@ Integrating a new model means integrating its source code and requires update of
| [Arm IoT Ecosystem Catalog](https://www.arm.com/why-arm/partner-ecosystem/iot-ecosystem-catalog) | Explore Arm IoT Ecosystem partners who can help transform an idea into a secure, market-leading device. |
| [Arm ML Model Zoo](https://github.com/ARM-software/ML-zoo) | A collection of machine learning models optimized for Arm IP. |
| [Arm Virtual Hardware Documentation](https://mdk-packs.github.io/VHT-TFLmicrospeech/overview/html/index.html) | Documentation for [Arm Virtual Hardware](https://www.arm.com/products/development-tools/simulation/virtual-hardware) |
| [AWS FreeRTOS](https://docs.aws.amazon.com/freertos/) | Documentation for AWS FreeRTOS. |
| [Arm Virtual Hardware source code](https://github.com/ARM-software/VHT) | Source code of[Arm Virtual Hardware](https://www.arm.com/products/development-tools/simulation/virtual-hardware) |
| [AWS FreeRTOS Documentation](https://docs.aws.amazon.com/freertos/) | Documentation for AWS FreeRTOS. |
| [AWS FreeRTOS source code](https://github.com/aws/amazon-freertos) | Source code of AWS FreeRTOS. |
| [AWS IoT](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html) | Documentation for AWS IoT. |
| [Trusted Firmware-M](https://tf-m-user-guide.trustedfirmware.org/) | Documentation for Trusted Firmware-M |
| [Trusted Firmware-M Documentation](https://tf-m-user-guide.trustedfirmware.org/) | Documentation for Trusted Firmware-M. |
| [Trusted Firmware-M Source code](https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git) | Source code of Trusted Firmware-M. |
| [Mbed Crypto](https://github.com/ARMmbed/mbedtls) | Mbed Crypto source code. |
| [MCU Boot](https://github.com/mcu-tools/mcuboot) | MCU Boot source code. |
| [ml-embedded-evaluation-kit](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit) | ML Embedded eval kit source code |
| Support | A [community.arm.com](http://community.arm.com/) forum exists for users to post queries. INTERNAL NOTE → they have – already set up on the test environment (link). This will be moved to the live environment on 19th October. |
# License and contributions
The software is provided under the Apache-2.0 license. All contributions to software and documents are licensed by contributors under the same license model as the software/document itself (ie. inbound == outbound licensing). ATS-Keyword may reuse software already licensed under another license, provided the license is permissive in nature and compatible with Apache v2.0.
Folders containing files under different permissive license than Apache 2.0 are listed in the LICENSE file.
\ No newline at end of file
Folders containing files under different permissive license than Apache 2.0 are listed in the LICENSE file.
#!/bin/bash
# Copyright (c) 2021 Arm Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# 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.
NAME="$(basename "$0")"
HERE="$(dirname "$0")"
SCRIPTS="$HERE/scripts"
function show_usage {
cat <<EOF
Usage: $0 <command> [command options]
Commands:
help Show this help
bootstrap,bs Bootstrap repository
build,b <example> Build <example>
run,r <example> Run example
build-n-run,br <example> Build and run example
pack,p Create CMSIS pack
EOF
}
function _assert {
if [[ ! $1 =~ $2 ]]; then
show_usage >&2
echo >&2
echo >&2 "Bad value \"$1\""
exit 1
fi
}
case "$1" in
-h|-help|--help|help)
show_usage
exit 0
;;
bootstrap|bs)
"$SCRIPTS/bootstrap.sh"
;;
build|b)
_assert "$2" "blinky|kws"
"$SCRIPTS/build.sh" "$2"
;;
run|r)
_assert "$2" "blinky|kws"
"$SCRIPTS/run.sh" "$2"
;;
build-n-run|br)
_assert "$2" "blinky|kws"
"$SCRIPTS/build.sh" "$2" && "$SCRIPTS/run.sh" "$2"
;;
pack|p)
"$SCRIPTS/make_cmsis_pack.sh"
;;
*)
show_usage >&2
exit 1
;;
esac
......@@ -15,6 +15,7 @@
*/
#include "FreeRTOS.h"
#include "stdio.h"
#include "task.h"
void vApplicationStackOverflowHook( TaskHandle_t xTask, char * pcTaskName )
......
......@@ -217,6 +217,9 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define democonfigNETWORK_TYPES ( AWSIOT_NETWORK_TYPE_ETH )
#define democonfigDEMO_PRIORITY ( configMAX_PRIORITIES-2 )
#define democonfigDEMO_STACKSIZE ( configMINIMAL_STACK_SIZE*2 )
#endif /* FREERTOS_CONFIG_H */
\ No newline at end of file
#ifndef democonfigDEMO_STACKSIZE
# define democonfigDEMO_STACKSIZE ( configMINIMAL_STACK_SIZE*8 )
#endif
#endif /* FREERTOS_CONFIG_H */
......@@ -24,8 +24,9 @@
*/
/* Default configuration for all demos. Individual demos can override these below */
#define democonfigDEMO_STACKSIZE ( configMINIMAL_STACK_SIZE * 8 )
#ifndef democonfigDEMO_STACKSIZE
# define democonfigDEMO_STACKSIZE ( configMINIMAL_STACK_SIZE * 8 )
#endif
#define democonfigNETWORK_TYPES ( AWSIOT_NETWORK_TYPE_ETH )
......
......@@ -40,8 +40,10 @@
* - IOT_LOG_NONE if neither IOT_LOG_LEVEL_DEMO nor IOT_LOG_LEVEL_GLOBAL are defined.
*/
#ifdef IOT_LOG_LEVEL_DEMO
#undef LIBRARY_LOG_LEVEL
#define LIBRARY_LOG_LEVEL IOT_LOG_LEVEL_DEMO
#else
#undef LIBRARY_LOG_LEVEL
#ifdef IOT_LOG_LEVEL_GLOBAL
#define LIBRARY_LOG_LEVEL IOT_LOG_LEVEL_GLOBAL
#else
......
......@@ -48,7 +48,6 @@
#ifndef LIBRARY_LOG_LEVEL
#define LIBRARY_LOG_LEVEL LOG_DEBUG
#endif
#define LIBRARY_LOG_LEVEL LOG_DEBUG
#include "logging_stack.h"
/************ End of logging configuration ****************/
......
......@@ -72,6 +72,7 @@
* bytes are read from network interface. Keeping this timeout to a sufficiently
* large value so as to account for delay of receipt of a large block of message.
*/
#undef MQTT_RECV_POLLING_TIMEOUT_MS /* Override the one from "core_mqtt_config_defaults.h" */
#define MQTT_RECV_POLLING_TIMEOUT_MS ( 1000U ) /* TODO Set a timeout in msecs for data received from MQTT. Recommend values > 1 s. */
/**
......@@ -92,6 +93,7 @@
* responsiveness of MQTT agent while processing pending MQTT operations as
* well as receive packets from network.
*/
#undef MQTT_AGENT_MAX_EVENT_QUEUE_WAIT_TIME /* Override the one from "core_mqtt_config_defaults.h" */
#define MQTT_AGENT_MAX_EVENT_QUEUE_WAIT_TIME ( 1U ) /* TODO */
#endif /* OTA_DEMO_CONFIG_H_ */
......@@ -81,8 +81,7 @@ BaseType_t xNetworkInterfaceInitialise( void )
//smsc9220_read_mac_address(&ETH_DEV, MACaddr);
read_MACaddr(MACaddr);
printf("%x %x %x %x %x %x %x %x ", MACaddr[0], MACaddr[1], MACaddr[2], MACaddr[3],
MACaddr[4], MACaddr[5], MACaddr[6], MACaddr[7] );
printf("%x %x %x %x %x %x", MACaddr[0], MACaddr[1], MACaddr[2], MACaddr[3], MACaddr[4], MACaddr[5]);
FreeRTOS_UpdateMACAddress((const uint8_t *)MACaddr);
xRXSemaphore = xSemaphoreCreateMutex();
......@@ -155,8 +154,6 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript
static void smsc9220_Receive_task( void *pvParameters )
{
FreeRTOS_debug_printf(("smsc9220 ethernet receive task created\r\n"));
uint32_t message_length = 0;
uint32_t received_bytes = 0;
NetworkBufferDescriptor_t *pxBufferDescriptor;
/* Used to indicate that xSendEventStructToIPTask() is being called because
of an Ethernet receive event. */
......@@ -201,7 +198,7 @@ static void smsc9220_Receive_task( void *pvParameters )
//received_bytes = smsc9220_receive_by_chunks(&ETH_DEV, pxBufferDescriptor->pucEthernetBuffer, message_length);
//pxBufferDescriptor->xDataLength = received_bytes;
if (!LAN91_receive_frame(pxBufferDescriptor->pucEthernetBuffer, &pxBufferDescriptor->xDataLength)) {
if (!LAN91_receive_frame((uint32_t*)pxBufferDescriptor->pucEthernetBuffer, &pxBufferDescriptor->xDataLength)) {
FreeRTOS_debug_printf(("Receive error!\r\n"));
}
......
......@@ -15,6 +15,7 @@
*/
#include "stdio.h"
#include <string.h>
#include "serial.h"
#include "print_log.h"
......
......@@ -22,6 +22,12 @@
static lan91_handle_t lan91c111_handle;
/** @brief Write a data value to PHY register. */
static void write_PHY(uint32_t PhyReg, int Value);
/** @brief Read a PHY register. */
static uint16_t read_PHY(uint32_t PhyReg);
void LAN91_init(void)
{
......
......@@ -319,18 +319,6 @@ void ETHERNET_Handler(void);
/** @brief Check Ethernet controller link status. */
lan91_phy_status_t LAN91_GetLinkStatus(void);
/** @brief Output a bit value to the MII PHY management interface. */
static void output_MDO(int bit_value);
/** @brief Input a bit value from the MII PHY management interface. */
static int input_MDI(void);
/** @brief Write a data value to PHY register. */
static void write_PHY(uint32_t PhyReg, int Value);
/** @brief Read a PHY register. */
static uint16_t read_PHY(uint32_t PhyReg);
/*******************************************************************************
* inline functions
......
......@@ -18,6 +18,7 @@
set -xe
HERE="$(dirname "$0")"
ROOT="$(realpath $HERE/..)"
$HERE/../build.sh blinky
$HERE/../build.sh kws
$ROOT/ats.sh build blinky
$ROOT/ats.sh build kws
......@@ -1883,9 +1883,6 @@ static BaseType_t prvRunOTADemo( void )
/* OTA interface context required for library interface functions.*/
OtaInterfaces_t xOtaInterfaces;
/* OTA library packet statistics per job.*/
OtaAgentStatistics_t xOtaStatistics = { 0 };
/* OTA Agent state returned from calling OTA_GetState.*/
OtaState_t xOtaState = OtaAgentStateStopped;
......
......@@ -54,40 +54,6 @@ struct Buffer
size_t alloc;
};
static RetType write_to_buffer(void *cookie, const char *data, LenType len)
{
struct Buffer *b = (struct Buffer *)cookie;
char *ptr = *b->ptr;
size_t newsize;
errno = EFBIG;
if (unlikely(add_check_overflow(*b->len, len, &newsize)))
return -1;
if (newsize >= b->alloc) { // NB! one extra byte is needed to avoid buffer overflow at close_buffer
// make room
size_t newalloc = newsize + newsize / 2 + 1; // give 50% more room
ptr = realloc(ptr, newalloc);
if (ptr == NULL)
return -1;
b->alloc = newalloc;
*b->ptr = ptr;
}
memcpy(ptr + *b->len, data, len);
*b->len = newsize;
return len;
}
static int close_buffer(void *cookie)
{
struct Buffer *b = (struct Buffer *)cookie;
if (*b->ptr)
(*b->ptr)[*b->len] = '\0';
free(b);
return 0;
}
FILE *open_memstream(char **bufptr, size_t *lenptr)
{
struct Buffer *b = (struct Buffer *)malloc(sizeof(struct Buffer));
......@@ -109,6 +75,8 @@ FILE *open_memstream(char **bufptr, size_t *lenptr)
close_buffer
};
return fopencookie(b, "w", vtable);
#else
return NULL;
#endif
}
......@@ -65,6 +65,10 @@
/* NOTE: The format specifiers in this string are placeholders only; the lengths of these
* strings are used to calculate buffer sizes.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration"
static const char pOtaJobsGetNextTopicTemplate[] = MQTT_API_THINGS "%s"MQTT_API_JOBS_NEXT_GET; /*!< Topic template to request next job. */
static const char pOtaJobsNotifyNextTopicTemplate[] = MQTT_API_THINGS "%s"MQTT_API_JOBS_NOTIFY_NEXT; /*!< Topic template to notify next . */
static const char pOtaJobStatusTopicTemplate[] = MQTT_API_THINGS "%s"MQTT_API_JOBS "%s"MQTT_API_UPDATE; /*!< Topic template to update the current job. */
......@@ -74,6 +78,8 @@ static const char pOtaGetStreamTopicTemplate[] = MQTT_API_THINGS "%s"MQTT_API_ST
static const char pOtaGetNextJobMsgTemplate[] = "{\"clientToken\":\"%u:%s\"}"; /*!< Used to specify client token id to authenticate job. */
static const char pOtaStringReceive[] = "\"receive\""; /*!< Used to build the job receive template. */
#pragma GCC diagnostic pop
/** We map all of the above status cases to one of these status strings.
* These are the only strings that are supported by the Job Service. You
* shall not change them to arbitrary strings or the job will not change
......
......@@ -30,6 +30,8 @@
*
*/
#include <string.h>
/* OTA PAL Port include. */
#include "ota_pal.h"
......@@ -110,7 +112,7 @@ static OtaPalStatus_t CalculatePSAImageID( uint8_t slot,
return OTA_PAL_COMBINE_ERR( OtaPalRxFileCreateFailed, 0 );
}
*pxImageID = FWU_CALCULATE_IMAGE_ID(slot, ulImageType, ( uint16_t )pFileContext);
*pxImageID = FWU_CALCULATE_IMAGE_ID(slot, ulImageType, ( uint16_t )( uintptr_t )pFileContext);
return OTA_PAL_COMBINE_ERR( OtaPalSuccess, 0 );
}
......@@ -140,8 +142,6 @@ static OtaPalStatus_t CalculatePSAImageID( uint8_t slot,
*/
OtaPalStatus_t otaPal_Abort( OtaFileContext_t * const pFileContext )
{
OtaPalStatus_t ota_ret = OTA_PAL_COMBINE_ERR( OtaPalAbortFailed, 0 );
if( (pFileContext == NULL) || ((pFileContext != pxSystemContext ) && ( pxSystemContext != NULL ) ) )
{
return OTA_PAL_COMBINE_ERR( OtaPalAbortFailed, 0 );
......@@ -207,7 +207,7 @@ OtaPalStatus_t otaPal_CreateFileForRx( OtaFileContext_t * const pFileContext )
pxSystemContext = pFileContext;
xOTAImageID = ulImageID;
pFileContext->pFile = &xOTAImageID;
pFileContext->pFile = (uint8_t*)&xOTAImageID;
return OTA_PAL_COMBINE_ERR( OtaPalSuccess, 0 );
}
......
......@@ -38,6 +38,7 @@
#include "iot_network_freertos.h"
#include "iot_logging_task.h"
#include "aws_dev_mode_key_provisioning.h"
#include "ota_provision.h"
#include "psa/update.h"
#include "version/application_version.h"
......
......@@ -10,264 +10,6 @@ diff -r --exclude=.git --exclude=resources_downloaded --exclude=log_build_defaul
#if defined(ASSERT_DISABLE)
#define ASSERT(args)
#else
diff -r --exclude=.git --exclude=resources_downloaded --exclude=log_build_default.log -w -Naur orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/core/distributed_runtime/rpc/grpc_util.cc patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/core/distributed_runtime/rpc/grpc_util.cc
--- orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/core/distributed_runtime/rpc/grpc_util.cc 2021-10-07 14:19:08.000000000 +0100
+++ patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/core/distributed_runtime/rpc/grpc_util.cc 2021-10-07 10:49:23.000000000 +0100
@@ -103,7 +103,7 @@
// GrpcMaybeParseProto simply copies bytes into the string.
bool GrpcMaybeParseProto(grpc::ByteBuffer* src, string* dst) {
dst->clear();
- dst->reserve(src->Length());
+ dst->reserve(src->size());
std::vector<::grpc::Slice> slices;
if (!src->Dump(&slices).ok()) {
return false;
@@ -117,7 +117,7 @@
// GrpcMaybeParseProto simply copies bytes into the tstring.
bool GrpcMaybeParseProto(grpc::ByteBuffer* src, tstring* dst) {
dst->clear();
- dst->reserve(src->Length());
+ dst->reserve(src->size());
std::vector<::grpc::Slice> slices;
if (!src->Dump(&slices).ok()) {
return false;
diff -r --exclude=.git --exclude=resources_downloaded --exclude=log_build_default.log -w -Naur orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/memory_helpers.cc patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/memory_helpers.cc
--- orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/memory_helpers.cc 2021-10-07 14:19:18.000000000 +0100
+++ patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/memory_helpers.cc 2021-10-07 10:48:03.000000000 +0100
@@ -100,7 +100,7 @@
// If flatbuffer_tensor.shape == nullptr, then flatbuffer_tensor is a scalar
// so has 1 element.
if (flatbuffer_tensor.shape() != nullptr) {
- for (size_t n = 0; n < flatbuffer_tensor.shape()->Length(); ++n) {
+ for (size_t n = 0; n < flatbuffer_tensor.shape()->size(); ++n) {
element_count *= flatbuffer_tensor.shape()->Get(n);
}
}
diff -r --exclude=.git --exclude=resources_downloaded --exclude=log_build_default.log -w -Naur orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/micro_allocator.cc patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/micro_allocator.cc
--- orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/micro_allocator.cc 2021-10-07 14:19:18.000000000 +0100
+++ patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/micro_allocator.cc 2021-10-07 11:01:09.000000000 +0100
@@ -406,16 +406,16 @@
// copy values from the flatbuffer into the newly allocated chunk.
kTfLiteArrayType* array =
reinterpret_cast<kTfLiteArrayType*>(allocator->AllocateFromTail(
- TfLiteIntArrayGetSizeInBytes(flatbuffer_array->Length()),
+ TfLiteIntArrayGetSizeInBytes(flatbuffer_array->size()),
alignof(kTfLiteArrayType)));
if (array == nullptr) {
TF_LITE_REPORT_ERROR(
error_reporter,
"Failed to allocate %d bytes of memory to copy an array.",
- TfLiteIntArrayGetSizeInBytes(flatbuffer_array->Length()));
+ TfLiteIntArrayGetSizeInBytes(flatbuffer_array->size()));
return kTfLiteError;
}
- array->size = flatbuffer_array->Length();
+ array->size = flatbuffer_array->size();
for (int i = 0; i < array->size; ++i) {
array->data[i] = flatbuffer_array->Get(i);
}
diff -r --exclude=.git --exclude=resources_downloaded --exclude=log_build_default.log -w -Naur orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/micro_interpreter.h patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/micro_interpreter.h
--- orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/micro_interpreter.h 2021-10-07 14:19:18.000000000 +0100
+++ patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/micro/micro_interpreter.h 2021-10-07 10:47:54.000000000 +0100
@@ -121,7 +121,7 @@
}
TfLiteTensor* input(size_t index);
- size_t inputs_size() const { return subgraph_->inputs()->Length(); }
+ size_t inputs_size() const { return subgraph_->inputs()->size(); }
const flatbuffers::Vector<int32_t>& inputs() const {
return *subgraph_->inputs();
}
@@ -137,7 +137,7 @@
}
TfLiteTensor* output(size_t index);
- size_t outputs_size() const { return subgraph_->outputs()->Length(); }
+ size_t outputs_size() const { return subgraph_->outputs()->size(); }
const flatbuffers::Vector<int32_t>& outputs() const {
return *subgraph_->outputs();
}
diff -r --exclude=.git --exclude=resources_downloaded --exclude=log_build_default.log -w -Naur orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/graph_transformations/resolve_reduce_attributes.cc patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/graph_transformations/resolve_reduce_attributes.cc
--- orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/graph_transformations/resolve_reduce_attributes.cc 2021-10-07 14:19:19.000000000 +0100
+++ patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/graph_transformations/resolve_reduce_attributes.cc 2021-10-07 10:46:20.000000000 +0100
@@ -38,7 +38,7 @@
// It is ok for indices_array to have a shape for an empty tensor. In that
// case, we don't bother setting 'axis'.
- if (indices_array.buffer->Length() == 0) return false;
+ if (indices_array.buffer->size() == 0) return false;
op->axis = indices_array.GetBuffer<ArrayDataType::kInt32>().data;
return true;
diff -r --exclude=.git --exclude=resources_downloaded --exclude=log_build_default.log -w -Naur orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/tflite/import.cc patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/tflite/import.cc
--- orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/tflite/import.cc 2021-10-07 14:19:19.000000000 +0100
+++ patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/tflite/import.cc 2021-10-07 10:46:11.000000000 +0100
@@ -70,7 +70,7 @@
// If the shape is 0-dimensional, make sure to record it as such,
// as oppose to leaving the array without a shape.
array.mutable_shape()->mutable_dims()->clear();
- for (uint32_t i = 0; i < shape->Length(); ++i) {
+ for (uint32_t i = 0; i < shape->size(); ++i) {
auto d = shape->Get(i);
array.mutable_shape()->mutable_dims()->push_back(d);
}
@@ -81,15 +81,15 @@
// Note that tf.mini only supports a single quantization parameters for
// the whole array.
if (quantization->min() && quantization->max()) {
- CHECK_EQ(1, quantization->min()->Length());
- CHECK_EQ(1, quantization->max()->Length());
+ CHECK_EQ(1, quantization->min()->size());
+ CHECK_EQ(1, quantization->max()->size());
MinMax& minmax = array.GetOrCreateMinMax();
minmax.min = quantization->min()->Get(0);
minmax.max = quantization->max()->Get(0);
}
if (quantization->scale() && quantization->zero_point()) {
- CHECK_EQ(1, quantization->scale()->Length());
- CHECK_EQ(1, quantization->zero_point()->Length());
+ CHECK_EQ(1, quantization->scale()->size());
+ CHECK_EQ(1, quantization->zero_point()->size());
QuantizationParams& q = array.GetOrCreateQuantizationParams();
q.scale = quantization->scale()->Get(0);
q.zero_point = quantization->zero_point()->Get(0);
@@ -144,7 +144,7 @@
// Make sure all the inputs and outputs are hooked up.
auto inputs = input_op->inputs();
- for (uint32_t i = 0; i < inputs->Length(); i++) {
+ for (uint32_t i = 0; i < inputs->size(); i++) {
auto input_index = inputs->Get(i);
// input_index == -1 indicates optional tensor.
if (input_index != -1) {
@@ -158,7 +158,7 @@
}
}
auto outputs = input_op->outputs();
- for (int i = 0, end = outputs->Length(); i < end; i++) {
+ for (int i = 0, end = outputs->size(); i < end; i++) {
auto output_index = outputs->Get(i);
const std::string& output_name = tensors_table.at(output_index);
op->outputs.push_back(output_name);
diff -r --exclude=.git --exclude=resources_downloaded --exclude=log_build_default.log -w -Naur orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/tooling_util.cc patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/tooling_util.cc
--- orig/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/tooling_util.cc 2021-10-07 14:19:19.000000000 +0100
+++ patched/lib/ml-embedded-evaluation-kit/dependencies/tensorflow/tensorflow/lite/toco/tooling_util.cc 2021-10-07 10:46:35.000000000 +0100
@@ -1066,7 +1066,7 @@
// Constant buffer should has a valid shape.
CheckValidShape(array->shape());
// The shape flat-size should agree with the buffer length.
- CHECK_EQ(array->buffer->Length(),
+ CHECK_EQ(array->buffer->size(),
RequiredBufferSizeForShape(array->shape()))