Skip to content

Commit

Permalink
missing test project
Browse files Browse the repository at this point in the history
  • Loading branch information
kali committed Jun 27, 2023
1 parent 2f071ce commit fb7a2ea
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test-rt/test-onnx-tflite-cycle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "test-onnx-tflit-cycle"
version = "0.1.0"
edition = "2021"

[dependencies]

[build-dependencies]
suite-onnx = { path = "../suite-onnx" }

[dev-dependencies]
lazy_static.workspace = true
log.workspace = true
tract-tflite = { path = "../../tflite", version = "=0.20.7-pre" }
tract-onnx-opl = { path = "../../onnx-opl", version = "=0.20.7-pre" }
suite-onnx = { path = "../suite-onnx" }
10 changes: 10 additions & 0 deletions test-rt/test-onnx-tflite-cycle/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn main() {
let mut suite = suite_onnx::suite().clone();
suite.ignore(&ignore);
suite.test_runtime("tflite_cycle", "suite_onnx::suite()", "tflite_cycle()");
}

fn ignore(t: &[String]) -> bool {
let name = t.last().unwrap();
!name.contains("_conv_")
}
31 changes: 31 additions & 0 deletions test-rt/test-onnx-tflite-cycle/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#![cfg(test)]
use std::borrow::Cow;

use log::*;
use tract_tflite::{internal::*, Tflite};

struct TfliteCyclingRuntime(Tflite);

impl Runtime for TfliteCyclingRuntime {
fn name(&self) -> Cow<str> {
"nnef_cycle".into()
}

fn prepare(&self, model: TypedModel) -> TractResult<Box<dyn Runnable>> {
info!("Store to Tflite");
let mut buffer = vec![];
self.0.write(&model, &mut buffer)?;
info!("Reload from Tflite");
let reloaded = self.0.model_for_read(&mut &*buffer)?;
Ok(Box::new(reloaded.into_optimized()?.into_runnable()?))
}
}

fn tflite_cycle() -> &'static TfliteCyclingRuntime {
lazy_static::lazy_static! {
static ref RT: TfliteCyclingRuntime = TfliteCyclingRuntime(Tflite::default());
};
&RT
}

include!(concat!(env!("OUT_DIR"), "/tests/tflite_cycle.rs"));

0 comments on commit fb7a2ea

Please sign in to comment.