Skip to content

Commit

Permalink
Upgraded to edgetpu runtime version(13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Namburger committed Feb 11, 2020
1 parent fd5ef16 commit 0894b0c
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 43 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ After installing all third party libraries and finish building the binaries, don
* Running the server is as easy as (run from project root dir):

```
// Notice: We'll have to link against this for now since the new runtime broke it :(
$ LD_LIBRARY_PATH=thirdparty/libedgetpu/direct/k8 ./out/k8/restor
$ ./out/k8/restor
I1223 22:54:52.376971 22708 main.cc:28] RESTOR
I1223 22:54:52.390523 22708 main.cc:35] found 1 TPU(s)
I1223 22:54:52.390568 22708 main.cc:37] config: config/restor.yaml
Expand Down
7 changes: 3 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ glog_library(with_gflags=0)
""",
)

TENSORFLOW_COMMIT = "5d0b55dd4a00c74809e5b32217070a26ac6ef823"
# One way to find this SHA256 number is to download the corresponding tar.gz file
# and then run `sha256sum` on local machine.
TENSORFLOW_SHA256 = "2602e177164e7152bd8c7a9a1cab71898ec84ae707ca442cafbd966abdbb07b7"
TENSORFLOW_COMMIT = "d855adfc5a0195788bf5f92c3c7352e638aa1109"
# Command to calculate: curl -OL <FILE-URL> | sha256sum | awk '{print $1}'
TENSORFLOW_SHA256 = "b8a691dbea2bb028fa8f7ce407b70ad236dae0a8705c8010dc7bad8af7e93bac"

http_archive(
name = "org_tensorflow",
Expand Down
1 change: 1 addition & 0 deletions src/utils/test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ void ResizeImage(
auto* params =
reinterpret_cast<TfLiteResizeBilinearParams*>(malloc(sizeof(TfLiteResizeBilinearParams)));
params->align_corners = false;
params->half_pixel_centers = false;
interpreter->AddNodeWithParameters({0, 1}, {2}, nullptr, 0, params, resize_op, nullptr);
interpreter->AllocateTensors();
// fill input image
Expand Down
4 changes: 2 additions & 2 deletions src/utils/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "edgetpu.h"

namespace coral {
const char kEdgeTpuCppWrapperVersion[] = "API(2.1) TF(5d0b55dd4a00c74809e5b32217070a26ac6ef823)";
const char kSupportedRuntimeVersion[] = "RuntimeVersion(12)";
const char kEdgeTpuCppWrapperVersion[] = "API(2.1) TF(d855adfc5a0195788bf5f92c3c7352e638aa1109)";
const char kSupportedRuntimeVersion[] = "RuntimeVersion(13)";
std::string GetRuntimeVersion() {
return ::edgetpu::EdgeTpuManager::GetSingleton()->Version();
}
Expand Down
Binary file modified thirdparty/libedgetpu/direct/aarch64/libedgetpu.so.1.0
Binary file not shown.
Binary file modified thirdparty/libedgetpu/direct/armv6/libedgetpu.so.1.0
Binary file not shown.
Binary file modified thirdparty/libedgetpu/direct/armv7a/libedgetpu.so.1.0
Binary file not shown.
Binary file modified thirdparty/libedgetpu/direct/k8/libedgetpu.so.1.0
Binary file not shown.
2 changes: 1 addition & 1 deletion thirdparty/libedgetpu/edgetpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ limitations under the License.
#define EDGETPU_EXPORT __declspec(dllimport)
#endif // EDGETPU_COMPILE_LIBRARY
#else
#define EDGETPU_EXPORT
#define EDGETPU_EXPORT __attribute__((visibility("default")))
#endif // _WIN32

namespace edgetpu {
Expand Down
78 changes: 44 additions & 34 deletions thirdparty/libedgetpu/edgetpu_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,60 @@ 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 header defines C API to provide edge TPU support for TensorFlow Lite
// framework. It is only available for non-NNAPI use cases.
//
// Typical API usage from C++ code involves serveral steps:
// This header defines C API to provide edge TPU support for TensorFlow Lite
// framework. It is only available for non-NNAPI use cases.
//
// 1. Create tflite::FlatBufferModel which may contain edge TPU custom op.
// Typical API usage from C++ code involves serveral steps:
//
// auto model =
// tflite::FlatBufferModel::BuildFromFile(model_file_name.c_str());
// 1. Create tflite::FlatBufferModel which may contain edge TPU custom op.
//
// 2. Create tflite::Interpreter.
// auto model =
// tflite::FlatBufferModel::BuildFromFile(model_file_name.c_str());
//
// tflite::ops::builtin::BuiltinOpResolver resolver;
// std::unique_ptr<tflite::Interpreter> interpreter;
// tflite::InterpreterBuilder(model, resolver)(&interpreter);
// 2. Create tflite::Interpreter.
//
// 3. Enumerate edge TPU devices.
// tflite::ops::builtin::BuiltinOpResolver resolver;
// std::unique_ptr<tflite::Interpreter> interpreter;
// tflite::InterpreterBuilder(model, resolver)(&interpreter);
//
// size_t num_devices;
// std::unique_ptr<edgetpu_device, decltype(&edgetpu_free_devices)> devices(
// edgetpu_list_devices(&num_devices), &edgetpu_free_devices);
// 3. Enumerate edge TPU devices.
//
// assert(num_devices > 0);
// const auto& device = devices.get()[0];
// size_t num_devices;
// std::unique_ptr<edgetpu_device, decltype(&edgetpu_free_devices)> devices(
// edgetpu_list_devices(&num_devices), &edgetpu_free_devices);
//
// 4. Modify interpreter with the delegate.
// assert(num_devices > 0);
// const auto& device = devices.get()[0];
//
// auto* delegate =
// edgetpu_create_delegate(device.type, device.path, nullptr, 0);
// interpreter->ModifyGraphWithDelegate({delegate, edgetpu_free_delegate});
// 4. Modify interpreter with the delegate.
//
// 5. Prepare input tensors and run inference.
// auto* delegate =
// edgetpu_create_delegate(device.type, device.path, nullptr, 0);
// interpreter->ModifyGraphWithDelegate({delegate, edgetpu_free_delegate});
//
// interpreter->AllocateTensors();
// .... (Prepare input tensors)
// interpreter->Invoke();
// .... (Retrieve the result from output tensors)
// 5. Prepare input tensors and run inference.
//
// interpreter->AllocateTensors();
// .... (Prepare input tensors)
// interpreter->Invoke();
// .... (Retrieve the result from output tensors)

#ifndef TFLITE_PUBLIC_EDGETPU_C_H_
#define TFLITE_PUBLIC_EDGETPU_C_H_

#include "tensorflow/lite/context.h"

#if defined(_WIN32)
#ifdef EDGETPU_COMPILE_LIBRARY
#define EDGETPU_EXPORT __declspec(dllexport)
#else
#define EDGETPU_EXPORT __declspec(dllimport)
#endif // EDGETPU_COMPILE_LIBRARY
#else
#define EDGETPU_EXPORT __attribute__((visibility("default")))
#endif // _WIN32

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -76,28 +87,27 @@ struct edgetpu_option {
};

// Returns array of connected edge TPU devices.
struct edgetpu_device* edgetpu_list_devices(size_t* num_devices);
EDGETPU_EXPORT struct edgetpu_device* edgetpu_list_devices(size_t* num_devices);

// Frees array returned by `edgetpu_list_devices`.
void edgetpu_free_devices(struct edgetpu_device* dev);
EDGETPU_EXPORT void edgetpu_free_devices(struct edgetpu_device* dev);

// Creates a delegate which handles all edge TPU custom ops inside
// `tflite::Interpreter`. Options must be available only during the call of this
// function.
TfLiteDelegate* edgetpu_create_delegate(enum edgetpu_device_type type,
const char* name,
const struct edgetpu_option* options,
size_t num_options);
EDGETPU_EXPORT TfLiteDelegate* edgetpu_create_delegate(
enum edgetpu_device_type type, const char* name,
const struct edgetpu_option* options, size_t num_options);

// Frees delegate returned by `edgetpu_create_delegate`.
void edgetpu_free_delegate(TfLiteDelegate* delegate);
EDGETPU_EXPORT void edgetpu_free_delegate(TfLiteDelegate* delegate);

// Sets verbosity of operating logs related to edge TPU.
// Verbosity level can be set to [0-10], in which 10 is the most verbose.
void edgetpu_verbosity(int verbosity);
EDGETPU_EXPORT void edgetpu_verbosity(int verbosity);

// Returns the version of edge TPU runtime stack.
const char* edgetpu_version();
EDGETPU_EXPORT const char* edgetpu_version();

#ifdef __cplusplus
} // extern "C"
Expand Down
Binary file modified thirdparty/libedgetpu/throttled/aarch64/libedgetpu.so.1.0
Binary file not shown.
Binary file modified thirdparty/libedgetpu/throttled/armv6/libedgetpu.so.1.0
Binary file not shown.
Binary file modified thirdparty/libedgetpu/throttled/armv7a/libedgetpu.so.1.0
Binary file not shown.
Binary file modified thirdparty/libedgetpu/throttled/k8/libedgetpu.so.1.0
Binary file not shown.

0 comments on commit 0894b0c

Please sign in to comment.