file_path
stringlengths
7
180
content
stringlengths
0
811k
repo
stringclasses
11 values
src/layers/normalize.rs
use super::LayerJson; use ndarray::{ArrayD, ArrayViewD}; use serde::Serialize; use super::Layer; #[derive(Clone, Serialize)] pub struct Normalize { name: String, input_shape: Vec<usize>, } impl Normalize { #[must_use] pub fn new(input_shape: Vec<usize>) -> Normalize { Normalize { name: "normalize".into(), input_shape, } } } impl Layer for Normalize { fn box_clone(&self) -> Box<dyn Layer> { Box::new(self.clone()) } fn apply(&self, input: &ArrayViewD<f32>) -> ArrayD<f32> { let input = input.clone().mapv(|x| x as i128); let norm = f32::sqrt(input.mapv(|x| x.pow(2)).sum() as f32); input.mapv(|x| x as f32 / norm).into_dyn() } fn input_shape(&self) -> Vec<usize> { self.input_shape.clone() } fn name(&self) -> &str { &self.name } fn num_params(&self) -> usize { 0 } fn num_muls(&self) -> usize { let mut muls = 1; for i in self.input_shape() { muls *= i; } 1 + muls } fn output_shape(&self) -> Vec<usize> { self.input_shape.clone() } fn to_json(&self) -> LayerJson { LayerJson::Normalize { input_shape: self.input_shape(), } } } #[cfg(test)] mod test { use super::*; use ndarray::{arr1, array}; #[test] fn normalize_test() { let input = arr1(&[ -6276474000., 8343393300., 8266027500., -7525360600., 7814137000., ]); let normalize = Normalize::new(vec![5]); let output = normalize.apply(&input.into_dyn().view()); let expected = array![-0.36541474, 0.4857503, 0.48124605, -0.43812463, 0.4549371]; let delta = &output - &expected; let max_error = delta.into_iter().map(f32::abs).fold(0.0, f32::max); assert!(max_error < 10.0 * f32::EPSILON); println!("{}", output); } }
https://github.com/worldcoin/proto-neural-zkp
src/layers/relu.rs
#![warn(clippy::all, clippy::pedantic, clippy::cargo, clippy::nursery)] use ndarray::{ArrayD, ArrayViewD}; use serde::Serialize; use super::{Layer, LayerJson}; #[derive(Clone, Serialize)] pub struct Relu { name: String, input_shape: Vec<usize>, } impl Relu { #[must_use] pub fn new(input_shape: Vec<usize>) -> Self { Self { name: "relu".into(), input_shape, } } } impl Layer for Relu { fn box_clone(&self) -> Box<dyn Layer> { Box::new(self.clone()) } fn apply(&self, input: &ArrayViewD<f32>) -> ArrayD<f32> { input.mapv(|x| f32::max(0.0, x)) } fn name(&self) -> &str { &self.name } fn num_params(&self) -> usize { let mut params = 1; for i in self.input_shape() { params *= i; } params } fn num_muls(&self) -> usize { 0 } fn output_shape(&self) -> Vec<usize> { self.input_shape.clone() } fn input_shape(&self) -> Vec<usize> { self.input_shape.clone() } fn to_json(&self) -> LayerJson { LayerJson::Relu { input_shape: self.input_shape(), } } } #[cfg(test)] pub mod test { use super::*; use ndarray::{arr1, arr3, Ix1, Ix3}; // Array3 ReLU #[test] fn relu_test3() { let input = arr3(&[[[1.2, -4.3], [-2.1, 4.3]], [[5.2, 6.1], [7.6, -1.8]], [ [9.3, 0.0], [1.2, 3.4], ]]); let relu = Relu::new(vec![3, 2, 2]); let output = relu.apply(&input.into_dyn().view()); let n_params = relu.num_params(); let n_multiplications = relu.num_muls(); assert_eq!( output, arr3(&[[[1.2, 0.0], [0.0, 4.3]], [[5.2, 6.1], [7.6, 0.0]], [ [9.3, 0.0], [1.2, 3.4], ]]) .into_dyn() ); let size: (usize, usize, usize) = (3, 2, 2); assert_eq!( &output.clone().into_dimensionality::<Ix3>().unwrap().dim(), &size ); println!( " {} # of parameters: {} output dim: {}x1 # of ops: {} output:\n{}", relu.name(), n_params, n_params, n_multiplications, output ); } // Array1 ReLU #[test] fn relu_test1() { let input = arr1(&[-4., -3.4, 6., 7., 1., -3.]).into_dyn(); let relu = Relu::new(vec![6]); let output = relu.apply(&input.into_dyn().view()); let n_params = relu.num_params(); let n_multiplications = relu.num_muls(); assert_eq!(output, arr1(&[0., 0., 6., 7., 1., 0.]).into_dyn()); assert_eq!( output.clone().into_dimensionality::<Ix1>().unwrap().len(), 6 ); println!( " {} # of parameters: {} output dim: {}x1 # of ops: {} output:\n{}", relu.name(), n_params, n_params, n_multiplications, output ); } }
https://github.com/worldcoin/proto-neural-zkp
src/lib.rs
// #![warn(clippy::all, clippy::pedantic, clippy::cargo, clippy::nursery)] // Stabilized soon: https://github.com/rust-lang/rust/pull/93827 // Disable globally while still iterating on design #![allow(clippy::missing_panics_doc)] // TODO #![allow(unreadable_literal)] // benchmarking #![feature(test)] mod allocator; mod anyhow; pub mod layers; pub mod nn; pub mod serialize; use self::{allocator::Allocator, anyhow::MapAny as _}; use bytesize::ByteSize; use eyre::{eyre, Result as EyreResult}; use log::Level; use plonky2::{ field::types::Field, iop::{ target::Target, witness::{PartialWitness, Witness}, }, plonk::{ circuit_builder::CircuitBuilder, circuit_data::{CircuitConfig, CircuitData}, config::{GenericConfig, KeccakGoldilocksConfig, PoseidonGoldilocksConfig}, proof::{CompressedProofWithPublicInputs, ProofWithPublicInputs}, }, }; use rand::Rng as _; use std::{iter::once, sync::atomic::Ordering, time::Instant}; use structopt::StructOpt; use tracing::{info, trace}; type Rng = rand_pcg::Mcg128Xsl64; #[cfg(not(feature = "mimalloc"))] #[global_allocator] pub static ALLOCATOR: Allocator<allocator::StdAlloc> = allocator::new_std(); #[cfg(feature = "mimalloc")] #[global_allocator] pub static ALLOCATOR: Allocator<allocator::MiMalloc> = allocator::new_mimalloc(); #[derive(Clone, Debug, PartialEq, StructOpt)] pub struct Options { /// Bench over increasing output sizes #[structopt(long)] pub bench: bool, /// The size of the input layer #[structopt(long, default_value = "1000")] pub input_size: usize, /// The size of the output layer #[structopt(long, default_value = "1000")] pub output_size: usize, /// Coefficient bits #[structopt(long, default_value = "16")] pub coefficient_bits: usize, /// Number of wire columns #[structopt(long, default_value = "400")] pub num_wires: usize, /// Number of routed wire columns #[structopt(long, default_value = "400")] pub num_routed_wires: usize, /// Number of constants per constant gate #[structopt(long, default_value = "90")] pub constant_gate_size: usize, } const D: usize = 2; type C = PoseidonGoldilocksConfig; // type C = KeccakGoldilocksConfig; type F = <C as GenericConfig<D>>::F; type Builder = CircuitBuilder<F, D>; type Proof = ProofWithPublicInputs<F, C, D>; // https://arxiv.org/pdf/1509.09308.pdf // https://en.wikipedia.org/wiki/Freivalds%27_algorithm ? fn to_field(value: i32) -> F { if value >= 0 { F::from_canonical_u32(value as u32) } else { -F::from_canonical_u32(-value as u32) } } /// Compute the inner product of `coefficients` and `input` fn dot(builder: &mut Builder, coefficients: &[i32], input: &[Target]) -> Target { // TODO: Compare this accumulator approach against a batch sum. assert_eq!(coefficients.len(), input.len()); // builder.push_context(Level::Info, "dot"); let mut sum = builder.zero(); // iterates over array coefficients and input and performs the dot product: // sum = co[0] * in[0] + co[1] * in[1] .... + co[len(co)] * in[len(in)] <=> // len(co) = len (in) each coefficient needs to be a Goldilocks field // element (modular arithmetic inside a field element) CircuitBuilder. // mul_const_add() // sum = co[0] * in[0] + co[1] * in[1] .... + co[len(co)] * in[len(in)] <=> // len(co) = len (in) each coefficient needs to be a Goldilocks field // element (modular arithmetic inside a field element) CircuitBuilder. // mul_const_add() for (&coefficient, &input) in coefficients.iter().zip(input) { let coefficient = to_field(coefficient); sum = builder.mul_const_add(coefficient, input, sum); } // builder.pop_context(); sum } // len(co) = k * len(in); k is a constant that belongs to N; k > 1 (ref 1) fn full(builder: &mut Builder, coefficients: &[i32], input: &[Target]) -> Vec<Target> { let input_size = input.len(); // len(output_size) = k let output_size = coefficients.len() / input_size; // enforces (ref 1) assert_eq!(coefficients.len(), input_size * output_size); // TODO: read docs CircuitBuilder.push_context(), Level builder.push_context(Level::Info, "full"); // output is a vector that contains dot products of coefficients and inputs, // len(output) = k // output is a vector that contains dot products of coefficients and inputs, // len(output) = k let mut output = Vec::with_capacity(output_size); // &[i32].chunks_exact() creates an iterator over k arrays of len(input) for coefficients in coefficients.chunks_exact(input_size) { // builder enforces Goldilock fields modular arithmetic output.push(dot(builder, coefficients, input)); } builder.pop_context(); output } // Plonky2 circuit struct Circuit { inputs: Vec<Target>, outputs: Vec<Target>, data: CircuitData<F, C, D>, } impl Circuit { // options are inputs that can be changed from cli and have default values fn build(options: &Options, coefficients: &[i32]) -> Circuit { assert_eq!(coefficients.len(), options.input_size * options.output_size); info!( "Building circuit for for {}x{} matrix-vector multiplication", options.input_size, options.output_size ); let config = CircuitConfig { num_wires: options.num_wires, num_routed_wires: options.num_routed_wires, // constant_gate_size: options.constant_gate_size, ..CircuitConfig::default() }; let mut builder = CircuitBuilder::<F, D>::new(config); // Inputs builder.push_context(Level::Info, "Inputs"); // TODO: Look at CircuitBuilder.add_virtual_targets() let inputs = builder.add_virtual_targets(options.input_size); inputs .iter() .for_each(|target| builder.register_public_input(*target)); builder.pop_context(); // Circuit let outputs = full(&mut builder, &coefficients, &inputs); outputs .iter() .for_each(|target| builder.register_public_input(*target)); // Log circuit size builder.print_gate_counts(0); let data = builder.build::<C>(); Self { inputs, outputs, data, } } fn prove(&self, input: &[i32]) -> EyreResult<Proof> { info!("Proving {} size input", input.len()); // TODO: Look into plonky2::iop::PartialWitness // What's the difference between PW and W let mut pw = PartialWitness::new(); for (&target, &value) in self.inputs.iter().zip(input) { pw.set_target(target, to_field(value)); } let proof = self.data.prove(pw).map_any()?; // let compressed = proof.clone().compress(&self.data.common).map_any()?; let proof_size = ByteSize(proof.to_bytes().map_any()?.len() as u64); info!("Proof size: {proof_size}"); Ok(proof) } fn verify(&self, proof: &Proof) -> EyreResult<()> { info!( "Verifying proof with {} public inputs", proof.public_inputs.len() ); // Why proof.clone() self.data.verify(proof.clone()).map_any() } } pub async fn main(mut rng: Rng, mut options: Options) -> EyreResult<()> { info!( "Computing proof for {}x{} matrix-vector multiplication", options.input_size, options.output_size ); println!( "input_size,output_size,build_time_s,proof_time_s,proof_mem_b,proof_size_b,verify_time_s" ); // TODO: What does this line mean? let output_sizes: Box<dyn Iterator<Item = usize>> = if options.bench { Box::new((1..).map(|n| n * 1000)) } else { // what is once Box::new(once(options.output_size)) }; for output_size in output_sizes { options.output_size = output_size; // Coefficients // what is quantizing? let quantize_coeff = |c: i32| c % (1 << options.coefficient_bits); let coefficients: Vec<i32> = (0..options.input_size * options.output_size) .map(|_| quantize_coeff(rng.gen())) .collect(); let now = Instant::now(); let circuit = Circuit::build(&options, &coefficients); let circuit_build_time = now.elapsed(); // Set witness for proof ALLOCATOR.peak_allocated.store(0, Ordering::Release); let input_values = (0..options.input_size as i32) .into_iter() .map(|_| rng.gen()) .collect::<Vec<_>>(); let now = Instant::now(); let proof = circuit.prove(&input_values)?; let proof_mem = ALLOCATOR.peak_allocated.load(Ordering::Acquire); let proof_time = now.elapsed(); let proof_size = proof.to_bytes().map_any()?.len() as u64; info!("Prover memory usage: {}", ByteSize(proof_mem as u64)); // Verifying let now = Instant::now(); circuit.verify(&proof)?; let verify_time = now.elapsed(); println!( "{},{},{},{},{},{},{}", options.input_size, options.output_size, circuit_build_time.as_secs_f64(), proof_time.as_secs_f64(), proof_mem, proof_size, verify_time.as_secs_f64() ); } Ok(()) } #[cfg(test)] pub mod test { use super::*; use proptest::proptest; use tracing::{error, warn}; use tracing_test::traced_test; #[allow(clippy::eq_op)] // fn test_with_proptest() { // proptest!(|(a in 0..5, b in 0..5)| { // assert_eq!(a + b, b + a); // }); // } #[traced_test] fn test_with_log_output() { error!("logged on the error level"); assert!(logs_contain("logged on the error level")); } #[tokio::test] #[traced_test] #[allow(clippy::semicolon_if_nothing_returned)] // False positive async fn async_test_with_log() { // Local log info!("This is being logged on the info level"); // Log from a spawned task (which runs in a separate thread) tokio::spawn(async { warn!("This is being logged on the warn level from a spawned task"); }) .await .unwrap(); // Ensure that `logs_contain` works as intended assert!(logs_contain("logged on the info level")); assert!(logs_contain("logged on the warn level")); assert!(!logs_contain("logged on the error level")); } } #[cfg(feature = "bench")] pub mod bench { use criterion::{black_box, BatchSize, Criterion}; use proptest::{ strategy::{Strategy, ValueTree}, test_runner::TestRunner, }; use std::time::Duration; use tokio::runtime; pub fn group(criterion: &mut Criterion) { bench_example_proptest(criterion); bench_example_async(criterion); } /// Constructs an executor for async tests pub(crate) fn runtime() -> runtime::Runtime { runtime::Builder::new_multi_thread() .enable_all() .build() .unwrap() } /// Example proptest benchmark /// Uses proptest to randomize the benchmark input fn bench_example_proptest(criterion: &mut Criterion) { let input = (0..5, 0..5); let mut runner = TestRunner::deterministic(); // Note: benchmarks need to have proper identifiers as names for // the CI to pick them up correctly. criterion.bench_function("example_proptest", move |bencher| { bencher.iter_batched( || input.new_tree(&mut runner).unwrap().current(), |(a, b)| { // Benchmark number addition black_box(a + b) }, BatchSize::LargeInput, ); }); } /// Example async benchmark /// See <https://bheisler.github.io/criterion.rs/book/user_guide/benchmarking_async.html> fn bench_example_async(criterion: &mut Criterion) { let duration = Duration::from_micros(1); criterion.bench_function("example_async", move |bencher| { bencher.to_async(runtime()).iter(|| async { tokio::time::sleep(duration).await; }); }); } }
https://github.com/worldcoin/proto-neural-zkp
src/nn.rs
use crate::layers::{ conv::Convolution, flatten::Flatten, fully_connected::FullyConnected, maxpool::MaxPool, normalize::Normalize, relu::Relu, NeuralNetwork, }; use ndarray::{Array1, Array2, Array4}; use ndarray_rand::{rand::SeedableRng, rand_distr::Uniform, RandomExt}; use rand::rngs::StdRng; // TODO: add_layer! macro -> neural_net.add_layer(Box::new(layer: Layer)) // TODO: rnd_Array(shape: Dim = D) pub fn create_neural_net() -> NeuralNetwork { let seed = 694201337; let mut rng = StdRng::seed_from_u64(seed); let mut neural_net = NeuralNetwork::new(); let kernel = Array4::random_using((32, 5, 5, 3), Uniform::<f32>::new(-10., 10.), &mut rng); neural_net.add_layer(Box::new(Convolution::new(kernel, vec![120, 80, 3]))); neural_net.add_layer(Box::new(MaxPool::new(2, vec![116, 76, 32]))); neural_net.add_layer(Box::new(Relu::new(vec![58, 38, 32]))); let kernel = Array4::random_using((32, 5, 5, 32), Uniform::<f32>::new(-10., 10.), &mut rng); neural_net.add_layer(Box::new(Convolution::new(kernel, vec![58, 38, 32]))); neural_net.add_layer(Box::new(MaxPool::new(2, vec![54, 34, 32]))); neural_net.add_layer(Box::new(Relu::new(vec![27, 17, 32]))); neural_net.add_layer(Box::new(Flatten::new(vec![27, 17, 32]))); let weights = Array2::random_using((1000, 14688), Uniform::<f32>::new(-10.0, 10.0), &mut rng); let biases = Array1::random_using(1000, Uniform::<f32>::new(-10.0, 10.0), &mut rng); neural_net.add_layer(Box::new(FullyConnected::new(weights, biases))); neural_net.add_layer(Box::new(Relu::new(vec![1000]))); let weights = Array2::random_using((5, 1000), Uniform::<f32>::new(-10.0, 10.0), &mut rng); let biases = Array1::random_using(5, Uniform::<f32>::new(-10.0, 10.0), &mut rng); neural_net.add_layer(Box::new(FullyConnected::new(weights, biases))); neural_net.add_layer(Box::new(Normalize::new(vec![5]))); neural_net } pub fn log_nn_table() { println!( "{:<20} | {:<15} | {:<15} | {:<15}", "layer", "output shape", "#parameters", "#ops" ); println!("{:-<77}", ""); } #[cfg(test)] pub mod tests { extern crate test; use crate::{ layers::{ conv::Convolution, flatten::Flatten, fully_connected::FullyConnected, maxpool::MaxPool, normalize::Normalize, relu::Relu, NeuralNetwork, }, serialize::deserialize_model_json, }; use ndarray::{ArcArray, Array1, Array2, Array3, Array4, Ix1, Ix2, Ix3, Ix4}; use ndarray_rand::{rand::SeedableRng, rand_distr::Uniform, RandomExt}; use rand::rngs::StdRng; use std::fs; use test::Bencher; use super::log_nn_table; #[test] fn neural_net() { // neural net layers: // conv // maxpool // relu // conv // max pool // relu // flatten // fully connected // relu // fully connected // normalization let seed = 694201337; let mut rng = StdRng::seed_from_u64(seed); log_nn_table(); let input = Array3::random_using((120, 80, 3), Uniform::<f32>::new(-5., 5.), &mut rng); let mut neural_net = NeuralNetwork::new(); let kernel = Array4::random_using((32, 5, 5, 3), Uniform::<f32>::new(-10., 10.), &mut rng); neural_net.add_layer(Box::new(Convolution::new(kernel, vec![120, 80, 3]))); neural_net.add_layer(Box::new(MaxPool::new(2, vec![116, 76, 32]))); neural_net.add_layer(Box::new(Relu::new(vec![58, 38, 32]))); let kernel = Array4::random_using((32, 5, 5, 32), Uniform::<f32>::new(-10., 10.), &mut rng); neural_net.add_layer(Box::new(Convolution::new(kernel, vec![58, 38, 32]))); neural_net.add_layer(Box::new(MaxPool::new(2, vec![54, 34, 32]))); neural_net.add_layer(Box::new(Relu::new(vec![27, 17, 32]))); neural_net.add_layer(Box::new(Flatten::new(vec![27, 17, 32]))); let weights = Array2::random_using((1000, 14688), Uniform::<f32>::new(-10.0, 10.0), &mut rng); let biases = Array1::random_using(1000, Uniform::<f32>::new(-10.0, 10.0), &mut rng); neural_net.add_layer(Box::new(FullyConnected::new(weights, biases))); neural_net.add_layer(Box::new(Relu::new(vec![1000]))); let weights = Array2::random_using((5, 1000), Uniform::<f32>::new(-10.0, 10.0), &mut rng); let biases = Array1::random_using(5, Uniform::<f32>::new(-10.0, 10.0), &mut rng); neural_net.add_layer(Box::new(FullyConnected::new(weights, biases))); neural_net.add_layer(Box::new(Normalize::new(vec![5]))); let output = neural_net.apply(&input.into_dyn().view(), 3); if output.is_some() { println!("final output (normalized):\n{}", output.unwrap()); } else { print!("Unsupported dimensionality of input Array"); } } #[bench] fn bench_neural_net(b: &mut Bencher) { log_nn_table(); let input_json = fs::read_to_string("./src/json/initial.json").expect("Unable to read file"); let input = serde_json::from_str::<ArcArray<f32, Ix3>>(&input_json).unwrap(); let neural_net = deserialize_model_json("./src/json/model.json"); // Python Vanilla CNN implementation, run time: 0.8297840171150046 (average over // 1000 runs on M1 Max Macbook Pro) b.iter(|| neural_net.apply(&input.clone().into_dyn().view(), 3)); // cargo bench - 0.151693329s +- 0.002147193s - (about 5.5x faster) } }
https://github.com/worldcoin/proto-neural-zkp
src/serialize.rs
use std::{fs, io::Write}; use crate::layers::{NNJson, NeuralNetwork}; /// path: &str -> e.g. deserialize_model_json("./src/json/model.json") /// Deserializes a model from JSON from the NNJson Struct in mod.rs pub fn deserialize_model_json(path: &str) -> NeuralNetwork { let model_data = fs::read_to_string(path).expect("Unable to read file"); let model_json = serde_json::from_str::<NNJson>(&model_data).unwrap(); let neural_net: NeuralNetwork = model_json.try_into().unwrap(); neural_net } /// path: &str - path for the creation of a json file containing serialized /// model representation /// model: NeuralNetwork - model to be serialized (dummy /// creation with nn::create_neural_net()) /// example usage: /// serialize_model_json("./src/json/nn.json", create_neural_net()) pub fn serialize_model_json(path: &str, model: NeuralNetwork) { let mut file = fs::File::create(path).expect("Error encountered while creating file!"); let model_json: NNJson = model.into(); file.write_all(serde_json::to_string(&model_json).unwrap().as_bytes()) .expect("Unable to write data"); } #[cfg(test)] pub mod tests { use ndarray::{ArcArray, Ix3}; use serde_json; use std::fs; extern crate test; use test::Bencher; use super::*; use crate::nn::{create_neural_net, log_nn_table}; #[test] fn serialize_nn_json() { serialize_model_json("./src/json/nn.json", create_neural_net()) } #[test] fn deserialize_nn_json() { // initial log log_nn_table(); // deserialize input JSON file into an ArcArray let input_json = fs::read_to_string("./src/json/initial.json").expect("Unable to read file"); let input = serde_json::from_str::<ArcArray<f32, Ix3>>(&input_json).unwrap(); // deserialize model let neural_net = deserialize_model_json("./src/json/model.json"); // run inference let output = neural_net.apply(&input.into_dyn().view(), 3); if output.is_some() { println!("final output (normalized):\n{}", output.unwrap()); } else { print!("Unsupported dimensionality of input Array"); } } #[test] fn serde_full_circle() { serialize_model_json("./src/json/nn.json", create_neural_net()); // initial log log_nn_table(); // deserialize input JSON file into an ArcArray let input_json = fs::read_to_string("./src/json/initial.json").expect("Unable to read file"); let input = serde_json::from_str::<ArcArray<f32, Ix3>>(&input_json).unwrap(); // deserialize model let neural_net = deserialize_model_json("./src/json/nn.json"); // run inference let output = neural_net.apply(&input.into_dyn().view(), 3); if output.is_some() { println!("final output (normalized):\n{}", output.unwrap()); } else { print!("Unsupported dimensionality of input Array"); } } #[bench] fn bench_deserialize_neural_net(b: &mut Bencher) { b.iter(deserialize_nn_json); // full deserialization benchmark times (M1 Max Macbook Pro) // cargo bench - 565,564,850 ns/iter (+/- 61,387,641) } #[bench] fn bench_serialize_neural_net(b: &mut Bencher) { b.iter(serialize_nn_json); // full serialization benchmark times (M1 Max Macbook Pro) // cargo bench - 579,057,637 ns/iter (+/- 20,202,535) } }
https://github.com/worldcoin/proto-neural-zkp
keras2circom/circom.py
# Ref: https://github.com/zk-ml/uchikoma/blob/main/python/uchikoma/circom.py from __future__ import annotations import typing import os from os import path import json from dataclasses import dataclass import re import numpy as np class SafeDict(dict): def __missing__(self, key): return '{' + key + '}' # template string for circom circom_template_string = '''pragma circom 2.0.0; {include} template Model() {brace_left} {signal} {component} {main} {brace_right} component main = Model(); ''' templates: typing.Dict[str, Template] = { } def parse_shape(shape: typing.List[int]) -> str: '''parse shape to integers enclosed by []''' shape_str = '' for dim in shape: shape_str += '[{}]'.format(dim) return shape_str def parse_index(shape: typing.List[int]) -> str: '''parse shape to indices enclosed by []''' index_str = '' for i in range(len(shape)): index_str += '[i{}]'.format(i) return index_str @dataclass class Template: op_name: str fpath: str args: typing.Dict[str] input_names: typing.List[str] = None input_dims: typing.List[int] = None output_names: typing.List[str] = None output_dims: typing.List[int] = None def __str__(self) -> str: args_str = ', '.join(self.args) args_str = '(' + args_str + ')' return '{:>20}{:30} {}{}{}{} \t<-- {}'.format( self.op_name, args_str, self.input_names, self.input_dims, self.output_names, self.output_dims, self.fpath) def file_parse(fpath): '''parse circom file and register templates''' with open(fpath, 'r') as f: lines = f.read().split('\n') lines = [l for l in lines if not l.strip().startswith('//')] lines = ' '.join(lines) lines = re.sub('/\*.*?\*/', 'IGN', lines) funcs = re.findall('template (\w+) ?\((.*?)\) ?\{(.*?)\}', lines) for func in funcs: op_name = func[0].strip() args = func[1].split(',') main = func[2].strip() assert op_name not in templates, \ 'duplicated template: {} in {} vs. {}'.format( op_name, templates[op_name].fpath, fpath) signals = re.findall('signal (\w+) (\w+)(.*?);', main) infos = [[] for i in range(4)] for sig in signals: sig_types = ['input', 'output'] assert sig[0] in sig_types, sig[1] + ' | ' + main idx = sig_types.index(sig[0]) infos[idx*2+0].append(sig[1]) sig_dim = sig[2].count('[') infos[idx*2+1].append(sig_dim) templates[op_name] = Template( op_name, fpath, [a.strip() for a in args], *infos) def dir_parse(dir_path, skips=[]): '''parse circom files in a directory''' names = os.listdir(dir_path) for name in names: if name in skips: continue fpath = path.join(dir_path, name) if os.path.isdir(fpath): dir_parse(fpath) elif os.path.isfile(fpath): if fpath.endswith('.circom'): file_parse(fpath) @dataclass class Signal: name: str shape: typing.List[int] value: typing.Any = None def inject_signal(self, comp_name: str) -> str: '''inject signal into the beginning of the circuit''' if self.value is not None or self.name == 'out' or self.name == 'remainder': return 'signal input {}_{}{};\n'.format( comp_name, self.name, parse_shape(self.shape)) return '' def inject_main(self, comp_name: str, prev_comp_name: str = None, prev_signal: Signal = None) -> str: '''inject signal into main''' inject_str = '' if self.value is not None or self.name == 'out' or self.name == 'remainder': if comp_name.endswith('softmax') and self.name == 'out': inject_str += '{}.out <== {}_out[0];\n'.format( comp_name, comp_name) return inject_str for i in range(len(self.shape)): inject_str += '{}for (var i{} = 0; i{} < {}; i{}++) {{\n'.format( ' '*i*4, i, i, self.shape[i], i) if 'activation' in comp_name or 're_lu' in comp_name: inject_str += '{}{}{}.{} <== {}_{}{};\n'.format(' '*(i+1)*4, comp_name, parse_index(self.shape), self.name, comp_name, self.name, parse_index(self.shape)) else: inject_str += '{}{}.{}{} <== {}_{}{};\n'.format(' '*(i+1)*4, comp_name, self.name, parse_index(self.shape), comp_name, self.name, parse_index(self.shape)) inject_str += '}'*len(self.shape)+'\n' return inject_str if self.shape != prev_signal.shape: raise ValueError('shape mismatch: {} vs. {}'.format(self.shape, prev_signal.shape)) for i in range(len(self.shape)): inject_str += '{}for (var i{} = 0; i{} < {}; i{}++) {{\n'.format( ' '*i*4, i, i, self.shape[i], i) if 'activation' in comp_name or 're_lu' in comp_name: inject_str += '{}{}{}.{} <== {}.{}{};\n'.format(' '*(i+1)*4, comp_name, parse_index(self.shape), self.name, prev_comp_name, prev_signal.name, parse_index(self.shape)) elif 'activation' in prev_comp_name or 're_lu' in prev_comp_name: inject_str += '{}{}.{}{} <== {}{}.{};\n'.format(' '*(i+1)*4, comp_name, self.name, parse_index(self.shape), prev_comp_name, parse_index(self.shape), prev_signal.name) else: inject_str += '{}{}.{}{} <== {}.{}{};\n'.format(' '*(i+1)*4, comp_name, self.name, parse_index(self.shape), prev_comp_name, prev_signal.name, parse_index(self.shape)) inject_str += '}'*len(self.shape)+'\n' return inject_str def inject_input_signal(self) -> str: '''inject the circuit input signal''' if self.value is not None: raise ValueError('input signal should not have value') return 'signal input in{};\n'.format(parse_shape(self.shape)) def inject_output_signal(self) -> str: '''inject the circuit output signal''' if self.value is not None: raise ValueError('output signal should not have value') return 'signal output out{};\n'.format(parse_shape(self.shape)) def inject_input_main(self, comp_name: str) -> str: '''inject the circuit input signal into main''' if self.value is not None: raise ValueError('input signal should not have value') inject_str = '' for i in range(len(self.shape)): inject_str += '{}for (var i{} = 0; i{} < {}; i{}++) {{\n'.format( ' '*i*4, i, i, self.shape[i], i) inject_str += '{}{}.{}{} <== in{};\n'.format(' '*(i+1)*4, comp_name, self.name, parse_index(self.shape), parse_index(self.shape)) inject_str += '}'*len(self.shape)+'\n' return inject_str def inject_output_main(self, prev_comp_name: str, prev_signal: Signal) -> str: '''inject the circuit output signal into main''' if self.value is not None: raise ValueError('output signal should not have value') if self.shape != prev_signal.shape: raise ValueError('shape mismatch: {} vs. {}'.format(self.shape, prev_signal.shape)) if 'softmax' in prev_comp_name: return 'out[0] <== {}.out;\n'.format(prev_comp_name) inject_str = '' for i in range(len(self.shape)): inject_str += '{}for (var i{} = 0; i{} < {}; i{}++) {{\n'.format( ' '*i*4, i, i, self.shape[i], i) if 're_lu' in prev_comp_name: inject_str += '{}out{} <== {}{}.{};\n'.format(' '*(i+1)*4, parse_index(self.shape), prev_comp_name, parse_index(self.shape), prev_signal.name) else: inject_str += '{}out{} <== {}.{}{};\n'.format(' '*(i+1)*4, parse_index(self.shape), prev_comp_name, prev_signal.name, parse_index(self.shape)) inject_str += '}'*len(self.shape)+'\n' return inject_str @dataclass class Component: name: str template: Template inputs: typing.List[Signal] outputs: typing.List[Signal] # optional args args: typing.Dict[str, typing.Any] = None def inject_include(self) -> str: '''include the component template''' return 'include "../{}";\n'.format(self.template.fpath) def inject_signal(self, prev_comp: Component = None, last_comp: bool = False) -> str: '''inject the component signals''' inject_str = '' for signal in self.inputs: if signal.name == 'out' or signal.name == 'remainder': inject_str += signal.inject_signal(self.name) if last_comp is True and signal.name == 'out': inject_str += signal.inject_output_signal() elif signal.value is None and prev_comp is None: inject_str += signal.inject_input_signal() elif signal.value is not None: inject_str += signal.inject_signal(self.name) return inject_str def inject_component(self) -> str: '''inject the component declaration''' if self.template.op_name == 'ReLU': for signal in self.inputs: if signal.name == 'out': output_signal = signal break inject_str = 'component {}{};\n'.format(self.name, parse_shape(output_signal.shape)) for i in range(len(output_signal.shape)): inject_str += '{}for (var i{} = 0; i{} < {}; i{}++) {{\n'.format( ' '*i*4, i, i, output_signal.shape[i], i) inject_str += '{}{}{} = ReLU();\n'.format(' '*(i+1)*4, self.name, parse_index(output_signal.shape)) inject_str += '}'*len(output_signal.shape)+'\n' return inject_str return 'component {} = {}({});\n'.format( self.name, self.template.op_name, self.parse_args(self.template.args, self.args)) def inject_main(self, prev_comp: Component = None, last_comp: bool = False) -> str: '''inject the component main''' inject_str = '' for signal in self.inputs: if signal.value is not None or signal.name == 'out' or signal.name == 'remainder': inject_str += signal.inject_main(self.name) elif prev_comp is None: inject_str += signal.inject_input_main(self.name) else: for sig in prev_comp.inputs: if sig.name == 'out': output_signal = sig break if output_signal is None: output_signal = prev_comp.outputs[0] inject_str += signal.inject_main(self.name, prev_comp.name, output_signal) print if last_comp: for signal in self.inputs: if signal.name == 'out': inject_str += signal.inject_output_main(self.name, signal) break for signal in self.outputs: inject_str += signal.inject_output_main(self.name, signal) return inject_str def to_json(self, dec: int) -> typing.Dict[str, typing.Any]: '''convert the component params to json format''' json_dict = {} for signal in self.inputs: if signal.value is not None: if signal.name == 'bias' or signal.name == 'b': scaling = float(10**(2*dec)) else: scaling = float(10**dec) value = [str(int(v*scaling)) for v in signal.value.flatten().tolist()] # reshape the value to match the circom shape if len(signal.shape) > 1: value = np.array(value).reshape(signal.shape).tolist() json_dict.update({f'{self.name}_{signal.name}': value}) return json_dict @staticmethod def parse_args(template_args: typing.List[str], args: typing.Dict[str, typing.Any]) -> str: '''parse the args to a format string, ready to be injected''' args_str = '{'+'}, {'.join(template_args)+'}' return args_str.format(**args) @dataclass class Circuit: components: typing.List[Component] def __init__(self): self.components = [] def add_component(self, component: Component): self.components.append(component) def add_components(self, components: typing.List[Component]): self.components.extend(components) def inject_include(self) -> str: '''inject the include statements''' inject_str = [] for component in self.components: inject_str.append(component.inject_include()) return ''.join(set(inject_str)) def inject_signal(self) -> str: '''inject the signal declarations''' inject_str = self.components[0].inject_signal() for i in range(1, len(self.components)): inject_str += self.components[i].inject_signal(self.components[i-1], i==len(self.components)-1) return inject_str def inject_component(self) -> str: '''inject the component declarations''' inject_str = '' for component in self.components: inject_str += component.inject_component() return inject_str def inject_main(self) -> str: '''inject the main template''' inject_str = self.components[0].inject_main() for i in range(1, len(self.components)): inject_str += self.components[i].inject_main(self.components[i-1], i==len(self.components)-1) return inject_str def to_circom(self) -> str: '''convert the circuit to a circom file''' return circom_template_string.format(**{ 'include': self.inject_include(), 'brace_left': '{', 'signal': self.inject_signal(), 'component': self.inject_component(), 'main': self.inject_main(), 'brace_right': '}', }) def to_json(self, dec: int) -> str: '''convert the model weights to json format''' json_dict = {} for component in self.components: json_dict.update(component.to_json(dec)) return json.dumps(json_dict)
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
keras2circom/model.py
# Read keras model into list of parameters like op, input, output, weight, bias from __future__ import annotations from dataclasses import dataclass import typing from tensorflow.keras.models import load_model from tensorflow.keras.layers import Layer as KerasLayer import numpy as np supported_ops = [ 'Activation', 'AveragePooling2D', 'BatchNormalization', 'Conv2D', 'Dense', 'Flatten', 'GlobalAveragePooling2D', 'GlobalMaxPooling2D', 'MaxPooling2D', 'ReLU', 'Softmax', ] skip_ops = [ 'Dropout', 'InputLayer', ] # read each layer in a model and convert it to a class called Layer @dataclass class Layer: ''' A single layer in a Keras model. ''' op: str name: str input: typing.List[int] output: typing.List[int] config: typing.Dict[str, typing.Any] weights: typing.List[np.ndarray] def __init__(self, layer: KerasLayer): self.op = layer.__class__.__name__ self.name = layer.name self.input = layer.input_shape[1:] self.output = layer.output_shape[1:] self.config = layer.get_config() self.weights = layer.get_weights() class Model: layers: typing.List[Layer] def __init__(self, filename: str, raw: bool = False): ''' Load a Keras model from a file. ''' model = load_model(filename) self.layers = [Layer(layer) for layer in model.layers if self._for_transpilation(layer.__class__.__name__)] @staticmethod def _for_transpilation(op: str) -> bool: if op in skip_ops: return False if op in supported_ops: return True raise NotImplementedError(f'Unsupported op: {op}')
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
keras2circom/script.py
from .circom import Circuit, Component # template string for circuit.py python_template_string = '''""" Make an interger-only circuit of the corresponding CIRCOM circuit. Usage: circuit.py <circuit.json> <input.json> [-o <output>] circuit.py (-h | --help) Options: -h --help Show this screen. -o <output> --output=<output> Output directory [default: output]. """ from docopt import docopt import json try: from keras2circom.util import * except: import sys import os # add parent directory to sys.path sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from keras2circom.util import * def inference(input, circuit): out = input['in'] output = {brackets} {components} return out, output def main(): """ Main entry point of the app """ args = docopt(__doc__) # parse input.json with open(args['<input.json>']) as f: input = json.load(f) # parse circuit.json with open(args['<circuit.json>']) as f: circuit = json.load(f) out, output = inference(input, circuit) # write output.json with open(args['--output'] + '/output.json', 'w') as f: json.dump(output, f) if __name__ == "__main__": """ This is executed when run from the command line """ main() ''' def to_py(circuit: Circuit, dec: int) -> str: comp_str = "" for component in circuit.components: comp_str += transpile_component(component, dec) return python_template_string.format( brackets="{}", components=comp_str, ) def transpile_component(component: Component, dec: int) -> str: comp_str = "" if component.template.op_name == "AveragePooling2D": comp_str += " out, remainder = AveragePooling2DInt({nRows}, {nCols}, {nChannels}, {poolSize}, {strides}, {input})\n".format( nRows=component.args["nRows"], nCols=component.args["nCols"], nChannels=component.args["nChannels"], poolSize=component.args["poolSize"], strides=component.args["strides"], input="out" ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) comp_str += " output['{name}_remainder'] = remainder\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "BatchNormalization2D": comp_str += " out, remainder = BatchNormalizationInt({nRows}, {nCols}, {nChannels}, {n}, {input}, {a}, {b})\n".format( nRows=component.args["nRows"], nCols=component.args["nCols"], nChannels=component.args["nChannels"], n=component.args["n"], input="out", a="circuit['{name}_a']".format(name=component.name), b="circuit['{name}_b']".format(name=component.name), ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) comp_str += " output['{name}_remainder'] = remainder\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "Conv1D": comp_str += " out, remainder = Conv1DInt({nInputs}, {nChannels}, {nFilters}, {kernelSize}, {strides}, {n}, {input}, {weights}, {bias})\n".format( nInputs=component.args["nInputs"], nChannels=component.args["nChannels"], nFilters=component.args["nFilters"], kernelSize=component.args["kernelSize"], strides=component.args["strides"], n=component.args["n"], input="out", weights="circuit['{name}_weights']".format(name=component.name), bias="circuit['{name}_bias']".format(name=component.name), ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) comp_str += " output['{name}_remainder'] = remainder\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "Conv2D": comp_str += " out, remainder = Conv2DInt({nRows}, {nCols}, {nChannels}, {nFilters}, {kernelSize}, {strides}, {n}, {input}, {weights}, {bias})\n".format( nRows=component.args["nRows"], nCols=component.args["nCols"], nChannels=component.args["nChannels"], nFilters=component.args["nFilters"], kernelSize=component.args["kernelSize"], strides=component.args["strides"], n=component.args["n"], input="out", weights="circuit['{name}_weights']".format(name=component.name), bias="circuit['{name}_bias']".format(name=component.name), ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) comp_str += " output['{name}_remainder'] = remainder\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "Dense": comp_str += " out, remainder = DenseInt({nInputs}, {nOutputs}, {n}, {input}, {weights}, {bias})\n".format( nInputs=component.args["nInputs"], nOutputs=component.args["nOutputs"], n=component.args["n"], input="out", weights="circuit['{name}_weights']".format(name=component.name), bias="circuit['{name}_bias']".format(name=component.name), ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) comp_str += " output['{name}_remainder'] = remainder\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "GlobalAveragePooling2D": comp_str += " out, remainder = GlobalAveragePooling2DInt({nRows}, {nCols}, {nChannels}, {input})\n".format( nRows=component.args["nRows"], nCols=component.args["nCols"], nChannels=component.args["nChannels"], input="out" ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) comp_str += " output['{name}_remainder'] = remainder\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "GlobalMaxPooling2D": comp_str += " out = GlobalMaxPooling2DInt({nRows}, {nCols}, {nChannels}, {input})\n".format( nRows=component.args["nRows"], nCols=component.args["nCols"], nChannels=component.args["nChannels"], input="out" ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "MaxPooling2D": comp_str += " out = MaxPooling2DInt({nRows}, {nCols}, {nChannels}, {poolSize}, {strides}, {input})\n".format( nRows=component.args["nRows"], nCols=component.args["nCols"], nChannels=component.args["nChannels"], poolSize=component.args["poolSize"], strides=component.args["strides"], input="out" ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "Flatten2D": comp_str += " out = Flatten2DInt({nRows}, {nCols}, {nChannels}, {input})\n".format( nRows=component.args["nRows"], nCols=component.args["nCols"], nChannels=component.args["nChannels"], input="out" ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "ReLU": nRows, nCols, nChannels = component.inputs[0].shape comp_str += " out = ReLUInt({nRows}, {nCols}, {nChannels}, {input})\n".format( nRows=nRows, nCols=nCols, nChannels=nChannels, input="out" ) comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) return comp_str+"\n" elif component.template.op_name == "ArgMax": comp_str += " out = ArgMaxInt(out)\n" comp_str += " output['{name}_out'] = out\n".format( name=component.name, ) return comp_str+"\n" else: raise ValueError("Unknown component type: {}".format(component.template.op_name))
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
keras2circom/transpiler.py
from .circom import * from .model import * from .script import * import os def transpile(filename: str, output_dir: str = 'output', raw: bool = False, dec: int = 18) -> Circuit: ''' Transpile a Keras model to a CIRCOM circuit.''' model = Model(filename, raw) circuit = Circuit() for layer in model.layers[:-1]: circuit.add_components(transpile_layer(layer, dec)) circuit.add_components(transpile_layer(model.layers[-1], dec, True)) if raw: if circuit.components[-1].template.op_name == 'ArgMax': circuit.components.pop() # create output directory if it doesn't exist if not os.path.exists(output_dir): os.makedirs(output_dir) with open(output_dir + '/circuit.circom', 'w') as f: f.write(circuit.to_circom()) with open(output_dir + '/circuit.json', 'w') as f: f.write(circuit.to_json(int(dec))) with open(output_dir + '/circuit.py', 'w') as f: f.write(to_py(circuit, int(dec))) return circuit def transpile_layer(layer: Layer, dec: int = 18, last: bool = False) -> typing.List[Component]: ''' Transpile a Keras layer to CIRCOM component(s).''' if layer.op == 'Activation': if layer.config['activation'] == 'softmax': if last: return transpile_ArgMax(layer) raise ValueError('Softmax must be the last layer') if layer.config['activation'] == 'relu': return transpile_ReLU(layer) if layer.config['activation'] == 'linear': return [] raise NotImplementedError(f'Activation {layer.config["activation"]} not implemented') if layer.op == 'Softmax': if last: return transpile_ArgMax(layer) raise ValueError('Softmax must be the last layer') if layer.op == 'ReLU': return transpile_ReLU(layer) if layer.op == 'AveragePooling2D': return transpile_AveragePooling2D(layer) if layer.op == 'BatchNormalization': return transpile_BatchNormalization2D(layer, dec) if layer.op == 'Conv2D': return transpile_Conv2D(layer, dec) if layer.op == 'Dense': return transpile_Dense(layer, dec, last) if layer.op == 'Flatten': return transpile_Flatten2D(layer) if layer.op == 'GlobalAveragePooling2D': return transpile_GlobalAveragePooling2D(layer) if layer.op == 'GlobalMaxPooling2D': return transpile_GlobalMaxPooling2D(layer) if layer.op == 'MaxPooling2D': return transpile_MaxPooling2D(layer) raise NotImplementedError(f'Layer {layer.op} is not supported yet.') def transpile_ArgMax(layer: Layer) -> typing.List[Component]: return [Component(layer.name, templates['ArgMax'], [Signal('in', layer.output), Signal('out', (1,))], [], {'n': layer.output[0]})] def transpile_ReLU(layer: Layer) -> typing.List[Component]: return [Component(layer.name, templates['ReLU'], [Signal('in', layer.output), Signal('out', layer.output)], [])] def transpile_AveragePooling2D(layer: Layer) -> typing.List[Component]: if layer.config['data_format'] != 'channels_last': raise NotImplementedError('Only data_format="channels_last" is supported') if layer.config['padding'] != 'valid': raise NotImplementedError('Only padding="valid" is supported') if layer.config['pool_size'][0] != layer.config['pool_size'][1]: raise NotImplementedError('Only pool_size[0] == pool_size[1] is supported') if layer.config['strides'][0] != layer.config['strides'][1]: raise NotImplementedError('Only strides[0] == strides[1] is supported') return [Component(layer.name, templates['AveragePooling2D'], [Signal('in', layer.input), Signal('out', layer.output), Signal('remainder', layer.output)],[],{ 'nRows': layer.input[0], 'nCols': layer.input[1], 'nChannels': layer.input[2], 'poolSize': layer.config['pool_size'][0], 'strides': layer.config['strides'][0], })] def transpile_BatchNormalization2D(layer: Layer, dec: int) -> typing.List[Component]: if layer.input.__len__() != 3: raise NotImplementedError('Only 2D inputs are supported') if layer.config['axis'][0] != 3: raise NotImplementedError('Only axis=3 is supported') if layer.config['center'] != True: raise NotImplementedError('Only center=True is supported') if layer.config['scale'] != True: raise NotImplementedError('Only scale=True is supported') gamma = layer.weights[0] beta = layer.weights[1] moving_mean = layer.weights[2] moving_var = layer.weights[3] epsilon = layer.config['epsilon'] a = gamma/(moving_var+epsilon)**.5 b = beta-gamma*moving_mean/(moving_var+epsilon)**.5 return [Component(layer.name, templates['BatchNormalization2D'], [ Signal('in', layer.input), Signal('a', a.shape, a), Signal('b', b.shape, b), Signal('out', layer.output), Signal('remainder', layer.output), ],[],{ 'nRows': layer.input[0], 'nCols': layer.input[1], 'nChannels': layer.input[2], 'n': '10**'+dec, })] def transpile_Conv2D(layer: Layer, dec: int) -> typing.List[Component]: if layer.config['data_format'] != 'channels_last': raise NotImplementedError('Only data_format="channels_last" is supported') if layer.config['padding'] != 'valid': raise NotImplementedError('Only padding="valid" is supported') if layer.config['strides'][0] != layer.config['strides'][1]: raise NotImplementedError('Only strides[0] == strides[1] is supported') if layer.config['kernel_size'][0] != layer.config['kernel_size'][1]: raise NotImplementedError('Only kernel_size[0] == kernel_size[1] is supported') if layer.config['dilation_rate'][0] != 1: raise NotImplementedError('Only dilation_rate[0] == 1 is supported') if layer.config['dilation_rate'][1] != 1: raise NotImplementedError('Only dilation_rate[1] == 1 is supported') if layer.config['groups'] != 1: raise NotImplementedError('Only groups == 1 is supported') if layer.config['activation'] not in ['linear', 'relu']: raise NotImplementedError(f'Activation {layer.config["activation"]} is not supported') if layer.config['use_bias'] == False: layer.weights.append(np.zeros(layer.weights[0].shape[-1])) conv = Component(layer.name, templates['Conv2D'], [ Signal('in', layer.input), Signal('weights', layer.weights[0].shape, layer.weights[0]), Signal('bias', layer.weights[1].shape, layer.weights[1]), Signal('out', layer.output), Signal('remainder', layer.output), ],[],{ 'nRows': layer.input[0], 'nCols': layer.input[1], 'nChannels': layer.input[2], 'nFilters': layer.config['filters'], 'kernelSize': layer.config['kernel_size'][0], 'strides': layer.config['strides'][0], 'n': '10**'+dec, }) if layer.config['activation'] == 'relu': activation = Component(layer.name+'_re_lu', templates['ReLU'], [Signal('in', layer.output), Signal('out', layer.output)], []) return [conv, activation] return [conv] def transpile_Dense(layer: Layer, dec: int, last: bool = False) -> typing.List[Component]: if not last and layer.config['activation'] == 'softmax': raise NotImplementedError('Softmax is only supported as last layer') if layer.config['activation'] not in ['linear', 'relu', 'softmax']: raise NotImplementedError(f'Activation {layer.config["activation"]} is not supported') if layer.config['use_bias'] == False: layer.weights.append(np.zeros(layer.weights[0].shape[-1])) dense = Component(layer.name, templates['Dense'], [ Signal('in', layer.input), Signal('weights', layer.weights[0].shape, layer.weights[0]), Signal('bias', layer.weights[1].shape, layer.weights[1]), Signal('out', layer.output), Signal('remainder', layer.output), ],[],{ 'nInputs': layer.input[0], 'nOutputs': layer.output[0], 'n': '10**'+dec, }) if layer.config['activation'] == 'relu': activation = Component(layer.name+'_re_lu', templates['ReLU'], [Signal('in', layer.output), Signal('out', layer.output)], []) return [dense, activation] if layer.config['activation'] == 'softmax': activation = Component(layer.name+'_softmax', templates['ArgMax'], [Signal('in', layer.output), Signal('out', (1,))], [], {'n': layer.output[0]}) return [dense, activation] return [dense] def transpile_Flatten2D(layer: Layer) -> typing.List[Component]: if layer.input.__len__() != 3: raise NotImplementedError('Only 2D inputs are supported') return [Component(layer.name, templates['Flatten2D'], [ Signal('in', layer.input), Signal('out', layer.output), ],[],{ 'nRows': layer.input[0], 'nCols': layer.input[1], 'nChannels': layer.input[2], })] def transpile_GlobalAveragePooling2D(layer: Layer) -> typing.List[Component]: if layer.config['data_format'] != 'channels_last': raise NotImplementedError('Only data_format="channels_last" is supported') if layer.config['keepdims']: raise NotImplementedError('Only keepdims=False is supported') return [Component(layer.name, templates['GlobalAveragePooling2D'], [ Signal('in', layer.input), Signal('out', layer.output), Signal('remainder', layer.output), ],[],{ 'nRows': layer.input[0], 'nCols': layer.input[1], 'nChannels': layer.input[2], })] def transpile_GlobalMaxPooling2D(layer: Layer) -> typing.List[Component]: if layer.config['data_format'] != 'channels_last': raise NotImplementedError('Only data_format="channels_last" is supported') if layer.config['keepdims']: raise NotImplementedError('Only keepdims=False is supported') return [Component(layer.name, templates['GlobalMaxPooling2D'], [ Signal('in', layer.input), Signal('out', layer.output), ],[],{ 'nRows': layer.input[0], 'nCols': layer.input[1], 'nChannels': layer.input[2], })] def transpile_MaxPooling2D(layer: Layer) -> typing.List[Component]: if layer.config['data_format'] != 'channels_last': raise NotImplementedError('Only data_format="channels_last" is supported') if layer.config['padding'] != 'valid': raise NotImplementedError('Only padding="valid" is supported') if layer.config['pool_size'][0] != layer.config['pool_size'][1]: raise NotImplementedError('Only pool_size[0] == pool_size[1] is supported') if layer.config['strides'][0] != layer.config['strides'][1]: raise NotImplementedError('Only strides[0] == strides[1] is supported') return [Component(layer.name, templates['MaxPooling2D'], [Signal('in', layer.input), Signal('out', layer.output)], [],{ 'nRows': layer.input[0], 'nCols': layer.input[1], 'nChannels': layer.input[2], 'poolSize': layer.config['pool_size'][0], 'strides': layer.config['strides'][0], })]
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
keras2circom/util.py
# assume all inputs are strings def AveragePooling2DInt (nRows, nCols, nChannels, poolSize, strides, input): out = [[[0 for _ in range(nChannels)] for _ in range((nCols-poolSize)//strides + 1)] for _ in range((nRows-poolSize)//strides + 1)] remainder = [[[None for _ in range(nChannels)] for _ in range((nCols-poolSize)//strides + 1)] for _ in range((nRows-poolSize)//strides + 1)] for i in range((nRows-poolSize)//strides + 1): for j in range((nCols-poolSize)//strides + 1): for k in range(nChannels): for x in range(poolSize): for y in range(poolSize): out[i][j][k] += int(input[i*strides+x][j*strides+y][k]) remainder[i][j][k] = str(out[i][j][k] % poolSize**2) out[i][j][k] = str(out[i][j][k] // poolSize**2) return out, remainder def BatchNormalizationInt(nRows, nCols, nChannels, n, X_in, a_in, b_in): out = [[[None for _ in range(nChannels)] for _ in range(nCols)] for _ in range(nRows)] remainder = [[[None for _ in range(nChannels)] for _ in range(nCols)] for _ in range(nRows)] for i in range(nRows): for j in range(nCols): for k in range(nChannels): out[i][j][k] = int(X_in[i][j][k])*int(a_in[k]) + int(b_in[k]) remainder[i][j][k] = str(out[i][j][k] % n) out[i][j][k] = str(out[i][j][k] // n) return out, remainder def Conv1DInt(nInputs, nChannels, nFilters, kernelSize, strides, n, input, weights, bias): out = [[0 for _ in range(nFilters)] for j in range((nInputs - kernelSize)//strides + 1)] remainder = [[None for _ in range(nFilters)] for _ in range((nInputs - kernelSize)//strides + 1)] for i in range((nInputs - kernelSize)//strides + 1): for j in range(nFilters): for k in range(kernelSize): for l in range(nChannels): out[i][j] += int(input[i*strides + k][l])*int(weights[k][l][j]) out[i][j] += int(bias[j]) remainder[i][j] = str(out[i][j] % n) out[i][j] = str(out[i][j] // n) return out, remainder def Conv2DInt(nRows, nCols, nChannels, nFilters, kernelSize, strides, n, input, weights, bias): out = [[[0 for _ in range(nFilters)] for _ in range((nCols - kernelSize)//strides + 1)] for _ in range((nRows - kernelSize)//strides + 1)] remainder = [[[None for _ in range(nFilters)] for _ in range((nCols - kernelSize)//strides + 1)] for _ in range((nRows - kernelSize)//strides + 1)] for i in range((nRows - kernelSize)//strides + 1): for j in range((nCols - kernelSize)//strides + 1): for m in range(nFilters): for k in range(nChannels): for x in range(kernelSize): for y in range(kernelSize): out[i][j][m] += int(input[i*strides+x][j*strides+y][k])*int(weights[x][y][k][m]) out[i][j][m] += int(bias[m]) remainder[i][j][m] = str(out[i][j][m] % n) out[i][j][m] = str(out[i][j][m] // n) return out, remainder def DenseInt(nInputs, nOutputs, n, input, weights, bias): out = [0 for _ in range(nOutputs)] remainder = [None for _ in range(nOutputs)] for j in range(nOutputs): for i in range(nInputs): out[j] += int(input[i])*int(weights[i][j]) out[j] += int(bias[j]) remainder[j] = str(out[j] % n) out[j] = str(out[j] // n) return out, remainder def GlobalAveragePooling2DInt(nRows, nCols, nChannels, input): out = [0 for _ in range(nChannels)] remainder = [None for _ in range(nChannels)] for k in range(nChannels): for i in range(nRows): for j in range(nCols): out[k] += int(input[i][j][k]) remainder[k] = str(out[k] % (nRows * nCols)) out[k] = str(out[k] // (nRows * nCols)) return out, remainder def GlobalMaxPooling2DInt(nRows, nCols, nChannels, input): out = [max(int(input[i][j][k]) for i in range(nRows) for j in range(nCols)) for k in range(nChannels)] return out def MaxPooling2DInt(nRows, nCols, nChannels, poolSize, strides, input): out = [[[str(max(int(input[i*strides + x][j*strides + y][k]) for x in range(poolSize) for y in range(poolSize))) for k in range(nChannels)] for j in range((nCols - poolSize) // strides + 1)] for i in range((nRows - poolSize) // strides + 1)] return out def Flatten2DInt(nRows, nCols, nChannels, input): out = [str(int(input[i][j][k])) for i in range(nRows) for j in range(nCols) for k in range(nChannels)] return out def ReLUInt(nRows, nCols, nChannels, input): out = [[[str(max(int(input[i][j][k]), 0)) for k in range(nChannels)] for j in range(nCols)] for i in range(nRows)] return out def ArgMaxInt(input): return [input.index(str(max(int(input[i]) for i in range(len(input)))))]
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
main.py
""" Transpile a Keras model to a CIRCOM circuit. Usage: main.py <model.h5> [-o <output>] [--raw] [-d <decimals>] main.py (-h | --help) Options: -h --help Show this screen. -o <output> --output=<output> Output directory [default: output]. --raw Output raw model outputs instead of the argmax of outputs [default: False]. -d <decimals> --decimals=<decimals> Number of decimals for model precision [default: 18]. """ from docopt import docopt from keras2circom import circom, transpiler def main(): """ Main entry point of the app """ args = docopt(__doc__) circom.dir_parse('node_modules/circomlib-ml/circuits/', skips=['util.circom', 'circomlib-matrix', 'circomlib', 'crypto']) transpiler.transpile(args['<model.h5>'], args['--output'], args['--raw'], args['--decimals']) if __name__ == "__main__": """ This is executed when run from the command line """ main()
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
models/model.ipynb
{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# list of supported layers\n", "from tensorflow.keras.layers import (\n", " Input,\n", " Activation,\n", " AveragePooling2D,\n", " BatchNormalization,\n", " Conv2D,\n", " Dense,\n", " Dropout,\n", " Flatten,\n", " GlobalAveragePooling2D,\n", " GlobalMaxPooling2D,\n", " MaxPooling2D,\n", " ReLU,\n", " Softmax,\n", " )\n", "from tensorflow.keras import Model\n", "from tensorflow.keras.datasets import mnist\n", "from tensorflow.keras.utils import to_categorical\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import tensorflow as tf" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# load MNIST dataset\n", "(X_train, y_train), (X_test, y_test) = mnist.load_data()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# convert y_train and y_test to one-hot encoding\n", "y_train = to_categorical(y_train)\n", "y_test = to_categorical(y_test)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# reshape X_train and X_test to 4D tensor\n", "X_train = X_train.reshape(X_train.shape[0], 28, 28, 1)\n", "X_test = X_test.reshape(X_test.shape[0], 28, 28, 1)\n", "\n", "#normalizing\n", "X_train = X_train.astype('float32')\n", "X_test = X_test.astype('float32')\n", "X_train /= 255.0\n", "X_test /= 255.0" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "inputs = Input(shape=(28,28,1))\n", "out = Conv2D(4, 3, use_bias=False)(inputs)\n", "out = BatchNormalization()(out)\n", "out = Activation('relu')(out)\n", "out = MaxPooling2D()(out)\n", "out = Conv2D(8, 3, use_bias=True, strides=2)(out)\n", "out = ReLU()(out)\n", "out = AveragePooling2D()(out)\n", "out = Flatten()(out)\n", "# out = Dropout(0.5)(out)\n", "out = Dense(10, activation=\"softmax\")(out)\n", "model = Model(inputs, out)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model: \"model\"\n", "_________________________________________________________________\n", " Layer (type) Output Shape Param # \n", "=================================================================\n", " input_1 (InputLayer) [(None, 28, 28, 1)] 0 \n", " \n", " conv2d (Conv2D) (None, 26, 26, 4) 36 \n", " \n", " batch_normalization (BatchN (None, 26, 26, 4) 16 \n", " ormalization) \n", " \n", " activation (Activation) (None, 26, 26, 4) 0 \n", " \n", " max_pooling2d (MaxPooling2D (None, 13, 13, 4) 0 \n", " ) \n", " \n", " conv2d_1 (Conv2D) (None, 6, 6, 8) 296 \n", " \n", " re_lu (ReLU) (None, 6, 6, 8) 0 \n", " \n", " average_pooling2d (AverageP (None, 3, 3, 8) 0 \n", " ooling2D) \n", " \n", " flatten (Flatten) (None, 72) 0 \n", " \n", " dense (Dense) (None, 10) 730 \n", " \n", "=================================================================\n", "Total params: 1,078\n", "Trainable params: 1,070\n", "Non-trainable params: 8\n", "_________________________________________________________________\n" ] } ], "source": [ "model.summary()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "model.compile(\n", " loss='categorical_crossentropy',\n", " optimizer='adam',\n", " metrics=['acc']\n", " )" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Epoch 1/15\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2023-11-26 21:47:52.776729: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1875/1875 [==============================] - 11s 6ms/step - loss: 0.5203 - acc: 0.8386 - val_loss: 0.2099 - val_acc: 0.9363\n", "Epoch 2/15\n", "1875/1875 [==============================] - 11s 6ms/step - loss: 0.1926 - acc: 0.9419 - val_loss: 0.1497 - val_acc: 0.9543\n", "Epoch 3/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.1551 - acc: 0.9522 - val_loss: 0.1263 - val_acc: 0.9591\n", "Epoch 4/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.1361 - acc: 0.9580 - val_loss: 0.1139 - val_acc: 0.9628\n", "Epoch 5/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.1253 - acc: 0.9617 - val_loss: 0.1031 - val_acc: 0.9679\n", "Epoch 6/15\n", "1875/1875 [==============================] - 11s 6ms/step - loss: 0.1168 - acc: 0.9636 - val_loss: 0.0976 - val_acc: 0.9697\n", "Epoch 7/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.1113 - acc: 0.9650 - val_loss: 0.0923 - val_acc: 0.9711\n", "Epoch 8/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.1072 - acc: 0.9673 - val_loss: 0.0884 - val_acc: 0.9732\n", "Epoch 9/15\n", "1875/1875 [==============================] - 12s 7ms/step - loss: 0.1026 - acc: 0.9683 - val_loss: 0.0879 - val_acc: 0.9725\n", "Epoch 10/15\n", "1875/1875 [==============================] - 11s 6ms/step - loss: 0.0999 - acc: 0.9691 - val_loss: 0.0928 - val_acc: 0.9719\n", "Epoch 11/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.0968 - acc: 0.9702 - val_loss: 0.0954 - val_acc: 0.9699\n", "Epoch 12/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.0945 - acc: 0.9706 - val_loss: 0.0841 - val_acc: 0.9740\n", "Epoch 13/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.0926 - acc: 0.9718 - val_loss: 0.0826 - val_acc: 0.9748\n", "Epoch 14/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.0893 - acc: 0.9723 - val_loss: 0.0803 - val_acc: 0.9751\n", "Epoch 15/15\n", "1875/1875 [==============================] - 10s 5ms/step - loss: 0.0892 - acc: 0.9723 - val_loss: 0.0767 - val_acc: 0.9757\n" ] }, { "data": { "text/plain": [ "<keras.callbacks.History at 0x177842d60>" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.fit(X_train, y_train, epochs=15, batch_size=32, validation_data=(X_test, y_test))" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "model.save('model.h5')" ] } ], "metadata": { "kernelspec": { "display_name": "keras2circom", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "71414dc221f26c27f268040756e42b4f7499507456a67f7434828e3314a20678" } } }, "nbformat": 4, "nbformat_minor": 2 }
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
test/accuracy.ipynb
{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!cd .. && python main.py models/model.h5" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "import sys\n", "import os\n", "# add parent directory to sys.path\n", "sys.path.append(os.path.dirname((os.getcwd())))\n", "from output.circuit import inference\n", "import json" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "with open('../output/circuit.json') as f:\n", " circuit = json.load(f)\n", "\n", "with open('y_test.json') as f:\n", " y_test = json.load(f)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "#0: 100.00%\n", "#1: 100.00%\n", "#2: 100.00%\n", "#3: 100.00%\n", "#4: 100.00%\n", "#5: 100.00%\n", "#6: 100.00%\n", "#7: 100.00%\n", "#8: 100.00%\n", "#9: 100.00%\n", "#10: 100.00%\n", "#11: 100.00%\n", "#12: 100.00%\n", "#13: 100.00%\n", "#14: 100.00%\n", "#15: 100.00%\n", "#16: 100.00%\n", "#17: 100.00%\n", "#18: 94.74%\n", "#19: 95.00%\n", "#20: 95.24%\n", "#21: 95.45%\n", "#22: 95.65%\n", "#23: 95.83%\n", "#24: 96.00%\n", "#25: 96.15%\n", "#26: 96.30%\n", "#27: 96.43%\n", "#28: 96.55%\n", "#29: 96.67%\n", "#30: 96.77%\n", "#31: 96.88%\n", "#32: 96.97%\n", "#33: 97.06%\n", "#34: 97.14%\n", "#35: 97.22%\n", "#36: 97.30%\n", "#37: 97.37%\n", "#38: 97.44%\n", "#39: 97.50%\n", "#40: 97.56%\n", "#41: 97.62%\n", "#42: 97.67%\n", "#43: 97.73%\n", "#44: 97.78%\n", "#45: 97.83%\n", "#46: 97.87%\n", "#47: 97.92%\n", "#48: 97.96%\n", "#49: 98.00%\n", "#50: 98.04%\n", "#51: 98.08%\n", "#52: 98.11%\n", "#53: 98.15%\n", "#54: 98.18%\n", "#55: 98.21%\n", "#56: 98.25%\n", "#57: 98.28%\n", "#58: 98.31%\n", "#59: 98.33%\n", "#60: 98.36%\n", "#61: 98.39%\n", "#62: 98.41%\n", "#63: 98.44%\n", "#64: 98.46%\n", "#65: 98.48%\n", "#66: 98.51%\n", "#67: 98.53%\n", "#68: 98.55%\n", "#69: 98.57%\n", "#70: 98.59%\n", "#71: 98.61%\n", "#72: 98.63%\n", "#73: 98.65%\n", "#74: 98.67%\n", "#75: 98.68%\n", "#76: 98.70%\n", "#77: 98.72%\n", "#78: 98.73%\n", "#79: 98.75%\n", "#80: 98.77%\n", "#81: 98.78%\n", "#82: 98.80%\n", "#83: 98.81%\n", "#84: 98.82%\n", "#85: 98.84%\n", "#86: 98.85%\n", "#87: 98.86%\n", "#88: 98.88%\n", "#89: 98.89%\n", "#90: 98.90%\n", "#91: 98.91%\n", "#92: 98.92%\n", "#93: 98.94%\n", "#94: 98.95%\n", "#95: 98.96%\n", "#96: 98.97%\n", "#97: 98.98%\n", "#98: 98.99%\n", "#99: 99.00%\n", "#100: 99.01%\n", "#101: 99.02%\n", "#102: 99.03%\n", "#103: 99.04%\n", "#104: 99.05%\n", "#105: 99.06%\n", "#106: 99.07%\n", "#107: 99.07%\n", "#108: 99.08%\n", "#109: 99.09%\n", "#110: 99.10%\n", "#111: 99.11%\n", "#112: 99.12%\n", "#113: 99.12%\n", "#114: 99.13%\n", "#115: 99.14%\n", "#116: 99.15%\n", "#117: 99.15%\n", "#118: 99.16%\n", "#119: 99.17%\n", "#120: 99.17%\n", "#121: 99.18%\n", "#122: 99.19%\n", "#123: 99.19%\n", "#124: 99.20%\n", "#125: 99.21%\n", "#126: 99.21%\n", "#127: 99.22%\n", "#128: 99.22%\n", "#129: 99.23%\n", "#130: 99.24%\n", "#131: 99.24%\n", "#132: 99.25%\n", "#133: 99.25%\n", "#134: 99.26%\n", "#135: 99.26%\n", "#136: 99.27%\n", "#137: 99.28%\n", "#138: 99.28%\n", "#139: 99.29%\n", "#140: 99.29%\n", "#141: 99.30%\n", "#142: 99.30%\n", "#143: 99.31%\n", "#144: 99.31%\n", "#145: 99.32%\n", "#146: 99.32%\n", "#147: 99.32%\n", "#148: 99.33%\n", "#149: 99.33%\n", "#150: 99.34%\n", "#151: 98.68%\n", "#152: 98.69%\n", "#153: 98.70%\n", "#154: 98.71%\n", "#155: 98.72%\n", "#156: 98.73%\n", "#157: 98.73%\n", "#158: 98.74%\n", "#159: 98.75%\n", "#160: 98.76%\n", "#161: 98.77%\n", "#162: 98.77%\n", "#163: 98.78%\n", "#164: 98.79%\n", "#165: 98.80%\n", "#166: 98.80%\n", "#167: 98.81%\n", "#168: 98.82%\n", "#169: 98.82%\n", "#170: 98.83%\n", "#171: 98.84%\n", "#172: 98.84%\n", "#173: 98.85%\n", "#174: 98.86%\n", "#175: 98.86%\n", "#176: 98.87%\n", "#177: 98.88%\n", "#178: 98.88%\n", "#179: 98.89%\n", "#180: 98.90%\n", "#181: 98.90%\n", "#182: 98.91%\n", "#183: 98.91%\n", "#184: 98.92%\n", "#185: 98.92%\n", "#186: 98.93%\n", "#187: 98.94%\n", "#188: 98.94%\n", "#189: 98.95%\n", "#190: 98.95%\n", "#191: 98.96%\n", "#192: 98.96%\n", "#193: 98.97%\n", "#194: 98.97%\n", "#195: 98.98%\n", "#196: 98.98%\n", "#197: 98.99%\n", "#198: 98.99%\n", "#199: 99.00%\n", "#200: 99.00%\n", "#201: 99.01%\n", "#202: 99.01%\n", "#203: 99.02%\n", "#204: 99.02%\n", "#205: 99.03%\n", "#206: 99.03%\n", "#207: 99.04%\n", "#208: 99.04%\n", "#209: 99.05%\n", "#210: 99.05%\n", "#211: 99.06%\n", "#212: 99.06%\n", "#213: 99.07%\n", "#214: 99.07%\n", "#215: 99.07%\n", "#216: 99.08%\n", "#217: 99.08%\n", "#218: 99.09%\n", "#219: 99.09%\n", "#220: 99.10%\n", "#221: 99.10%\n", "#222: 99.10%\n", "#223: 99.11%\n", "#224: 99.11%\n", "#225: 99.12%\n", "#226: 99.12%\n", "#227: 99.12%\n", "#228: 99.13%\n", "#229: 99.13%\n", "#230: 99.13%\n", "#231: 99.14%\n", "#232: 99.14%\n", "#233: 99.15%\n", "#234: 99.15%\n", "#235: 99.15%\n", "#236: 99.16%\n", "#237: 99.16%\n", "#238: 99.16%\n", "#239: 99.17%\n", "#240: 99.17%\n", "#241: 98.76%\n", "#242: 98.77%\n", "#243: 98.77%\n", "#244: 98.78%\n", "#245: 98.78%\n", "#246: 98.79%\n", "#247: 98.39%\n", "#248: 98.39%\n", "#249: 98.40%\n", "#250: 98.41%\n", "#251: 98.41%\n", "#252: 98.42%\n", "#253: 98.43%\n", "#254: 98.43%\n", "#255: 98.44%\n", "#256: 98.44%\n", "#257: 98.45%\n", "#258: 98.46%\n", "#259: 98.08%\n", "#260: 98.08%\n", "#261: 98.09%\n", "#262: 98.10%\n", "#263: 98.11%\n", "#264: 97.74%\n", "#265: 97.74%\n", "#266: 97.38%\n", "#267: 97.39%\n", "#268: 97.40%\n", "#269: 97.41%\n", "#270: 97.42%\n", "#271: 97.43%\n", "#272: 97.44%\n", "#273: 97.45%\n", "#274: 97.45%\n", "#275: 97.46%\n", "#276: 97.47%\n", "#277: 97.48%\n", "#278: 97.49%\n", "#279: 97.50%\n", "#280: 97.51%\n", "#281: 97.52%\n", "#282: 97.17%\n", "#283: 97.18%\n", "#284: 97.19%\n", "#285: 97.20%\n", "#286: 97.21%\n", "#287: 97.22%\n", "#288: 97.23%\n", "#289: 97.24%\n", "#290: 97.25%\n", "#291: 97.26%\n", "#292: 97.27%\n", "#293: 97.28%\n", "#294: 97.29%\n", "#295: 97.30%\n", "#296: 97.31%\n", "#297: 97.32%\n", "#298: 97.32%\n", "#299: 97.33%\n", "#300: 97.34%\n", "#301: 97.35%\n", "#302: 97.36%\n", "#303: 97.37%\n", "#304: 97.38%\n", "#305: 97.39%\n", "#306: 97.39%\n", "#307: 97.40%\n", "#308: 97.41%\n", "#309: 97.42%\n", "#310: 97.43%\n", "#311: 97.44%\n", "#312: 97.44%\n", "#313: 97.45%\n", "#314: 97.46%\n", "#315: 97.47%\n", "#316: 97.48%\n", "#317: 97.48%\n", "#318: 97.49%\n", "#319: 97.50%\n", "#320: 97.20%\n", "#321: 97.20%\n", "#322: 97.21%\n", "#323: 97.22%\n", "#324: 97.23%\n", "#325: 97.24%\n", "#326: 97.25%\n", "#327: 97.26%\n", "#328: 97.26%\n", "#329: 97.27%\n", "#330: 97.28%\n", "#331: 97.29%\n", "#332: 97.30%\n", "#333: 97.31%\n", "#334: 97.31%\n", "#335: 97.32%\n", "#336: 97.33%\n", "#337: 97.34%\n", "#338: 97.35%\n", "#339: 97.35%\n", "#340: 97.36%\n", "#341: 97.37%\n", "#342: 97.38%\n", "#343: 97.38%\n", "#344: 97.39%\n", "#345: 97.40%\n", "#346: 97.41%\n", "#347: 97.41%\n", "#348: 97.42%\n", "#349: 97.43%\n", "#350: 97.44%\n", "#351: 97.44%\n", "#352: 97.45%\n", "#353: 97.46%\n", "#354: 97.46%\n", "#355: 97.47%\n", "#356: 97.48%\n", "#357: 97.49%\n", "#358: 97.21%\n", "#359: 97.22%\n", "#360: 97.23%\n", "#361: 97.24%\n", "#362: 97.25%\n", "#363: 97.25%\n", "#364: 97.26%\n", "#365: 97.27%\n", "#366: 97.28%\n", "#367: 97.28%\n", "#368: 97.29%\n", "#369: 97.30%\n", "#370: 97.30%\n", "#371: 97.31%\n", "#372: 97.32%\n", "#373: 97.33%\n", "#374: 97.33%\n", "#375: 97.34%\n", "#376: 97.35%\n", "#377: 97.35%\n", "#378: 97.36%\n", "#379: 97.37%\n", "#380: 97.38%\n", "#381: 97.38%\n", "#382: 97.39%\n", "#383: 97.40%\n", "#384: 97.40%\n", "#385: 97.41%\n", "#386: 97.42%\n", "#387: 97.42%\n", "#388: 97.43%\n", "#389: 97.44%\n", "#390: 97.44%\n", "#391: 97.45%\n", "#392: 97.46%\n", "#393: 97.46%\n", "#394: 97.47%\n", "#395: 97.47%\n", "#396: 97.48%\n", "#397: 97.49%\n", "#398: 97.49%\n", "#399: 97.50%\n", "#400: 97.51%\n", "#401: 97.51%\n", "#402: 97.52%\n", "#403: 97.28%\n", "#404: 97.28%\n", "#405: 97.29%\n", "#406: 97.30%\n", "#407: 97.30%\n", "#408: 97.31%\n", "#409: 97.32%\n", "#410: 97.32%\n", "#411: 97.33%\n", "#412: 97.34%\n", "#413: 97.34%\n", "#414: 97.35%\n", "#415: 97.36%\n", "#416: 97.36%\n", "#417: 97.37%\n", "#418: 97.37%\n", "#419: 97.38%\n", "#420: 97.39%\n", "#421: 97.39%\n", "#422: 97.40%\n", "#423: 97.41%\n", "#424: 97.41%\n", "#425: 97.42%\n", "#426: 97.42%\n", "#427: 97.43%\n", "#428: 97.44%\n", "#429: 97.44%\n", "#430: 97.45%\n", "#431: 97.45%\n", "#432: 97.46%\n", "#433: 97.47%\n", "#434: 97.47%\n", "#435: 97.25%\n", "#436: 97.25%\n", "#437: 97.26%\n", "#438: 97.27%\n", "#439: 97.27%\n", "#440: 97.28%\n", "#441: 97.29%\n", "#442: 97.29%\n", "#443: 97.30%\n", "#444: 97.30%\n", "#445: 97.09%\n", "#446: 97.09%\n", "#447: 97.10%\n", "#448: 97.10%\n", "#449: 97.11%\n", "#450: 97.12%\n", "#451: 97.12%\n", "#452: 97.13%\n", "#453: 97.14%\n", "#454: 97.14%\n", "#455: 97.15%\n", "#456: 97.16%\n", "#457: 97.16%\n", "#458: 97.17%\n", "#459: 97.17%\n", "#460: 97.18%\n", "#461: 97.19%\n", "#462: 97.19%\n", "#463: 97.20%\n", "#464: 96.99%\n", "#465: 97.00%\n", "#466: 97.00%\n", "#467: 97.01%\n", "#468: 97.01%\n", "#469: 97.02%\n", "#470: 97.03%\n", "#471: 97.03%\n", "#472: 97.04%\n", "#473: 97.05%\n", "#474: 97.05%\n", "#475: 97.06%\n", "#476: 97.06%\n", "#477: 97.07%\n", "#478: 97.08%\n", "#479: 97.08%\n", "#480: 97.09%\n", "#481: 97.10%\n", "#482: 97.10%\n", "#483: 97.11%\n", "#484: 97.11%\n", "#485: 97.12%\n", "#486: 97.13%\n", "#487: 97.13%\n", "#488: 97.14%\n", "#489: 97.14%\n", "#490: 97.15%\n", "#491: 97.15%\n", "#492: 97.16%\n", "#493: 97.17%\n", "#494: 97.17%\n", "#495: 96.98%\n", "#496: 96.98%\n", "#497: 96.99%\n", "#498: 96.99%\n", "#499: 97.00%\n", "#500: 97.01%\n", "#501: 97.01%\n", "#502: 97.02%\n", "#503: 97.02%\n", "#504: 97.03%\n", "#505: 97.04%\n", "#506: 97.04%\n", "#507: 97.05%\n", "#508: 97.05%\n", "#509: 97.06%\n", "#510: 97.06%\n", "#511: 97.07%\n", "#512: 97.08%\n", "#513: 97.08%\n", "#514: 97.09%\n", "#515: 97.09%\n", "#516: 97.10%\n", "#517: 97.10%\n", "#518: 97.11%\n", "#519: 97.12%\n", "#520: 97.12%\n", "#521: 97.13%\n", "#522: 97.13%\n", "#523: 97.14%\n", "#524: 97.14%\n", "#525: 97.15%\n", "#526: 97.15%\n", "#527: 97.16%\n", "#528: 97.16%\n", "#529: 97.17%\n", "#530: 97.18%\n", "#531: 97.18%\n", "#532: 97.19%\n", "#533: 97.19%\n", "#534: 97.20%\n", "#535: 97.20%\n", "#536: 97.21%\n", "#537: 97.21%\n", "#538: 97.22%\n", "#539: 97.22%\n", "#540: 97.23%\n", "#541: 97.23%\n", "#542: 97.05%\n", "#543: 97.06%\n", "#544: 97.06%\n", "#545: 97.07%\n", "#546: 97.07%\n", "#547: 97.08%\n", "#548: 97.09%\n", "#549: 97.09%\n", "#550: 97.10%\n", "#551: 97.10%\n", "#552: 97.11%\n", "#553: 97.11%\n", "#554: 97.12%\n", "#555: 97.12%\n", "#556: 97.13%\n", "#557: 97.13%\n", "#558: 97.14%\n", "#559: 97.14%\n", "#560: 97.15%\n", "#561: 97.15%\n", "#562: 97.16%\n", "#563: 97.16%\n", "#564: 97.17%\n", "#565: 97.17%\n", "#566: 97.18%\n", "#567: 97.18%\n", "#568: 97.19%\n", "#569: 97.19%\n", "#570: 97.20%\n", "#571: 97.20%\n", "#572: 97.21%\n", "#573: 97.21%\n", "#574: 97.22%\n", "#575: 97.22%\n", "#576: 97.23%\n", "#577: 97.23%\n", "#578: 97.24%\n", "#579: 97.24%\n", "#580: 97.25%\n", "#581: 97.25%\n", "#582: 97.08%\n", "#583: 97.09%\n", "#584: 97.09%\n", "#585: 97.10%\n", "#586: 97.10%\n", "#587: 97.11%\n", "#588: 97.11%\n", "#589: 97.12%\n", "#590: 97.12%\n", "#591: 97.13%\n", "#592: 97.13%\n", "#593: 97.14%\n", "#594: 97.14%\n", "#595: 97.15%\n", "#596: 97.15%\n", "#597: 97.16%\n", "#598: 97.16%\n", "#599: 97.17%\n", "#600: 97.17%\n", "#601: 97.18%\n", "#602: 97.18%\n", "#603: 97.19%\n", "#604: 97.19%\n", "#605: 97.03%\n", "#606: 97.03%\n", "#607: 97.04%\n", "#608: 97.04%\n", "#609: 97.05%\n", "#610: 97.05%\n", "#611: 97.06%\n", "#612: 97.06%\n", "#613: 97.07%\n", "#614: 97.07%\n", "#615: 97.08%\n", "#616: 97.08%\n", "#617: 97.09%\n", "#618: 97.09%\n", "#619: 97.10%\n", "#620: 97.10%\n", "#621: 97.11%\n", "#622: 97.11%\n", "#623: 97.12%\n", "#624: 97.12%\n", "#625: 97.12%\n", "#626: 97.13%\n", "#627: 97.13%\n", "#628: 97.14%\n", "#629: 97.14%\n", "#630: 97.15%\n", "#631: 97.15%\n", "#632: 97.16%\n", "#633: 97.16%\n", "#634: 97.17%\n", "#635: 97.17%\n", "#636: 97.17%\n", "#637: 97.18%\n", "#638: 97.18%\n", "#639: 97.19%\n", "#640: 97.19%\n", "#641: 97.20%\n", "#642: 97.20%\n", "#643: 97.20%\n", "#644: 97.21%\n", "#645: 97.21%\n", "#646: 97.22%\n", "#647: 97.22%\n", "#648: 97.23%\n", "#649: 97.23%\n", "#650: 97.24%\n", "#651: 97.24%\n", "#652: 97.24%\n", "#653: 97.25%\n", "#654: 97.25%\n", "#655: 97.26%\n", "#656: 97.26%\n", "#657: 97.26%\n", "#658: 97.27%\n", "#659: 97.27%\n", "#660: 97.28%\n", "#661: 97.28%\n", "#662: 97.29%\n", "#663: 97.29%\n", "#664: 97.29%\n", "#665: 97.30%\n", "#666: 97.30%\n", "#667: 97.31%\n", "#668: 97.31%\n", "#669: 97.31%\n", "#670: 97.32%\n", "#671: 97.32%\n", "#672: 97.33%\n", "#673: 97.33%\n", "#674: 97.33%\n", "#675: 97.34%\n", "#676: 97.34%\n", "#677: 97.35%\n", "#678: 97.35%\n", "#679: 97.35%\n", "#680: 97.36%\n", "#681: 97.36%\n", "#682: 97.36%\n", "#683: 97.37%\n", "#684: 97.23%\n", "#685: 97.23%\n", "#686: 97.23%\n", "#687: 97.24%\n", "#688: 97.24%\n", "#689: 97.10%\n", "#690: 97.11%\n", "#691: 97.11%\n", "#692: 97.11%\n", "#693: 97.12%\n", "#694: 97.12%\n", "#695: 97.13%\n", "#696: 97.13%\n", "#697: 97.13%\n", "#698: 97.14%\n", "#699: 97.14%\n", "#700: 97.15%\n", "#701: 97.15%\n", "#702: 97.16%\n", "#703: 97.16%\n", "#704: 97.16%\n", "#705: 97.17%\n", "#706: 97.17%\n", "#707: 97.18%\n", "#708: 97.18%\n", "#709: 97.18%\n", "#710: 97.19%\n", "#711: 97.19%\n", "#712: 97.19%\n", "#713: 97.20%\n", "#714: 97.20%\n", "#715: 97.21%\n", "#716: 97.21%\n", "#717: 97.08%\n", "#718: 97.08%\n", "#719: 97.08%\n", "#720: 97.09%\n", "#721: 97.09%\n", "#722: 97.10%\n", "#723: 97.10%\n", "#724: 97.10%\n", "#725: 97.11%\n", "#726: 96.97%\n", "#727: 96.98%\n", "#728: 96.98%\n", "#729: 96.99%\n", "#730: 96.99%\n", "#731: 96.99%\n", "#732: 97.00%\n", "#733: 97.00%\n", "#734: 97.01%\n", "#735: 97.01%\n", "#736: 97.01%\n", "#737: 97.02%\n", "#738: 97.02%\n", "#739: 97.03%\n", "#740: 97.03%\n", "#741: 97.04%\n", "#742: 97.04%\n", "#743: 97.04%\n", "#744: 97.05%\n", "#745: 97.05%\n", "#746: 97.05%\n", "#747: 97.06%\n", "#748: 97.06%\n", "#749: 97.07%\n", "#750: 97.07%\n", "#751: 97.07%\n", "#752: 97.08%\n", "#753: 97.08%\n", "#754: 97.09%\n", "#755: 97.09%\n", "#756: 97.09%\n", "#757: 97.10%\n", "#758: 97.10%\n", "#759: 97.11%\n", "#760: 97.11%\n", "#761: 97.11%\n", "#762: 97.12%\n", "#763: 97.12%\n", "#764: 97.12%\n", "#765: 97.13%\n", "#766: 97.13%\n", "#767: 97.14%\n", "#768: 97.14%\n", "#769: 97.14%\n", "#770: 97.15%\n", "#771: 97.15%\n", "#772: 97.15%\n", "#773: 97.16%\n", "#774: 97.16%\n", "#775: 97.16%\n", "#776: 97.17%\n", "#777: 97.17%\n", "#778: 97.18%\n", "#779: 97.18%\n", "#780: 97.18%\n", "#781: 97.19%\n", "#782: 97.19%\n", "#783: 97.19%\n", "#784: 97.20%\n", "#785: 97.20%\n", "#786: 97.20%\n", "#787: 97.21%\n", "#788: 97.21%\n", "#789: 97.22%\n", "#790: 97.22%\n", "#791: 97.22%\n", "#792: 97.23%\n", "#793: 97.23%\n", "#794: 97.23%\n", "#795: 97.24%\n", "#796: 97.24%\n", "#797: 97.24%\n", "#798: 97.25%\n", "#799: 97.25%\n", "#800: 97.25%\n", "#801: 97.26%\n", "#802: 97.26%\n", "#803: 97.26%\n", "#804: 97.27%\n", "#805: 97.27%\n", "#806: 97.27%\n", "#807: 97.28%\n", "#808: 97.28%\n", "#809: 97.28%\n", "#810: 97.29%\n", "#811: 97.29%\n", "#812: 97.29%\n", "#813: 97.17%\n", "#814: 97.18%\n", "#815: 97.18%\n", "#816: 97.18%\n", "#817: 97.19%\n", "#818: 97.19%\n", "#819: 97.20%\n", "#820: 97.20%\n", "#821: 97.20%\n", "#822: 97.21%\n", "#823: 97.21%\n", "#824: 97.21%\n", "#825: 97.22%\n", "#826: 97.22%\n", "#827: 97.22%\n", "#828: 97.23%\n", "#829: 97.23%\n", "#830: 97.23%\n", "#831: 97.24%\n", "#832: 97.24%\n", "#833: 97.24%\n", "#834: 97.25%\n", "#835: 97.25%\n", "#836: 97.25%\n", "#837: 97.26%\n", "#838: 97.26%\n", "#839: 97.26%\n", "#840: 97.27%\n", "#841: 97.27%\n", "#842: 97.27%\n", "#843: 97.27%\n", "#844: 97.28%\n", "#845: 97.28%\n", "#846: 97.28%\n", "#847: 97.29%\n", "#848: 97.29%\n", "#849: 97.29%\n", "#850: 97.30%\n", "#851: 97.30%\n", "#852: 97.30%\n", "#853: 97.31%\n", "#854: 97.31%\n", "#855: 97.31%\n", "#856: 97.32%\n", "#857: 97.32%\n", "#858: 97.32%\n", "#859: 97.33%\n", "#860: 97.33%\n", "#861: 97.33%\n", "#862: 97.33%\n", "#863: 97.34%\n", "#864: 97.34%\n", "#865: 97.34%\n", "#866: 97.35%\n", "#867: 97.35%\n", "#868: 97.35%\n", "#869: 97.36%\n", "#870: 97.36%\n", "#871: 97.36%\n", "#872: 97.37%\n", "#873: 97.37%\n", "#874: 97.37%\n", "#875: 97.37%\n", "#876: 97.38%\n", "#877: 97.38%\n", "#878: 97.38%\n", "#879: 97.39%\n", "#880: 97.39%\n", "#881: 97.39%\n", "#882: 97.40%\n", "#883: 97.40%\n", "#884: 97.40%\n", "#885: 97.40%\n", "#886: 97.41%\n", "#887: 97.41%\n", "#888: 97.41%\n", "#889: 97.42%\n", "#890: 97.42%\n", "#891: 97.42%\n", "#892: 97.42%\n", "#893: 97.43%\n", "#894: 97.43%\n", "#895: 97.43%\n", "#896: 97.44%\n", "#897: 97.44%\n", "#898: 97.33%\n", "#899: 97.33%\n", "#900: 97.34%\n", "#901: 97.34%\n", "#902: 97.34%\n", "#903: 97.35%\n", "#904: 97.35%\n", "#905: 97.35%\n", "#906: 97.35%\n", "#907: 97.36%\n", "#908: 97.36%\n", "#909: 97.36%\n", "#910: 97.37%\n", "#911: 97.37%\n", "#912: 97.37%\n", "#913: 97.37%\n", "#914: 97.38%\n", "#915: 97.38%\n", "#916: 97.38%\n", "#917: 97.39%\n", "#918: 97.39%\n", "#919: 97.39%\n", "#920: 97.39%\n", "#921: 97.40%\n", "#922: 97.40%\n", "#923: 97.40%\n", "#924: 97.41%\n", "#925: 97.41%\n", "#926: 97.41%\n", "#927: 97.41%\n", "#928: 97.42%\n", "#929: 97.42%\n", "#930: 97.42%\n", "#931: 97.42%\n", "#932: 97.43%\n", "#933: 97.43%\n", "#934: 97.43%\n", "#935: 97.44%\n", "#936: 97.44%\n", "#937: 97.44%\n", "#938: 97.44%\n", "#939: 97.45%\n", "#940: 97.45%\n", "#941: 97.45%\n", "#942: 97.45%\n", "#943: 97.46%\n", "#944: 97.46%\n", "#945: 97.46%\n", "#946: 97.47%\n", "#947: 97.36%\n", "#948: 97.37%\n", "#949: 97.37%\n", "#950: 97.37%\n", "#951: 97.37%\n", "#952: 97.38%\n", "#953: 97.38%\n", "#954: 97.38%\n", "#955: 97.38%\n", "#956: 97.28%\n", "#957: 97.29%\n", "#958: 97.29%\n", "#959: 97.29%\n", "#960: 97.29%\n", "#961: 97.30%\n", "#962: 97.30%\n", "#963: 97.30%\n", "#964: 97.31%\n", "#965: 97.20%\n", "#966: 97.21%\n", "#967: 97.21%\n", "#968: 97.21%\n", "#969: 97.22%\n", "#970: 97.22%\n", "#971: 97.22%\n", "#972: 97.23%\n", "#973: 97.23%\n", "#974: 97.23%\n", "#975: 97.23%\n", "#976: 97.24%\n", "#977: 97.24%\n", "#978: 97.24%\n", "#979: 97.24%\n", "#980: 97.25%\n", "#981: 97.25%\n", "#982: 97.25%\n", "#983: 97.26%\n", "#984: 97.26%\n", "#985: 97.26%\n", "#986: 97.26%\n", "#987: 97.27%\n", "#988: 97.27%\n", "#989: 97.27%\n", "#990: 97.28%\n", "#991: 97.28%\n", "#992: 97.28%\n", "#993: 97.28%\n", "#994: 97.29%\n", "#995: 97.29%\n", "#996: 97.29%\n", "#997: 97.29%\n", "#998: 97.30%\n", "#999: 97.30%\n", "#1000: 97.30%\n", "#1001: 97.31%\n", "#1002: 97.31%\n", "#1003: 97.31%\n", "#1004: 97.31%\n", "#1005: 97.32%\n", "#1006: 97.32%\n", "#1007: 97.32%\n", "#1008: 97.32%\n", "#1009: 97.33%\n", "#1010: 97.33%\n", "#1011: 97.33%\n", "#1012: 97.33%\n", "#1013: 97.34%\n", "#1014: 97.24%\n", "#1015: 97.24%\n", "#1016: 97.25%\n", "#1017: 97.25%\n", "#1018: 97.25%\n", "#1019: 97.25%\n", "#1020: 97.26%\n", "#1021: 97.26%\n", "#1022: 97.26%\n", "#1023: 97.27%\n", "#1024: 97.27%\n", "#1025: 97.27%\n", "#1026: 97.27%\n", "#1027: 97.28%\n", "#1028: 97.28%\n", "#1029: 97.28%\n", "#1030: 97.28%\n", "#1031: 97.29%\n", "#1032: 97.29%\n", "#1033: 97.29%\n", "#1034: 97.29%\n", "#1035: 97.30%\n", "#1036: 97.30%\n", "#1037: 97.30%\n", "#1038: 97.31%\n", "#1039: 97.21%\n", "#1040: 97.21%\n", "#1041: 97.22%\n", "#1042: 97.22%\n", "#1043: 97.22%\n", "#1044: 97.22%\n", "#1045: 97.23%\n", "#1046: 97.23%\n", "#1047: 97.23%\n", "#1048: 97.24%\n", "#1049: 97.24%\n", "#1050: 97.24%\n", "#1051: 97.24%\n", "#1052: 97.25%\n", "#1053: 97.25%\n", "#1054: 97.25%\n", "#1055: 97.25%\n", "#1056: 97.26%\n", "#1057: 97.26%\n", "#1058: 97.26%\n", "#1059: 97.26%\n", "#1060: 97.27%\n", "#1061: 97.27%\n", "#1062: 97.18%\n", "#1063: 97.18%\n", "#1064: 97.18%\n", "#1065: 97.19%\n", "#1066: 97.19%\n", "#1067: 97.19%\n", "#1068: 97.10%\n", "#1069: 97.10%\n", "#1070: 97.11%\n", "#1071: 97.11%\n", "#1072: 97.11%\n", "#1073: 97.11%\n", "#1074: 97.12%\n", "#1075: 97.12%\n", "#1076: 97.12%\n", "#1077: 97.12%\n", "#1078: 97.13%\n", "#1079: 97.13%\n", "#1080: 97.13%\n", "#1081: 97.13%\n", "#1082: 97.14%\n", "#1083: 97.14%\n", "#1084: 97.14%\n", "#1085: 97.15%\n", "#1086: 97.15%\n", "#1087: 97.15%\n", "#1088: 97.15%\n", "#1089: 97.16%\n", "#1090: 97.16%\n", "#1091: 97.16%\n", "#1092: 97.16%\n", "#1093: 97.17%\n", "#1094: 97.17%\n", "#1095: 97.17%\n", "#1096: 97.17%\n", "#1097: 97.18%\n", "#1098: 97.18%\n", "#1099: 97.18%\n", "#1100: 97.18%\n", "#1101: 97.19%\n", "#1102: 97.19%\n", "#1103: 97.19%\n", "#1104: 97.19%\n", "#1105: 97.20%\n", "#1106: 97.20%\n", "#1107: 97.11%\n", "#1108: 97.11%\n", "#1109: 97.12%\n", "#1110: 97.12%\n", "#1111: 97.12%\n", "#1112: 97.04%\n", "#1113: 97.04%\n", "#1114: 96.95%\n", "#1115: 96.95%\n", "#1116: 96.96%\n", "#1117: 96.96%\n", "#1118: 96.96%\n", "#1119: 96.96%\n", "#1120: 96.97%\n", "#1121: 96.97%\n", "#1122: 96.97%\n", "#1123: 96.98%\n", "#1124: 96.98%\n", "#1125: 96.89%\n", "#1126: 96.89%\n", "#1127: 96.90%\n", "#1128: 96.90%\n", "#1129: 96.90%\n", "#1130: 96.91%\n", "#1131: 96.91%\n", "#1132: 96.91%\n", "#1133: 96.91%\n", "#1134: 96.92%\n", "#1135: 96.92%\n", "#1136: 96.92%\n", "#1137: 96.92%\n", "#1138: 96.93%\n", "#1139: 96.93%\n", "#1140: 96.93%\n", "#1141: 96.94%\n", "#1142: 96.94%\n", "#1143: 96.85%\n", "#1144: 96.86%\n", "#1145: 96.86%\n", "#1146: 96.86%\n", "#1147: 96.86%\n", "#1148: 96.87%\n", "#1149: 96.87%\n", "#1150: 96.87%\n", "#1151: 96.88%\n", "#1152: 96.88%\n", "#1153: 96.88%\n", "#1154: 96.88%\n", "#1155: 96.89%\n", "#1156: 96.89%\n", "#1157: 96.89%\n", "#1158: 96.89%\n", "#1159: 96.90%\n", "#1160: 96.90%\n", "#1161: 96.90%\n", "#1162: 96.90%\n", "#1163: 96.91%\n", "#1164: 96.91%\n", "#1165: 96.91%\n", "#1166: 96.92%\n", "#1167: 96.92%\n", "#1168: 96.92%\n", "#1169: 96.92%\n", "#1170: 96.93%\n", "#1171: 96.93%\n", "#1172: 96.93%\n", "#1173: 96.93%\n", "#1174: 96.94%\n", "#1175: 96.94%\n", "#1176: 96.94%\n", "#1177: 96.94%\n", "#1178: 96.95%\n", "#1179: 96.95%\n", "#1180: 96.95%\n", "#1181: 96.95%\n", "#1182: 96.87%\n", "#1183: 96.88%\n", "#1184: 96.88%\n", "#1185: 96.88%\n", "#1186: 96.88%\n", "#1187: 96.89%\n", "#1188: 96.89%\n", "#1189: 96.89%\n", "#1190: 96.89%\n", "#1191: 96.81%\n", "#1192: 96.81%\n", "#1193: 96.82%\n", "#1194: 96.82%\n", "#1195: 96.82%\n", "#1196: 96.83%\n", "#1197: 96.83%\n", "#1198: 96.83%\n", "#1199: 96.83%\n", "#1200: 96.84%\n", "#1201: 96.84%\n", "#1202: 96.84%\n", "#1203: 96.84%\n", "#1204: 96.85%\n", "#1205: 96.85%\n", "#1206: 96.85%\n", "#1207: 96.85%\n", "#1208: 96.86%\n", "#1209: 96.86%\n", "#1210: 96.86%\n", "#1211: 96.86%\n", "#1212: 96.87%\n", "#1213: 96.87%\n", "#1214: 96.87%\n", "#1215: 96.88%\n", "#1216: 96.88%\n", "#1217: 96.88%\n", "#1218: 96.88%\n", "#1219: 96.89%\n", "#1220: 96.89%\n", "#1221: 96.89%\n", "#1222: 96.89%\n", "#1223: 96.90%\n", "#1224: 96.90%\n", "#1225: 96.90%\n", "#1226: 96.82%\n", "#1227: 96.82%\n", "#1228: 96.83%\n", "#1229: 96.83%\n", "#1230: 96.83%\n", "#1231: 96.83%\n", "#1232: 96.84%\n", "#1233: 96.84%\n", "#1234: 96.84%\n", "#1235: 96.84%\n", "#1236: 96.85%\n", "#1237: 96.85%\n", "#1238: 96.85%\n", "#1239: 96.85%\n", "#1240: 96.86%\n", "#1241: 96.86%\n", "#1242: 96.86%\n", "#1243: 96.86%\n", "#1244: 96.87%\n", "#1245: 96.87%\n", "#1246: 96.87%\n", "#1247: 96.79%\n", "#1248: 96.80%\n", "#1249: 96.80%\n", "#1250: 96.80%\n", "#1251: 96.81%\n", "#1252: 96.81%\n", "#1253: 96.81%\n", "#1254: 96.81%\n", "#1255: 96.82%\n", "#1256: 96.82%\n", "#1257: 96.82%\n", "#1258: 96.82%\n", "#1259: 96.83%\n", "#1260: 96.75%\n", "#1261: 96.75%\n", "#1262: 96.75%\n", "#1263: 96.76%\n", "#1264: 96.76%\n", "#1265: 96.76%\n", "#1266: 96.76%\n", "#1267: 96.77%\n", "#1268: 96.77%\n", "#1269: 96.77%\n", "#1270: 96.77%\n", "#1271: 96.78%\n", "#1272: 96.78%\n", "#1273: 96.78%\n", "#1274: 96.78%\n", "#1275: 96.79%\n", "#1276: 96.79%\n", "#1277: 96.79%\n", "#1278: 96.79%\n", "#1279: 96.80%\n", "#1280: 96.80%\n", "#1281: 96.80%\n", "#1282: 96.80%\n", "#1283: 96.81%\n", "#1284: 96.81%\n", "#1285: 96.81%\n", "#1286: 96.81%\n", "#1287: 96.82%\n", "#1288: 96.82%\n", "#1289: 96.82%\n", "#1290: 96.75%\n", "#1291: 96.75%\n", "#1292: 96.75%\n", "#1293: 96.75%\n", "#1294: 96.76%\n", "#1295: 96.76%\n", "#1296: 96.76%\n", "#1297: 96.76%\n", "#1298: 96.77%\n", "#1299: 96.69%\n", "#1300: 96.69%\n", "#1301: 96.70%\n", "#1302: 96.70%\n", "#1303: 96.70%\n", "#1304: 96.70%\n", "#1305: 96.71%\n", "#1306: 96.71%\n", "#1307: 96.71%\n", "#1308: 96.72%\n", "#1309: 96.72%\n", "#1310: 96.72%\n", "#1311: 96.72%\n", "#1312: 96.73%\n", "#1313: 96.73%\n", "#1314: 96.73%\n", "#1315: 96.73%\n", "#1316: 96.74%\n", "#1317: 96.74%\n", "#1318: 96.74%\n", "#1319: 96.67%\n", "#1320: 96.67%\n", "#1321: 96.67%\n", "#1322: 96.67%\n", "#1323: 96.68%\n", "#1324: 96.68%\n", "#1325: 96.68%\n", "#1326: 96.68%\n", "#1327: 96.69%\n", "#1328: 96.69%\n", "#1329: 96.69%\n", "#1330: 96.69%\n", "#1331: 96.70%\n", "#1332: 96.70%\n", "#1333: 96.70%\n", "#1334: 96.70%\n", "#1335: 96.71%\n", "#1336: 96.71%\n", "#1337: 96.71%\n", "#1338: 96.71%\n", "#1339: 96.72%\n", "#1340: 96.72%\n", "#1341: 96.72%\n", "#1342: 96.72%\n", "#1343: 96.73%\n", "#1344: 96.73%\n", "#1345: 96.73%\n", "#1346: 96.73%\n", "#1347: 96.74%\n", "#1348: 96.74%\n", "#1349: 96.74%\n", "#1350: 96.74%\n", "#1351: 96.75%\n", "#1352: 96.75%\n", "#1353: 96.75%\n", "#1354: 96.75%\n", "#1355: 96.76%\n", "#1356: 96.76%\n", "#1357: 96.76%\n", "#1358: 96.76%\n", "#1359: 96.76%\n", "#1360: 96.77%\n", "#1361: 96.77%\n", "#1362: 96.77%\n", "#1363: 96.77%\n", "#1364: 96.70%\n", "#1365: 96.71%\n", "#1366: 96.71%\n", "#1367: 96.71%\n", "#1368: 96.71%\n", "#1369: 96.72%\n", "#1370: 96.72%\n", "#1371: 96.72%\n", "#1372: 96.72%\n", "#1373: 96.72%\n", "#1374: 96.73%\n", "#1375: 96.73%\n", "#1376: 96.73%\n", "#1377: 96.73%\n", "#1378: 96.74%\n", "#1379: 96.74%\n", "#1380: 96.74%\n", "#1381: 96.74%\n", "#1382: 96.75%\n", "#1383: 96.68%\n", "#1384: 96.68%\n", "#1385: 96.68%\n", "#1386: 96.68%\n", "#1387: 96.69%\n", "#1388: 96.69%\n", "#1389: 96.69%\n", "#1390: 96.69%\n", "#1391: 96.70%\n", "#1392: 96.70%\n", "#1393: 96.70%\n", "#1394: 96.70%\n", "#1395: 96.70%\n", "#1396: 96.71%\n", "#1397: 96.71%\n", "#1398: 96.71%\n", "#1399: 96.71%\n", "#1400: 96.72%\n", "#1401: 96.72%\n", "#1402: 96.72%\n", "#1403: 96.72%\n", "#1404: 96.73%\n", "#1405: 96.73%\n", "#1406: 96.73%\n", "#1407: 96.73%\n", "#1408: 96.74%\n", "#1409: 96.74%\n", "#1410: 96.74%\n", "#1411: 96.74%\n", "#1412: 96.74%\n", "#1413: 96.75%\n", "#1414: 96.75%\n", "#1415: 96.68%\n", "#1416: 96.68%\n", "#1417: 96.69%\n", "#1418: 96.69%\n", "#1419: 96.69%\n", "#1420: 96.69%\n", "#1421: 96.69%\n", "#1422: 96.70%\n", "#1423: 96.70%\n", "#1424: 96.70%\n", "#1425: 96.70%\n", "#1426: 96.71%\n", "#1427: 96.71%\n", "#1428: 96.71%\n", "#1429: 96.71%\n", "#1430: 96.72%\n", "#1431: 96.72%\n", "#1432: 96.72%\n", "#1433: 96.72%\n", "#1434: 96.72%\n", "#1435: 96.73%\n", "#1436: 96.73%\n", "#1437: 96.73%\n", "#1438: 96.73%\n", "#1439: 96.74%\n", "#1440: 96.67%\n", "#1441: 96.67%\n", "#1442: 96.67%\n", "#1443: 96.68%\n", "#1444: 96.68%\n", "#1445: 96.68%\n", "#1446: 96.68%\n", "#1447: 96.69%\n", "#1448: 96.69%\n", "#1449: 96.69%\n", "#1450: 96.69%\n", "#1451: 96.69%\n", "#1452: 96.70%\n", "#1453: 96.70%\n", "#1454: 96.70%\n", "#1455: 96.70%\n", "#1456: 96.71%\n", "#1457: 96.71%\n", "#1458: 96.71%\n", "#1459: 96.71%\n", "#1460: 96.71%\n", "#1461: 96.72%\n", "#1462: 96.72%\n", "#1463: 96.72%\n", "#1464: 96.72%\n", "#1465: 96.73%\n", "#1466: 96.73%\n", "#1467: 96.73%\n", "#1468: 96.73%\n", "#1469: 96.73%\n", "#1470: 96.74%\n", "#1471: 96.74%\n", "#1472: 96.74%\n", "#1473: 96.74%\n", "#1474: 96.75%\n", "#1475: 96.75%\n", "#1476: 96.75%\n", "#1477: 96.75%\n", "#1478: 96.75%\n", "#1479: 96.76%\n", "#1480: 96.76%\n", "#1481: 96.76%\n", "#1482: 96.76%\n", "#1483: 96.77%\n", "#1484: 96.77%\n", "#1485: 96.77%\n", "#1486: 96.77%\n", "#1487: 96.77%\n", "#1488: 96.78%\n", "#1489: 96.78%\n", "#1490: 96.78%\n", "#1491: 96.78%\n", "#1492: 96.78%\n", "#1493: 96.79%\n", "#1494: 96.79%\n", "#1495: 96.79%\n", "#1496: 96.79%\n", "#1497: 96.80%\n", "#1498: 96.80%\n", "#1499: 96.80%\n", "#1500: 96.80%\n", "#1501: 96.80%\n", "#1502: 96.81%\n", "#1503: 96.81%\n", "#1504: 96.81%\n", "#1505: 96.81%\n", "#1506: 96.81%\n", "#1507: 96.82%\n", "#1508: 96.82%\n", "#1509: 96.82%\n", "#1510: 96.82%\n", "#1511: 96.83%\n", "#1512: 96.83%\n", "#1513: 96.83%\n", "#1514: 96.83%\n", "#1515: 96.83%\n", "#1516: 96.84%\n", "#1517: 96.84%\n", "#1518: 96.84%\n", "#1519: 96.84%\n", "#1520: 96.84%\n", "#1521: 96.85%\n", "#1522: 96.85%\n", "#1523: 96.85%\n", "#1524: 96.85%\n", "#1525: 96.85%\n", "#1526: 96.86%\n", "#1527: 96.79%\n", "#1528: 96.80%\n", "#1529: 96.80%\n", "#1530: 96.73%\n", "#1531: 96.74%\n", "#1532: 96.74%\n", "#1533: 96.74%\n", "#1534: 96.74%\n", "#1535: 96.74%\n", "#1536: 96.75%\n", "#1537: 96.75%\n", "#1538: 96.75%\n", "#1539: 96.75%\n", "#1540: 96.76%\n", "#1541: 96.76%\n", "#1542: 96.76%\n", "#1543: 96.76%\n", "#1544: 96.76%\n", "#1545: 96.77%\n", "#1546: 96.77%\n", "#1547: 96.77%\n", "#1548: 96.77%\n", "#1549: 96.77%\n", "#1550: 96.78%\n", "#1551: 96.78%\n", "#1552: 96.78%\n", "#1553: 96.72%\n", "#1554: 96.72%\n", "#1555: 96.72%\n", "#1556: 96.72%\n", "#1557: 96.73%\n", "#1558: 96.73%\n", "#1559: 96.67%\n", "#1560: 96.67%\n", "#1561: 96.67%\n", "#1562: 96.67%\n", "#1563: 96.68%\n", "#1564: 96.68%\n", "#1565: 96.68%\n", "#1566: 96.68%\n", "#1567: 96.68%\n", "#1568: 96.69%\n", "#1569: 96.69%\n", "#1570: 96.69%\n", "#1571: 96.69%\n", "#1572: 96.69%\n", "#1573: 96.70%\n", "#1574: 96.70%\n", "#1575: 96.70%\n", "#1576: 96.70%\n", "#1577: 96.70%\n", "#1578: 96.71%\n", "#1579: 96.71%\n", "#1580: 96.71%\n", "#1581: 96.71%\n", "#1582: 96.72%\n", "#1583: 96.72%\n", "#1584: 96.72%\n", "#1585: 96.72%\n", "#1586: 96.72%\n", "#1587: 96.73%\n", "#1588: 96.73%\n", "#1589: 96.73%\n", "#1590: 96.73%\n", "#1591: 96.73%\n", "#1592: 96.74%\n", "#1593: 96.74%\n", "#1594: 96.74%\n", "#1595: 96.74%\n", "#1596: 96.74%\n", "#1597: 96.75%\n", "#1598: 96.75%\n", "#1599: 96.75%\n", "#1600: 96.75%\n", "#1601: 96.75%\n", "#1602: 96.76%\n", "#1603: 96.76%\n", "#1604: 96.76%\n", "#1605: 96.76%\n", "#1606: 96.76%\n", "#1607: 96.70%\n", "#1608: 96.71%\n", "#1609: 96.71%\n", "#1610: 96.71%\n", "#1611: 96.65%\n", "#1612: 96.65%\n", "#1613: 96.65%\n", "#1614: 96.66%\n", "#1615: 96.66%\n", "#1616: 96.66%\n", "#1617: 96.66%\n", "#1618: 96.66%\n", "#1619: 96.67%\n", "#1620: 96.67%\n", "#1621: 96.61%\n", "#1622: 96.61%\n", "#1623: 96.61%\n", "#1624: 96.62%\n", "#1625: 96.62%\n", "#1626: 96.62%\n", "#1627: 96.62%\n", "#1628: 96.62%\n", "#1629: 96.63%\n", "#1630: 96.63%\n", "#1631: 96.63%\n", "#1632: 96.63%\n", "#1633: 96.63%\n", "#1634: 96.64%\n", "#1635: 96.64%\n", "#1636: 96.64%\n", "#1637: 96.64%\n", "#1638: 96.64%\n", "#1639: 96.65%\n", "#1640: 96.59%\n", "#1641: 96.59%\n", "#1642: 96.59%\n", "#1643: 96.59%\n", "#1644: 96.60%\n", "#1645: 96.60%\n", "#1646: 96.60%\n", "#1647: 96.60%\n", "#1648: 96.60%\n", "#1649: 96.61%\n", "#1650: 96.61%\n", "#1651: 96.61%\n", "#1652: 96.61%\n", "#1653: 96.61%\n", "#1654: 96.62%\n", "#1655: 96.62%\n", "#1656: 96.62%\n", "#1657: 96.62%\n", "#1658: 96.62%\n", "#1659: 96.63%\n", "#1660: 96.63%\n", "#1661: 96.63%\n", "#1662: 96.63%\n", "#1663: 96.63%\n", "#1664: 96.64%\n", "#1665: 96.64%\n", "#1666: 96.64%\n", "#1667: 96.64%\n", "#1668: 96.64%\n", "#1669: 96.65%\n", "#1670: 96.65%\n", "#1671: 96.65%\n", "#1672: 96.65%\n", "#1673: 96.65%\n", "#1674: 96.66%\n", "#1675: 96.66%\n", "#1676: 96.66%\n", "#1677: 96.66%\n", "#1678: 96.66%\n", "#1679: 96.67%\n", "#1680: 96.67%\n", "#1681: 96.61%\n", "#1682: 96.61%\n", "#1683: 96.62%\n", "#1684: 96.62%\n", "#1685: 96.62%\n", "#1686: 96.56%\n", "#1687: 96.56%\n", "#1688: 96.57%\n", "#1689: 96.57%\n", "#1690: 96.57%\n", "#1691: 96.57%\n", "#1692: 96.57%\n", "#1693: 96.58%\n", "#1694: 96.58%\n", "#1695: 96.58%\n", "#1696: 96.58%\n", "#1697: 96.58%\n", "#1698: 96.59%\n", "#1699: 96.59%\n", "#1700: 96.59%\n", "#1701: 96.59%\n", "#1702: 96.59%\n", "#1703: 96.60%\n", "#1704: 96.60%\n", "#1705: 96.60%\n", "#1706: 96.60%\n", "#1707: 96.60%\n", "#1708: 96.61%\n", "#1709: 96.55%\n", "#1710: 96.55%\n", "#1711: 96.55%\n", "#1712: 96.56%\n", "#1713: 96.56%\n", "#1714: 96.56%\n", "#1715: 96.56%\n", "#1716: 96.56%\n", "#1717: 96.51%\n", "#1718: 96.51%\n", "#1719: 96.51%\n", "#1720: 96.51%\n", "#1721: 96.52%\n", "#1722: 96.52%\n", "#1723: 96.52%\n", "#1724: 96.52%\n", "#1725: 96.52%\n", "#1726: 96.53%\n", "#1727: 96.53%\n", "#1728: 96.53%\n", "#1729: 96.53%\n", "#1730: 96.53%\n", "#1731: 96.54%\n", "#1732: 96.54%\n", "#1733: 96.54%\n", "#1734: 96.54%\n", "#1735: 96.54%\n", "#1736: 96.55%\n", "#1737: 96.49%\n", "#1738: 96.49%\n", "#1739: 96.49%\n", "#1740: 96.50%\n", "#1741: 96.50%\n", "#1742: 96.50%\n", "#1743: 96.50%\n", "#1744: 96.50%\n", "#1745: 96.51%\n", "#1746: 96.51%\n", "#1747: 96.45%\n", "#1748: 96.46%\n", "#1749: 96.46%\n", "#1750: 96.46%\n", "#1751: 96.46%\n", "#1752: 96.46%\n", "#1753: 96.47%\n", "#1754: 96.41%\n", "#1755: 96.41%\n", "#1756: 96.41%\n", "#1757: 96.42%\n", "#1758: 96.42%\n", "#1759: 96.42%\n", "#1760: 96.42%\n", "#1761: 96.42%\n", "#1762: 96.43%\n", "#1763: 96.43%\n", "#1764: 96.43%\n", "#1765: 96.43%\n", "#1766: 96.43%\n", "#1767: 96.44%\n", "#1768: 96.44%\n", "#1769: 96.44%\n", "#1770: 96.44%\n", "#1771: 96.44%\n", "#1772: 96.45%\n", "#1773: 96.45%\n", "#1774: 96.45%\n", "#1775: 96.45%\n", "#1776: 96.45%\n", "#1777: 96.46%\n", "#1778: 96.46%\n", "#1779: 96.46%\n", "#1780: 96.46%\n", "#1781: 96.46%\n", "#1782: 96.47%\n", "#1783: 96.47%\n", "#1784: 96.47%\n", "#1785: 96.47%\n", "#1786: 96.47%\n", "#1787: 96.48%\n", "#1788: 96.48%\n", "#1789: 96.48%\n", "#1790: 96.48%\n", "#1791: 96.48%\n", "#1792: 96.49%\n", "#1793: 96.49%\n", "#1794: 96.49%\n", "#1795: 96.49%\n", "#1796: 96.49%\n", "#1797: 96.50%\n", "#1798: 96.50%\n", "#1799: 96.50%\n", "#1800: 96.50%\n", "#1801: 96.50%\n", "#1802: 96.51%\n", "#1803: 96.51%\n", "#1804: 96.51%\n", "#1805: 96.51%\n", "#1806: 96.51%\n", "#1807: 96.52%\n", "#1808: 96.52%\n", "#1809: 96.52%\n", "#1810: 96.52%\n", "#1811: 96.52%\n", "#1812: 96.53%\n", "#1813: 96.53%\n", "#1814: 96.53%\n", "#1815: 96.53%\n", "#1816: 96.53%\n", "#1817: 96.53%\n", "#1818: 96.54%\n", "#1819: 96.54%\n", "#1820: 96.54%\n", "#1821: 96.54%\n", "#1822: 96.54%\n", "#1823: 96.55%\n", "#1824: 96.55%\n", "#1825: 96.55%\n", "#1826: 96.55%\n", "#1827: 96.55%\n", "#1828: 96.56%\n", "#1829: 96.56%\n", "#1830: 96.56%\n", "#1831: 96.56%\n", "#1832: 96.56%\n", "#1833: 96.56%\n", "#1834: 96.57%\n", "#1835: 96.57%\n", "#1836: 96.57%\n", "#1837: 96.57%\n", "#1838: 96.57%\n", "#1839: 96.58%\n", "#1840: 96.58%\n", "#1841: 96.58%\n", "#1842: 96.58%\n", "#1843: 96.58%\n", "#1844: 96.59%\n", "#1845: 96.59%\n", "#1846: 96.59%\n", "#1847: 96.59%\n", "#1848: 96.59%\n", "#1849: 96.59%\n", "#1850: 96.60%\n", "#1851: 96.60%\n", "#1852: 96.60%\n", "#1853: 96.60%\n", "#1854: 96.60%\n", "#1855: 96.61%\n", "#1856: 96.61%\n", "#1857: 96.61%\n", "#1858: 96.61%\n", "#1859: 96.61%\n", "#1860: 96.61%\n", "#1861: 96.62%\n", "#1862: 96.62%\n", "#1863: 96.62%\n", "#1864: 96.62%\n", "#1865: 96.62%\n", "#1866: 96.63%\n", "#1867: 96.63%\n", "#1868: 96.63%\n", "#1869: 96.63%\n", "#1870: 96.63%\n", "#1871: 96.63%\n", "#1872: 96.64%\n", "#1873: 96.64%\n", "#1874: 96.64%\n", "#1875: 96.64%\n", "#1876: 96.64%\n", "#1877: 96.65%\n", "#1878: 96.65%\n", "#1879: 96.65%\n", "#1880: 96.65%\n", "#1881: 96.65%\n", "#1882: 96.65%\n", "#1883: 96.60%\n", "#1884: 96.60%\n", "#1885: 96.61%\n", "#1886: 96.61%\n", "#1887: 96.61%\n", "#1888: 96.61%\n", "#1889: 96.61%\n", "#1890: 96.62%\n", "#1891: 96.62%\n", "#1892: 96.62%\n", "#1893: 96.62%\n", "#1894: 96.62%\n", "#1895: 96.62%\n", "#1896: 96.63%\n", "#1897: 96.63%\n", "#1898: 96.63%\n", "#1899: 96.63%\n", "#1900: 96.63%\n", "#1901: 96.58%\n", "#1902: 96.58%\n", "#1903: 96.59%\n", "#1904: 96.59%\n", "#1905: 96.59%\n", "#1906: 96.59%\n", "#1907: 96.59%\n", "#1908: 96.60%\n", "#1909: 96.60%\n", "#1910: 96.60%\n", "#1911: 96.60%\n", "#1912: 96.60%\n", "#1913: 96.60%\n", "#1914: 96.61%\n", "#1915: 96.61%\n", "#1916: 96.61%\n", "#1917: 96.61%\n", "#1918: 96.61%\n", "#1919: 96.61%\n", "#1920: 96.62%\n", "#1921: 96.62%\n", "#1922: 96.62%\n", "#1923: 96.62%\n", "#1924: 96.62%\n", "#1925: 96.63%\n", "#1926: 96.63%\n", "#1927: 96.63%\n", "#1928: 96.63%\n", "#1929: 96.63%\n", "#1930: 96.63%\n", "#1931: 96.64%\n", "#1932: 96.64%\n", "#1933: 96.64%\n", "#1934: 96.64%\n", "#1935: 96.64%\n", "#1936: 96.64%\n", "#1937: 96.65%\n", "#1938: 96.65%\n", "#1939: 96.65%\n", "#1940: 96.65%\n", "#1941: 96.65%\n", "#1942: 96.65%\n", "#1943: 96.66%\n", "#1944: 96.66%\n", "#1945: 96.66%\n", "#1946: 96.66%\n", "#1947: 96.66%\n", "#1948: 96.66%\n", "#1949: 96.67%\n", "#1950: 96.67%\n", "#1951: 96.67%\n", "#1952: 96.67%\n", "#1953: 96.67%\n", "#1954: 96.68%\n", "#1955: 96.63%\n", "#1956: 96.63%\n", "#1957: 96.63%\n", "#1958: 96.63%\n", "#1959: 96.63%\n", "#1960: 96.63%\n", "#1961: 96.64%\n", "#1962: 96.64%\n", "#1963: 96.64%\n", "#1964: 96.64%\n", "#1965: 96.64%\n", "#1966: 96.64%\n", "#1967: 96.65%\n", "#1968: 96.65%\n", "#1969: 96.65%\n", "#1970: 96.65%\n", "#1971: 96.65%\n", "#1972: 96.65%\n", "#1973: 96.66%\n", "#1974: 96.66%\n", "#1975: 96.66%\n", "#1976: 96.66%\n", "#1977: 96.66%\n", "#1978: 96.66%\n", "#1979: 96.67%\n", "#1980: 96.67%\n", "#1981: 96.67%\n", "#1982: 96.67%\n", "#1983: 96.67%\n", "#1984: 96.68%\n", "#1985: 96.68%\n", "#1986: 96.68%\n", "#1987: 96.68%\n", "#1988: 96.68%\n", "#1989: 96.68%\n", "#1990: 96.69%\n", "#1991: 96.69%\n", "#1992: 96.69%\n", "#1993: 96.69%\n", "#1994: 96.69%\n", "#1995: 96.69%\n", "#1996: 96.70%\n", "#1997: 96.70%\n", "#1998: 96.70%\n", "#1999: 96.70%\n", "#2000: 96.70%\n", "#2001: 96.70%\n", "#2002: 96.70%\n", "#2003: 96.71%\n", "#2004: 96.71%\n", "#2005: 96.71%\n", "#2006: 96.71%\n", "#2007: 96.71%\n", "#2008: 96.71%\n", "#2009: 96.72%\n", "#2010: 96.72%\n", "#2011: 96.72%\n", "#2012: 96.72%\n", "#2013: 96.72%\n", "#2014: 96.72%\n", "#2015: 96.73%\n", "#2016: 96.73%\n", "#2017: 96.73%\n", "#2018: 96.68%\n", "#2019: 96.68%\n", "#2020: 96.68%\n", "#2021: 96.69%\n", "#2022: 96.69%\n", "#2023: 96.69%\n", "#2024: 96.69%\n", "#2025: 96.64%\n", "#2026: 96.65%\n", "#2027: 96.65%\n", "#2028: 96.65%\n", "#2029: 96.65%\n", "#2030: 96.65%\n", "#2031: 96.65%\n", "#2032: 96.66%\n", "#2033: 96.66%\n", "#2034: 96.66%\n", "#2035: 96.66%\n", "#2036: 96.66%\n", "#2037: 96.66%\n", "#2038: 96.67%\n", "#2039: 96.67%\n", "#2040: 96.67%\n", "#2041: 96.67%\n", "#2042: 96.67%\n", "#2043: 96.62%\n", "#2044: 96.63%\n", "#2045: 96.63%\n", "#2046: 96.63%\n", "#2047: 96.63%\n", "#2048: 96.63%\n", "#2049: 96.63%\n", "#2050: 96.64%\n", "#2051: 96.64%\n", "#2052: 96.64%\n", "#2053: 96.64%\n", "#2054: 96.64%\n", "#2055: 96.64%\n", "#2056: 96.65%\n", "#2057: 96.65%\n", "#2058: 96.65%\n", "#2059: 96.65%\n", "#2060: 96.65%\n", "#2061: 96.65%\n", "#2062: 96.66%\n", "#2063: 96.66%\n", "#2064: 96.66%\n", "#2065: 96.66%\n", "#2066: 96.66%\n", "#2067: 96.66%\n", "#2068: 96.67%\n", "#2069: 96.67%\n", "#2070: 96.62%\n", "#2071: 96.62%\n", "#2072: 96.62%\n", "#2073: 96.62%\n", "#2074: 96.63%\n", "#2075: 96.63%\n", "#2076: 96.63%\n", "#2077: 96.63%\n", "#2078: 96.63%\n", "#2079: 96.63%\n", "#2080: 96.64%\n", "#2081: 96.64%\n", "#2082: 96.64%\n", "#2083: 96.64%\n", "#2084: 96.64%\n", "#2085: 96.64%\n", "#2086: 96.65%\n", "#2087: 96.65%\n", "#2088: 96.65%\n", "#2089: 96.65%\n", "#2090: 96.65%\n", "#2091: 96.65%\n", "#2092: 96.66%\n", "#2093: 96.66%\n", "#2094: 96.66%\n", "#2095: 96.66%\n", "#2096: 96.66%\n", "#2097: 96.66%\n", "#2098: 96.62%\n", "#2099: 96.62%\n", "#2100: 96.62%\n", "#2101: 96.62%\n", "#2102: 96.62%\n", "#2103: 96.63%\n", "#2104: 96.63%\n", "#2105: 96.63%\n", "#2106: 96.63%\n", "#2107: 96.63%\n", "#2108: 96.63%\n", "#2109: 96.59%\n", "#2110: 96.59%\n", "#2111: 96.59%\n", "#2112: 96.59%\n", "#2113: 96.59%\n", "#2114: 96.60%\n", "#2115: 96.60%\n", "#2116: 96.60%\n", "#2117: 96.60%\n", "#2118: 96.55%\n", "#2119: 96.56%\n", "#2120: 96.56%\n", "#2121: 96.56%\n", "#2122: 96.56%\n", "#2123: 96.56%\n", "#2124: 96.56%\n", "#2125: 96.57%\n", "#2126: 96.57%\n", "#2127: 96.57%\n", "#2128: 96.57%\n", "#2129: 96.57%\n", "#2130: 96.53%\n", "#2131: 96.53%\n", "#2132: 96.53%\n", "#2133: 96.53%\n", "#2134: 96.53%\n", "#2135: 96.49%\n", "#2136: 96.49%\n", "#2137: 96.49%\n", "#2138: 96.49%\n", "#2139: 96.50%\n", "#2140: 96.50%\n", "#2141: 96.50%\n", "#2142: 96.50%\n", "#2143: 96.50%\n", "#2144: 96.50%\n", "#2145: 96.51%\n", "#2146: 96.51%\n", "#2147: 96.51%\n", "#2148: 96.51%\n", "#2149: 96.51%\n", "#2150: 96.51%\n", "#2151: 96.51%\n", "#2152: 96.52%\n", "#2153: 96.52%\n", "#2154: 96.52%\n", "#2155: 96.52%\n", "#2156: 96.52%\n", "#2157: 96.52%\n", "#2158: 96.53%\n", "#2159: 96.53%\n", "#2160: 96.53%\n", "#2161: 96.53%\n", "#2162: 96.53%\n", "#2163: 96.53%\n", "#2164: 96.54%\n", "#2165: 96.54%\n", "#2166: 96.54%\n", "#2167: 96.54%\n", "#2168: 96.54%\n", "#2169: 96.54%\n", "#2170: 96.55%\n", "#2171: 96.55%\n", "#2172: 96.55%\n", "#2173: 96.55%\n", "#2174: 96.55%\n", "#2175: 96.55%\n", "#2176: 96.55%\n", "#2177: 96.56%\n", "#2178: 96.56%\n", "#2179: 96.56%\n", "#2180: 96.56%\n", "#2181: 96.56%\n", "#2182: 96.56%\n", "#2183: 96.57%\n", "#2184: 96.57%\n", "#2185: 96.52%\n", "#2186: 96.48%\n", "#2187: 96.48%\n", "#2188: 96.48%\n", "#2189: 96.44%\n", "#2190: 96.44%\n", "#2191: 96.44%\n", "#2192: 96.44%\n", "#2193: 96.44%\n", "#2194: 96.45%\n", "#2195: 96.45%\n", "#2196: 96.45%\n", "#2197: 96.45%\n", "#2198: 96.45%\n", "#2199: 96.45%\n", "#2200: 96.46%\n", "#2201: 96.46%\n", "#2202: 96.46%\n", "#2203: 96.46%\n", "#2204: 96.46%\n", "#2205: 96.46%\n", "#2206: 96.47%\n", "#2207: 96.47%\n", "#2208: 96.47%\n", "#2209: 96.47%\n", "#2210: 96.47%\n", "#2211: 96.47%\n", "#2212: 96.48%\n", "#2213: 96.48%\n", "#2214: 96.48%\n", "#2215: 96.48%\n", "#2216: 96.48%\n", "#2217: 96.48%\n", "#2218: 96.48%\n", "#2219: 96.49%\n", "#2220: 96.49%\n", "#2221: 96.49%\n", "#2222: 96.49%\n", "#2223: 96.49%\n", "#2224: 96.49%\n", "#2225: 96.50%\n", "#2226: 96.50%\n", "#2227: 96.50%\n", "#2228: 96.50%\n", "#2229: 96.50%\n", "#2230: 96.50%\n", "#2231: 96.51%\n", "#2232: 96.51%\n", "#2233: 96.51%\n", "#2234: 96.51%\n", "#2235: 96.51%\n", "#2236: 96.51%\n", "#2237: 96.51%\n", "#2238: 96.52%\n", "#2239: 96.52%\n", "#2240: 96.52%\n", "#2241: 96.52%\n", "#2242: 96.52%\n", "#2243: 96.52%\n", "#2244: 96.53%\n", "#2245: 96.53%\n", "#2246: 96.53%\n", "#2247: 96.53%\n", "#2248: 96.53%\n", "#2249: 96.53%\n", "#2250: 96.53%\n", "#2251: 96.54%\n", "#2252: 96.54%\n", "#2253: 96.54%\n", "#2254: 96.54%\n", "#2255: 96.54%\n", "#2256: 96.54%\n", "#2257: 96.55%\n", "#2258: 96.55%\n", "#2259: 96.55%\n", "#2260: 96.55%\n", "#2261: 96.55%\n", "#2262: 96.55%\n", "#2263: 96.55%\n", "#2264: 96.56%\n", "#2265: 96.56%\n", "#2266: 96.52%\n", "#2267: 96.52%\n", "#2268: 96.52%\n", "#2269: 96.52%\n", "#2270: 96.52%\n", "#2271: 96.52%\n", "#2272: 96.52%\n", "#2273: 96.53%\n", "#2274: 96.53%\n", "#2275: 96.53%\n", "#2276: 96.53%\n", "#2277: 96.53%\n", "#2278: 96.53%\n", "#2279: 96.54%\n", "#2280: 96.49%\n", "#2281: 96.49%\n", "#2282: 96.50%\n", "#2283: 96.50%\n", "#2284: 96.50%\n", "#2285: 96.50%\n", "#2286: 96.50%\n", "#2287: 96.50%\n", "#2288: 96.51%\n", "#2289: 96.51%\n", "#2290: 96.51%\n", "#2291: 96.51%\n", "#2292: 96.51%\n", "#2293: 96.51%\n", "#2294: 96.51%\n", "#2295: 96.52%\n", "#2296: 96.52%\n", "#2297: 96.52%\n", "#2298: 96.52%\n", "#2299: 96.52%\n", "#2300: 96.52%\n", "#2301: 96.52%\n", "#2302: 96.53%\n", "#2303: 96.53%\n", "#2304: 96.53%\n", "#2305: 96.53%\n", "#2306: 96.53%\n", "#2307: 96.53%\n", "#2308: 96.49%\n", "#2309: 96.49%\n", "#2310: 96.50%\n", "#2311: 96.50%\n", "#2312: 96.50%\n", "#2313: 96.50%\n", "#2314: 96.50%\n", "#2315: 96.50%\n", "#2316: 96.50%\n", "#2317: 96.51%\n", "#2318: 96.51%\n", "#2319: 96.51%\n", "#2320: 96.51%\n", "#2321: 96.51%\n", "#2322: 96.51%\n", "#2323: 96.51%\n", "#2324: 96.52%\n", "#2325: 96.52%\n", "#2326: 96.52%\n", "#2327: 96.52%\n", "#2328: 96.52%\n", "#2329: 96.52%\n", "#2330: 96.53%\n", "#2331: 96.53%\n", "#2332: 96.53%\n", "#2333: 96.53%\n", "#2334: 96.53%\n", "#2335: 96.53%\n", "#2336: 96.53%\n", "#2337: 96.54%\n", "#2338: 96.54%\n", "#2339: 96.54%\n", "#2340: 96.54%\n", "#2341: 96.54%\n", "#2342: 96.54%\n", "#2343: 96.54%\n", "#2344: 96.55%\n", "#2345: 96.55%\n", "#2346: 96.55%\n", "#2347: 96.55%\n", "#2348: 96.55%\n", "#2349: 96.55%\n", "#2350: 96.55%\n", "#2351: 96.56%\n", "#2352: 96.56%\n", "#2353: 96.56%\n", "#2354: 96.56%\n", "#2355: 96.56%\n", "#2356: 96.56%\n", "#2357: 96.56%\n", "#2358: 96.57%\n", "#2359: 96.57%\n", "#2360: 96.57%\n", "#2361: 96.57%\n", "#2362: 96.57%\n", "#2363: 96.57%\n", "#2364: 96.58%\n", "#2365: 96.58%\n", "#2366: 96.58%\n", "#2367: 96.58%\n", "#2368: 96.58%\n", "#2369: 96.58%\n", "#2370: 96.58%\n", "#2371: 96.59%\n", "#2372: 96.59%\n", "#2373: 96.59%\n", "#2374: 96.59%\n", "#2375: 96.59%\n", "#2376: 96.59%\n", "#2377: 96.59%\n", "#2378: 96.60%\n", "#2379: 96.60%\n", "#2380: 96.60%\n", "#2381: 96.60%\n", "#2382: 96.60%\n", "#2383: 96.60%\n", "#2384: 96.60%\n", "#2385: 96.61%\n", "#2386: 96.61%\n", "#2387: 96.61%\n", "#2388: 96.61%\n", "#2389: 96.61%\n", "#2390: 96.61%\n", "#2391: 96.61%\n", "#2392: 96.62%\n", "#2393: 96.62%\n", "#2394: 96.62%\n", "#2395: 96.62%\n", "#2396: 96.62%\n", "#2397: 96.62%\n", "#2398: 96.62%\n", "#2399: 96.62%\n", "#2400: 96.63%\n", "#2401: 96.63%\n", "#2402: 96.63%\n", "#2403: 96.63%\n", "#2404: 96.63%\n", "#2405: 96.63%\n", "#2406: 96.63%\n", "#2407: 96.64%\n", "#2408: 96.64%\n", "#2409: 96.64%\n", "#2410: 96.64%\n", "#2411: 96.64%\n", "#2412: 96.64%\n", "#2413: 96.64%\n", "#2414: 96.65%\n", "#2415: 96.65%\n", "#2416: 96.65%\n", "#2417: 96.65%\n", "#2418: 96.65%\n", "#2419: 96.65%\n", "#2420: 96.65%\n", "#2421: 96.66%\n", "#2422: 96.66%\n", "#2423: 96.66%\n", "#2424: 96.66%\n", "#2425: 96.66%\n", "#2426: 96.66%\n", "#2427: 96.66%\n", "#2428: 96.67%\n", "#2429: 96.67%\n", "#2430: 96.67%\n", "#2431: 96.67%\n", "#2432: 96.67%\n", "#2433: 96.67%\n", "#2434: 96.67%\n", "#2435: 96.67%\n", "#2436: 96.68%\n", "#2437: 96.68%\n", "#2438: 96.68%\n", "#2439: 96.68%\n", "#2440: 96.68%\n", "#2441: 96.68%\n", "#2442: 96.68%\n", "#2443: 96.69%\n", "#2444: 96.69%\n", "#2445: 96.69%\n", "#2446: 96.69%\n", "#2447: 96.69%\n", "#2448: 96.69%\n", "#2449: 96.69%\n", "#2450: 96.70%\n", "#2451: 96.70%\n", "#2452: 96.70%\n", "#2453: 96.70%\n", "#2454: 96.66%\n", "#2455: 96.66%\n", "#2456: 96.66%\n", "#2457: 96.66%\n", "#2458: 96.67%\n", "#2459: 96.67%\n", "#2460: 96.67%\n", "#2461: 96.67%\n", "#2462: 96.63%\n", "#2463: 96.63%\n", "#2464: 96.63%\n", "#2465: 96.63%\n", "#2466: 96.64%\n", "#2467: 96.64%\n", "#2468: 96.64%\n", "#2469: 96.64%\n", "#2470: 96.64%\n", "#2471: 96.64%\n", "#2472: 96.64%\n", "#2473: 96.65%\n", "#2474: 96.65%\n", "#2475: 96.65%\n", "#2476: 96.65%\n", "#2477: 96.65%\n", "#2478: 96.65%\n", "#2479: 96.65%\n", "#2480: 96.65%\n", "#2481: 96.66%\n", "#2482: 96.66%\n", "#2483: 96.66%\n", "#2484: 96.66%\n", "#2485: 96.66%\n", "#2486: 96.66%\n", "#2487: 96.66%\n", "#2488: 96.63%\n", "#2489: 96.63%\n", "#2490: 96.63%\n", "#2491: 96.63%\n", "#2492: 96.63%\n", "#2493: 96.63%\n", "#2494: 96.63%\n", "#2495: 96.63%\n", "#2496: 96.64%\n", "#2497: 96.64%\n", "#2498: 96.64%\n", "#2499: 96.64%\n", "#2500: 96.64%\n", "#2501: 96.64%\n", "#2502: 96.64%\n", "#2503: 96.65%\n", "#2504: 96.65%\n", "#2505: 96.65%\n", "#2506: 96.65%\n", "#2507: 96.65%\n", "#2508: 96.65%\n", "#2509: 96.65%\n", "#2510: 96.65%\n", "#2511: 96.66%\n", "#2512: 96.66%\n", "#2513: 96.66%\n", "#2514: 96.66%\n", "#2515: 96.66%\n", "#2516: 96.66%\n", "#2517: 96.66%\n", "#2518: 96.67%\n", "#2519: 96.67%\n", "#2520: 96.67%\n", "#2521: 96.67%\n", "#2522: 96.67%\n", "#2523: 96.67%\n", "#2524: 96.67%\n", "#2525: 96.67%\n", "#2526: 96.68%\n", "#2527: 96.68%\n", "#2528: 96.68%\n", "#2529: 96.68%\n", "#2530: 96.68%\n", "#2531: 96.68%\n", "#2532: 96.68%\n", "#2533: 96.65%\n", "#2534: 96.61%\n", "#2535: 96.61%\n", "#2536: 96.61%\n", "#2537: 96.61%\n", "#2538: 96.61%\n", "#2539: 96.61%\n", "#2540: 96.62%\n", "#2541: 96.62%\n", "#2542: 96.62%\n", "#2543: 96.62%\n", "#2544: 96.62%\n", "#2545: 96.62%\n", "#2546: 96.62%\n", "#2547: 96.62%\n", "#2548: 96.63%\n", "#2549: 96.63%\n", "#2550: 96.63%\n", "#2551: 96.63%\n", "#2552: 96.63%\n", "#2553: 96.63%\n", "#2554: 96.63%\n", "#2555: 96.64%\n", "#2556: 96.64%\n", "#2557: 96.64%\n", "#2558: 96.64%\n", "#2559: 96.64%\n", "#2560: 96.60%\n", "#2561: 96.60%\n", "#2562: 96.61%\n", "#2563: 96.61%\n", "#2564: 96.61%\n", "#2565: 96.61%\n", "#2566: 96.61%\n", "#2567: 96.61%\n", "#2568: 96.61%\n", "#2569: 96.61%\n", "#2570: 96.62%\n", "#2571: 96.62%\n", "#2572: 96.62%\n", "#2573: 96.62%\n", "#2574: 96.62%\n", "#2575: 96.62%\n", "#2576: 96.62%\n", "#2577: 96.63%\n", "#2578: 96.63%\n", "#2579: 96.63%\n", "#2580: 96.63%\n", "#2581: 96.63%\n", "#2582: 96.63%\n", "#2583: 96.63%\n", "#2584: 96.63%\n", "#2585: 96.64%\n", "#2586: 96.64%\n", "#2587: 96.64%\n", "#2588: 96.64%\n", "#2589: 96.64%\n", "#2590: 96.64%\n", "#2591: 96.64%\n", "#2592: 96.64%\n", "#2593: 96.65%\n", "#2594: 96.61%\n", "#2595: 96.61%\n", "#2596: 96.61%\n", "#2597: 96.57%\n", "#2598: 96.58%\n", "#2599: 96.58%\n", "#2600: 96.58%\n", "#2601: 96.58%\n", "#2602: 96.58%\n", "#2603: 96.58%\n", "#2604: 96.58%\n", "#2605: 96.58%\n", "#2606: 96.59%\n", "#2607: 96.59%\n", "#2608: 96.59%\n", "#2609: 96.59%\n", "#2610: 96.59%\n", "#2611: 96.59%\n", "#2612: 96.59%\n", "#2613: 96.60%\n", "#2614: 96.60%\n", "#2615: 96.60%\n", "#2616: 96.60%\n", "#2617: 96.60%\n", "#2618: 96.60%\n", "#2619: 96.60%\n", "#2620: 96.60%\n", "#2621: 96.61%\n", "#2622: 96.61%\n", "#2623: 96.61%\n", "#2624: 96.61%\n", "#2625: 96.61%\n", "#2626: 96.61%\n", "#2627: 96.61%\n", "#2628: 96.61%\n", "#2629: 96.62%\n", "#2630: 96.62%\n", "#2631: 96.62%\n", "#2632: 96.62%\n", "#2633: 96.62%\n", "#2634: 96.62%\n", "#2635: 96.62%\n", "#2636: 96.59%\n", "#2637: 96.59%\n", "#2638: 96.59%\n", "#2639: 96.59%\n", "#2640: 96.59%\n", "#2641: 96.59%\n", "#2642: 96.59%\n", "#2643: 96.60%\n", "#2644: 96.60%\n", "#2645: 96.60%\n", "#2646: 96.60%\n", "#2647: 96.60%\n", "#2648: 96.60%\n", "#2649: 96.60%\n", "#2650: 96.61%\n", "#2651: 96.61%\n", "#2652: 96.61%\n", "#2653: 96.61%\n", "#2654: 96.57%\n", "#2655: 96.57%\n", "#2656: 96.58%\n", "#2657: 96.58%\n", "#2658: 96.58%\n", "#2659: 96.58%\n", "#2660: 96.58%\n", "#2661: 96.58%\n", "#2662: 96.58%\n", "#2663: 96.58%\n", "#2664: 96.59%\n", "#2665: 96.59%\n", "#2666: 96.59%\n", "#2667: 96.59%\n", "#2668: 96.59%\n", "#2669: 96.59%\n", "#2670: 96.59%\n", "#2671: 96.59%\n", "#2672: 96.60%\n", "#2673: 96.60%\n", "#2674: 96.60%\n", "#2675: 96.60%\n", "#2676: 96.60%\n", "#2677: 96.60%\n", "#2678: 96.60%\n", "#2679: 96.60%\n", "#2680: 96.61%\n", "#2681: 96.61%\n", "#2682: 96.61%\n", "#2683: 96.61%\n", "#2684: 96.61%\n", "#2685: 96.61%\n", "#2686: 96.61%\n", "#2687: 96.61%\n", "#2688: 96.62%\n", "#2689: 96.62%\n", "#2690: 96.62%\n", "#2691: 96.62%\n", "#2692: 96.62%\n", "#2693: 96.62%\n", "#2694: 96.62%\n", "#2695: 96.62%\n", "#2696: 96.63%\n", "#2697: 96.63%\n", "#2698: 96.63%\n", "#2699: 96.63%\n", "#2700: 96.63%\n", "#2701: 96.63%\n", "#2702: 96.63%\n", "#2703: 96.63%\n", "#2704: 96.64%\n", "#2705: 96.64%\n", "#2706: 96.64%\n", "#2707: 96.64%\n", "#2708: 96.64%\n", "#2709: 96.64%\n", "#2710: 96.64%\n", "#2711: 96.64%\n", "#2712: 96.65%\n", "#2713: 96.65%\n", "#2714: 96.65%\n", "#2715: 96.65%\n", "#2716: 96.65%\n", "#2717: 96.65%\n", "#2718: 96.65%\n", "#2719: 96.65%\n", "#2720: 96.66%\n", "#2721: 96.66%\n", "#2722: 96.66%\n", "#2723: 96.66%\n", "#2724: 96.66%\n", "#2725: 96.66%\n", "#2726: 96.66%\n", "#2727: 96.66%\n", "#2728: 96.67%\n", "#2729: 96.67%\n", "#2730: 96.67%\n", "#2731: 96.67%\n", "#2732: 96.67%\n", "#2733: 96.67%\n", "#2734: 96.67%\n", "#2735: 96.67%\n", "#2736: 96.68%\n", "#2737: 96.68%\n", "#2738: 96.68%\n", "#2739: 96.68%\n", "#2740: 96.68%\n", "#2741: 96.68%\n", "#2742: 96.68%\n", "#2743: 96.68%\n", "#2744: 96.68%\n", "#2745: 96.69%\n", "#2746: 96.69%\n", "#2747: 96.69%\n", "#2748: 96.69%\n", "#2749: 96.69%\n", "#2750: 96.69%\n", "#2751: 96.69%\n", "#2752: 96.69%\n", "#2753: 96.70%\n", "#2754: 96.70%\n", "#2755: 96.70%\n", "#2756: 96.70%\n", "#2757: 96.70%\n", "#2758: 96.70%\n", "#2759: 96.70%\n", "#2760: 96.67%\n", "#2761: 96.67%\n", "#2762: 96.67%\n", "#2763: 96.67%\n", "#2764: 96.67%\n", "#2765: 96.67%\n", "#2766: 96.68%\n", "#2767: 96.68%\n", "#2768: 96.68%\n", "#2769: 96.68%\n", "#2770: 96.64%\n", "#2771: 96.65%\n", "#2772: 96.65%\n", "#2773: 96.65%\n", "#2774: 96.65%\n", "#2775: 96.65%\n", "#2776: 96.65%\n", "#2777: 96.65%\n", "#2778: 96.62%\n", "#2779: 96.62%\n", "#2780: 96.58%\n", "#2781: 96.59%\n", "#2782: 96.59%\n", "#2783: 96.59%\n", "#2784: 96.59%\n", "#2785: 96.59%\n", "#2786: 96.59%\n", "#2787: 96.59%\n", "#2788: 96.59%\n", "#2789: 96.59%\n", "#2790: 96.60%\n", "#2791: 96.60%\n", "#2792: 96.60%\n", "#2793: 96.60%\n", "#2794: 96.60%\n", "#2795: 96.60%\n", "#2796: 96.60%\n", "#2797: 96.60%\n", "#2798: 96.61%\n", "#2799: 96.61%\n", "#2800: 96.61%\n", "#2801: 96.61%\n", "#2802: 96.61%\n", "#2803: 96.61%\n", "#2804: 96.61%\n", "#2805: 96.61%\n", "#2806: 96.62%\n", "#2807: 96.62%\n", "#2808: 96.62%\n", "#2809: 96.62%\n", "#2810: 96.62%\n", "#2811: 96.62%\n", "#2812: 96.62%\n", "#2813: 96.62%\n", "#2814: 96.63%\n", "#2815: 96.63%\n", "#2816: 96.63%\n", "#2817: 96.63%\n", "#2818: 96.63%\n", "#2819: 96.63%\n", "#2820: 96.63%\n", "#2821: 96.63%\n", "#2822: 96.63%\n", "#2823: 96.60%\n", "#2824: 96.60%\n", "#2825: 96.60%\n", "#2826: 96.60%\n", "#2827: 96.61%\n", "#2828: 96.61%\n", "#2829: 96.61%\n", "#2830: 96.61%\n", "#2831: 96.61%\n", "#2832: 96.61%\n", "#2833: 96.61%\n", "#2834: 96.61%\n", "#2835: 96.61%\n", "#2836: 96.62%\n", "#2837: 96.62%\n", "#2838: 96.62%\n", "#2839: 96.62%\n", "#2840: 96.62%\n", "#2841: 96.62%\n", "#2842: 96.62%\n", "#2843: 96.62%\n", "#2844: 96.63%\n", "#2845: 96.63%\n", "#2846: 96.63%\n", "#2847: 96.63%\n", "#2848: 96.63%\n", "#2849: 96.63%\n", "#2850: 96.63%\n", "#2851: 96.63%\n", "#2852: 96.64%\n", "#2853: 96.64%\n", "#2854: 96.64%\n", "#2855: 96.64%\n", "#2856: 96.64%\n", "#2857: 96.64%\n", "#2858: 96.64%\n", "#2859: 96.64%\n", "#2860: 96.64%\n", "#2861: 96.65%\n", "#2862: 96.65%\n", "#2863: 96.65%\n", "#2864: 96.65%\n", "#2865: 96.65%\n", "#2866: 96.65%\n", "#2867: 96.65%\n", "#2868: 96.65%\n", "#2869: 96.66%\n", "#2870: 96.66%\n", "#2871: 96.66%\n", "#2872: 96.66%\n", "#2873: 96.66%\n", "#2874: 96.66%\n", "#2875: 96.66%\n", "#2876: 96.66%\n", "#2877: 96.66%\n", "#2878: 96.67%\n", "#2879: 96.67%\n", "#2880: 96.67%\n", "#2881: 96.67%\n", "#2882: 96.67%\n", "#2883: 96.67%\n", "#2884: 96.67%\n", "#2885: 96.67%\n", "#2886: 96.67%\n", "#2887: 96.68%\n", "#2888: 96.68%\n", "#2889: 96.68%\n", "#2890: 96.68%\n", "#2891: 96.68%\n", "#2892: 96.68%\n", "#2893: 96.68%\n", "#2894: 96.68%\n", "#2895: 96.69%\n", "#2896: 96.65%\n", "#2897: 96.65%\n", "#2898: 96.65%\n", "#2899: 96.66%\n", "#2900: 96.66%\n", "#2901: 96.66%\n", "#2902: 96.66%\n", "#2903: 96.66%\n", "#2904: 96.66%\n", "#2905: 96.66%\n", "#2906: 96.66%\n", "#2907: 96.66%\n", "#2908: 96.67%\n", "#2909: 96.67%\n", "#2910: 96.67%\n", "#2911: 96.67%\n", "#2912: 96.67%\n", "#2913: 96.67%\n", "#2914: 96.67%\n", "#2915: 96.67%\n", "#2916: 96.67%\n", "#2917: 96.68%\n", "#2918: 96.68%\n", "#2919: 96.68%\n", "#2920: 96.68%\n", "#2921: 96.68%\n", "#2922: 96.68%\n", "#2923: 96.68%\n", "#2924: 96.68%\n", "#2925: 96.68%\n", "#2926: 96.69%\n", "#2927: 96.65%\n", "#2928: 96.65%\n", "#2929: 96.66%\n", "#2930: 96.66%\n", "#2931: 96.66%\n", "#2932: 96.66%\n", "#2933: 96.66%\n", "#2934: 96.66%\n", "#2935: 96.66%\n", "#2936: 96.66%\n", "#2937: 96.66%\n", "#2938: 96.67%\n", "#2939: 96.63%\n", "#2940: 96.63%\n", "#2941: 96.63%\n", "#2942: 96.64%\n", "#2943: 96.64%\n", "#2944: 96.64%\n", "#2945: 96.64%\n", "#2946: 96.64%\n", "#2947: 96.64%\n", "#2948: 96.64%\n", "#2949: 96.64%\n", "#2950: 96.65%\n", "#2951: 96.65%\n", "#2952: 96.61%\n", "#2953: 96.61%\n", "#2954: 96.62%\n", "#2955: 96.62%\n", "#2956: 96.62%\n", "#2957: 96.62%\n", "#2958: 96.62%\n", "#2959: 96.62%\n", "#2960: 96.62%\n", "#2961: 96.62%\n", "#2962: 96.63%\n", "#2963: 96.63%\n", "#2964: 96.63%\n", "#2965: 96.63%\n", "#2966: 96.63%\n", "#2967: 96.63%\n", "#2968: 96.63%\n", "#2969: 96.63%\n", "#2970: 96.63%\n", "#2971: 96.64%\n", "#2972: 96.64%\n", "#2973: 96.64%\n", "#2974: 96.64%\n", "#2975: 96.64%\n", "#2976: 96.64%\n", "#2977: 96.64%\n", "#2978: 96.64%\n", "#2979: 96.64%\n", "#2980: 96.65%\n", "#2981: 96.65%\n", "#2982: 96.65%\n", "#2983: 96.65%\n", "#2984: 96.65%\n", "#2985: 96.65%\n", "#2986: 96.65%\n", "#2987: 96.65%\n", "#2988: 96.65%\n", "#2989: 96.66%\n", "#2990: 96.66%\n", "#2991: 96.66%\n", "#2992: 96.66%\n", "#2993: 96.66%\n", "#2994: 96.66%\n", "#2995: 96.63%\n", "#2996: 96.63%\n", "#2997: 96.63%\n", "#2998: 96.63%\n", "#2999: 96.63%\n", "#3000: 96.63%\n", "#3001: 96.64%\n", "#3002: 96.64%\n", "#3003: 96.64%\n", "#3004: 96.64%\n", "#3005: 96.61%\n", "#3006: 96.61%\n", "#3007: 96.61%\n", "#3008: 96.61%\n", "#3009: 96.61%\n", "#3010: 96.61%\n", "#3011: 96.61%\n", "#3012: 96.61%\n", "#3013: 96.62%\n", "#3014: 96.62%\n", "#3015: 96.62%\n", "#3016: 96.62%\n", "#3017: 96.62%\n", "#3018: 96.62%\n", "#3019: 96.62%\n", "#3020: 96.62%\n", "#3021: 96.62%\n", "#3022: 96.63%\n", "#3023: 96.63%\n", "#3024: 96.63%\n", "#3025: 96.63%\n", "#3026: 96.63%\n", "#3027: 96.63%\n", "#3028: 96.63%\n", "#3029: 96.63%\n", "#3030: 96.60%\n", "#3031: 96.60%\n", "#3032: 96.60%\n", "#3033: 96.61%\n", "#3034: 96.61%\n", "#3035: 96.61%\n", "#3036: 96.61%\n", "#3037: 96.61%\n", "#3038: 96.61%\n", "#3039: 96.61%\n", "#3040: 96.61%\n", "#3041: 96.61%\n", "#3042: 96.62%\n", "#3043: 96.62%\n", "#3044: 96.62%\n", "#3045: 96.62%\n", "#3046: 96.62%\n", "#3047: 96.62%\n", "#3048: 96.62%\n", "#3049: 96.62%\n", "#3050: 96.62%\n", "#3051: 96.63%\n", "#3052: 96.63%\n", "#3053: 96.63%\n", "#3054: 96.63%\n", "#3055: 96.63%\n", "#3056: 96.63%\n", "#3057: 96.63%\n", "#3058: 96.63%\n", "#3059: 96.63%\n", "#3060: 96.60%\n", "#3061: 96.60%\n", "#3062: 96.60%\n", "#3063: 96.61%\n", "#3064: 96.61%\n", "#3065: 96.61%\n", "#3066: 96.61%\n", "#3067: 96.61%\n", "#3068: 96.61%\n", "#3069: 96.61%\n", "#3070: 96.61%\n", "#3071: 96.61%\n", "#3072: 96.62%\n", "#3073: 96.58%\n", "#3074: 96.59%\n", "#3075: 96.59%\n", "#3076: 96.59%\n", "#3077: 96.59%\n", "#3078: 96.59%\n", "#3079: 96.59%\n", "#3080: 96.59%\n", "#3081: 96.59%\n", "#3082: 96.59%\n", "#3083: 96.60%\n", "#3084: 96.60%\n", "#3085: 96.60%\n", "#3086: 96.60%\n", "#3087: 96.60%\n", "#3088: 96.60%\n", "#3089: 96.60%\n", "#3090: 96.60%\n", "#3091: 96.60%\n", "#3092: 96.61%\n", "#3093: 96.61%\n", "#3094: 96.61%\n", "#3095: 96.61%\n", "#3096: 96.61%\n", "#3097: 96.61%\n", "#3098: 96.61%\n", "#3099: 96.61%\n", "#3100: 96.61%\n", "#3101: 96.62%\n", "#3102: 96.62%\n", "#3103: 96.62%\n", "#3104: 96.62%\n", "#3105: 96.62%\n", "#3106: 96.62%\n", "#3107: 96.62%\n", "#3108: 96.62%\n", "#3109: 96.62%\n", "#3110: 96.62%\n", "#3111: 96.63%\n", "#3112: 96.63%\n", "#3113: 96.63%\n", "#3114: 96.60%\n", "#3115: 96.60%\n", "#3116: 96.60%\n", "#3117: 96.60%\n", "#3118: 96.60%\n", "#3119: 96.60%\n", "#3120: 96.60%\n", "#3121: 96.60%\n", "#3122: 96.61%\n", "#3123: 96.61%\n", "#3124: 96.61%\n", "#3125: 96.61%\n", "#3126: 96.61%\n", "#3127: 96.61%\n", "#3128: 96.61%\n", "#3129: 96.61%\n", "#3130: 96.61%\n", "#3131: 96.62%\n", "#3132: 96.62%\n", "#3133: 96.62%\n", "#3134: 96.62%\n", "#3135: 96.62%\n", "#3136: 96.62%\n", "#3137: 96.62%\n", "#3138: 96.62%\n", "#3139: 96.62%\n", "#3140: 96.63%\n", "#3141: 96.63%\n", "#3142: 96.63%\n", "#3143: 96.63%\n", "#3144: 96.63%\n", "#3145: 96.63%\n", "#3146: 96.63%\n", "#3147: 96.63%\n", "#3148: 96.63%\n", "#3149: 96.63%\n", "#3150: 96.64%\n", "#3151: 96.64%\n", "#3152: 96.64%\n", "#3153: 96.64%\n", "#3154: 96.64%\n", "#3155: 96.64%\n", "#3156: 96.64%\n", "#3157: 96.64%\n", "#3158: 96.64%\n", "#3159: 96.65%\n", "#3160: 96.65%\n", "#3161: 96.65%\n", "#3162: 96.65%\n", "#3163: 96.65%\n", "#3164: 96.65%\n", "#3165: 96.65%\n", "#3166: 96.65%\n", "#3167: 96.65%\n", "#3168: 96.66%\n", "#3169: 96.66%\n", "#3170: 96.66%\n", "#3171: 96.66%\n", "#3172: 96.66%\n", "#3173: 96.66%\n", "#3174: 96.66%\n", "#3175: 96.66%\n", "#3176: 96.66%\n", "#3177: 96.66%\n", "#3178: 96.67%\n", "#3179: 96.67%\n", "#3180: 96.67%\n", "#3181: 96.67%\n", "#3182: 96.67%\n", "#3183: 96.67%\n", "#3184: 96.67%\n", "#3185: 96.67%\n", "#3186: 96.67%\n", "#3187: 96.68%\n", "#3188: 96.68%\n", "#3189: 96.65%\n", "#3190: 96.65%\n", "#3191: 96.65%\n", "#3192: 96.65%\n", "#3193: 96.65%\n", "#3194: 96.65%\n", "#3195: 96.65%\n", "#3196: 96.65%\n", "#3197: 96.65%\n", "#3198: 96.66%\n", "#3199: 96.66%\n", "#3200: 96.66%\n", "#3201: 96.66%\n", "#3202: 96.66%\n", "#3203: 96.66%\n", "#3204: 96.66%\n", "#3205: 96.66%\n", "#3206: 96.66%\n", "#3207: 96.66%\n", "#3208: 96.67%\n", "#3209: 96.67%\n", "#3210: 96.67%\n", "#3211: 96.67%\n", "#3212: 96.67%\n", "#3213: 96.67%\n", "#3214: 96.67%\n", "#3215: 96.67%\n", "#3216: 96.67%\n", "#3217: 96.67%\n", "#3218: 96.68%\n", "#3219: 96.68%\n", "#3220: 96.68%\n", "#3221: 96.68%\n", "#3222: 96.68%\n", "#3223: 96.68%\n", "#3224: 96.68%\n", "#3225: 96.68%\n", "#3226: 96.68%\n", "#3227: 96.69%\n", "#3228: 96.69%\n", "#3229: 96.69%\n", "#3230: 96.69%\n", "#3231: 96.69%\n", "#3232: 96.69%\n", "#3233: 96.69%\n", "#3234: 96.69%\n", "#3235: 96.69%\n", "#3236: 96.69%\n", "#3237: 96.70%\n", "#3238: 96.70%\n", "#3239: 96.67%\n", "#3240: 96.67%\n", "#3241: 96.67%\n", "#3242: 96.67%\n", "#3243: 96.67%\n", "#3244: 96.67%\n", "#3245: 96.67%\n", "#3246: 96.64%\n", "#3247: 96.64%\n", "#3248: 96.65%\n", "#3249: 96.65%\n", "#3250: 96.65%\n", "#3251: 96.65%\n", "#3252: 96.65%\n", "#3253: 96.65%\n", "#3254: 96.65%\n", "#3255: 96.65%\n", "#3256: 96.65%\n", "#3257: 96.65%\n", "#3258: 96.66%\n", "#3259: 96.66%\n", "#3260: 96.66%\n", "#3261: 96.66%\n", "#3262: 96.63%\n", "#3263: 96.63%\n", "#3264: 96.63%\n", "#3265: 96.63%\n", "#3266: 96.63%\n", "#3267: 96.63%\n", "#3268: 96.64%\n", "#3269: 96.64%\n", "#3270: 96.64%\n", "#3271: 96.64%\n", "#3272: 96.64%\n", "#3273: 96.64%\n", "#3274: 96.64%\n", "#3275: 96.64%\n", "#3276: 96.64%\n", "#3277: 96.64%\n", "#3278: 96.65%\n", "#3279: 96.65%\n", "#3280: 96.65%\n", "#3281: 96.65%\n", "#3282: 96.65%\n", "#3283: 96.65%\n", "#3284: 96.65%\n", "#3285: 96.65%\n", "#3286: 96.65%\n", "#3287: 96.65%\n", "#3288: 96.66%\n", "#3289: 96.63%\n", "#3290: 96.63%\n", "#3291: 96.63%\n", "#3292: 96.63%\n", "#3293: 96.63%\n", "#3294: 96.63%\n", "#3295: 96.63%\n", "#3296: 96.63%\n", "#3297: 96.63%\n", "#3298: 96.64%\n", "#3299: 96.64%\n", "#3300: 96.64%\n", "#3301: 96.64%\n", "#3302: 96.64%\n", "#3303: 96.64%\n", "#3304: 96.64%\n", "#3305: 96.64%\n", "#3306: 96.64%\n", "#3307: 96.64%\n", "#3308: 96.65%\n", "#3309: 96.65%\n", "#3310: 96.65%\n", "#3311: 96.65%\n", "#3312: 96.65%\n", "#3313: 96.65%\n", "#3314: 96.65%\n", "#3315: 96.65%\n", "#3316: 96.62%\n", "#3317: 96.62%\n", "#3318: 96.63%\n", "#3319: 96.60%\n", "#3320: 96.60%\n", "#3321: 96.60%\n", "#3322: 96.60%\n", "#3323: 96.60%\n", "#3324: 96.60%\n", "#3325: 96.60%\n", "#3326: 96.60%\n", "#3327: 96.60%\n", "#3328: 96.61%\n", "#3329: 96.61%\n", "#3330: 96.61%\n", "#3331: 96.61%\n", "#3332: 96.61%\n", "#3333: 96.58%\n", "#3334: 96.58%\n", "#3335: 96.58%\n", "#3336: 96.58%\n", "#3337: 96.58%\n", "#3338: 96.59%\n", "#3339: 96.59%\n", "#3340: 96.59%\n", "#3341: 96.59%\n", "#3342: 96.59%\n", "#3343: 96.59%\n", "#3344: 96.59%\n", "#3345: 96.59%\n", "#3346: 96.59%\n", "#3347: 96.59%\n", "#3348: 96.60%\n", "#3349: 96.60%\n", "#3350: 96.60%\n", "#3351: 96.60%\n", "#3352: 96.60%\n", "#3353: 96.60%\n", "#3354: 96.60%\n", "#3355: 96.60%\n", "#3356: 96.60%\n", "#3357: 96.61%\n", "#3358: 96.61%\n", "#3359: 96.61%\n", "#3360: 96.61%\n", "#3361: 96.61%\n", "#3362: 96.61%\n", "#3363: 96.61%\n", "#3364: 96.61%\n", "#3365: 96.61%\n", "#3366: 96.61%\n", "#3367: 96.62%\n", "#3368: 96.62%\n", "#3369: 96.62%\n", "#3370: 96.62%\n", "#3371: 96.62%\n", "#3372: 96.62%\n", "#3373: 96.62%\n", "#3374: 96.62%\n", "#3375: 96.62%\n", "#3376: 96.62%\n", "#3377: 96.63%\n", "#3378: 96.63%\n", "#3379: 96.63%\n", "#3380: 96.63%\n", "#3381: 96.63%\n", "#3382: 96.63%\n", "#3383: 96.63%\n", "#3384: 96.63%\n", "#3385: 96.63%\n", "#3386: 96.63%\n", "#3387: 96.64%\n", "#3388: 96.64%\n", "#3389: 96.64%\n", "#3390: 96.64%\n", "#3391: 96.64%\n", "#3392: 96.64%\n", "#3393: 96.64%\n", "#3394: 96.64%\n", "#3395: 96.64%\n", "#3396: 96.64%\n", "#3397: 96.65%\n", "#3398: 96.65%\n", "#3399: 96.65%\n", "#3400: 96.65%\n", "#3401: 96.65%\n", "#3402: 96.65%\n", "#3403: 96.65%\n", "#3404: 96.65%\n", "#3405: 96.65%\n", "#3406: 96.65%\n", "#3407: 96.65%\n", "#3408: 96.66%\n", "#3409: 96.66%\n", "#3410: 96.66%\n", "#3411: 96.66%\n", "#3412: 96.66%\n", "#3413: 96.66%\n", "#3414: 96.66%\n", "#3415: 96.66%\n", "#3416: 96.66%\n", "#3417: 96.66%\n", "#3418: 96.67%\n", "#3419: 96.67%\n", "#3420: 96.67%\n", "#3421: 96.67%\n", "#3422: 96.67%\n", "#3423: 96.67%\n", "#3424: 96.67%\n", "#3425: 96.67%\n", "#3426: 96.67%\n", "#3427: 96.67%\n", "#3428: 96.68%\n", "#3429: 96.68%\n", "#3430: 96.68%\n", "#3431: 96.68%\n", "#3432: 96.68%\n", "#3433: 96.68%\n", "#3434: 96.68%\n", "#3435: 96.68%\n", "#3436: 96.68%\n", "#3437: 96.68%\n", "#3438: 96.69%\n", "#3439: 96.69%\n", "#3440: 96.69%\n", "#3441: 96.69%\n", "#3442: 96.69%\n", "#3443: 96.69%\n", "#3444: 96.69%\n", "#3445: 96.69%\n", "#3446: 96.69%\n", "#3447: 96.69%\n", "#3448: 96.69%\n", "#3449: 96.70%\n", "#3450: 96.70%\n", "#3451: 96.70%\n", "#3452: 96.70%\n", "#3453: 96.70%\n", "#3454: 96.70%\n", "#3455: 96.70%\n", "#3456: 96.70%\n", "#3457: 96.70%\n", "#3458: 96.70%\n", "#3459: 96.71%\n", "#3460: 96.71%\n", "#3461: 96.71%\n", "#3462: 96.71%\n", "#3463: 96.71%\n", "#3464: 96.71%\n", "#3465: 96.71%\n", "#3466: 96.71%\n", "#3467: 96.71%\n", "#3468: 96.71%\n", "#3469: 96.71%\n", "#3470: 96.72%\n", "#3471: 96.72%\n", "#3472: 96.72%\n", "#3473: 96.72%\n", "#3474: 96.72%\n", "#3475: 96.72%\n", "#3476: 96.72%\n", "#3477: 96.72%\n", "#3478: 96.72%\n", "#3479: 96.72%\n", "#3480: 96.73%\n", "#3481: 96.73%\n", "#3482: 96.73%\n", "#3483: 96.73%\n", "#3484: 96.73%\n", "#3485: 96.73%\n", "#3486: 96.73%\n", "#3487: 96.73%\n", "#3488: 96.73%\n", "#3489: 96.73%\n", "#3490: 96.73%\n", "#3491: 96.74%\n", "#3492: 96.74%\n", "#3493: 96.74%\n", "#3494: 96.74%\n", "#3495: 96.74%\n", "#3496: 96.74%\n", "#3497: 96.74%\n", "#3498: 96.74%\n", "#3499: 96.74%\n", "#3500: 96.74%\n", "#3501: 96.74%\n", "#3502: 96.75%\n", "#3503: 96.72%\n", "#3504: 96.72%\n", "#3505: 96.72%\n", "#3506: 96.72%\n", "#3507: 96.72%\n", "#3508: 96.72%\n", "#3509: 96.72%\n", "#3510: 96.72%\n", "#3511: 96.73%\n", "#3512: 96.73%\n", "#3513: 96.73%\n", "#3514: 96.73%\n", "#3515: 96.73%\n", "#3516: 96.73%\n", "#3517: 96.73%\n", "#3518: 96.73%\n", "#3519: 96.73%\n", "#3520: 96.71%\n", "#3521: 96.71%\n", "#3522: 96.71%\n", "#3523: 96.71%\n", "#3524: 96.71%\n", "#3525: 96.71%\n", "#3526: 96.71%\n", "#3527: 96.71%\n", "#3528: 96.71%\n", "#3529: 96.71%\n", "#3530: 96.71%\n", "#3531: 96.72%\n", "#3532: 96.72%\n", "#3533: 96.72%\n", "#3534: 96.72%\n", "#3535: 96.72%\n", "#3536: 96.72%\n", "#3537: 96.72%\n", "#3538: 96.72%\n", "#3539: 96.72%\n", "#3540: 96.72%\n", "#3541: 96.73%\n", "#3542: 96.73%\n", "#3543: 96.73%\n", "#3544: 96.73%\n", "#3545: 96.73%\n", "#3546: 96.73%\n", "#3547: 96.73%\n", "#3548: 96.73%\n", "#3549: 96.73%\n", "#3550: 96.73%\n", "#3551: 96.73%\n", "#3552: 96.74%\n", "#3553: 96.74%\n", "#3554: 96.74%\n", "#3555: 96.74%\n", "#3556: 96.74%\n", "#3557: 96.74%\n", "#3558: 96.74%\n", "#3559: 96.71%\n", "#3560: 96.71%\n", "#3561: 96.72%\n", "#3562: 96.72%\n", "#3563: 96.72%\n", "#3564: 96.72%\n", "#3565: 96.72%\n", "#3566: 96.72%\n", "#3567: 96.72%\n", "#3568: 96.72%\n", "#3569: 96.72%\n", "#3570: 96.72%\n", "#3571: 96.72%\n", "#3572: 96.73%\n", "#3573: 96.73%\n", "#3574: 96.73%\n", "#3575: 96.73%\n", "#3576: 96.73%\n", "#3577: 96.73%\n", "#3578: 96.73%\n", "#3579: 96.73%\n", "#3580: 96.73%\n", "#3581: 96.73%\n", "#3582: 96.73%\n", "#3583: 96.74%\n", "#3584: 96.74%\n", "#3585: 96.74%\n", "#3586: 96.74%\n", "#3587: 96.74%\n", "#3588: 96.74%\n", "#3589: 96.74%\n", "#3590: 96.74%\n", "#3591: 96.74%\n", "#3592: 96.74%\n", "#3593: 96.74%\n", "#3594: 96.75%\n", "#3595: 96.75%\n", "#3596: 96.75%\n", "#3597: 96.72%\n", "#3598: 96.72%\n", "#3599: 96.72%\n", "#3600: 96.72%\n", "#3601: 96.72%\n", "#3602: 96.72%\n", "#3603: 96.73%\n", "#3604: 96.73%\n", "#3605: 96.73%\n", "#3606: 96.73%\n", "#3607: 96.73%\n", "#3608: 96.73%\n", "#3609: 96.73%\n", "#3610: 96.73%\n", "#3611: 96.73%\n", "#3612: 96.73%\n", "#3613: 96.73%\n", "#3614: 96.74%\n", "#3615: 96.74%\n", "#3616: 96.74%\n", "#3617: 96.74%\n", "#3618: 96.74%\n", "#3619: 96.74%\n", "#3620: 96.74%\n", "#3621: 96.74%\n", "#3622: 96.74%\n", "#3623: 96.74%\n", "#3624: 96.74%\n", "#3625: 96.75%\n", "#3626: 96.75%\n", "#3627: 96.75%\n", "#3628: 96.75%\n", "#3629: 96.75%\n", "#3630: 96.75%\n", "#3631: 96.75%\n", "#3632: 96.75%\n", "#3633: 96.75%\n", "#3634: 96.75%\n", "#3635: 96.75%\n", "#3636: 96.76%\n", "#3637: 96.76%\n", "#3638: 96.76%\n", "#3639: 96.76%\n", "#3640: 96.76%\n", "#3641: 96.76%\n", "#3642: 96.76%\n", "#3643: 96.76%\n", "#3644: 96.76%\n", "#3645: 96.76%\n", "#3646: 96.76%\n", "#3647: 96.77%\n", "#3648: 96.77%\n", "#3649: 96.77%\n", "#3650: 96.77%\n", "#3651: 96.77%\n", "#3652: 96.77%\n", "#3653: 96.77%\n", "#3654: 96.77%\n", "#3655: 96.77%\n", "#3656: 96.77%\n", "#3657: 96.77%\n", "#3658: 96.78%\n", "#3659: 96.78%\n", "#3660: 96.78%\n", "#3661: 96.78%\n", "#3662: 96.78%\n", "#3663: 96.78%\n", "#3664: 96.78%\n", "#3665: 96.78%\n", "#3666: 96.78%\n", "#3667: 96.78%\n", "#3668: 96.78%\n", "#3669: 96.78%\n", "#3670: 96.79%\n", "#3671: 96.79%\n", "#3672: 96.79%\n", "#3673: 96.79%\n", "#3674: 96.79%\n", "#3675: 96.79%\n", "#3676: 96.79%\n", "#3677: 96.79%\n", "#3678: 96.79%\n", "#3679: 96.79%\n", "#3680: 96.79%\n", "#3681: 96.80%\n", "#3682: 96.80%\n", "#3683: 96.80%\n", "#3684: 96.80%\n", "#3685: 96.80%\n", "#3686: 96.80%\n", "#3687: 96.80%\n", "#3688: 96.80%\n", "#3689: 96.80%\n", "#3690: 96.80%\n", "#3691: 96.80%\n", "#3692: 96.80%\n", "#3693: 96.81%\n", "#3694: 96.81%\n", "#3695: 96.81%\n", "#3696: 96.81%\n", "#3697: 96.81%\n", "#3698: 96.81%\n", "#3699: 96.81%\n", "#3700: 96.81%\n", "#3701: 96.81%\n", "#3702: 96.81%\n", "#3703: 96.81%\n", "#3704: 96.82%\n", "#3705: 96.82%\n", "#3706: 96.82%\n", "#3707: 96.82%\n", "#3708: 96.82%\n", "#3709: 96.82%\n", "#3710: 96.82%\n", "#3711: 96.82%\n", "#3712: 96.82%\n", "#3713: 96.82%\n", "#3714: 96.82%\n", "#3715: 96.82%\n", "#3716: 96.83%\n", "#3717: 96.83%\n", "#3718: 96.83%\n", "#3719: 96.83%\n", "#3720: 96.83%\n", "#3721: 96.83%\n", "#3722: 96.83%\n", "#3723: 96.83%\n", "#3724: 96.83%\n", "#3725: 96.83%\n", "#3726: 96.81%\n", "#3727: 96.81%\n", "#3728: 96.81%\n", "#3729: 96.81%\n", "#3730: 96.81%\n", "#3731: 96.81%\n", "#3732: 96.81%\n", "#3733: 96.81%\n", "#3734: 96.81%\n", "#3735: 96.81%\n", "#3736: 96.82%\n", "#3737: 96.82%\n", "#3738: 96.79%\n", "#3739: 96.79%\n", "#3740: 96.79%\n", "#3741: 96.79%\n", "#3742: 96.79%\n", "#3743: 96.79%\n", "#3744: 96.80%\n", "#3745: 96.80%\n", "#3746: 96.80%\n", "#3747: 96.80%\n", "#3748: 96.80%\n", "#3749: 96.80%\n", "#3750: 96.80%\n", "#3751: 96.80%\n", "#3752: 96.80%\n", "#3753: 96.80%\n", "#3754: 96.80%\n", "#3755: 96.81%\n", "#3756: 96.81%\n", "#3757: 96.78%\n", "#3758: 96.78%\n", "#3759: 96.78%\n", "#3760: 96.78%\n", "#3761: 96.78%\n", "#3762: 96.78%\n", "#3763: 96.79%\n", "#3764: 96.79%\n", "#3765: 96.79%\n", "#3766: 96.79%\n", "#3767: 96.76%\n", "#3768: 96.76%\n", "#3769: 96.76%\n", "#3770: 96.76%\n", "#3771: 96.77%\n", "#3772: 96.77%\n", "#3773: 96.77%\n", "#3774: 96.77%\n", "#3775: 96.77%\n", "#3776: 96.77%\n", "#3777: 96.77%\n", "#3778: 96.77%\n", "#3779: 96.77%\n", "#3780: 96.75%\n", "#3781: 96.75%\n", "#3782: 96.75%\n", "#3783: 96.75%\n", "#3784: 96.75%\n", "#3785: 96.75%\n", "#3786: 96.75%\n", "#3787: 96.75%\n", "#3788: 96.75%\n", "#3789: 96.75%\n", "#3790: 96.76%\n", "#3791: 96.76%\n", "#3792: 96.76%\n", "#3793: 96.76%\n", "#3794: 96.76%\n", "#3795: 96.76%\n", "#3796: 96.76%\n", "#3797: 96.76%\n", "#3798: 96.76%\n", "#3799: 96.76%\n", "#3800: 96.76%\n", "#3801: 96.76%\n", "#3802: 96.77%\n", "#3803: 96.77%\n", "#3804: 96.77%\n", "#3805: 96.77%\n", "#3806: 96.77%\n", "#3807: 96.77%\n", "#3808: 96.74%\n", "#3809: 96.75%\n", "#3810: 96.75%\n", "#3811: 96.75%\n", "#3812: 96.75%\n", "#3813: 96.75%\n", "#3814: 96.75%\n", "#3815: 96.75%\n", "#3816: 96.75%\n", "#3817: 96.75%\n", "#3818: 96.75%\n", "#3819: 96.75%\n", "#3820: 96.75%\n", "#3821: 96.76%\n", "#3822: 96.76%\n", "#3823: 96.76%\n", "#3824: 96.76%\n", "#3825: 96.76%\n", "#3826: 96.76%\n", "#3827: 96.76%\n", "#3828: 96.76%\n", "#3829: 96.76%\n", "#3830: 96.76%\n", "#3831: 96.76%\n", "#3832: 96.76%\n", "#3833: 96.77%\n", "#3834: 96.77%\n", "#3835: 96.77%\n", "#3836: 96.77%\n", "#3837: 96.77%\n", "#3838: 96.77%\n", "#3839: 96.77%\n", "#3840: 96.77%\n", "#3841: 96.77%\n", "#3842: 96.77%\n", "#3843: 96.77%\n", "#3844: 96.78%\n", "#3845: 96.78%\n", "#3846: 96.78%\n", "#3847: 96.78%\n", "#3848: 96.78%\n", "#3849: 96.78%\n", "#3850: 96.75%\n", "#3851: 96.75%\n", "#3852: 96.76%\n", "#3853: 96.76%\n", "#3854: 96.76%\n", "#3855: 96.73%\n", "#3856: 96.73%\n", "#3857: 96.73%\n", "#3858: 96.73%\n", "#3859: 96.74%\n", "#3860: 96.74%\n", "#3861: 96.74%\n", "#3862: 96.74%\n", "#3863: 96.74%\n", "#3864: 96.74%\n", "#3865: 96.74%\n", "#3866: 96.74%\n", "#3867: 96.74%\n", "#3868: 96.74%\n", "#3869: 96.74%\n", "#3870: 96.75%\n", "#3871: 96.75%\n", "#3872: 96.75%\n", "#3873: 96.75%\n", "#3874: 96.75%\n", "#3875: 96.75%\n", "#3876: 96.75%\n", "#3877: 96.75%\n", "#3878: 96.75%\n", "#3879: 96.75%\n", "#3880: 96.75%\n", "#3881: 96.75%\n", "#3882: 96.76%\n", "#3883: 96.76%\n", "#3884: 96.76%\n", "#3885: 96.76%\n", "#3886: 96.76%\n", "#3887: 96.76%\n", "#3888: 96.76%\n", "#3889: 96.76%\n", "#3890: 96.76%\n", "#3891: 96.76%\n", "#3892: 96.76%\n", "#3893: 96.76%\n", "#3894: 96.77%\n", "#3895: 96.77%\n", "#3896: 96.77%\n", "#3897: 96.77%\n", "#3898: 96.77%\n", "#3899: 96.77%\n", "#3900: 96.77%\n", "#3901: 96.77%\n", "#3902: 96.77%\n", "#3903: 96.77%\n", "#3904: 96.77%\n", "#3905: 96.77%\n", "#3906: 96.75%\n", "#3907: 96.75%\n", "#3908: 96.75%\n", "#3909: 96.75%\n", "#3910: 96.75%\n", "#3911: 96.75%\n", "#3912: 96.75%\n", "#3913: 96.76%\n", "#3914: 96.76%\n", "#3915: 96.76%\n", "#3916: 96.76%\n", "#3917: 96.76%\n", "#3918: 96.76%\n", "#3919: 96.76%\n", "#3920: 96.76%\n", "#3921: 96.76%\n", "#3922: 96.76%\n", "#3923: 96.76%\n", "#3924: 96.76%\n", "#3925: 96.77%\n", "#3926: 96.77%\n", "#3927: 96.77%\n", "#3928: 96.77%\n", "#3929: 96.77%\n", "#3930: 96.77%\n", "#3931: 96.77%\n", "#3932: 96.77%\n", "#3933: 96.77%\n", "#3934: 96.77%\n", "#3935: 96.77%\n", "#3936: 96.77%\n", "#3937: 96.78%\n", "#3938: 96.78%\n", "#3939: 96.78%\n", "#3940: 96.78%\n", "#3941: 96.78%\n", "#3942: 96.78%\n", "#3943: 96.75%\n", "#3944: 96.76%\n", "#3945: 96.76%\n", "#3946: 96.76%\n", "#3947: 96.76%\n", "#3948: 96.76%\n", "#3949: 96.76%\n", "#3950: 96.76%\n", "#3951: 96.76%\n", "#3952: 96.76%\n", "#3953: 96.76%\n", "#3954: 96.76%\n", "#3955: 96.76%\n", "#3956: 96.77%\n", "#3957: 96.77%\n", "#3958: 96.77%\n", "#3959: 96.77%\n", "#3960: 96.77%\n", "#3961: 96.77%\n", "#3962: 96.77%\n", "#3963: 96.77%\n", "#3964: 96.77%\n", "#3965: 96.77%\n", "#3966: 96.77%\n", "#3967: 96.77%\n", "#3968: 96.78%\n", "#3969: 96.78%\n", "#3970: 96.78%\n", "#3971: 96.78%\n", "#3972: 96.78%\n", "#3973: 96.78%\n", "#3974: 96.78%\n", "#3975: 96.78%\n", "#3976: 96.76%\n", "#3977: 96.76%\n", "#3978: 96.76%\n", "#3979: 96.76%\n", "#3980: 96.76%\n", "#3981: 96.76%\n", "#3982: 96.76%\n", "#3983: 96.76%\n", "#3984: 96.76%\n", "#3985: 96.76%\n", "#3986: 96.76%\n", "#3987: 96.77%\n", "#3988: 96.77%\n", "#3989: 96.77%\n", "#3990: 96.77%\n", "#3991: 96.77%\n", "#3992: 96.77%\n", "#3993: 96.77%\n", "#3994: 96.77%\n", "#3995: 96.77%\n", "#3996: 96.77%\n", "#3997: 96.77%\n", "#3998: 96.77%\n", "#3999: 96.78%\n", "#4000: 96.78%\n", "#4001: 96.78%\n", "#4002: 96.78%\n", "#4003: 96.78%\n", "#4004: 96.78%\n", "#4005: 96.78%\n", "#4006: 96.78%\n", "#4007: 96.78%\n", "#4008: 96.78%\n", "#4009: 96.78%\n", "#4010: 96.78%\n", "#4011: 96.78%\n", "#4012: 96.79%\n", "#4013: 96.79%\n", "#4014: 96.79%\n", "#4015: 96.79%\n", "#4016: 96.79%\n", "#4017: 96.79%\n", "#4018: 96.79%\n", "#4019: 96.79%\n", "#4020: 96.79%\n", "#4021: 96.79%\n", "#4022: 96.79%\n", "#4023: 96.79%\n", "#4024: 96.80%\n", "#4025: 96.80%\n", "#4026: 96.80%\n", "#4027: 96.80%\n", "#4028: 96.80%\n", "#4029: 96.80%\n", "#4030: 96.80%\n", "#4031: 96.80%\n", "#4032: 96.80%\n", "#4033: 96.80%\n", "#4034: 96.80%\n", "#4035: 96.80%\n", "#4036: 96.80%\n", "#4037: 96.81%\n", "#4038: 96.81%\n", "#4039: 96.81%\n", "#4040: 96.81%\n", "#4041: 96.81%\n", "#4042: 96.81%\n", "#4043: 96.81%\n", "#4044: 96.81%\n", "#4045: 96.81%\n", "#4046: 96.81%\n", "#4047: 96.81%\n", "#4048: 96.81%\n", "#4049: 96.81%\n", "#4050: 96.82%\n", "#4051: 96.82%\n", "#4052: 96.82%\n", "#4053: 96.82%\n", "#4054: 96.82%\n", "#4055: 96.82%\n", "#4056: 96.82%\n", "#4057: 96.82%\n", "#4058: 96.82%\n", "#4059: 96.82%\n", "#4060: 96.82%\n", "#4061: 96.82%\n", "#4062: 96.83%\n", "#4063: 96.80%\n", "#4064: 96.80%\n", "#4065: 96.80%\n", "#4066: 96.80%\n", "#4067: 96.80%\n", "#4068: 96.81%\n", "#4069: 96.81%\n", "#4070: 96.81%\n", "#4071: 96.81%\n", "#4072: 96.81%\n", "#4073: 96.81%\n", "#4074: 96.81%\n", "#4075: 96.81%\n", "#4076: 96.81%\n", "#4077: 96.81%\n", "#4078: 96.79%\n", "#4079: 96.79%\n", "#4080: 96.79%\n", "#4081: 96.79%\n", "#4082: 96.79%\n", "#4083: 96.79%\n", "#4084: 96.79%\n", "#4085: 96.79%\n", "#4086: 96.79%\n", "#4087: 96.80%\n", "#4088: 96.80%\n", "#4089: 96.80%\n", "#4090: 96.80%\n", "#4091: 96.80%\n", "#4092: 96.80%\n", "#4093: 96.80%\n", "#4094: 96.80%\n", "#4095: 96.80%\n", "#4096: 96.80%\n", "#4097: 96.80%\n", "#4098: 96.80%\n", "#4099: 96.80%\n", "#4100: 96.81%\n", "#4101: 96.81%\n", "#4102: 96.81%\n", "#4103: 96.81%\n", "#4104: 96.81%\n", "#4105: 96.81%\n", "#4106: 96.81%\n", "#4107: 96.81%\n", "#4108: 96.81%\n", "#4109: 96.81%\n", "#4110: 96.81%\n", "#4111: 96.81%\n", "#4112: 96.81%\n", "#4113: 96.82%\n", "#4114: 96.82%\n", "#4115: 96.82%\n", "#4116: 96.79%\n", "#4117: 96.79%\n", "#4118: 96.80%\n", "#4119: 96.80%\n", "#4120: 96.80%\n", "#4121: 96.80%\n", "#4122: 96.80%\n", "#4123: 96.77%\n", "#4124: 96.78%\n", "#4125: 96.78%\n", "#4126: 96.78%\n", "#4127: 96.78%\n", "#4128: 96.78%\n", "#4129: 96.78%\n", "#4130: 96.78%\n", "#4131: 96.78%\n", "#4132: 96.78%\n", "#4133: 96.78%\n", "#4134: 96.78%\n", "#4135: 96.78%\n", "#4136: 96.79%\n", "#4137: 96.79%\n", "#4138: 96.79%\n", "#4139: 96.79%\n", "#4140: 96.79%\n", "#4141: 96.79%\n", "#4142: 96.79%\n", "#4143: 96.79%\n", "#4144: 96.79%\n", "#4145: 96.79%\n", "#4146: 96.79%\n", "#4147: 96.79%\n", "#4148: 96.79%\n", "#4149: 96.80%\n", "#4150: 96.80%\n", "#4151: 96.80%\n", "#4152: 96.80%\n", "#4153: 96.80%\n", "#4154: 96.80%\n", "#4155: 96.80%\n", "#4156: 96.80%\n", "#4157: 96.80%\n", "#4158: 96.80%\n", "#4159: 96.80%\n", "#4160: 96.80%\n", "#4161: 96.80%\n", "#4162: 96.81%\n", "#4163: 96.78%\n", "#4164: 96.78%\n", "#4165: 96.78%\n", "#4166: 96.78%\n", "#4167: 96.79%\n", "#4168: 96.79%\n", "#4169: 96.79%\n", "#4170: 96.79%\n", "#4171: 96.79%\n", "#4172: 96.79%\n", "#4173: 96.79%\n", "#4174: 96.79%\n", "#4175: 96.79%\n", "#4176: 96.77%\n", "#4177: 96.77%\n", "#4178: 96.77%\n", "#4179: 96.77%\n", "#4180: 96.77%\n", "#4181: 96.77%\n", "#4182: 96.77%\n", "#4183: 96.77%\n", "#4184: 96.77%\n", "#4185: 96.77%\n", "#4186: 96.78%\n", "#4187: 96.78%\n", "#4188: 96.78%\n", "#4189: 96.78%\n", "#4190: 96.78%\n", "#4191: 96.78%\n", "#4192: 96.78%\n", "#4193: 96.78%\n", "#4194: 96.78%\n", "#4195: 96.78%\n", "#4196: 96.78%\n", "#4197: 96.78%\n", "#4198: 96.78%\n", "#4199: 96.79%\n", "#4200: 96.79%\n", "#4201: 96.79%\n", "#4202: 96.79%\n", "#4203: 96.79%\n", "#4204: 96.79%\n", "#4205: 96.77%\n", "#4206: 96.77%\n", "#4207: 96.77%\n", "#4208: 96.77%\n", "#4209: 96.77%\n", "#4210: 96.77%\n", "#4211: 96.77%\n", "#4212: 96.77%\n", "#4213: 96.77%\n", "#4214: 96.77%\n", "#4215: 96.77%\n", "#4216: 96.77%\n", "#4217: 96.78%\n", "#4218: 96.78%\n", "#4219: 96.78%\n", "#4220: 96.78%\n", "#4221: 96.78%\n", "#4222: 96.78%\n", "#4223: 96.78%\n", "#4224: 96.78%\n", "#4225: 96.78%\n", "#4226: 96.78%\n", "#4227: 96.78%\n", "#4228: 96.78%\n", "#4229: 96.78%\n", "#4230: 96.79%\n", "#4231: 96.79%\n", "#4232: 96.79%\n", "#4233: 96.79%\n", "#4234: 96.79%\n", "#4235: 96.79%\n", "#4236: 96.79%\n", "#4237: 96.79%\n", "#4238: 96.79%\n", "#4239: 96.79%\n", "#4240: 96.79%\n", "#4241: 96.79%\n", "#4242: 96.79%\n", "#4243: 96.80%\n", "#4244: 96.80%\n", "#4245: 96.80%\n", "#4246: 96.80%\n", "#4247: 96.80%\n", "#4248: 96.80%\n", "#4249: 96.80%\n", "#4250: 96.80%\n", "#4251: 96.80%\n", "#4252: 96.80%\n", "#4253: 96.80%\n", "#4254: 96.80%\n", "#4255: 96.80%\n", "#4256: 96.78%\n", "#4257: 96.78%\n", "#4258: 96.78%\n", "#4259: 96.78%\n", "#4260: 96.78%\n", "#4261: 96.79%\n", "#4262: 96.79%\n", "#4263: 96.79%\n", "#4264: 96.79%\n", "#4265: 96.77%\n", "#4266: 96.77%\n", "#4267: 96.77%\n", "#4268: 96.77%\n", "#4269: 96.77%\n", "#4270: 96.77%\n", "#4271: 96.77%\n", "#4272: 96.77%\n", "#4273: 96.77%\n", "#4274: 96.77%\n", "#4275: 96.77%\n", "#4276: 96.77%\n", "#4277: 96.77%\n", "#4278: 96.77%\n", "#4279: 96.78%\n", "#4280: 96.78%\n", "#4281: 96.78%\n", "#4282: 96.78%\n", "#4283: 96.78%\n", "#4284: 96.78%\n", "#4285: 96.78%\n", "#4286: 96.78%\n", "#4287: 96.78%\n", "#4288: 96.78%\n", "#4289: 96.78%\n", "#4290: 96.78%\n", "#4291: 96.78%\n", "#4292: 96.79%\n", "#4293: 96.79%\n", "#4294: 96.79%\n", "#4295: 96.79%\n", "#4296: 96.79%\n", "#4297: 96.79%\n", "#4298: 96.79%\n", "#4299: 96.79%\n", "#4300: 96.79%\n", "#4301: 96.79%\n", "#4302: 96.79%\n", "#4303: 96.79%\n", "#4304: 96.79%\n", "#4305: 96.80%\n", "#4306: 96.77%\n", "#4307: 96.77%\n", "#4308: 96.77%\n", "#4309: 96.77%\n", "#4310: 96.78%\n", "#4311: 96.78%\n", "#4312: 96.78%\n", "#4313: 96.78%\n", "#4314: 96.78%\n", "#4315: 96.78%\n", "#4316: 96.78%\n", "#4317: 96.78%\n", "#4318: 96.78%\n", "#4319: 96.78%\n", "#4320: 96.78%\n", "#4321: 96.78%\n", "#4322: 96.78%\n", "#4323: 96.79%\n", "#4324: 96.79%\n", "#4325: 96.79%\n", "#4326: 96.79%\n", "#4327: 96.79%\n", "#4328: 96.79%\n", "#4329: 96.79%\n", "#4330: 96.79%\n", "#4331: 96.79%\n", "#4332: 96.79%\n", "#4333: 96.79%\n", "#4334: 96.79%\n", "#4335: 96.79%\n", "#4336: 96.80%\n", "#4337: 96.80%\n", "#4338: 96.80%\n", "#4339: 96.80%\n", "#4340: 96.80%\n", "#4341: 96.80%\n", "#4342: 96.80%\n", "#4343: 96.80%\n", "#4344: 96.80%\n", "#4345: 96.80%\n", "#4346: 96.80%\n", "#4347: 96.80%\n", "#4348: 96.80%\n", "#4349: 96.80%\n", "#4350: 96.81%\n", "#4351: 96.81%\n", "#4352: 96.81%\n", "#4353: 96.81%\n", "#4354: 96.81%\n", "#4355: 96.81%\n", "#4356: 96.81%\n", "#4357: 96.81%\n", "#4358: 96.81%\n", "#4359: 96.81%\n", "#4360: 96.81%\n", "#4361: 96.81%\n", "#4362: 96.81%\n", "#4363: 96.81%\n", "#4364: 96.82%\n", "#4365: 96.82%\n", "#4366: 96.82%\n", "#4367: 96.82%\n", "#4368: 96.82%\n", "#4369: 96.82%\n", "#4370: 96.82%\n", "#4371: 96.82%\n", "#4372: 96.82%\n", "#4373: 96.82%\n", "#4374: 96.82%\n", "#4375: 96.82%\n", "#4376: 96.82%\n", "#4377: 96.83%\n", "#4378: 96.83%\n", "#4379: 96.83%\n", "#4380: 96.83%\n", "#4381: 96.83%\n", "#4382: 96.83%\n", "#4383: 96.83%\n", "#4384: 96.83%\n", "#4385: 96.83%\n", "#4386: 96.83%\n", "#4387: 96.83%\n", "#4388: 96.83%\n", "#4389: 96.83%\n", "#4390: 96.83%\n", "#4391: 96.81%\n", "#4392: 96.81%\n", "#4393: 96.81%\n", "#4394: 96.81%\n", "#4395: 96.82%\n", "#4396: 96.82%\n", "#4397: 96.82%\n", "#4398: 96.82%\n", "#4399: 96.82%\n", "#4400: 96.80%\n", "#4401: 96.80%\n", "#4402: 96.80%\n", "#4403: 96.80%\n", "#4404: 96.80%\n", "#4405: 96.80%\n", "#4406: 96.80%\n", "#4407: 96.80%\n", "#4408: 96.80%\n", "#4409: 96.80%\n", "#4410: 96.80%\n", "#4411: 96.80%\n", "#4412: 96.80%\n", "#4413: 96.81%\n", "#4414: 96.81%\n", "#4415: 96.81%\n", "#4416: 96.81%\n", "#4417: 96.81%\n", "#4418: 96.81%\n", "#4419: 96.81%\n", "#4420: 96.81%\n", "#4421: 96.81%\n", "#4422: 96.81%\n", "#4423: 96.81%\n", "#4424: 96.81%\n", "#4425: 96.81%\n", "#4426: 96.81%\n", "#4427: 96.82%\n", "#4428: 96.82%\n", "#4429: 96.82%\n", "#4430: 96.82%\n", "#4431: 96.82%\n", "#4432: 96.82%\n", "#4433: 96.82%\n", "#4434: 96.82%\n", "#4435: 96.82%\n", "#4436: 96.82%\n", "#4437: 96.82%\n", "#4438: 96.82%\n", "#4439: 96.82%\n", "#4440: 96.83%\n", "#4441: 96.83%\n", "#4442: 96.83%\n", "#4443: 96.80%\n", "#4444: 96.81%\n", "#4445: 96.81%\n", "#4446: 96.81%\n", "#4447: 96.81%\n", "#4448: 96.81%\n", "#4449: 96.81%\n", "#4450: 96.81%\n", "#4451: 96.81%\n", "#4452: 96.81%\n", "#4453: 96.81%\n", "#4454: 96.81%\n", "#4455: 96.81%\n", "#4456: 96.81%\n", "#4457: 96.81%\n", "#4458: 96.82%\n", "#4459: 96.82%\n", "#4460: 96.82%\n", "#4461: 96.82%\n", "#4462: 96.82%\n", "#4463: 96.82%\n", "#4464: 96.82%\n", "#4465: 96.82%\n", "#4466: 96.82%\n", "#4467: 96.82%\n", "#4468: 96.82%\n", "#4469: 96.82%\n", "#4470: 96.82%\n", "#4471: 96.82%\n", "#4472: 96.83%\n", "#4473: 96.83%\n", "#4474: 96.83%\n", "#4475: 96.83%\n", "#4476: 96.83%\n", "#4477: 96.83%\n", "#4478: 96.83%\n", "#4479: 96.83%\n", "#4480: 96.83%\n", "#4481: 96.83%\n", "#4482: 96.83%\n", "#4483: 96.83%\n", "#4484: 96.83%\n", "#4485: 96.83%\n", "#4486: 96.84%\n", "#4487: 96.84%\n", "#4488: 96.84%\n", "#4489: 96.84%\n", "#4490: 96.84%\n", "#4491: 96.84%\n", "#4492: 96.84%\n", "#4493: 96.84%\n", "#4494: 96.84%\n", "#4495: 96.84%\n", "#4496: 96.84%\n", "#4497: 96.82%\n", "#4498: 96.82%\n", "#4499: 96.82%\n", "#4500: 96.80%\n", "#4501: 96.80%\n", "#4502: 96.80%\n", "#4503: 96.80%\n", "#4504: 96.80%\n", "#4505: 96.78%\n", "#4506: 96.78%\n", "#4507: 96.78%\n", "#4508: 96.78%\n", "#4509: 96.78%\n", "#4510: 96.79%\n", "#4511: 96.79%\n", "#4512: 96.79%\n", "#4513: 96.79%\n", "#4514: 96.79%\n", "#4515: 96.79%\n", "#4516: 96.79%\n", "#4517: 96.79%\n", "#4518: 96.79%\n", "#4519: 96.79%\n", "#4520: 96.79%\n", "#4521: 96.79%\n", "#4522: 96.79%\n", "#4523: 96.79%\n", "#4524: 96.80%\n", "#4525: 96.80%\n", "#4526: 96.80%\n", "#4527: 96.80%\n", "#4528: 96.80%\n", "#4529: 96.80%\n", "#4530: 96.80%\n", "#4531: 96.80%\n", "#4532: 96.80%\n", "#4533: 96.80%\n", "#4534: 96.80%\n", "#4535: 96.80%\n", "#4536: 96.78%\n", "#4537: 96.78%\n", "#4538: 96.78%\n", "#4539: 96.78%\n", "#4540: 96.78%\n", "#4541: 96.79%\n", "#4542: 96.79%\n", "#4543: 96.79%\n", "#4544: 96.79%\n", "#4545: 96.79%\n", "#4546: 96.79%\n", "#4547: 96.79%\n", "#4548: 96.79%\n", "#4549: 96.79%\n", "#4550: 96.79%\n", "#4551: 96.79%\n", "#4552: 96.79%\n", "#4553: 96.79%\n", "#4554: 96.79%\n", "#4555: 96.80%\n", "#4556: 96.80%\n", "#4557: 96.80%\n", "#4558: 96.80%\n", "#4559: 96.80%\n", "#4560: 96.80%\n", "#4561: 96.80%\n", "#4562: 96.80%\n", "#4563: 96.80%\n", "#4564: 96.80%\n", "#4565: 96.80%\n", "#4566: 96.80%\n", "#4567: 96.80%\n", "#4568: 96.80%\n", "#4569: 96.81%\n", "#4570: 96.81%\n", "#4571: 96.78%\n", "#4572: 96.79%\n", "#4573: 96.79%\n", "#4574: 96.79%\n", "#4575: 96.79%\n", "#4576: 96.79%\n", "#4577: 96.79%\n", "#4578: 96.77%\n", "#4579: 96.77%\n", "#4580: 96.77%\n", "#4581: 96.77%\n", "#4582: 96.77%\n", "#4583: 96.77%\n", "#4584: 96.77%\n", "#4585: 96.77%\n", "#4586: 96.77%\n", "#4587: 96.77%\n", "#4588: 96.77%\n", "#4589: 96.78%\n", "#4590: 96.78%\n", "#4591: 96.78%\n", "#4592: 96.78%\n", "#4593: 96.78%\n", "#4594: 96.78%\n", "#4595: 96.78%\n", "#4596: 96.78%\n", "#4597: 96.78%\n", "#4598: 96.78%\n", "#4599: 96.78%\n", "#4600: 96.78%\n", "#4601: 96.78%\n", "#4602: 96.78%\n", "#4603: 96.79%\n", "#4604: 96.79%\n", "#4605: 96.79%\n", "#4606: 96.79%\n", "#4607: 96.79%\n", "#4608: 96.79%\n", "#4609: 96.79%\n", "#4610: 96.79%\n", "#4611: 96.79%\n", "#4612: 96.79%\n", "#4613: 96.79%\n", "#4614: 96.79%\n", "#4615: 96.77%\n", "#4616: 96.77%\n", "#4617: 96.77%\n", "#4618: 96.77%\n", "#4619: 96.77%\n", "#4620: 96.78%\n", "#4621: 96.78%\n", "#4622: 96.78%\n", "#4623: 96.78%\n", "#4624: 96.78%\n", "#4625: 96.78%\n", "#4626: 96.78%\n", "#4627: 96.78%\n", "#4628: 96.78%\n", "#4629: 96.78%\n", "#4630: 96.78%\n", "#4631: 96.78%\n", "#4632: 96.78%\n", "#4633: 96.78%\n", "#4634: 96.79%\n", "#4635: 96.79%\n", "#4636: 96.79%\n", "#4637: 96.79%\n", "#4638: 96.79%\n", "#4639: 96.77%\n", "#4640: 96.77%\n", "#4641: 96.77%\n", "#4642: 96.77%\n", "#4643: 96.77%\n", "#4644: 96.77%\n", "#4645: 96.77%\n", "#4646: 96.77%\n", "#4647: 96.77%\n", "#4648: 96.77%\n", "#4649: 96.77%\n", "#4650: 96.77%\n", "#4651: 96.78%\n", "#4652: 96.78%\n", "#4653: 96.78%\n", "#4654: 96.78%\n", "#4655: 96.78%\n", "#4656: 96.78%\n", "#4657: 96.78%\n", "#4658: 96.78%\n", "#4659: 96.78%\n", "#4660: 96.78%\n", "#4661: 96.78%\n", "#4662: 96.78%\n", "#4663: 96.78%\n", "#4664: 96.78%\n", "#4665: 96.79%\n", "#4666: 96.79%\n", "#4667: 96.79%\n", "#4668: 96.79%\n", "#4669: 96.79%\n", "#4670: 96.79%\n", "#4671: 96.79%\n", "#4672: 96.79%\n", "#4673: 96.79%\n", "#4674: 96.79%\n", "#4675: 96.79%\n", "#4676: 96.79%\n", "#4677: 96.79%\n", "#4678: 96.79%\n", "#4679: 96.79%\n", "#4680: 96.80%\n", "#4681: 96.80%\n", "#4682: 96.80%\n", "#4683: 96.80%\n", "#4684: 96.80%\n", "#4685: 96.80%\n", "#4686: 96.80%\n", "#4687: 96.80%\n", "#4688: 96.80%\n", "#4689: 96.80%\n", "#4690: 96.80%\n", "#4691: 96.80%\n", "#4692: 96.80%\n", "#4693: 96.80%\n", "#4694: 96.81%\n", "#4695: 96.81%\n", "#4696: 96.81%\n", "#4697: 96.81%\n", "#4698: 96.81%\n", "#4699: 96.81%\n", "#4700: 96.81%\n", "#4701: 96.81%\n", "#4702: 96.81%\n", "#4703: 96.81%\n", "#4704: 96.81%\n", "#4705: 96.81%\n", "#4706: 96.81%\n", "#4707: 96.81%\n", "#4708: 96.81%\n", "#4709: 96.82%\n", "#4710: 96.82%\n", "#4711: 96.82%\n", "#4712: 96.82%\n", "#4713: 96.82%\n", "#4714: 96.82%\n", "#4715: 96.82%\n", "#4716: 96.82%\n", "#4717: 96.82%\n", "#4718: 96.82%\n", "#4719: 96.82%\n", "#4720: 96.82%\n", "#4721: 96.82%\n", "#4722: 96.82%\n", "#4723: 96.82%\n", "#4724: 96.83%\n", "#4725: 96.83%\n", "#4726: 96.83%\n", "#4727: 96.83%\n", "#4728: 96.83%\n", "#4729: 96.83%\n", "#4730: 96.83%\n", "#4731: 96.83%\n", "#4732: 96.83%\n", "#4733: 96.83%\n", "#4734: 96.83%\n", "#4735: 96.83%\n", "#4736: 96.83%\n", "#4737: 96.81%\n", "#4738: 96.81%\n", "#4739: 96.81%\n", "#4740: 96.79%\n", "#4741: 96.79%\n", "#4742: 96.80%\n", "#4743: 96.80%\n", "#4744: 96.80%\n", "#4745: 96.80%\n", "#4746: 96.80%\n", "#4747: 96.80%\n", "#4748: 96.80%\n", "#4749: 96.80%\n", "#4750: 96.80%\n", "#4751: 96.78%\n", "#4752: 96.78%\n", "#4753: 96.78%\n", "#4754: 96.78%\n", "#4755: 96.78%\n", "#4756: 96.78%\n", "#4757: 96.78%\n", "#4758: 96.79%\n", "#4759: 96.79%\n", "#4760: 96.79%\n", "#4761: 96.77%\n", "#4762: 96.77%\n", "#4763: 96.77%\n", "#4764: 96.77%\n", "#4765: 96.77%\n", "#4766: 96.77%\n", "#4767: 96.77%\n", "#4768: 96.77%\n", "#4769: 96.77%\n", "#4770: 96.77%\n", "#4771: 96.77%\n", "#4772: 96.77%\n", "#4773: 96.77%\n", "#4774: 96.77%\n", "#4775: 96.78%\n", "#4776: 96.78%\n", "#4777: 96.78%\n", "#4778: 96.78%\n", "#4779: 96.78%\n", "#4780: 96.78%\n", "#4781: 96.78%\n", "#4782: 96.78%\n", "#4783: 96.76%\n", "#4784: 96.76%\n", "#4785: 96.76%\n", "#4786: 96.76%\n", "#4787: 96.76%\n", "#4788: 96.76%\n", "#4789: 96.76%\n", "#4790: 96.76%\n", "#4791: 96.77%\n", "#4792: 96.77%\n", "#4793: 96.77%\n", "#4794: 96.77%\n", "#4795: 96.77%\n", "#4796: 96.77%\n", "#4797: 96.77%\n", "#4798: 96.77%\n", "#4799: 96.77%\n", "#4800: 96.77%\n", "#4801: 96.77%\n", "#4802: 96.77%\n", "#4803: 96.77%\n", "#4804: 96.77%\n", "#4805: 96.77%\n", "#4806: 96.78%\n", "#4807: 96.76%\n", "#4808: 96.74%\n", "#4809: 96.74%\n", "#4810: 96.74%\n", "#4811: 96.74%\n", "#4812: 96.74%\n", "#4813: 96.74%\n", "#4814: 96.74%\n", "#4815: 96.74%\n", "#4816: 96.74%\n", "#4817: 96.74%\n", "#4818: 96.74%\n", "#4819: 96.74%\n", "#4820: 96.74%\n", "#4821: 96.74%\n", "#4822: 96.74%\n", "#4823: 96.75%\n", "#4824: 96.75%\n", "#4825: 96.75%\n", "#4826: 96.75%\n", "#4827: 96.75%\n", "#4828: 96.75%\n", "#4829: 96.75%\n", "#4830: 96.75%\n", "#4831: 96.75%\n", "#4832: 96.75%\n", "#4833: 96.75%\n", "#4834: 96.75%\n", "#4835: 96.75%\n", "#4836: 96.75%\n", "#4837: 96.75%\n", "#4838: 96.73%\n", "#4839: 96.74%\n", "#4840: 96.74%\n", "#4841: 96.74%\n", "#4842: 96.74%\n", "#4843: 96.74%\n", "#4844: 96.74%\n", "#4845: 96.74%\n", "#4846: 96.74%\n", "#4847: 96.74%\n", "#4848: 96.74%\n", "#4849: 96.74%\n", "#4850: 96.74%\n", "#4851: 96.74%\n", "#4852: 96.72%\n", "#4853: 96.72%\n", "#4854: 96.73%\n", "#4855: 96.73%\n", "#4856: 96.73%\n", "#4857: 96.73%\n", "#4858: 96.73%\n", "#4859: 96.73%\n", "#4860: 96.71%\n", "#4861: 96.71%\n", "#4862: 96.71%\n", "#4863: 96.71%\n", "#4864: 96.71%\n", "#4865: 96.71%\n", "#4866: 96.71%\n", "#4867: 96.71%\n", "#4868: 96.71%\n", "#4869: 96.71%\n", "#4870: 96.72%\n", "#4871: 96.72%\n", "#4872: 96.72%\n", "#4873: 96.72%\n", "#4874: 96.70%\n", "#4875: 96.70%\n", "#4876: 96.70%\n", "#4877: 96.70%\n", "#4878: 96.70%\n", "#4879: 96.68%\n", "#4880: 96.68%\n", "#4881: 96.68%\n", "#4882: 96.68%\n", "#4883: 96.68%\n", "#4884: 96.68%\n", "#4885: 96.68%\n", "#4886: 96.69%\n", "#4887: 96.69%\n", "#4888: 96.69%\n", "#4889: 96.69%\n", "#4890: 96.67%\n", "#4891: 96.67%\n", "#4892: 96.67%\n", "#4893: 96.67%\n", "#4894: 96.67%\n", "#4895: 96.67%\n", "#4896: 96.67%\n", "#4897: 96.67%\n", "#4898: 96.67%\n", "#4899: 96.67%\n", "#4900: 96.67%\n", "#4901: 96.67%\n", "#4902: 96.68%\n", "#4903: 96.68%\n", "#4904: 96.68%\n", "#4905: 96.68%\n", "#4906: 96.68%\n", "#4907: 96.68%\n", "#4908: 96.68%\n", "#4909: 96.68%\n", "#4910: 96.68%\n", "#4911: 96.68%\n", "#4912: 96.68%\n", "#4913: 96.68%\n", "#4914: 96.68%\n", "#4915: 96.68%\n", "#4916: 96.68%\n", "#4917: 96.69%\n", "#4918: 96.69%\n", "#4919: 96.69%\n", "#4920: 96.69%\n", "#4921: 96.69%\n", "#4922: 96.69%\n", "#4923: 96.69%\n", "#4924: 96.69%\n", "#4925: 96.69%\n", "#4926: 96.69%\n", "#4927: 96.69%\n", "#4928: 96.69%\n", "#4929: 96.69%\n", "#4930: 96.69%\n", "#4931: 96.70%\n", "#4932: 96.70%\n", "#4933: 96.70%\n", "#4934: 96.70%\n", "#4935: 96.70%\n", "#4936: 96.70%\n", "#4937: 96.70%\n", "#4938: 96.70%\n", "#4939: 96.70%\n", "#4940: 96.70%\n", "#4941: 96.70%\n", "#4942: 96.70%\n", "#4943: 96.70%\n", "#4944: 96.70%\n", "#4945: 96.70%\n", "#4946: 96.71%\n", "#4947: 96.71%\n", "#4948: 96.71%\n", "#4949: 96.71%\n", "#4950: 96.71%\n", "#4951: 96.71%\n", "#4952: 96.71%\n", "#4953: 96.71%\n", "#4954: 96.71%\n", "#4955: 96.71%\n", "#4956: 96.69%\n", "#4957: 96.69%\n", "#4958: 96.69%\n", "#4959: 96.69%\n", "#4960: 96.69%\n", "#4961: 96.69%\n", "#4962: 96.70%\n", "#4963: 96.70%\n", "#4964: 96.70%\n", "#4965: 96.70%\n", "#4966: 96.70%\n", "#4967: 96.70%\n", "#4968: 96.70%\n", "#4969: 96.70%\n", "#4970: 96.70%\n", "#4971: 96.70%\n", "#4972: 96.70%\n", "#4973: 96.70%\n", "#4974: 96.70%\n", "#4975: 96.70%\n", "#4976: 96.70%\n", "#4977: 96.71%\n", "#4978: 96.69%\n", "#4979: 96.69%\n", "#4980: 96.69%\n", "#4981: 96.69%\n", "#4982: 96.69%\n", "#4983: 96.69%\n", "#4984: 96.69%\n", "#4985: 96.69%\n", "#4986: 96.69%\n", "#4987: 96.69%\n", "#4988: 96.69%\n", "#4989: 96.69%\n", "#4990: 96.69%\n", "#4991: 96.69%\n", "#4992: 96.70%\n", "#4993: 96.70%\n", "#4994: 96.70%\n", "#4995: 96.70%\n", "#4996: 96.70%\n", "#4997: 96.70%\n", "#4998: 96.70%\n", "#4999: 96.70%\n", "#5000: 96.70%\n", "#5001: 96.70%\n", "#5002: 96.70%\n", "#5003: 96.70%\n", "#5004: 96.70%\n", "#5005: 96.70%\n", "#5006: 96.70%\n", "#5007: 96.71%\n", "#5008: 96.71%\n", "#5009: 96.71%\n", "#5010: 96.71%\n", "#5011: 96.71%\n", "#5012: 96.71%\n", "#5013: 96.71%\n", "#5014: 96.71%\n", "#5015: 96.71%\n", "#5016: 96.71%\n", "#5017: 96.71%\n", "#5018: 96.71%\n", "#5019: 96.71%\n", "#5020: 96.71%\n", "#5021: 96.71%\n", "#5022: 96.72%\n", "#5023: 96.72%\n", "#5024: 96.72%\n", "#5025: 96.72%\n", "#5026: 96.72%\n", "#5027: 96.72%\n", "#5028: 96.72%\n", "#5029: 96.72%\n", "#5030: 96.72%\n", "#5031: 96.72%\n", "#5032: 96.72%\n", "#5033: 96.72%\n", "#5034: 96.72%\n", "#5035: 96.72%\n", "#5036: 96.72%\n", "#5037: 96.72%\n", "#5038: 96.73%\n", "#5039: 96.73%\n", "#5040: 96.73%\n", "#5041: 96.73%\n", "#5042: 96.73%\n", "#5043: 96.73%\n", "#5044: 96.73%\n", "#5045: 96.73%\n", "#5046: 96.73%\n", "#5047: 96.73%\n", "#5048: 96.73%\n", "#5049: 96.73%\n", "#5050: 96.73%\n", "#5051: 96.73%\n", "#5052: 96.73%\n", "#5053: 96.74%\n", "#5054: 96.74%\n", "#5055: 96.74%\n", "#5056: 96.74%\n", "#5057: 96.74%\n", "#5058: 96.74%\n", "#5059: 96.74%\n", "#5060: 96.74%\n", "#5061: 96.74%\n", "#5062: 96.74%\n", "#5063: 96.74%\n", "#5064: 96.74%\n", "#5065: 96.74%\n", "#5066: 96.74%\n", "#5067: 96.74%\n", "#5068: 96.74%\n", "#5069: 96.75%\n", "#5070: 96.75%\n", "#5071: 96.75%\n", "#5072: 96.75%\n", "#5073: 96.75%\n", "#5074: 96.75%\n", "#5075: 96.75%\n", "#5076: 96.75%\n", "#5077: 96.75%\n", "#5078: 96.75%\n", "#5079: 96.75%\n", "#5080: 96.75%\n", "#5081: 96.75%\n", "#5082: 96.75%\n", "#5083: 96.75%\n", "#5084: 96.76%\n", "#5085: 96.76%\n", "#5086: 96.76%\n", "#5087: 96.76%\n", "#5088: 96.76%\n", "#5089: 96.76%\n", "#5090: 96.76%\n", "#5091: 96.76%\n", "#5092: 96.76%\n", "#5093: 96.76%\n", "#5094: 96.76%\n", "#5095: 96.76%\n", "#5096: 96.76%\n", "#5097: 96.76%\n", "#5098: 96.76%\n", "#5099: 96.76%\n", "#5100: 96.77%\n", "#5101: 96.77%\n", "#5102: 96.77%\n", "#5103: 96.77%\n", "#5104: 96.77%\n", "#5105: 96.77%\n", "#5106: 96.77%\n", "#5107: 96.77%\n", "#5108: 96.77%\n", "#5109: 96.77%\n", "#5110: 96.77%\n", "#5111: 96.77%\n", "#5112: 96.77%\n", "#5113: 96.77%\n", "#5114: 96.77%\n", "#5115: 96.77%\n", "#5116: 96.78%\n", "#5117: 96.78%\n", "#5118: 96.78%\n", "#5119: 96.78%\n", "#5120: 96.78%\n", "#5121: 96.78%\n", "#5122: 96.78%\n", "#5123: 96.78%\n", "#5124: 96.78%\n", "#5125: 96.78%\n", "#5126: 96.78%\n", "#5127: 96.78%\n", "#5128: 96.78%\n", "#5129: 96.78%\n", "#5130: 96.78%\n", "#5131: 96.78%\n", "#5132: 96.79%\n", "#5133: 96.79%\n", "#5134: 96.79%\n", "#5135: 96.79%\n", "#5136: 96.79%\n", "#5137: 96.79%\n", "#5138: 96.79%\n", "#5139: 96.79%\n", "#5140: 96.77%\n", "#5141: 96.77%\n", "#5142: 96.77%\n", "#5143: 96.77%\n", "#5144: 96.77%\n", "#5145: 96.77%\n", "#5146: 96.77%\n", "#5147: 96.78%\n", "#5148: 96.78%\n", "#5149: 96.78%\n", "#5150: 96.78%\n", "#5151: 96.78%\n", "#5152: 96.78%\n", "#5153: 96.78%\n", "#5154: 96.78%\n", "#5155: 96.78%\n", "#5156: 96.78%\n", "#5157: 96.78%\n", "#5158: 96.78%\n", "#5159: 96.76%\n", "#5160: 96.76%\n", "#5161: 96.76%\n", "#5162: 96.77%\n", "#5163: 96.77%\n", "#5164: 96.77%\n", "#5165: 96.77%\n", "#5166: 96.77%\n", "#5167: 96.77%\n", "#5168: 96.77%\n", "#5169: 96.77%\n", "#5170: 96.77%\n", "#5171: 96.77%\n", "#5172: 96.77%\n", "#5173: 96.77%\n", "#5174: 96.77%\n", "#5175: 96.77%\n", "#5176: 96.75%\n", "#5177: 96.76%\n", "#5178: 96.76%\n", "#5179: 96.76%\n", "#5180: 96.76%\n", "#5181: 96.76%\n", "#5182: 96.76%\n", "#5183: 96.74%\n", "#5184: 96.74%\n", "#5185: 96.74%\n", "#5186: 96.74%\n", "#5187: 96.74%\n", "#5188: 96.74%\n", "#5189: 96.74%\n", "#5190: 96.74%\n", "#5191: 96.74%\n", "#5192: 96.75%\n", "#5193: 96.75%\n", "#5194: 96.75%\n", "#5195: 96.75%\n", "#5196: 96.75%\n", "#5197: 96.75%\n", "#5198: 96.75%\n", "#5199: 96.75%\n", "#5200: 96.75%\n", "#5201: 96.75%\n", "#5202: 96.75%\n", "#5203: 96.75%\n", "#5204: 96.75%\n", "#5205: 96.75%\n", "#5206: 96.75%\n", "#5207: 96.75%\n", "#5208: 96.76%\n", "#5209: 96.76%\n", "#5210: 96.76%\n", "#5211: 96.76%\n", "#5212: 96.76%\n", "#5213: 96.76%\n", "#5214: 96.76%\n", "#5215: 96.76%\n", "#5216: 96.76%\n", "#5217: 96.76%\n", "#5218: 96.76%\n", "#5219: 96.76%\n", "#5220: 96.76%\n", "#5221: 96.76%\n", "#5222: 96.76%\n", "#5223: 96.76%\n", "#5224: 96.77%\n", "#5225: 96.77%\n", "#5226: 96.77%\n", "#5227: 96.77%\n", "#5228: 96.77%\n", "#5229: 96.77%\n", "#5230: 96.77%\n", "#5231: 96.77%\n", "#5232: 96.77%\n", "#5233: 96.77%\n", "#5234: 96.77%\n", "#5235: 96.77%\n", "#5236: 96.77%\n", "#5237: 96.77%\n", "#5238: 96.77%\n", "#5239: 96.77%\n", "#5240: 96.78%\n", "#5241: 96.78%\n", "#5242: 96.78%\n", "#5243: 96.78%\n", "#5244: 96.78%\n", "#5245: 96.78%\n", "#5246: 96.78%\n", "#5247: 96.78%\n", "#5248: 96.78%\n", "#5249: 96.78%\n", "#5250: 96.78%\n", "#5251: 96.78%\n", "#5252: 96.78%\n", "#5253: 96.78%\n", "#5254: 96.78%\n", "#5255: 96.78%\n", "#5256: 96.79%\n", "#5257: 96.79%\n", "#5258: 96.79%\n", "#5259: 96.79%\n", "#5260: 96.79%\n", "#5261: 96.79%\n", "#5262: 96.79%\n", "#5263: 96.79%\n", "#5264: 96.79%\n", "#5265: 96.79%\n", "#5266: 96.79%\n", "#5267: 96.79%\n", "#5268: 96.79%\n", "#5269: 96.79%\n", "#5270: 96.79%\n", "#5271: 96.79%\n", "#5272: 96.79%\n", "#5273: 96.80%\n", "#5274: 96.80%\n", "#5275: 96.80%\n", "#5276: 96.80%\n", "#5277: 96.80%\n", "#5278: 96.80%\n", "#5279: 96.80%\n", "#5280: 96.80%\n", "#5281: 96.80%\n", "#5282: 96.80%\n", "#5283: 96.80%\n", "#5284: 96.80%\n", "#5285: 96.80%\n", "#5286: 96.80%\n", "#5287: 96.80%\n", "#5288: 96.80%\n", "#5289: 96.81%\n", "#5290: 96.81%\n", "#5291: 96.81%\n", "#5292: 96.81%\n", "#5293: 96.81%\n", "#5294: 96.81%\n", "#5295: 96.81%\n", "#5296: 96.81%\n", "#5297: 96.81%\n", "#5298: 96.81%\n", "#5299: 96.81%\n", "#5300: 96.81%\n", "#5301: 96.81%\n", "#5302: 96.81%\n", "#5303: 96.81%\n", "#5304: 96.81%\n", "#5305: 96.81%\n", "#5306: 96.82%\n", "#5307: 96.82%\n", "#5308: 96.82%\n", "#5309: 96.82%\n", "#5310: 96.82%\n", "#5311: 96.82%\n", "#5312: 96.82%\n", "#5313: 96.82%\n", "#5314: 96.82%\n", "#5315: 96.82%\n", "#5316: 96.82%\n", "#5317: 96.82%\n", "#5318: 96.82%\n", "#5319: 96.82%\n", "#5320: 96.82%\n", "#5321: 96.82%\n", "#5322: 96.83%\n", "#5323: 96.83%\n", "#5324: 96.83%\n", "#5325: 96.83%\n", "#5326: 96.83%\n", "#5327: 96.83%\n", "#5328: 96.83%\n", "#5329: 96.83%\n", "#5330: 96.83%\n", "#5331: 96.83%\n", "#5332: 96.83%\n", "#5333: 96.83%\n", "#5334: 96.83%\n", "#5335: 96.83%\n", "#5336: 96.83%\n", "#5337: 96.83%\n", "#5338: 96.83%\n", "#5339: 96.84%\n", "#5340: 96.84%\n", "#5341: 96.84%\n", "#5342: 96.84%\n", "#5343: 96.84%\n", "#5344: 96.84%\n", "#5345: 96.84%\n", "#5346: 96.84%\n", "#5347: 96.84%\n", "#5348: 96.84%\n", "#5349: 96.84%\n", "#5350: 96.84%\n", "#5351: 96.84%\n", "#5352: 96.84%\n", "#5353: 96.84%\n", "#5354: 96.84%\n", "#5355: 96.84%\n", "#5356: 96.85%\n", "#5357: 96.85%\n", "#5358: 96.85%\n", "#5359: 96.85%\n", "#5360: 96.85%\n", "#5361: 96.85%\n", "#5362: 96.85%\n", "#5363: 96.85%\n", "#5364: 96.85%\n", "#5365: 96.85%\n", "#5366: 96.85%\n", "#5367: 96.85%\n", "#5368: 96.85%\n", "#5369: 96.85%\n", "#5370: 96.85%\n", "#5371: 96.85%\n", "#5372: 96.85%\n", "#5373: 96.86%\n", "#5374: 96.86%\n", "#5375: 96.86%\n", "#5376: 96.86%\n", "#5377: 96.86%\n", "#5378: 96.86%\n", "#5379: 96.86%\n", "#5380: 96.86%\n", "#5381: 96.86%\n", "#5382: 96.86%\n", "#5383: 96.86%\n", "#5384: 96.86%\n", "#5385: 96.86%\n", "#5386: 96.86%\n", "#5387: 96.86%\n", "#5388: 96.86%\n", "#5389: 96.86%\n", "#5390: 96.87%\n", "#5391: 96.87%\n", "#5392: 96.87%\n", "#5393: 96.87%\n", "#5394: 96.87%\n", "#5395: 96.87%\n", "#5396: 96.87%\n", "#5397: 96.87%\n", "#5398: 96.87%\n", "#5399: 96.87%\n", "#5400: 96.87%\n", "#5401: 96.87%\n", "#5402: 96.87%\n", "#5403: 96.87%\n", "#5404: 96.87%\n", "#5405: 96.87%\n", "#5406: 96.87%\n", "#5407: 96.88%\n", "#5408: 96.88%\n", "#5409: 96.88%\n", "#5410: 96.88%\n", "#5411: 96.88%\n", "#5412: 96.88%\n", "#5413: 96.88%\n", "#5414: 96.88%\n", "#5415: 96.88%\n", "#5416: 96.88%\n", "#5417: 96.88%\n", "#5418: 96.88%\n", "#5419: 96.88%\n", "#5420: 96.88%\n", "#5421: 96.88%\n", "#5422: 96.88%\n", "#5423: 96.88%\n", "#5424: 96.88%\n", "#5425: 96.89%\n", "#5426: 96.89%\n", "#5427: 96.89%\n", "#5428: 96.89%\n", "#5429: 96.89%\n", "#5430: 96.89%\n", "#5431: 96.89%\n", "#5432: 96.89%\n", "#5433: 96.89%\n", "#5434: 96.89%\n", "#5435: 96.89%\n", "#5436: 96.89%\n", "#5437: 96.89%\n", "#5438: 96.89%\n", "#5439: 96.89%\n", "#5440: 96.89%\n", "#5441: 96.89%\n", "#5442: 96.90%\n", "#5443: 96.90%\n", "#5444: 96.90%\n", "#5445: 96.90%\n", "#5446: 96.90%\n", "#5447: 96.90%\n", "#5448: 96.90%\n", "#5449: 96.90%\n", "#5450: 96.90%\n", "#5451: 96.90%\n", "#5452: 96.90%\n", "#5453: 96.90%\n", "#5454: 96.90%\n", "#5455: 96.90%\n", "#5456: 96.90%\n", "#5457: 96.90%\n", "#5458: 96.90%\n", "#5459: 96.90%\n", "#5460: 96.91%\n", "#5461: 96.91%\n", "#5462: 96.91%\n", "#5463: 96.91%\n", "#5464: 96.91%\n", "#5465: 96.91%\n", "#5466: 96.91%\n", "#5467: 96.91%\n", "#5468: 96.91%\n", "#5469: 96.91%\n", "#5470: 96.91%\n", "#5471: 96.91%\n", "#5472: 96.91%\n", "#5473: 96.91%\n", "#5474: 96.91%\n", "#5475: 96.91%\n", "#5476: 96.91%\n", "#5477: 96.91%\n", "#5478: 96.92%\n", "#5479: 96.92%\n", "#5480: 96.92%\n", "#5481: 96.92%\n", "#5482: 96.92%\n", "#5483: 96.92%\n", "#5484: 96.92%\n", "#5485: 96.92%\n", "#5486: 96.92%\n", "#5487: 96.92%\n", "#5488: 96.92%\n", "#5489: 96.92%\n", "#5490: 96.92%\n", "#5491: 96.92%\n", "#5492: 96.92%\n", "#5493: 96.92%\n", "#5494: 96.92%\n", "#5495: 96.93%\n", "#5496: 96.93%\n", "#5497: 96.93%\n", "#5498: 96.93%\n", "#5499: 96.93%\n", "#5500: 96.93%\n", "#5501: 96.93%\n", "#5502: 96.93%\n", "#5503: 96.93%\n", "#5504: 96.93%\n", "#5505: 96.93%\n", "#5506: 96.93%\n", "#5507: 96.93%\n", "#5508: 96.93%\n", "#5509: 96.93%\n", "#5510: 96.93%\n", "#5511: 96.93%\n", "#5512: 96.93%\n", "#5513: 96.94%\n", "#5514: 96.94%\n", "#5515: 96.94%\n", "#5516: 96.94%\n", "#5517: 96.94%\n", "#5518: 96.94%\n", "#5519: 96.94%\n", "#5520: 96.94%\n", "#5521: 96.94%\n", "#5522: 96.94%\n", "#5523: 96.94%\n", "#5524: 96.94%\n", "#5525: 96.94%\n", "#5526: 96.94%\n", "#5527: 96.94%\n", "#5528: 96.94%\n", "#5529: 96.94%\n", "#5530: 96.94%\n", "#5531: 96.95%\n", "#5532: 96.95%\n", "#5533: 96.95%\n", "#5534: 96.95%\n", "#5535: 96.95%\n", "#5536: 96.95%\n", "#5537: 96.95%\n", "#5538: 96.95%\n", "#5539: 96.95%\n", "#5540: 96.95%\n", "#5541: 96.95%\n", "#5542: 96.95%\n", "#5543: 96.95%\n", "#5544: 96.95%\n", "#5545: 96.95%\n", "#5546: 96.95%\n", "#5547: 96.95%\n", "#5548: 96.95%\n", "#5549: 96.95%\n", "#5550: 96.96%\n", "#5551: 96.96%\n", "#5552: 96.96%\n", "#5553: 96.96%\n", "#5554: 96.96%\n", "#5555: 96.96%\n", "#5556: 96.96%\n", "#5557: 96.96%\n", "#5558: 96.96%\n", "#5559: 96.96%\n", "#5560: 96.96%\n", "#5561: 96.96%\n", "#5562: 96.96%\n", "#5563: 96.96%\n", "#5564: 96.96%\n", "#5565: 96.96%\n", "#5566: 96.96%\n", "#5567: 96.96%\n", "#5568: 96.97%\n", "#5569: 96.97%\n", "#5570: 96.97%\n", "#5571: 96.97%\n", "#5572: 96.97%\n", "#5573: 96.97%\n", "#5574: 96.97%\n", "#5575: 96.97%\n", "#5576: 96.97%\n", "#5577: 96.97%\n", "#5578: 96.97%\n", "#5579: 96.97%\n", "#5580: 96.97%\n", "#5581: 96.97%\n", "#5582: 96.97%\n", "#5583: 96.97%\n", "#5584: 96.97%\n", "#5585: 96.97%\n", "#5586: 96.98%\n", "#5587: 96.98%\n", "#5588: 96.98%\n", "#5589: 96.98%\n", "#5590: 96.98%\n", "#5591: 96.98%\n", "#5592: 96.98%\n", "#5593: 96.98%\n", "#5594: 96.98%\n", "#5595: 96.98%\n", "#5596: 96.98%\n", "#5597: 96.98%\n", "#5598: 96.98%\n", "#5599: 96.98%\n", "#5600: 96.96%\n", "#5601: 96.97%\n", "#5602: 96.97%\n", "#5603: 96.97%\n", "#5604: 96.97%\n", "#5605: 96.97%\n", "#5606: 96.97%\n", "#5607: 96.97%\n", "#5608: 96.97%\n", "#5609: 96.97%\n", "#5610: 96.97%\n", "#5611: 96.97%\n", "#5612: 96.97%\n", "#5613: 96.97%\n", "#5614: 96.97%\n", "#5615: 96.97%\n", "#5616: 96.97%\n", "#5617: 96.97%\n", "#5618: 96.97%\n", "#5619: 96.98%\n", "#5620: 96.98%\n", "#5621: 96.98%\n", "#5622: 96.98%\n", "#5623: 96.98%\n", "#5624: 96.98%\n", "#5625: 96.98%\n", "#5626: 96.98%\n", "#5627: 96.98%\n", "#5628: 96.98%\n", "#5629: 96.98%\n", "#5630: 96.98%\n", "#5631: 96.98%\n", "#5632: 96.98%\n", "#5633: 96.98%\n", "#5634: 96.98%\n", "#5635: 96.98%\n", "#5636: 96.98%\n", "#5637: 96.98%\n", "#5638: 96.99%\n", "#5639: 96.99%\n", "#5640: 96.99%\n", "#5641: 96.99%\n", "#5642: 96.99%\n", "#5643: 96.99%\n", "#5644: 96.99%\n", "#5645: 96.99%\n", "#5646: 96.99%\n", "#5647: 96.99%\n", "#5648: 96.99%\n", "#5649: 96.99%\n", "#5650: 96.99%\n", "#5651: 96.99%\n", "#5652: 96.99%\n", "#5653: 96.99%\n", "#5654: 96.99%\n", "#5655: 96.99%\n", "#5656: 96.99%\n", "#5657: 97.00%\n", "#5658: 97.00%\n", "#5659: 97.00%\n", "#5660: 97.00%\n", "#5661: 97.00%\n", "#5662: 97.00%\n", "#5663: 97.00%\n", "#5664: 97.00%\n", "#5665: 97.00%\n", "#5666: 97.00%\n", "#5667: 97.00%\n", "#5668: 97.00%\n", "#5669: 97.00%\n", "#5670: 97.00%\n", "#5671: 97.00%\n", "#5672: 97.00%\n", "#5673: 97.00%\n", "#5674: 97.00%\n", "#5675: 97.00%\n", "#5676: 97.01%\n", "#5677: 97.01%\n", "#5678: 97.01%\n", "#5679: 97.01%\n", "#5680: 97.01%\n", "#5681: 97.01%\n", "#5682: 97.01%\n", "#5683: 97.01%\n", "#5684: 97.01%\n", "#5685: 97.01%\n", "#5686: 97.01%\n", "#5687: 97.01%\n", "#5688: 97.01%\n", "#5689: 97.01%\n", "#5690: 97.01%\n", "#5691: 97.01%\n", "#5692: 97.01%\n", "#5693: 97.01%\n", "#5694: 97.01%\n", "#5695: 97.02%\n", "#5696: 97.02%\n", "#5697: 97.02%\n", "#5698: 97.02%\n", "#5699: 97.02%\n", "#5700: 97.02%\n", "#5701: 97.02%\n", "#5702: 97.02%\n", "#5703: 97.02%\n", "#5704: 97.02%\n", "#5705: 97.02%\n", "#5706: 97.02%\n", "#5707: 97.02%\n", "#5708: 97.02%\n", "#5709: 97.02%\n", "#5710: 97.02%\n", "#5711: 97.02%\n", "#5712: 97.02%\n", "#5713: 97.02%\n", "#5714: 97.03%\n", "#5715: 97.03%\n", "#5716: 97.03%\n", "#5717: 97.03%\n", "#5718: 97.03%\n", "#5719: 97.03%\n", "#5720: 97.03%\n", "#5721: 97.03%\n", "#5722: 97.03%\n", "#5723: 97.03%\n", "#5724: 97.03%\n", "#5725: 97.03%\n", "#5726: 97.03%\n", "#5727: 97.03%\n", "#5728: 97.03%\n", "#5729: 97.03%\n", "#5730: 97.03%\n", "#5731: 97.03%\n", "#5732: 97.03%\n", "#5733: 97.04%\n", "#5734: 97.02%\n", "#5735: 97.02%\n", "#5736: 97.02%\n", "#5737: 97.02%\n", "#5738: 97.02%\n", "#5739: 97.02%\n", "#5740: 97.02%\n", "#5741: 97.02%\n", "#5742: 97.02%\n", "#5743: 97.02%\n", "#5744: 97.02%\n", "#5745: 97.02%\n", "#5746: 97.02%\n", "#5747: 97.03%\n", "#5748: 97.03%\n", "#5749: 97.03%\n", "#5750: 97.03%\n", "#5751: 97.03%\n", "#5752: 97.03%\n", "#5753: 97.03%\n", "#5754: 97.03%\n", "#5755: 97.03%\n", "#5756: 97.03%\n", "#5757: 97.03%\n", "#5758: 97.03%\n", "#5759: 97.03%\n", "#5760: 97.03%\n", "#5761: 97.03%\n", "#5762: 97.03%\n", "#5763: 97.03%\n", "#5764: 97.03%\n", "#5765: 97.03%\n", "#5766: 97.03%\n", "#5767: 97.04%\n", "#5768: 97.04%\n", "#5769: 97.04%\n", "#5770: 97.04%\n", "#5771: 97.04%\n", "#5772: 97.04%\n", "#5773: 97.04%\n", "#5774: 97.04%\n", "#5775: 97.04%\n", "#5776: 97.04%\n", "#5777: 97.04%\n", "#5778: 97.04%\n", "#5779: 97.04%\n", "#5780: 97.04%\n", "#5781: 97.04%\n", "#5782: 97.04%\n", "#5783: 97.04%\n", "#5784: 97.04%\n", "#5785: 97.04%\n", "#5786: 97.05%\n", "#5787: 97.05%\n", "#5788: 97.05%\n", "#5789: 97.05%\n", "#5790: 97.05%\n", "#5791: 97.05%\n", "#5792: 97.05%\n", "#5793: 97.05%\n", "#5794: 97.05%\n", "#5795: 97.05%\n", "#5796: 97.05%\n", "#5797: 97.05%\n", "#5798: 97.05%\n", "#5799: 97.05%\n", "#5800: 97.05%\n", "#5801: 97.05%\n", "#5802: 97.05%\n", "#5803: 97.05%\n", "#5804: 97.05%\n", "#5805: 97.05%\n", "#5806: 97.06%\n", "#5807: 97.06%\n", "#5808: 97.06%\n", "#5809: 97.06%\n", "#5810: 97.06%\n", "#5811: 97.06%\n", "#5812: 97.06%\n", "#5813: 97.06%\n", "#5814: 97.06%\n", "#5815: 97.06%\n", "#5816: 97.06%\n", "#5817: 97.06%\n", "#5818: 97.06%\n", "#5819: 97.06%\n", "#5820: 97.06%\n", "#5821: 97.06%\n", "#5822: 97.06%\n", "#5823: 97.06%\n", "#5824: 97.06%\n", "#5825: 97.06%\n", "#5826: 97.07%\n", "#5827: 97.07%\n", "#5828: 97.07%\n", "#5829: 97.07%\n", "#5830: 97.07%\n", "#5831: 97.07%\n", "#5832: 97.07%\n", "#5833: 97.07%\n", "#5834: 97.07%\n", "#5835: 97.07%\n", "#5836: 97.07%\n", "#5837: 97.07%\n", "#5838: 97.07%\n", "#5839: 97.07%\n", "#5840: 97.07%\n", "#5841: 97.06%\n", "#5842: 97.04%\n", "#5843: 97.04%\n", "#5844: 97.04%\n", "#5845: 97.04%\n", "#5846: 97.04%\n", "#5847: 97.04%\n", "#5848: 97.04%\n", "#5849: 97.04%\n", "#5850: 97.04%\n", "#5851: 97.04%\n", "#5852: 97.04%\n", "#5853: 97.04%\n", "#5854: 97.05%\n", "#5855: 97.05%\n", "#5856: 97.05%\n", "#5857: 97.05%\n", "#5858: 97.05%\n", "#5859: 97.05%\n", "#5860: 97.05%\n", "#5861: 97.05%\n", "#5862: 97.05%\n", "#5863: 97.05%\n", "#5864: 97.05%\n", "#5865: 97.05%\n", "#5866: 97.05%\n", "#5867: 97.05%\n", "#5868: 97.05%\n", "#5869: 97.05%\n", "#5870: 97.05%\n", "#5871: 97.05%\n", "#5872: 97.05%\n", "#5873: 97.05%\n", "#5874: 97.06%\n", "#5875: 97.06%\n", "#5876: 97.06%\n", "#5877: 97.06%\n", "#5878: 97.06%\n", "#5879: 97.06%\n", "#5880: 97.06%\n", "#5881: 97.06%\n", "#5882: 97.06%\n", "#5883: 97.06%\n", "#5884: 97.06%\n", "#5885: 97.06%\n", "#5886: 97.06%\n", "#5887: 97.04%\n", "#5888: 97.05%\n", "#5889: 97.05%\n", "#5890: 97.05%\n", "#5891: 97.05%\n", "#5892: 97.05%\n", "#5893: 97.05%\n", "#5894: 97.05%\n", "#5895: 97.05%\n", "#5896: 97.05%\n", "#5897: 97.05%\n", "#5898: 97.05%\n", "#5899: 97.05%\n", "#5900: 97.05%\n", "#5901: 97.05%\n", "#5902: 97.05%\n", "#5903: 97.05%\n", "#5904: 97.05%\n", "#5905: 97.05%\n", "#5906: 97.05%\n", "#5907: 97.05%\n", "#5908: 97.06%\n", "#5909: 97.06%\n", "#5910: 97.06%\n", "#5911: 97.06%\n", "#5912: 97.06%\n", "#5913: 97.06%\n", "#5914: 97.06%\n", "#5915: 97.06%\n", "#5916: 97.06%\n", "#5917: 97.06%\n", "#5918: 97.06%\n", "#5919: 97.06%\n", "#5920: 97.06%\n", "#5921: 97.06%\n", "#5922: 97.06%\n", "#5923: 97.06%\n", "#5924: 97.06%\n", "#5925: 97.06%\n", "#5926: 97.06%\n", "#5927: 97.06%\n", "#5928: 97.07%\n", "#5929: 97.07%\n", "#5930: 97.07%\n", "#5931: 97.07%\n", "#5932: 97.07%\n", "#5933: 97.07%\n", "#5934: 97.07%\n", "#5935: 97.07%\n", "#5936: 97.07%\n", "#5937: 97.07%\n", "#5938: 97.07%\n", "#5939: 97.07%\n", "#5940: 97.07%\n", "#5941: 97.07%\n", "#5942: 97.07%\n", "#5943: 97.07%\n", "#5944: 97.07%\n", "#5945: 97.07%\n", "#5946: 97.07%\n", "#5947: 97.07%\n", "#5948: 97.08%\n", "#5949: 97.08%\n", "#5950: 97.08%\n", "#5951: 97.08%\n", "#5952: 97.08%\n", "#5953: 97.08%\n", "#5954: 97.08%\n", "#5955: 97.06%\n", "#5956: 97.06%\n", "#5957: 97.06%\n", "#5958: 97.06%\n", "#5959: 97.06%\n", "#5960: 97.06%\n", "#5961: 97.06%\n", "#5962: 97.07%\n", "#5963: 97.07%\n", "#5964: 97.07%\n", "#5965: 97.07%\n", "#5966: 97.07%\n", "#5967: 97.07%\n", "#5968: 97.07%\n", "#5969: 97.07%\n", "#5970: 97.07%\n", "#5971: 97.07%\n", "#5972: 97.07%\n", "#5973: 97.05%\n", "#5974: 97.05%\n", "#5975: 97.05%\n", "#5976: 97.06%\n", "#5977: 97.06%\n", "#5978: 97.06%\n", "#5979: 97.06%\n", "#5980: 97.06%\n", "#5981: 97.06%\n", "#5982: 97.06%\n", "#5983: 97.06%\n", "#5984: 97.06%\n", "#5985: 97.06%\n", "#5986: 97.06%\n", "#5987: 97.06%\n", "#5988: 97.06%\n", "#5989: 97.06%\n", "#5990: 97.06%\n", "#5991: 97.06%\n", "#5992: 97.06%\n", "#5993: 97.06%\n", "#5994: 97.06%\n", "#5995: 97.06%\n", "#5996: 97.07%\n", "#5997: 97.05%\n", "#5998: 97.05%\n", "#5999: 97.05%\n", "#6000: 97.05%\n", "#6001: 97.05%\n", "#6002: 97.05%\n", "#6003: 97.05%\n", "#6004: 97.05%\n", "#6005: 97.05%\n", "#6006: 97.05%\n", "#6007: 97.05%\n", "#6008: 97.05%\n", "#6009: 97.05%\n", "#6010: 97.06%\n", "#6011: 97.06%\n", "#6012: 97.06%\n", "#6013: 97.06%\n", "#6014: 97.06%\n", "#6015: 97.06%\n", "#6016: 97.06%\n", "#6017: 97.06%\n", "#6018: 97.06%\n", "#6019: 97.06%\n", "#6020: 97.06%\n", "#6021: 97.06%\n", "#6022: 97.06%\n", "#6023: 97.05%\n", "#6024: 97.05%\n", "#6025: 97.05%\n", "#6026: 97.05%\n", "#6027: 97.05%\n", "#6028: 97.05%\n", "#6029: 97.05%\n", "#6030: 97.05%\n", "#6031: 97.05%\n", "#6032: 97.05%\n", "#6033: 97.05%\n", "#6034: 97.05%\n", "#6035: 97.05%\n", "#6036: 97.05%\n", "#6037: 97.05%\n", "#6038: 97.05%\n", "#6039: 97.05%\n", "#6040: 97.05%\n", "#6041: 97.05%\n", "#6042: 97.05%\n", "#6043: 97.05%\n", "#6044: 97.06%\n", "#6045: 97.06%\n", "#6046: 97.06%\n", "#6047: 97.06%\n", "#6048: 97.06%\n", "#6049: 97.06%\n", "#6050: 97.06%\n", "#6051: 97.06%\n", "#6052: 97.06%\n", "#6053: 97.06%\n", "#6054: 97.06%\n", "#6055: 97.06%\n", "#6056: 97.06%\n", "#6057: 97.06%\n", "#6058: 97.06%\n", "#6059: 97.05%\n", "#6060: 97.05%\n", "#6061: 97.05%\n", "#6062: 97.05%\n", "#6063: 97.05%\n", "#6064: 97.05%\n", "#6065: 97.03%\n", "#6066: 97.03%\n", "#6067: 97.03%\n", "#6068: 97.03%\n", "#6069: 97.03%\n", "#6070: 97.04%\n", "#6071: 97.04%\n", "#6072: 97.04%\n", "#6073: 97.04%\n", "#6074: 97.04%\n", "#6075: 97.04%\n", "#6076: 97.04%\n", "#6077: 97.04%\n", "#6078: 97.04%\n", "#6079: 97.04%\n", "#6080: 97.04%\n", "#6081: 97.04%\n", "#6082: 97.04%\n", "#6083: 97.04%\n", "#6084: 97.04%\n", "#6085: 97.03%\n", "#6086: 97.03%\n", "#6087: 97.03%\n", "#6088: 97.03%\n", "#6089: 97.03%\n", "#6090: 97.03%\n", "#6091: 97.01%\n", "#6092: 97.01%\n", "#6093: 97.01%\n", "#6094: 97.01%\n", "#6095: 97.01%\n", "#6096: 97.01%\n", "#6097: 97.02%\n", "#6098: 97.02%\n", "#6099: 97.02%\n", "#6100: 97.02%\n", "#6101: 97.02%\n", "#6102: 97.02%\n", "#6103: 97.02%\n", "#6104: 97.02%\n", "#6105: 97.02%\n", "#6106: 97.02%\n", "#6107: 97.02%\n", "#6108: 97.02%\n", "#6109: 97.02%\n", "#6110: 97.02%\n", "#6111: 97.02%\n", "#6112: 97.02%\n", "#6113: 97.02%\n", "#6114: 97.02%\n", "#6115: 97.02%\n", "#6116: 97.02%\n", "#6117: 97.03%\n", "#6118: 97.03%\n", "#6119: 97.03%\n", "#6120: 97.03%\n", "#6121: 97.03%\n", "#6122: 97.03%\n", "#6123: 97.03%\n", "#6124: 97.03%\n", "#6125: 97.03%\n", "#6126: 97.03%\n", "#6127: 97.03%\n", "#6128: 97.03%\n", "#6129: 97.03%\n", "#6130: 97.03%\n", "#6131: 97.03%\n", "#6132: 97.03%\n", "#6133: 97.03%\n", "#6134: 97.03%\n", "#6135: 97.03%\n", "#6136: 97.03%\n", "#6137: 97.03%\n", "#6138: 97.04%\n", "#6139: 97.04%\n", "#6140: 97.04%\n", "#6141: 97.04%\n", "#6142: 97.04%\n", "#6143: 97.04%\n", "#6144: 97.04%\n", "#6145: 97.04%\n", "#6146: 97.04%\n", "#6147: 97.04%\n", "#6148: 97.04%\n", "#6149: 97.04%\n", "#6150: 97.04%\n", "#6151: 97.04%\n", "#6152: 97.04%\n", "#6153: 97.04%\n", "#6154: 97.04%\n", "#6155: 97.04%\n", "#6156: 97.04%\n", "#6157: 97.04%\n", "#6158: 97.04%\n", "#6159: 97.05%\n", "#6160: 97.05%\n", "#6161: 97.05%\n", "#6162: 97.05%\n", "#6163: 97.05%\n", "#6164: 97.05%\n", "#6165: 97.05%\n", "#6166: 97.05%\n", "#6167: 97.05%\n", "#6168: 97.05%\n", "#6169: 97.05%\n", "#6170: 97.05%\n", "#6171: 97.05%\n", "#6172: 97.04%\n", "#6173: 97.04%\n", "#6174: 97.04%\n", "#6175: 97.04%\n", "#6176: 97.04%\n", "#6177: 97.04%\n", "#6178: 97.04%\n", "#6179: 97.04%\n", "#6180: 97.04%\n", "#6181: 97.04%\n", "#6182: 97.04%\n", "#6183: 97.04%\n", "#6184: 97.04%\n", "#6185: 97.04%\n", "#6186: 97.04%\n", "#6187: 97.04%\n", "#6188: 97.04%\n", "#6189: 97.04%\n", "#6190: 97.04%\n", "#6191: 97.04%\n", "#6192: 97.05%\n", "#6193: 97.05%\n", "#6194: 97.05%\n", "#6195: 97.05%\n", "#6196: 97.05%\n", "#6197: 97.05%\n", "#6198: 97.05%\n", "#6199: 97.05%\n", "#6200: 97.05%\n", "#6201: 97.05%\n", "#6202: 97.05%\n", "#6203: 97.05%\n", "#6204: 97.05%\n", "#6205: 97.05%\n", "#6206: 97.05%\n", "#6207: 97.05%\n", "#6208: 97.05%\n", "#6209: 97.05%\n", "#6210: 97.05%\n", "#6211: 97.05%\n", "#6212: 97.05%\n", "#6213: 97.06%\n", "#6214: 97.06%\n", "#6215: 97.06%\n", "#6216: 97.06%\n", "#6217: 97.06%\n", "#6218: 97.06%\n", "#6219: 97.06%\n", "#6220: 97.06%\n", "#6221: 97.06%\n", "#6222: 97.06%\n", "#6223: 97.06%\n", "#6224: 97.06%\n", "#6225: 97.06%\n", "#6226: 97.06%\n", "#6227: 97.06%\n", "#6228: 97.06%\n", "#6229: 97.06%\n", "#6230: 97.06%\n", "#6231: 97.06%\n", "#6232: 97.06%\n", "#6233: 97.06%\n", "#6234: 97.06%\n", "#6235: 97.07%\n", "#6236: 97.07%\n", "#6237: 97.07%\n", "#6238: 97.07%\n", "#6239: 97.07%\n", "#6240: 97.07%\n", "#6241: 97.07%\n", "#6242: 97.07%\n", "#6243: 97.07%\n", "#6244: 97.07%\n", "#6245: 97.07%\n", "#6246: 97.07%\n", "#6247: 97.07%\n", "#6248: 97.07%\n", "#6249: 97.07%\n", "#6250: 97.07%\n", "#6251: 97.07%\n", "#6252: 97.07%\n", "#6253: 97.07%\n", "#6254: 97.07%\n", "#6255: 97.07%\n", "#6256: 97.08%\n", "#6257: 97.08%\n", "#6258: 97.08%\n", "#6259: 97.08%\n", "#6260: 97.08%\n", "#6261: 97.08%\n", "#6262: 97.08%\n", "#6263: 97.08%\n", "#6264: 97.08%\n", "#6265: 97.08%\n", "#6266: 97.08%\n", "#6267: 97.08%\n", "#6268: 97.08%\n", "#6269: 97.08%\n", "#6270: 97.08%\n", "#6271: 97.08%\n", "#6272: 97.08%\n", "#6273: 97.08%\n", "#6274: 97.08%\n", "#6275: 97.08%\n", "#6276: 97.08%\n", "#6277: 97.09%\n", "#6278: 97.09%\n", "#6279: 97.09%\n", "#6280: 97.09%\n", "#6281: 97.09%\n", "#6282: 97.09%\n", "#6283: 97.09%\n", "#6284: 97.09%\n", "#6285: 97.09%\n", "#6286: 97.09%\n", "#6287: 97.09%\n", "#6288: 97.09%\n", "#6289: 97.09%\n", "#6290: 97.09%\n", "#6291: 97.09%\n", "#6292: 97.09%\n", "#6293: 97.09%\n", "#6294: 97.09%\n", "#6295: 97.09%\n", "#6296: 97.09%\n", "#6297: 97.09%\n", "#6298: 97.09%\n", "#6299: 97.10%\n", "#6300: 97.10%\n", "#6301: 97.10%\n", "#6302: 97.10%\n", "#6303: 97.10%\n", "#6304: 97.10%\n", "#6305: 97.10%\n", "#6306: 97.10%\n", "#6307: 97.10%\n", "#6308: 97.10%\n", "#6309: 97.10%\n", "#6310: 97.10%\n", "#6311: 97.10%\n", "#6312: 97.10%\n", "#6313: 97.10%\n", "#6314: 97.10%\n", "#6315: 97.10%\n", "#6316: 97.10%\n", "#6317: 97.10%\n", "#6318: 97.10%\n", "#6319: 97.10%\n", "#6320: 97.10%\n", "#6321: 97.11%\n", "#6322: 97.11%\n", "#6323: 97.11%\n", "#6324: 97.11%\n", "#6325: 97.11%\n", "#6326: 97.11%\n", "#6327: 97.11%\n", "#6328: 97.11%\n", "#6329: 97.11%\n", "#6330: 97.11%\n", "#6331: 97.11%\n", "#6332: 97.11%\n", "#6333: 97.11%\n", "#6334: 97.11%\n", "#6335: 97.11%\n", "#6336: 97.11%\n", "#6337: 97.11%\n", "#6338: 97.11%\n", "#6339: 97.11%\n", "#6340: 97.11%\n", "#6341: 97.11%\n", "#6342: 97.11%\n", "#6343: 97.12%\n", "#6344: 97.12%\n", "#6345: 97.12%\n", "#6346: 97.12%\n", "#6347: 97.12%\n", "#6348: 97.12%\n", "#6349: 97.12%\n", "#6350: 97.12%\n", "#6351: 97.12%\n", "#6352: 97.12%\n", "#6353: 97.12%\n", "#6354: 97.12%\n", "#6355: 97.12%\n", "#6356: 97.12%\n", "#6357: 97.12%\n", "#6358: 97.12%\n", "#6359: 97.12%\n", "#6360: 97.12%\n", "#6361: 97.12%\n", "#6362: 97.12%\n", "#6363: 97.12%\n", "#6364: 97.12%\n", "#6365: 97.13%\n", "#6366: 97.13%\n", "#6367: 97.13%\n", "#6368: 97.13%\n", "#6369: 97.13%\n", "#6370: 97.13%\n", "#6371: 97.13%\n", "#6372: 97.13%\n", "#6373: 97.13%\n", "#6374: 97.13%\n", "#6375: 97.13%\n", "#6376: 97.13%\n", "#6377: 97.13%\n", "#6378: 97.13%\n", "#6379: 97.13%\n", "#6380: 97.13%\n", "#6381: 97.13%\n", "#6382: 97.13%\n", "#6383: 97.13%\n", "#6384: 97.13%\n", "#6385: 97.13%\n", "#6386: 97.13%\n", "#6387: 97.14%\n", "#6388: 97.14%\n", "#6389: 97.14%\n", "#6390: 97.14%\n", "#6391: 97.14%\n", "#6392: 97.14%\n", "#6393: 97.14%\n", "#6394: 97.14%\n", "#6395: 97.14%\n", "#6396: 97.14%\n", "#6397: 97.14%\n", "#6398: 97.14%\n", "#6399: 97.14%\n", "#6400: 97.14%\n", "#6401: 97.14%\n", "#6402: 97.14%\n", "#6403: 97.14%\n", "#6404: 97.14%\n", "#6405: 97.14%\n", "#6406: 97.14%\n", "#6407: 97.14%\n", "#6408: 97.14%\n", "#6409: 97.15%\n", "#6410: 97.15%\n", "#6411: 97.15%\n", "#6412: 97.15%\n", "#6413: 97.15%\n", "#6414: 97.15%\n", "#6415: 97.15%\n", "#6416: 97.15%\n", "#6417: 97.15%\n", "#6418: 97.15%\n", "#6419: 97.15%\n", "#6420: 97.15%\n", "#6421: 97.15%\n", "#6422: 97.15%\n", "#6423: 97.15%\n", "#6424: 97.15%\n", "#6425: 97.15%\n", "#6426: 97.15%\n", "#6427: 97.15%\n", "#6428: 97.15%\n", "#6429: 97.15%\n", "#6430: 97.15%\n", "#6431: 97.15%\n", "#6432: 97.16%\n", "#6433: 97.16%\n", "#6434: 97.16%\n", "#6435: 97.16%\n", "#6436: 97.16%\n", "#6437: 97.16%\n", "#6438: 97.16%\n", "#6439: 97.16%\n", "#6440: 97.16%\n", "#6441: 97.16%\n", "#6442: 97.16%\n", "#6443: 97.16%\n", "#6444: 97.16%\n", "#6445: 97.16%\n", "#6446: 97.16%\n", "#6447: 97.16%\n", "#6448: 97.16%\n", "#6449: 97.16%\n", "#6450: 97.16%\n", "#6451: 97.16%\n", "#6452: 97.16%\n", "#6453: 97.16%\n", "#6454: 97.16%\n", "#6455: 97.17%\n", "#6456: 97.17%\n", "#6457: 97.17%\n", "#6458: 97.17%\n", "#6459: 97.17%\n", "#6460: 97.17%\n", "#6461: 97.17%\n", "#6462: 97.17%\n", "#6463: 97.17%\n", "#6464: 97.17%\n", "#6465: 97.17%\n", "#6466: 97.17%\n", "#6467: 97.17%\n", "#6468: 97.17%\n", "#6469: 97.17%\n", "#6470: 97.17%\n", "#6471: 97.17%\n", "#6472: 97.17%\n", "#6473: 97.17%\n", "#6474: 97.17%\n", "#6475: 97.17%\n", "#6476: 97.17%\n", "#6477: 97.18%\n", "#6478: 97.18%\n", "#6479: 97.18%\n", "#6480: 97.18%\n", "#6481: 97.18%\n", "#6482: 97.18%\n", "#6483: 97.18%\n", "#6484: 97.18%\n", "#6485: 97.18%\n", "#6486: 97.18%\n", "#6487: 97.18%\n", "#6488: 97.18%\n", "#6489: 97.18%\n", "#6490: 97.18%\n", "#6491: 97.18%\n", "#6492: 97.18%\n", "#6493: 97.18%\n", "#6494: 97.18%\n", "#6495: 97.18%\n", "#6496: 97.18%\n", "#6497: 97.18%\n", "#6498: 97.18%\n", "#6499: 97.18%\n", "#6500: 97.19%\n", "#6501: 97.19%\n", "#6502: 97.19%\n", "#6503: 97.19%\n", "#6504: 97.19%\n", "#6505: 97.17%\n", "#6506: 97.17%\n", "#6507: 97.17%\n", "#6508: 97.17%\n", "#6509: 97.17%\n", "#6510: 97.17%\n", "#6511: 97.17%\n", "#6512: 97.17%\n", "#6513: 97.18%\n", "#6514: 97.18%\n", "#6515: 97.18%\n", "#6516: 97.18%\n", "#6517: 97.18%\n", "#6518: 97.18%\n", "#6519: 97.18%\n", "#6520: 97.18%\n", "#6521: 97.18%\n", "#6522: 97.18%\n", "#6523: 97.18%\n", "#6524: 97.18%\n", "#6525: 97.18%\n", "#6526: 97.18%\n", "#6527: 97.18%\n", "#6528: 97.18%\n", "#6529: 97.18%\n", "#6530: 97.18%\n", "#6531: 97.18%\n", "#6532: 97.18%\n", "#6533: 97.18%\n", "#6534: 97.18%\n", "#6535: 97.18%\n", "#6536: 97.19%\n", "#6537: 97.19%\n", "#6538: 97.19%\n", "#6539: 97.19%\n", "#6540: 97.19%\n", "#6541: 97.19%\n", "#6542: 97.19%\n", "#6543: 97.19%\n", "#6544: 97.19%\n", "#6545: 97.19%\n", "#6546: 97.19%\n", "#6547: 97.19%\n", "#6548: 97.19%\n", "#6549: 97.19%\n", "#6550: 97.19%\n", "#6551: 97.19%\n", "#6552: 97.19%\n", "#6553: 97.19%\n", "#6554: 97.19%\n", "#6555: 97.18%\n", "#6556: 97.18%\n", "#6557: 97.18%\n", "#6558: 97.18%\n", "#6559: 97.18%\n", "#6560: 97.18%\n", "#6561: 97.18%\n", "#6562: 97.18%\n", "#6563: 97.18%\n", "#6564: 97.18%\n", "#6565: 97.18%\n", "#6566: 97.18%\n", "#6567: 97.18%\n", "#6568: 97.18%\n", "#6569: 97.18%\n", "#6570: 97.18%\n", "#6571: 97.19%\n", "#6572: 97.17%\n", "#6573: 97.17%\n", "#6574: 97.17%\n", "#6575: 97.17%\n", "#6576: 97.17%\n", "#6577: 97.17%\n", "#6578: 97.16%\n", "#6579: 97.16%\n", "#6580: 97.16%\n", "#6581: 97.16%\n", "#6582: 97.16%\n", "#6583: 97.16%\n", "#6584: 97.16%\n", "#6585: 97.16%\n", "#6586: 97.16%\n", "#6587: 97.16%\n", "#6588: 97.16%\n", "#6589: 97.16%\n", "#6590: 97.16%\n", "#6591: 97.16%\n", "#6592: 97.16%\n", "#6593: 97.16%\n", "#6594: 97.16%\n", "#6595: 97.16%\n", "#6596: 97.17%\n", "#6597: 97.15%\n", "#6598: 97.15%\n", "#6599: 97.14%\n", "#6600: 97.14%\n", "#6601: 97.14%\n", "#6602: 97.14%\n", "#6603: 97.14%\n", "#6604: 97.14%\n", "#6605: 97.14%\n", "#6606: 97.14%\n", "#6607: 97.14%\n", "#6608: 97.14%\n", "#6609: 97.14%\n", "#6610: 97.14%\n", "#6611: 97.14%\n", "#6612: 97.14%\n", "#6613: 97.14%\n", "#6614: 97.14%\n", "#6615: 97.14%\n", "#6616: 97.14%\n", "#6617: 97.14%\n", "#6618: 97.14%\n", "#6619: 97.15%\n", "#6620: 97.15%\n", "#6621: 97.15%\n", "#6622: 97.15%\n", "#6623: 97.15%\n", "#6624: 97.15%\n", "#6625: 97.15%\n", "#6626: 97.15%\n", "#6627: 97.15%\n", "#6628: 97.15%\n", "#6629: 97.15%\n", "#6630: 97.15%\n", "#6631: 97.15%\n", "#6632: 97.15%\n", "#6633: 97.15%\n", "#6634: 97.15%\n", "#6635: 97.15%\n", "#6636: 97.15%\n", "#6637: 97.15%\n", "#6638: 97.15%\n", "#6639: 97.15%\n", "#6640: 97.15%\n", "#6641: 97.15%\n", "#6642: 97.15%\n", "#6643: 97.16%\n", "#6644: 97.16%\n", "#6645: 97.16%\n", "#6646: 97.16%\n", "#6647: 97.16%\n", "#6648: 97.16%\n", "#6649: 97.16%\n", "#6650: 97.16%\n", "#6651: 97.16%\n", "#6652: 97.16%\n", "#6653: 97.16%\n", "#6654: 97.16%\n", "#6655: 97.16%\n", "#6656: 97.16%\n", "#6657: 97.16%\n", "#6658: 97.16%\n", "#6659: 97.16%\n", "#6660: 97.16%\n", "#6661: 97.16%\n", "#6662: 97.16%\n", "#6663: 97.16%\n", "#6664: 97.16%\n", "#6665: 97.16%\n", "#6666: 97.17%\n", "#6667: 97.17%\n", "#6668: 97.17%\n", "#6669: 97.17%\n", "#6670: 97.17%\n", "#6671: 97.17%\n", "#6672: 97.17%\n", "#6673: 97.17%\n", "#6674: 97.17%\n", "#6675: 97.17%\n", "#6676: 97.17%\n", "#6677: 97.17%\n", "#6678: 97.17%\n", "#6679: 97.17%\n", "#6680: 97.17%\n", "#6681: 97.17%\n", "#6682: 97.17%\n", "#6683: 97.17%\n", "#6684: 97.17%\n", "#6685: 97.17%\n", "#6686: 97.17%\n", "#6687: 97.17%\n", "#6688: 97.17%\n", "#6689: 97.17%\n", "#6690: 97.18%\n", "#6691: 97.18%\n", "#6692: 97.18%\n", "#6693: 97.18%\n", "#6694: 97.18%\n", "#6695: 97.18%\n", "#6696: 97.18%\n", "#6697: 97.18%\n", "#6698: 97.18%\n", "#6699: 97.18%\n", "#6700: 97.18%\n", "#6701: 97.18%\n", "#6702: 97.18%\n", "#6703: 97.18%\n", "#6704: 97.18%\n", "#6705: 97.18%\n", "#6706: 97.18%\n", "#6707: 97.18%\n", "#6708: 97.18%\n", "#6709: 97.18%\n", "#6710: 97.18%\n", "#6711: 97.18%\n", "#6712: 97.18%\n", "#6713: 97.18%\n", "#6714: 97.19%\n", "#6715: 97.19%\n", "#6716: 97.19%\n", "#6717: 97.19%\n", "#6718: 97.19%\n", "#6719: 97.19%\n", "#6720: 97.19%\n", "#6721: 97.19%\n", "#6722: 97.19%\n", "#6723: 97.19%\n", "#6724: 97.19%\n", "#6725: 97.19%\n", "#6726: 97.19%\n", "#6727: 97.19%\n", "#6728: 97.19%\n", "#6729: 97.19%\n", "#6730: 97.19%\n", "#6731: 97.19%\n", "#6732: 97.19%\n", "#6733: 97.19%\n", "#6734: 97.19%\n", "#6735: 97.19%\n", "#6736: 97.19%\n", "#6737: 97.20%\n", "#6738: 97.20%\n", "#6739: 97.20%\n", "#6740: 97.18%\n", "#6741: 97.18%\n", "#6742: 97.18%\n", "#6743: 97.18%\n", "#6744: 97.18%\n", "#6745: 97.18%\n", "#6746: 97.18%\n", "#6747: 97.18%\n", "#6748: 97.18%\n", "#6749: 97.19%\n", "#6750: 97.19%\n", "#6751: 97.19%\n", "#6752: 97.19%\n", "#6753: 97.19%\n", "#6754: 97.19%\n", "#6755: 97.17%\n", "#6756: 97.16%\n", "#6757: 97.16%\n", "#6758: 97.16%\n", "#6759: 97.16%\n", "#6760: 97.16%\n", "#6761: 97.16%\n", "#6762: 97.16%\n", "#6763: 97.16%\n", "#6764: 97.16%\n", "#6765: 97.16%\n", "#6766: 97.16%\n", "#6767: 97.16%\n", "#6768: 97.16%\n", "#6769: 97.16%\n", "#6770: 97.16%\n", "#6771: 97.16%\n", "#6772: 97.17%\n", "#6773: 97.17%\n", "#6774: 97.17%\n", "#6775: 97.17%\n", "#6776: 97.17%\n", "#6777: 97.17%\n", "#6778: 97.17%\n", "#6779: 97.17%\n", "#6780: 97.17%\n", "#6781: 97.17%\n", "#6782: 97.17%\n", "#6783: 97.16%\n", "#6784: 97.16%\n", "#6785: 97.16%\n", "#6786: 97.16%\n", "#6787: 97.16%\n", "#6788: 97.16%\n", "#6789: 97.16%\n", "#6790: 97.16%\n", "#6791: 97.16%\n", "#6792: 97.16%\n", "#6793: 97.16%\n", "#6794: 97.16%\n", "#6795: 97.16%\n", "#6796: 97.16%\n", "#6797: 97.16%\n", "#6798: 97.16%\n", "#6799: 97.16%\n", "#6800: 97.16%\n", "#6801: 97.16%\n", "#6802: 97.16%\n", "#6803: 97.16%\n", "#6804: 97.16%\n", "#6805: 97.16%\n", "#6806: 97.16%\n", "#6807: 97.17%\n", "#6808: 97.17%\n", "#6809: 97.17%\n", "#6810: 97.17%\n", "#6811: 97.17%\n", "#6812: 97.17%\n", "#6813: 97.17%\n", "#6814: 97.17%\n", "#6815: 97.17%\n", "#6816: 97.17%\n", "#6817: 97.17%\n", "#6818: 97.17%\n", "#6819: 97.17%\n", "#6820: 97.17%\n", "#6821: 97.17%\n", "#6822: 97.17%\n", "#6823: 97.17%\n", "#6824: 97.17%\n", "#6825: 97.17%\n", "#6826: 97.17%\n", "#6827: 97.17%\n", "#6828: 97.17%\n", "#6829: 97.17%\n", "#6830: 97.17%\n", "#6831: 97.18%\n", "#6832: 97.18%\n", "#6833: 97.18%\n", "#6834: 97.18%\n", "#6835: 97.18%\n", "#6836: 97.18%\n", "#6837: 97.18%\n", "#6838: 97.18%\n", "#6839: 97.18%\n", "#6840: 97.18%\n", "#6841: 97.18%\n", "#6842: 97.18%\n", "#6843: 97.18%\n", "#6844: 97.18%\n", "#6845: 97.18%\n", "#6846: 97.18%\n", "#6847: 97.18%\n", "#6848: 97.18%\n", "#6849: 97.18%\n", "#6850: 97.18%\n", "#6851: 97.18%\n", "#6852: 97.18%\n", "#6853: 97.18%\n", "#6854: 97.18%\n", "#6855: 97.18%\n", "#6856: 97.19%\n", "#6857: 97.19%\n", "#6858: 97.19%\n", "#6859: 97.19%\n", "#6860: 97.19%\n", "#6861: 97.19%\n", "#6862: 97.19%\n", "#6863: 97.19%\n", "#6864: 97.19%\n", "#6865: 97.19%\n", "#6866: 97.19%\n", "#6867: 97.19%\n", "#6868: 97.19%\n", "#6869: 97.19%\n", "#6870: 97.19%\n", "#6871: 97.19%\n", "#6872: 97.19%\n", "#6873: 97.19%\n", "#6874: 97.19%\n", "#6875: 97.19%\n", "#6876: 97.19%\n", "#6877: 97.19%\n", "#6878: 97.19%\n", "#6879: 97.19%\n", "#6880: 97.20%\n", "#6881: 97.20%\n", "#6882: 97.20%\n", "#6883: 97.20%\n", "#6884: 97.20%\n", "#6885: 97.20%\n", "#6886: 97.20%\n", "#6887: 97.20%\n", "#6888: 97.20%\n", "#6889: 97.20%\n", "#6890: 97.20%\n", "#6891: 97.20%\n", "#6892: 97.20%\n", "#6893: 97.20%\n", "#6894: 97.20%\n", "#6895: 97.20%\n", "#6896: 97.20%\n", "#6897: 97.20%\n", "#6898: 97.20%\n", "#6899: 97.20%\n", "#6900: 97.20%\n", "#6901: 97.20%\n", "#6902: 97.20%\n", "#6903: 97.20%\n", "#6904: 97.20%\n", "#6905: 97.21%\n", "#6906: 97.21%\n", "#6907: 97.21%\n", "#6908: 97.21%\n", "#6909: 97.21%\n", "#6910: 97.21%\n", "#6911: 97.21%\n", "#6912: 97.21%\n", "#6913: 97.21%\n", "#6914: 97.21%\n", "#6915: 97.21%\n", "#6916: 97.21%\n", "#6917: 97.21%\n", "#6918: 97.21%\n", "#6919: 97.21%\n", "#6920: 97.21%\n", "#6921: 97.21%\n", "#6922: 97.21%\n", "#6923: 97.21%\n", "#6924: 97.21%\n", "#6925: 97.21%\n", "#6926: 97.21%\n", "#6927: 97.21%\n", "#6928: 97.21%\n", "#6929: 97.22%\n", "#6930: 97.22%\n", "#6931: 97.22%\n", "#6932: 97.22%\n", "#6933: 97.22%\n", "#6934: 97.22%\n", "#6935: 97.22%\n", "#6936: 97.22%\n", "#6937: 97.22%\n", "#6938: 97.22%\n", "#6939: 97.22%\n", "#6940: 97.22%\n", "#6941: 97.22%\n", "#6942: 97.22%\n", "#6943: 97.22%\n", "#6944: 97.22%\n", "#6945: 97.22%\n", "#6946: 97.22%\n", "#6947: 97.22%\n", "#6948: 97.22%\n", "#6949: 97.22%\n", "#6950: 97.22%\n", "#6951: 97.22%\n", "#6952: 97.22%\n", "#6953: 97.22%\n", "#6954: 97.23%\n", "#6955: 97.23%\n", "#6956: 97.23%\n", "#6957: 97.23%\n", "#6958: 97.23%\n", "#6959: 97.23%\n", "#6960: 97.23%\n", "#6961: 97.23%\n", "#6962: 97.23%\n", "#6963: 97.23%\n", "#6964: 97.23%\n", "#6965: 97.23%\n", "#6966: 97.23%\n", "#6967: 97.23%\n", "#6968: 97.23%\n", "#6969: 97.23%\n", "#6970: 97.23%\n", "#6971: 97.23%\n", "#6972: 97.23%\n", "#6973: 97.23%\n", "#6974: 97.23%\n", "#6975: 97.23%\n", "#6976: 97.23%\n", "#6977: 97.23%\n", "#6978: 97.23%\n", "#6979: 97.23%\n", "#6980: 97.24%\n", "#6981: 97.24%\n", "#6982: 97.24%\n", "#6983: 97.24%\n", "#6984: 97.24%\n", "#6985: 97.24%\n", "#6986: 97.24%\n", "#6987: 97.24%\n", "#6988: 97.24%\n", "#6989: 97.24%\n", "#6990: 97.24%\n", "#6991: 97.24%\n", "#6992: 97.24%\n", "#6993: 97.24%\n", "#6994: 97.24%\n", "#6995: 97.24%\n", "#6996: 97.24%\n", "#6997: 97.24%\n", "#6998: 97.24%\n", "#6999: 97.24%\n", "#7000: 97.24%\n", "#7001: 97.24%\n", "#7002: 97.24%\n", "#7003: 97.24%\n", "#7004: 97.24%\n", "#7005: 97.25%\n", "#7006: 97.25%\n", "#7007: 97.25%\n", "#7008: 97.25%\n", "#7009: 97.25%\n", "#7010: 97.25%\n", "#7011: 97.25%\n", "#7012: 97.25%\n", "#7013: 97.25%\n", "#7014: 97.25%\n", "#7015: 97.25%\n", "#7016: 97.25%\n", "#7017: 97.25%\n", "#7018: 97.25%\n", "#7019: 97.25%\n", "#7020: 97.25%\n", "#7021: 97.25%\n", "#7022: 97.25%\n", "#7023: 97.25%\n", "#7024: 97.25%\n", "#7025: 97.25%\n", "#7026: 97.25%\n", "#7027: 97.25%\n", "#7028: 97.25%\n", "#7029: 97.25%\n", "#7030: 97.26%\n", "#7031: 97.26%\n", "#7032: 97.26%\n", "#7033: 97.26%\n", "#7034: 97.26%\n", "#7035: 97.26%\n", "#7036: 97.26%\n", "#7037: 97.26%\n", "#7038: 97.26%\n", "#7039: 97.26%\n", "#7040: 97.24%\n", "#7041: 97.25%\n", "#7042: 97.25%\n", "#7043: 97.25%\n", "#7044: 97.25%\n", "#7045: 97.25%\n", "#7046: 97.25%\n", "#7047: 97.25%\n", "#7048: 97.25%\n", "#7049: 97.25%\n", "#7050: 97.25%\n", "#7051: 97.25%\n", "#7052: 97.25%\n", "#7053: 97.25%\n", "#7054: 97.25%\n", "#7055: 97.25%\n", "#7056: 97.25%\n", "#7057: 97.25%\n", "#7058: 97.25%\n", "#7059: 97.25%\n", "#7060: 97.25%\n", "#7061: 97.25%\n", "#7062: 97.25%\n", "#7063: 97.25%\n", "#7064: 97.25%\n", "#7065: 97.25%\n", "#7066: 97.25%\n", "#7067: 97.26%\n", "#7068: 97.26%\n", "#7069: 97.26%\n", "#7070: 97.26%\n", "#7071: 97.26%\n", "#7072: 97.26%\n", "#7073: 97.26%\n", "#7074: 97.26%\n", "#7075: 97.26%\n", "#7076: 97.26%\n", "#7077: 97.26%\n", "#7078: 97.26%\n", "#7079: 97.26%\n", "#7080: 97.26%\n", "#7081: 97.26%\n", "#7082: 97.26%\n", "#7083: 97.26%\n", "#7084: 97.26%\n", "#7085: 97.26%\n", "#7086: 97.26%\n", "#7087: 97.26%\n", "#7088: 97.26%\n", "#7089: 97.26%\n", "#7090: 97.26%\n", "#7091: 97.26%\n", "#7092: 97.26%\n", "#7093: 97.27%\n", "#7094: 97.27%\n", "#7095: 97.27%\n", "#7096: 97.27%\n", "#7097: 97.27%\n", "#7098: 97.27%\n", "#7099: 97.27%\n", "#7100: 97.27%\n", "#7101: 97.27%\n", "#7102: 97.27%\n", "#7103: 97.27%\n", "#7104: 97.27%\n", "#7105: 97.27%\n", "#7106: 97.27%\n", "#7107: 97.27%\n", "#7108: 97.27%\n", "#7109: 97.27%\n", "#7110: 97.27%\n", "#7111: 97.27%\n", "#7112: 97.27%\n", "#7113: 97.27%\n", "#7114: 97.27%\n", "#7115: 97.27%\n", "#7116: 97.27%\n", "#7117: 97.27%\n", "#7118: 97.27%\n", "#7119: 97.28%\n", "#7120: 97.28%\n", "#7121: 97.26%\n", "#7122: 97.26%\n", "#7123: 97.26%\n", "#7124: 97.26%\n", "#7125: 97.26%\n", "#7126: 97.26%\n", "#7127: 97.26%\n", "#7128: 97.26%\n", "#7129: 97.27%\n", "#7130: 97.27%\n", "#7131: 97.27%\n", "#7132: 97.27%\n", "#7133: 97.27%\n", "#7134: 97.27%\n", "#7135: 97.27%\n", "#7136: 97.27%\n", "#7137: 97.27%\n", "#7138: 97.27%\n", "#7139: 97.27%\n", "#7140: 97.27%\n", "#7141: 97.27%\n", "#7142: 97.27%\n", "#7143: 97.27%\n", "#7144: 97.27%\n", "#7145: 97.27%\n", "#7146: 97.27%\n", "#7147: 97.27%\n", "#7148: 97.27%\n", "#7149: 97.27%\n", "#7150: 97.27%\n", "#7151: 97.27%\n", "#7152: 97.27%\n", "#7153: 97.27%\n", "#7154: 97.27%\n", "#7155: 97.28%\n", "#7156: 97.28%\n", "#7157: 97.28%\n", "#7158: 97.28%\n", "#7159: 97.28%\n", "#7160: 97.28%\n", "#7161: 97.28%\n", "#7162: 97.28%\n", "#7163: 97.28%\n", "#7164: 97.28%\n", "#7165: 97.28%\n", "#7166: 97.28%\n", "#7167: 97.28%\n", "#7168: 97.28%\n", "#7169: 97.28%\n", "#7170: 97.28%\n", "#7171: 97.28%\n", "#7172: 97.28%\n", "#7173: 97.28%\n", "#7174: 97.28%\n", "#7175: 97.28%\n", "#7176: 97.28%\n", "#7177: 97.28%\n", "#7178: 97.28%\n", "#7179: 97.28%\n", "#7180: 97.28%\n", "#7181: 97.28%\n", "#7182: 97.29%\n", "#7183: 97.29%\n", "#7184: 97.29%\n", "#7185: 97.29%\n", "#7186: 97.29%\n", "#7187: 97.29%\n", "#7188: 97.29%\n", "#7189: 97.29%\n", "#7190: 97.29%\n", "#7191: 97.29%\n", "#7192: 97.29%\n", "#7193: 97.29%\n", "#7194: 97.29%\n", "#7195: 97.29%\n", "#7196: 97.29%\n", "#7197: 97.29%\n", "#7198: 97.29%\n", "#7199: 97.29%\n", "#7200: 97.29%\n", "#7201: 97.29%\n", "#7202: 97.29%\n", "#7203: 97.29%\n", "#7204: 97.29%\n", "#7205: 97.29%\n", "#7206: 97.29%\n", "#7207: 97.29%\n", "#7208: 97.30%\n", "#7209: 97.30%\n", "#7210: 97.30%\n", "#7211: 97.30%\n", "#7212: 97.30%\n", "#7213: 97.30%\n", "#7214: 97.30%\n", "#7215: 97.30%\n", "#7216: 97.30%\n", "#7217: 97.30%\n", "#7218: 97.30%\n", "#7219: 97.30%\n", "#7220: 97.30%\n", "#7221: 97.30%\n", "#7222: 97.30%\n", "#7223: 97.30%\n", "#7224: 97.30%\n", "#7225: 97.30%\n", "#7226: 97.30%\n", "#7227: 97.30%\n", "#7228: 97.30%\n", "#7229: 97.30%\n", "#7230: 97.30%\n", "#7231: 97.30%\n", "#7232: 97.30%\n", "#7233: 97.30%\n", "#7234: 97.30%\n", "#7235: 97.31%\n", "#7236: 97.31%\n", "#7237: 97.31%\n", "#7238: 97.31%\n", "#7239: 97.31%\n", "#7240: 97.31%\n", "#7241: 97.31%\n", "#7242: 97.31%\n", "#7243: 97.31%\n", "#7244: 97.31%\n", "#7245: 97.31%\n", "#7246: 97.31%\n", "#7247: 97.31%\n", "#7248: 97.31%\n", "#7249: 97.31%\n", "#7250: 97.31%\n", "#7251: 97.31%\n", "#7252: 97.31%\n", "#7253: 97.31%\n", "#7254: 97.31%\n", "#7255: 97.31%\n", "#7256: 97.31%\n", "#7257: 97.31%\n", "#7258: 97.31%\n", "#7259: 97.31%\n", "#7260: 97.31%\n", "#7261: 97.31%\n", "#7262: 97.32%\n", "#7263: 97.32%\n", "#7264: 97.32%\n", "#7265: 97.32%\n", "#7266: 97.32%\n", "#7267: 97.32%\n", "#7268: 97.32%\n", "#7269: 97.32%\n", "#7270: 97.32%\n", "#7271: 97.32%\n", "#7272: 97.32%\n", "#7273: 97.32%\n", "#7274: 97.32%\n", "#7275: 97.32%\n", "#7276: 97.32%\n", "#7277: 97.32%\n", "#7278: 97.32%\n", "#7279: 97.32%\n", "#7280: 97.32%\n", "#7281: 97.32%\n", "#7282: 97.32%\n", "#7283: 97.32%\n", "#7284: 97.32%\n", "#7285: 97.32%\n", "#7286: 97.32%\n", "#7287: 97.32%\n", "#7288: 97.32%\n", "#7289: 97.33%\n", "#7290: 97.33%\n", "#7291: 97.33%\n", "#7292: 97.33%\n", "#7293: 97.33%\n", "#7294: 97.33%\n", "#7295: 97.33%\n", "#7296: 97.33%\n", "#7297: 97.33%\n", "#7298: 97.33%\n", "#7299: 97.33%\n", "#7300: 97.33%\n", "#7301: 97.33%\n", "#7302: 97.33%\n", "#7303: 97.33%\n", "#7304: 97.33%\n", "#7305: 97.33%\n", "#7306: 97.33%\n", "#7307: 97.33%\n", "#7308: 97.33%\n", "#7309: 97.33%\n", "#7310: 97.33%\n", "#7311: 97.33%\n", "#7312: 97.33%\n", "#7313: 97.33%\n", "#7314: 97.33%\n", "#7315: 97.33%\n", "#7316: 97.33%\n", "#7317: 97.34%\n", "#7318: 97.34%\n", "#7319: 97.34%\n", "#7320: 97.34%\n", "#7321: 97.34%\n", "#7322: 97.34%\n", "#7323: 97.34%\n", "#7324: 97.34%\n", "#7325: 97.34%\n", "#7326: 97.34%\n", "#7327: 97.34%\n", "#7328: 97.34%\n", "#7329: 97.34%\n", "#7330: 97.34%\n", "#7331: 97.34%\n", "#7332: 97.34%\n", "#7333: 97.34%\n", "#7334: 97.34%\n", "#7335: 97.34%\n", "#7336: 97.34%\n", "#7337: 97.34%\n", "#7338: 97.34%\n", "#7339: 97.34%\n", "#7340: 97.34%\n", "#7341: 97.34%\n", "#7342: 97.34%\n", "#7343: 97.34%\n", "#7344: 97.35%\n", "#7345: 97.35%\n", "#7346: 97.35%\n", "#7347: 97.35%\n", "#7348: 97.35%\n", "#7349: 97.35%\n", "#7350: 97.35%\n", "#7351: 97.35%\n", "#7352: 97.35%\n", "#7353: 97.35%\n", "#7354: 97.35%\n", "#7355: 97.35%\n", "#7356: 97.35%\n", "#7357: 97.35%\n", "#7358: 97.35%\n", "#7359: 97.35%\n", "#7360: 97.35%\n", "#7361: 97.35%\n", "#7362: 97.35%\n", "#7363: 97.35%\n", "#7364: 97.35%\n", "#7365: 97.35%\n", "#7366: 97.35%\n", "#7367: 97.35%\n", "#7368: 97.35%\n", "#7369: 97.35%\n", "#7370: 97.35%\n", "#7371: 97.35%\n", "#7372: 97.36%\n", "#7373: 97.36%\n", "#7374: 97.36%\n", "#7375: 97.36%\n", "#7376: 97.36%\n", "#7377: 97.36%\n", "#7378: 97.36%\n", "#7379: 97.36%\n", "#7380: 97.36%\n", "#7381: 97.36%\n", "#7382: 97.36%\n", "#7383: 97.36%\n", "#7384: 97.36%\n", "#7385: 97.36%\n", "#7386: 97.36%\n", "#7387: 97.36%\n", "#7388: 97.36%\n", "#7389: 97.36%\n", "#7390: 97.36%\n", "#7391: 97.36%\n", "#7392: 97.36%\n", "#7393: 97.36%\n", "#7394: 97.36%\n", "#7395: 97.36%\n", "#7396: 97.36%\n", "#7397: 97.36%\n", "#7398: 97.36%\n", "#7399: 97.36%\n", "#7400: 97.37%\n", "#7401: 97.37%\n", "#7402: 97.37%\n", "#7403: 97.37%\n", "#7404: 97.37%\n", "#7405: 97.37%\n", "#7406: 97.37%\n", "#7407: 97.37%\n", "#7408: 97.37%\n", "#7409: 97.37%\n", "#7410: 97.37%\n", "#7411: 97.37%\n", "#7412: 97.37%\n", "#7413: 97.37%\n", "#7414: 97.37%\n", "#7415: 97.37%\n", "#7416: 97.37%\n", "#7417: 97.37%\n", "#7418: 97.37%\n", "#7419: 97.37%\n", "#7420: 97.37%\n", "#7421: 97.37%\n", "#7422: 97.37%\n", "#7423: 97.37%\n", "#7424: 97.37%\n", "#7425: 97.37%\n", "#7426: 97.37%\n", "#7427: 97.37%\n", "#7428: 97.38%\n", "#7429: 97.38%\n", "#7430: 97.38%\n", "#7431: 97.38%\n", "#7432: 97.38%\n", "#7433: 97.38%\n", "#7434: 97.38%\n", "#7435: 97.38%\n", "#7436: 97.38%\n", "#7437: 97.38%\n", "#7438: 97.38%\n", "#7439: 97.38%\n", "#7440: 97.38%\n", "#7441: 97.38%\n", "#7442: 97.38%\n", "#7443: 97.38%\n", "#7444: 97.38%\n", "#7445: 97.38%\n", "#7446: 97.38%\n", "#7447: 97.38%\n", "#7448: 97.38%\n", "#7449: 97.38%\n", "#7450: 97.38%\n", "#7451: 97.37%\n", "#7452: 97.37%\n", "#7453: 97.37%\n", "#7454: 97.37%\n", "#7455: 97.37%\n", "#7456: 97.37%\n", "#7457: 97.37%\n", "#7458: 97.37%\n", "#7459: 97.37%\n", "#7460: 97.37%\n", "#7461: 97.37%\n", "#7462: 97.37%\n", "#7463: 97.37%\n", "#7464: 97.37%\n", "#7465: 97.37%\n", "#7466: 97.38%\n", "#7467: 97.38%\n", "#7468: 97.38%\n", "#7469: 97.38%\n", "#7470: 97.38%\n", "#7471: 97.38%\n", "#7472: 97.38%\n", "#7473: 97.38%\n", "#7474: 97.38%\n", "#7475: 97.38%\n", "#7476: 97.38%\n", "#7477: 97.38%\n", "#7478: 97.38%\n", "#7479: 97.38%\n", "#7480: 97.38%\n", "#7481: 97.38%\n", "#7482: 97.38%\n", "#7483: 97.38%\n", "#7484: 97.38%\n", "#7485: 97.38%\n", "#7486: 97.38%\n", "#7487: 97.38%\n", "#7488: 97.38%\n", "#7489: 97.38%\n", "#7490: 97.38%\n", "#7491: 97.38%\n", "#7492: 97.38%\n", "#7493: 97.38%\n", "#7494: 97.38%\n", "#7495: 97.39%\n", "#7496: 97.39%\n", "#7497: 97.39%\n", "#7498: 97.39%\n", "#7499: 97.39%\n", "#7500: 97.39%\n", "#7501: 97.39%\n", "#7502: 97.39%\n", "#7503: 97.39%\n", "#7504: 97.39%\n", "#7505: 97.39%\n", "#7506: 97.39%\n", "#7507: 97.39%\n", "#7508: 97.39%\n", "#7509: 97.39%\n", "#7510: 97.39%\n", "#7511: 97.39%\n", "#7512: 97.39%\n", "#7513: 97.39%\n", "#7514: 97.38%\n", "#7515: 97.38%\n", "#7516: 97.38%\n", "#7517: 97.38%\n", "#7518: 97.38%\n", "#7519: 97.38%\n", "#7520: 97.38%\n", "#7521: 97.38%\n", "#7522: 97.38%\n", "#7523: 97.38%\n", "#7524: 97.38%\n", "#7525: 97.38%\n", "#7526: 97.38%\n", "#7527: 97.38%\n", "#7528: 97.38%\n", "#7529: 97.38%\n", "#7530: 97.38%\n", "#7531: 97.38%\n", "#7532: 97.38%\n", "#7533: 97.39%\n", "#7534: 97.39%\n", "#7535: 97.39%\n", "#7536: 97.39%\n", "#7537: 97.39%\n", "#7538: 97.39%\n", "#7539: 97.39%\n", "#7540: 97.39%\n", "#7541: 97.39%\n", "#7542: 97.39%\n", "#7543: 97.39%\n", "#7544: 97.39%\n", "#7545: 97.39%\n", "#7546: 97.39%\n", "#7547: 97.39%\n", "#7548: 97.39%\n", "#7549: 97.39%\n", "#7550: 97.39%\n", "#7551: 97.39%\n", "#7552: 97.39%\n", "#7553: 97.39%\n", "#7554: 97.39%\n", "#7555: 97.39%\n", "#7556: 97.39%\n", "#7557: 97.39%\n", "#7558: 97.39%\n", "#7559: 97.39%\n", "#7560: 97.39%\n", "#7561: 97.39%\n", "#7562: 97.40%\n", "#7563: 97.40%\n", "#7564: 97.40%\n", "#7565: 97.40%\n", "#7566: 97.40%\n", "#7567: 97.40%\n", "#7568: 97.40%\n", "#7569: 97.40%\n", "#7570: 97.40%\n", "#7571: 97.40%\n", "#7572: 97.40%\n", "#7573: 97.40%\n", "#7574: 97.40%\n", "#7575: 97.40%\n", "#7576: 97.40%\n", "#7577: 97.40%\n", "#7578: 97.40%\n", "#7579: 97.40%\n", "#7580: 97.40%\n", "#7581: 97.40%\n", "#7582: 97.40%\n", "#7583: 97.40%\n", "#7584: 97.40%\n", "#7585: 97.40%\n", "#7586: 97.40%\n", "#7587: 97.40%\n", "#7588: 97.40%\n", "#7589: 97.40%\n", "#7590: 97.40%\n", "#7591: 97.41%\n", "#7592: 97.41%\n", "#7593: 97.41%\n", "#7594: 97.41%\n", "#7595: 97.41%\n", "#7596: 97.41%\n", "#7597: 97.41%\n", "#7598: 97.41%\n", "#7599: 97.41%\n", "#7600: 97.41%\n", "#7601: 97.41%\n", "#7602: 97.41%\n", "#7603: 97.41%\n", "#7604: 97.41%\n", "#7605: 97.41%\n", "#7606: 97.41%\n", "#7607: 97.41%\n", "#7608: 97.41%\n", "#7609: 97.41%\n", "#7610: 97.41%\n", "#7611: 97.41%\n", "#7612: 97.41%\n", "#7613: 97.41%\n", "#7614: 97.41%\n", "#7615: 97.41%\n", "#7616: 97.41%\n", "#7617: 97.41%\n", "#7618: 97.41%\n", "#7619: 97.41%\n", "#7620: 97.42%\n", "#7621: 97.42%\n", "#7622: 97.42%\n", "#7623: 97.42%\n", "#7624: 97.42%\n", "#7625: 97.42%\n", "#7626: 97.42%\n", "#7627: 97.42%\n", "#7628: 97.42%\n", "#7629: 97.42%\n", "#7630: 97.42%\n", "#7631: 97.42%\n", "#7632: 97.42%\n", "#7633: 97.42%\n", "#7634: 97.42%\n", "#7635: 97.42%\n", "#7636: 97.42%\n", "#7637: 97.42%\n", "#7638: 97.42%\n", "#7639: 97.42%\n", "#7640: 97.42%\n", "#7641: 97.42%\n", "#7642: 97.42%\n", "#7643: 97.42%\n", "#7644: 97.42%\n", "#7645: 97.42%\n", "#7646: 97.42%\n", "#7647: 97.42%\n", "#7648: 97.42%\n", "#7649: 97.42%\n", "#7650: 97.43%\n", "#7651: 97.43%\n", "#7652: 97.43%\n", "#7653: 97.43%\n", "#7654: 97.43%\n", "#7655: 97.43%\n", "#7656: 97.43%\n", "#7657: 97.43%\n", "#7658: 97.43%\n", "#7659: 97.43%\n", "#7660: 97.43%\n", "#7661: 97.43%\n", "#7662: 97.43%\n", "#7663: 97.43%\n", "#7664: 97.43%\n", "#7665: 97.43%\n", "#7666: 97.43%\n", "#7667: 97.43%\n", "#7668: 97.43%\n", "#7669: 97.43%\n", "#7670: 97.43%\n", "#7671: 97.43%\n", "#7672: 97.43%\n", "#7673: 97.43%\n", "#7674: 97.43%\n", "#7675: 97.43%\n", "#7676: 97.43%\n", "#7677: 97.43%\n", "#7678: 97.43%\n", "#7679: 97.43%\n", "#7680: 97.44%\n", "#7681: 97.44%\n", "#7682: 97.44%\n", "#7683: 97.44%\n", "#7684: 97.44%\n", "#7685: 97.44%\n", "#7686: 97.44%\n", "#7687: 97.44%\n", "#7688: 97.44%\n", "#7689: 97.44%\n", "#7690: 97.44%\n", "#7691: 97.44%\n", "#7692: 97.44%\n", "#7693: 97.44%\n", "#7694: 97.44%\n", "#7695: 97.44%\n", "#7696: 97.44%\n", "#7697: 97.44%\n", "#7698: 97.44%\n", "#7699: 97.44%\n", "#7700: 97.44%\n", "#7701: 97.44%\n", "#7702: 97.44%\n", "#7703: 97.44%\n", "#7704: 97.44%\n", "#7705: 97.44%\n", "#7706: 97.44%\n", "#7707: 97.44%\n", "#7708: 97.44%\n", "#7709: 97.44%\n", "#7710: 97.45%\n", "#7711: 97.45%\n", "#7712: 97.45%\n", "#7713: 97.45%\n", "#7714: 97.45%\n", "#7715: 97.45%\n", "#7716: 97.45%\n", "#7717: 97.45%\n", "#7718: 97.45%\n", "#7719: 97.45%\n", "#7720: 97.45%\n", "#7721: 97.45%\n", "#7722: 97.45%\n", "#7723: 97.45%\n", "#7724: 97.45%\n", "#7725: 97.45%\n", "#7726: 97.45%\n", "#7727: 97.45%\n", "#7728: 97.45%\n", "#7729: 97.45%\n", "#7730: 97.45%\n", "#7731: 97.45%\n", "#7732: 97.45%\n", "#7733: 97.45%\n", "#7734: 97.45%\n", "#7735: 97.45%\n", "#7736: 97.45%\n", "#7737: 97.45%\n", "#7738: 97.45%\n", "#7739: 97.45%\n", "#7740: 97.46%\n", "#7741: 97.46%\n", "#7742: 97.46%\n", "#7743: 97.46%\n", "#7744: 97.46%\n", "#7745: 97.46%\n", "#7746: 97.46%\n", "#7747: 97.46%\n", "#7748: 97.46%\n", "#7749: 97.46%\n", "#7750: 97.46%\n", "#7751: 97.46%\n", "#7752: 97.46%\n", "#7753: 97.46%\n", "#7754: 97.46%\n", "#7755: 97.46%\n", "#7756: 97.46%\n", "#7757: 97.46%\n", "#7758: 97.46%\n", "#7759: 97.46%\n", "#7760: 97.46%\n", "#7761: 97.46%\n", "#7762: 97.46%\n", "#7763: 97.46%\n", "#7764: 97.46%\n", "#7765: 97.46%\n", "#7766: 97.46%\n", "#7767: 97.46%\n", "#7768: 97.46%\n", "#7769: 97.46%\n", "#7770: 97.46%\n", "#7771: 97.47%\n", "#7772: 97.47%\n", "#7773: 97.47%\n", "#7774: 97.47%\n", "#7775: 97.47%\n", "#7776: 97.47%\n", "#7777: 97.47%\n", "#7778: 97.47%\n", "#7779: 97.47%\n", "#7780: 97.47%\n", "#7781: 97.47%\n", "#7782: 97.47%\n", "#7783: 97.47%\n", "#7784: 97.47%\n", "#7785: 97.47%\n", "#7786: 97.47%\n", "#7787: 97.47%\n", "#7788: 97.47%\n", "#7789: 97.47%\n", "#7790: 97.47%\n", "#7791: 97.47%\n", "#7792: 97.47%\n", "#7793: 97.47%\n", "#7794: 97.47%\n", "#7795: 97.47%\n", "#7796: 97.47%\n", "#7797: 97.47%\n", "#7798: 97.47%\n", "#7799: 97.47%\n", "#7800: 97.47%\n", "#7801: 97.48%\n", "#7802: 97.48%\n", "#7803: 97.48%\n", "#7804: 97.48%\n", "#7805: 97.48%\n", "#7806: 97.48%\n", "#7807: 97.48%\n", "#7808: 97.48%\n", "#7809: 97.48%\n", "#7810: 97.48%\n", "#7811: 97.48%\n", "#7812: 97.48%\n", "#7813: 97.48%\n", "#7814: 97.48%\n", "#7815: 97.48%\n", "#7816: 97.48%\n", "#7817: 97.48%\n", "#7818: 97.48%\n", "#7819: 97.48%\n", "#7820: 97.48%\n", "#7821: 97.48%\n", "#7822: 97.48%\n", "#7823: 97.48%\n", "#7824: 97.48%\n", "#7825: 97.48%\n", "#7826: 97.48%\n", "#7827: 97.48%\n", "#7828: 97.48%\n", "#7829: 97.48%\n", "#7830: 97.48%\n", "#7831: 97.48%\n", "#7832: 97.48%\n", "#7833: 97.49%\n", "#7834: 97.49%\n", "#7835: 97.49%\n", "#7836: 97.49%\n", "#7837: 97.49%\n", "#7838: 97.49%\n", "#7839: 97.49%\n", "#7840: 97.49%\n", "#7841: 97.49%\n", "#7842: 97.49%\n", "#7843: 97.49%\n", "#7844: 97.49%\n", "#7845: 97.48%\n", "#7846: 97.48%\n", "#7847: 97.48%\n", "#7848: 97.48%\n", "#7849: 97.48%\n", "#7850: 97.48%\n", "#7851: 97.48%\n", "#7852: 97.48%\n", "#7853: 97.48%\n", "#7854: 97.48%\n", "#7855: 97.48%\n", "#7856: 97.48%\n", "#7857: 97.48%\n", "#7858: 97.48%\n", "#7859: 97.48%\n", "#7860: 97.48%\n", "#7861: 97.48%\n", "#7862: 97.48%\n", "#7863: 97.48%\n", "#7864: 97.48%\n", "#7865: 97.48%\n", "#7866: 97.48%\n", "#7867: 97.48%\n", "#7868: 97.48%\n", "#7869: 97.48%\n", "#7870: 97.48%\n", "#7871: 97.48%\n", "#7872: 97.49%\n", "#7873: 97.49%\n", "#7874: 97.49%\n", "#7875: 97.49%\n", "#7876: 97.49%\n", "#7877: 97.49%\n", "#7878: 97.49%\n", "#7879: 97.49%\n", "#7880: 97.49%\n", "#7881: 97.49%\n", "#7882: 97.49%\n", "#7883: 97.49%\n", "#7884: 97.49%\n", "#7885: 97.49%\n", "#7886: 97.48%\n", "#7887: 97.48%\n", "#7888: 97.48%\n", "#7889: 97.48%\n", "#7890: 97.48%\n", "#7891: 97.48%\n", "#7892: 97.48%\n", "#7893: 97.48%\n", "#7894: 97.48%\n", "#7895: 97.48%\n", "#7896: 97.48%\n", "#7897: 97.48%\n", "#7898: 97.48%\n", "#7899: 97.48%\n", "#7900: 97.48%\n", "#7901: 97.48%\n", "#7902: 97.48%\n", "#7903: 97.48%\n", "#7904: 97.48%\n", "#7905: 97.48%\n", "#7906: 97.48%\n", "#7907: 97.48%\n", "#7908: 97.48%\n", "#7909: 97.48%\n", "#7910: 97.48%\n", "#7911: 97.48%\n", "#7912: 97.49%\n", "#7913: 97.49%\n", "#7914: 97.49%\n", "#7915: 97.47%\n", "#7916: 97.47%\n", "#7917: 97.47%\n", "#7918: 97.47%\n", "#7919: 97.47%\n", "#7920: 97.48%\n", "#7921: 97.48%\n", "#7922: 97.48%\n", "#7923: 97.48%\n", "#7924: 97.48%\n", "#7925: 97.48%\n", "#7926: 97.48%\n", "#7927: 97.46%\n", "#7928: 97.47%\n", "#7929: 97.47%\n", "#7930: 97.47%\n", "#7931: 97.47%\n", "#7932: 97.47%\n", "#7933: 97.47%\n", "#7934: 97.47%\n", "#7935: 97.47%\n", "#7936: 97.47%\n", "#7937: 97.47%\n", "#7938: 97.47%\n", "#7939: 97.47%\n", "#7940: 97.47%\n", "#7941: 97.47%\n", "#7942: 97.47%\n", "#7943: 97.47%\n", "#7944: 97.47%\n", "#7945: 97.47%\n", "#7946: 97.47%\n", "#7947: 97.47%\n", "#7948: 97.47%\n", "#7949: 97.47%\n", "#7950: 97.47%\n", "#7951: 97.47%\n", "#7952: 97.47%\n", "#7953: 97.47%\n", "#7954: 97.47%\n", "#7955: 97.47%\n", "#7956: 97.47%\n", "#7957: 97.47%\n", "#7958: 97.47%\n", "#7959: 97.47%\n", "#7960: 97.48%\n", "#7961: 97.48%\n", "#7962: 97.48%\n", "#7963: 97.48%\n", "#7964: 97.48%\n", "#7965: 97.48%\n", "#7966: 97.48%\n", "#7967: 97.48%\n", "#7968: 97.48%\n", "#7969: 97.48%\n", "#7970: 97.48%\n", "#7971: 97.48%\n", "#7972: 97.48%\n", "#7973: 97.48%\n", "#7974: 97.48%\n", "#7975: 97.48%\n", "#7976: 97.48%\n", "#7977: 97.48%\n", "#7978: 97.48%\n", "#7979: 97.48%\n", "#7980: 97.48%\n", "#7981: 97.48%\n", "#7982: 97.48%\n", "#7983: 97.48%\n", "#7984: 97.48%\n", "#7985: 97.48%\n", "#7986: 97.48%\n", "#7987: 97.48%\n", "#7988: 97.48%\n", "#7989: 97.48%\n", "#7990: 97.48%\n", "#7991: 97.48%\n", "#7992: 97.49%\n", "#7993: 97.49%\n", "#7994: 97.49%\n", "#7995: 97.49%\n", "#7996: 97.49%\n", "#7997: 97.49%\n", "#7998: 97.49%\n", "#7999: 97.49%\n", "#8000: 97.49%\n", "#8001: 97.49%\n", "#8002: 97.49%\n", "#8003: 97.49%\n", "#8004: 97.49%\n", "#8005: 97.49%\n", "#8006: 97.49%\n", "#8007: 97.49%\n", "#8008: 97.49%\n", "#8009: 97.49%\n", "#8010: 97.49%\n", "#8011: 97.49%\n", "#8012: 97.49%\n", "#8013: 97.49%\n", "#8014: 97.49%\n", "#8015: 97.49%\n", "#8016: 97.49%\n", "#8017: 97.49%\n", "#8018: 97.49%\n", "#8019: 97.49%\n", "#8020: 97.49%\n", "#8021: 97.49%\n", "#8022: 97.49%\n", "#8023: 97.50%\n", "#8024: 97.50%\n", "#8025: 97.50%\n", "#8026: 97.50%\n", "#8027: 97.50%\n", "#8028: 97.50%\n", "#8029: 97.50%\n", "#8030: 97.50%\n", "#8031: 97.50%\n", "#8032: 97.50%\n", "#8033: 97.50%\n", "#8034: 97.50%\n", "#8035: 97.50%\n", "#8036: 97.50%\n", "#8037: 97.50%\n", "#8038: 97.50%\n", "#8039: 97.50%\n", "#8040: 97.50%\n", "#8041: 97.50%\n", "#8042: 97.50%\n", "#8043: 97.50%\n", "#8044: 97.50%\n", "#8045: 97.50%\n", "#8046: 97.50%\n", "#8047: 97.49%\n", "#8048: 97.49%\n", "#8049: 97.49%\n", "#8050: 97.49%\n", "#8051: 97.49%\n", "#8052: 97.49%\n", "#8053: 97.49%\n", "#8054: 97.49%\n", "#8055: 97.49%\n", "#8056: 97.49%\n", "#8057: 97.49%\n", "#8058: 97.49%\n", "#8059: 97.48%\n", "#8060: 97.48%\n", "#8061: 97.48%\n", "#8062: 97.48%\n", "#8063: 97.48%\n", "#8064: 97.48%\n", "#8065: 97.48%\n", "#8066: 97.48%\n", "#8067: 97.48%\n", "#8068: 97.48%\n", "#8069: 97.48%\n", "#8070: 97.48%\n", "#8071: 97.49%\n", "#8072: 97.49%\n", "#8073: 97.49%\n", "#8074: 97.49%\n", "#8075: 97.49%\n", "#8076: 97.49%\n", "#8077: 97.49%\n", "#8078: 97.49%\n", "#8079: 97.49%\n", "#8080: 97.49%\n", "#8081: 97.49%\n", "#8082: 97.49%\n", "#8083: 97.49%\n", "#8084: 97.49%\n", "#8085: 97.49%\n", "#8086: 97.49%\n", "#8087: 97.49%\n", "#8088: 97.49%\n", "#8089: 97.49%\n", "#8090: 97.49%\n", "#8091: 97.48%\n", "#8092: 97.48%\n", "#8093: 97.48%\n", "#8094: 97.47%\n", "#8095: 97.47%\n", "#8096: 97.47%\n", "#8097: 97.47%\n", "#8098: 97.47%\n", "#8099: 97.47%\n", "#8100: 97.47%\n", "#8101: 97.47%\n", "#8102: 97.47%\n", "#8103: 97.47%\n", "#8104: 97.47%\n", "#8105: 97.47%\n", "#8106: 97.47%\n", "#8107: 97.47%\n", "#8108: 97.47%\n", "#8109: 97.47%\n", "#8110: 97.47%\n", "#8111: 97.47%\n", "#8112: 97.47%\n", "#8113: 97.47%\n", "#8114: 97.47%\n", "#8115: 97.47%\n", "#8116: 97.47%\n", "#8117: 97.47%\n", "#8118: 97.48%\n", "#8119: 97.48%\n", "#8120: 97.48%\n", "#8121: 97.48%\n", "#8122: 97.48%\n", "#8123: 97.48%\n", "#8124: 97.48%\n", "#8125: 97.48%\n", "#8126: 97.48%\n", "#8127: 97.48%\n", "#8128: 97.48%\n", "#8129: 97.48%\n", "#8130: 97.48%\n", "#8131: 97.48%\n", "#8132: 97.48%\n", "#8133: 97.48%\n", "#8134: 97.48%\n", "#8135: 97.48%\n", "#8136: 97.48%\n", "#8137: 97.48%\n", "#8138: 97.48%\n", "#8139: 97.48%\n", "#8140: 97.48%\n", "#8141: 97.48%\n", "#8142: 97.48%\n", "#8143: 97.48%\n", "#8144: 97.48%\n", "#8145: 97.48%\n", "#8146: 97.48%\n", "#8147: 97.48%\n", "#8148: 97.48%\n", "#8149: 97.48%\n", "#8150: 97.48%\n", "#8151: 97.49%\n", "#8152: 97.49%\n", "#8153: 97.49%\n", "#8154: 97.49%\n", "#8155: 97.49%\n", "#8156: 97.49%\n", "#8157: 97.49%\n", "#8158: 97.49%\n", "#8159: 97.49%\n", "#8160: 97.49%\n", "#8161: 97.49%\n", "#8162: 97.49%\n", "#8163: 97.49%\n", "#8164: 97.49%\n", "#8165: 97.49%\n", "#8166: 97.49%\n", "#8167: 97.49%\n", "#8168: 97.49%\n", "#8169: 97.49%\n", "#8170: 97.49%\n", "#8171: 97.49%\n", "#8172: 97.49%\n", "#8173: 97.49%\n", "#8174: 97.49%\n", "#8175: 97.49%\n", "#8176: 97.49%\n", "#8177: 97.49%\n", "#8178: 97.49%\n", "#8179: 97.49%\n", "#8180: 97.49%\n", "#8181: 97.49%\n", "#8182: 97.49%\n", "#8183: 97.50%\n", "#8184: 97.50%\n", "#8185: 97.50%\n", "#8186: 97.50%\n", "#8187: 97.50%\n", "#8188: 97.50%\n", "#8189: 97.50%\n", "#8190: 97.50%\n", "#8191: 97.50%\n", "#8192: 97.50%\n", "#8193: 97.50%\n", "#8194: 97.50%\n", "#8195: 97.50%\n", "#8196: 97.50%\n", "#8197: 97.50%\n", "#8198: 97.50%\n", "#8199: 97.50%\n", "#8200: 97.50%\n", "#8201: 97.50%\n", "#8202: 97.50%\n", "#8203: 97.50%\n", "#8204: 97.50%\n", "#8205: 97.50%\n", "#8206: 97.50%\n", "#8207: 97.50%\n", "#8208: 97.50%\n", "#8209: 97.50%\n", "#8210: 97.50%\n", "#8211: 97.50%\n", "#8212: 97.50%\n", "#8213: 97.50%\n", "#8214: 97.50%\n", "#8215: 97.50%\n", "#8216: 97.51%\n", "#8217: 97.51%\n", "#8218: 97.51%\n", "#8219: 97.51%\n", "#8220: 97.51%\n", "#8221: 97.51%\n", "#8222: 97.51%\n", "#8223: 97.51%\n", "#8224: 97.51%\n", "#8225: 97.51%\n", "#8226: 97.51%\n", "#8227: 97.51%\n", "#8228: 97.51%\n", "#8229: 97.51%\n", "#8230: 97.51%\n", "#8231: 97.51%\n", "#8232: 97.51%\n", "#8233: 97.51%\n", "#8234: 97.51%\n", "#8235: 97.51%\n", "#8236: 97.51%\n", "#8237: 97.51%\n", "#8238: 97.51%\n", "#8239: 97.51%\n", "#8240: 97.51%\n", "#8241: 97.51%\n", "#8242: 97.51%\n", "#8243: 97.51%\n", "#8244: 97.51%\n", "#8245: 97.51%\n", "#8246: 97.51%\n", "#8247: 97.51%\n", "#8248: 97.51%\n", "#8249: 97.52%\n", "#8250: 97.52%\n", "#8251: 97.52%\n", "#8252: 97.52%\n", "#8253: 97.52%\n", "#8254: 97.52%\n", "#8255: 97.52%\n", "#8256: 97.52%\n", "#8257: 97.52%\n", "#8258: 97.52%\n", "#8259: 97.52%\n", "#8260: 97.52%\n", "#8261: 97.52%\n", "#8262: 97.52%\n", "#8263: 97.52%\n", "#8264: 97.52%\n", "#8265: 97.52%\n", "#8266: 97.52%\n", "#8267: 97.52%\n", "#8268: 97.52%\n", "#8269: 97.52%\n", "#8270: 97.52%\n", "#8271: 97.52%\n", "#8272: 97.52%\n", "#8273: 97.52%\n", "#8274: 97.52%\n", "#8275: 97.52%\n", "#8276: 97.52%\n", "#8277: 97.52%\n", "#8278: 97.51%\n", "#8279: 97.51%\n", "#8280: 97.51%\n", "#8281: 97.51%\n", "#8282: 97.51%\n", "#8283: 97.51%\n", "#8284: 97.51%\n", "#8285: 97.51%\n", "#8286: 97.51%\n", "#8287: 97.51%\n", "#8288: 97.51%\n", "#8289: 97.52%\n", "#8290: 97.52%\n", "#8291: 97.52%\n", "#8292: 97.52%\n", "#8293: 97.52%\n", "#8294: 97.52%\n", "#8295: 97.52%\n", "#8296: 97.52%\n", "#8297: 97.52%\n", "#8298: 97.52%\n", "#8299: 97.52%\n", "#8300: 97.52%\n", "#8301: 97.52%\n", "#8302: 97.52%\n", "#8303: 97.52%\n", "#8304: 97.52%\n", "#8305: 97.52%\n", "#8306: 97.52%\n", "#8307: 97.52%\n", "#8308: 97.52%\n", "#8309: 97.52%\n", "#8310: 97.52%\n", "#8311: 97.52%\n", "#8312: 97.52%\n", "#8313: 97.52%\n", "#8314: 97.52%\n", "#8315: 97.52%\n", "#8316: 97.51%\n", "#8317: 97.51%\n", "#8318: 97.51%\n", "#8319: 97.51%\n", "#8320: 97.51%\n", "#8321: 97.51%\n", "#8322: 97.50%\n", "#8323: 97.50%\n", "#8324: 97.50%\n", "#8325: 97.49%\n", "#8326: 97.49%\n", "#8327: 97.49%\n", "#8328: 97.49%\n", "#8329: 97.49%\n", "#8330: 97.49%\n", "#8331: 97.49%\n", "#8332: 97.49%\n", "#8333: 97.49%\n", "#8334: 97.49%\n", "#8335: 97.49%\n", "#8336: 97.49%\n", "#8337: 97.49%\n", "#8338: 97.49%\n", "#8339: 97.49%\n", "#8340: 97.49%\n", "#8341: 97.49%\n", "#8342: 97.49%\n", "#8343: 97.50%\n", "#8344: 97.50%\n", "#8345: 97.50%\n", "#8346: 97.50%\n", "#8347: 97.50%\n", "#8348: 97.50%\n", "#8349: 97.50%\n", "#8350: 97.50%\n", "#8351: 97.50%\n", "#8352: 97.50%\n", "#8353: 97.49%\n", "#8354: 97.49%\n", "#8355: 97.49%\n", "#8356: 97.49%\n", "#8357: 97.49%\n", "#8358: 97.49%\n", "#8359: 97.49%\n", "#8360: 97.49%\n", "#8361: 97.49%\n", "#8362: 97.49%\n", "#8363: 97.49%\n", "#8364: 97.49%\n", "#8365: 97.49%\n", "#8366: 97.49%\n", "#8367: 97.49%\n", "#8368: 97.49%\n", "#8369: 97.49%\n", "#8370: 97.49%\n", "#8371: 97.49%\n", "#8372: 97.49%\n", "#8373: 97.49%\n", "#8374: 97.49%\n", "#8375: 97.48%\n", "#8376: 97.48%\n", "#8377: 97.48%\n", "#8378: 97.48%\n", "#8379: 97.48%\n", "#8380: 97.48%\n", "#8381: 97.48%\n", "#8382: 97.48%\n", "#8383: 97.48%\n", "#8384: 97.48%\n", "#8385: 97.48%\n", "#8386: 97.48%\n", "#8387: 97.48%\n", "#8388: 97.48%\n", "#8389: 97.49%\n", "#8390: 97.49%\n", "#8391: 97.49%\n", "#8392: 97.49%\n", "#8393: 97.49%\n", "#8394: 97.49%\n", "#8395: 97.49%\n", "#8396: 97.49%\n", "#8397: 97.49%\n", "#8398: 97.49%\n", "#8399: 97.49%\n", "#8400: 97.49%\n", "#8401: 97.49%\n", "#8402: 97.49%\n", "#8403: 97.49%\n", "#8404: 97.49%\n", "#8405: 97.49%\n", "#8406: 97.49%\n", "#8407: 97.49%\n", "#8408: 97.48%\n", "#8409: 97.48%\n", "#8410: 97.47%\n", "#8411: 97.47%\n", "#8412: 97.47%\n", "#8413: 97.47%\n", "#8414: 97.47%\n", "#8415: 97.47%\n", "#8416: 97.47%\n", "#8417: 97.47%\n", "#8418: 97.47%\n", "#8419: 97.47%\n", "#8420: 97.47%\n", "#8421: 97.47%\n", "#8422: 97.47%\n", "#8423: 97.47%\n", "#8424: 97.47%\n", "#8425: 97.47%\n", "#8426: 97.47%\n", "#8427: 97.47%\n", "#8428: 97.47%\n", "#8429: 97.47%\n", "#8430: 97.47%\n", "#8431: 97.47%\n", "#8432: 97.47%\n", "#8433: 97.47%\n", "#8434: 97.47%\n", "#8435: 97.48%\n", "#8436: 97.48%\n", "#8437: 97.48%\n", "#8438: 97.48%\n", "#8439: 97.48%\n", "#8440: 97.48%\n", "#8441: 97.48%\n", "#8442: 97.48%\n", "#8443: 97.48%\n", "#8444: 97.48%\n", "#8445: 97.48%\n", "#8446: 97.48%\n", "#8447: 97.48%\n", "#8448: 97.48%\n", "#8449: 97.48%\n", "#8450: 97.48%\n", "#8451: 97.48%\n", "#8452: 97.48%\n", "#8453: 97.48%\n", "#8454: 97.48%\n", "#8455: 97.48%\n", "#8456: 97.48%\n", "#8457: 97.48%\n", "#8458: 97.48%\n", "#8459: 97.48%\n", "#8460: 97.48%\n", "#8461: 97.48%\n", "#8462: 97.48%\n", "#8463: 97.48%\n", "#8464: 97.48%\n", "#8465: 97.48%\n", "#8466: 97.48%\n", "#8467: 97.48%\n", "#8468: 97.48%\n", "#8469: 97.49%\n", "#8470: 97.49%\n", "#8471: 97.49%\n", "#8472: 97.49%\n", "#8473: 97.49%\n", "#8474: 97.49%\n", "#8475: 97.49%\n", "#8476: 97.49%\n", "#8477: 97.49%\n", "#8478: 97.49%\n", "#8479: 97.49%\n", "#8480: 97.49%\n", "#8481: 97.49%\n", "#8482: 97.49%\n", "#8483: 97.49%\n", "#8484: 97.49%\n", "#8485: 97.49%\n", "#8486: 97.49%\n", "#8487: 97.49%\n", "#8488: 97.49%\n", "#8489: 97.49%\n", "#8490: 97.49%\n", "#8491: 97.49%\n", "#8492: 97.49%\n", "#8493: 97.49%\n", "#8494: 97.49%\n", "#8495: 97.49%\n", "#8496: 97.49%\n", "#8497: 97.49%\n", "#8498: 97.49%\n", "#8499: 97.49%\n", "#8500: 97.49%\n", "#8501: 97.49%\n", "#8502: 97.50%\n", "#8503: 97.50%\n", "#8504: 97.50%\n", "#8505: 97.50%\n", "#8506: 97.50%\n", "#8507: 97.50%\n", "#8508: 97.50%\n", "#8509: 97.50%\n", "#8510: 97.50%\n", "#8511: 97.50%\n", "#8512: 97.50%\n", "#8513: 97.50%\n", "#8514: 97.50%\n", "#8515: 97.50%\n", "#8516: 97.50%\n", "#8517: 97.50%\n", "#8518: 97.50%\n", "#8519: 97.50%\n", "#8520: 97.50%\n", "#8521: 97.50%\n", "#8522: 97.49%\n", "#8523: 97.49%\n", "#8524: 97.49%\n", "#8525: 97.49%\n", "#8526: 97.49%\n", "#8527: 97.49%\n", "#8528: 97.49%\n", "#8529: 97.49%\n", "#8530: 97.49%\n", "#8531: 97.49%\n", "#8532: 97.49%\n", "#8533: 97.49%\n", "#8534: 97.49%\n", "#8535: 97.49%\n", "#8536: 97.49%\n", "#8537: 97.49%\n", "#8538: 97.49%\n", "#8539: 97.49%\n", "#8540: 97.49%\n", "#8541: 97.49%\n", "#8542: 97.50%\n", "#8543: 97.50%\n", "#8544: 97.50%\n", "#8545: 97.50%\n", "#8546: 97.50%\n", "#8547: 97.50%\n", "#8548: 97.50%\n", "#8549: 97.50%\n", "#8550: 97.50%\n", "#8551: 97.50%\n", "#8552: 97.50%\n", "#8553: 97.50%\n", "#8554: 97.50%\n", "#8555: 97.50%\n", "#8556: 97.50%\n", "#8557: 97.50%\n", "#8558: 97.50%\n", "#8559: 97.50%\n", "#8560: 97.50%\n", "#8561: 97.50%\n", "#8562: 97.50%\n", "#8563: 97.50%\n", "#8564: 97.50%\n", "#8565: 97.50%\n", "#8566: 97.50%\n", "#8567: 97.50%\n", "#8568: 97.50%\n", "#8569: 97.50%\n", "#8570: 97.50%\n", "#8571: 97.50%\n", "#8572: 97.50%\n", "#8573: 97.50%\n", "#8574: 97.50%\n", "#8575: 97.50%\n", "#8576: 97.50%\n", "#8577: 97.51%\n", "#8578: 97.51%\n", "#8579: 97.51%\n", "#8580: 97.51%\n", "#8581: 97.51%\n", "#8582: 97.51%\n", "#8583: 97.51%\n", "#8584: 97.51%\n", "#8585: 97.51%\n", "#8586: 97.51%\n", "#8587: 97.51%\n", "#8588: 97.51%\n", "#8589: 97.51%\n", "#8590: 97.51%\n", "#8591: 97.51%\n", "#8592: 97.51%\n", "#8593: 97.51%\n", "#8594: 97.51%\n", "#8595: 97.51%\n", "#8596: 97.51%\n", "#8597: 97.51%\n", "#8598: 97.51%\n", "#8599: 97.51%\n", "#8600: 97.51%\n", "#8601: 97.51%\n", "#8602: 97.51%\n", "#8603: 97.51%\n", "#8604: 97.51%\n", "#8605: 97.51%\n", "#8606: 97.51%\n", "#8607: 97.51%\n", "#8608: 97.51%\n", "#8609: 97.51%\n", "#8610: 97.51%\n", "#8611: 97.52%\n", "#8612: 97.52%\n", "#8613: 97.52%\n", "#8614: 97.52%\n", "#8615: 97.52%\n", "#8616: 97.52%\n", "#8617: 97.52%\n", "#8618: 97.52%\n", "#8619: 97.52%\n", "#8620: 97.52%\n", "#8621: 97.52%\n", "#8622: 97.52%\n", "#8623: 97.52%\n", "#8624: 97.52%\n", "#8625: 97.52%\n", "#8626: 97.52%\n", "#8627: 97.52%\n", "#8628: 97.52%\n", "#8629: 97.52%\n", "#8630: 97.52%\n", "#8631: 97.52%\n", "#8632: 97.52%\n", "#8633: 97.52%\n", "#8634: 97.52%\n", "#8635: 97.52%\n", "#8636: 97.52%\n", "#8637: 97.52%\n", "#8638: 97.52%\n", "#8639: 97.52%\n", "#8640: 97.52%\n", "#8641: 97.52%\n", "#8642: 97.52%\n", "#8643: 97.52%\n", "#8644: 97.52%\n", "#8645: 97.52%\n", "#8646: 97.53%\n", "#8647: 97.53%\n", "#8648: 97.53%\n", "#8649: 97.53%\n", "#8650: 97.53%\n", "#8651: 97.53%\n", "#8652: 97.53%\n", "#8653: 97.53%\n", "#8654: 97.53%\n", "#8655: 97.53%\n", "#8656: 97.53%\n", "#8657: 97.53%\n", "#8658: 97.53%\n", "#8659: 97.53%\n", "#8660: 97.53%\n", "#8661: 97.53%\n", "#8662: 97.53%\n", "#8663: 97.53%\n", "#8664: 97.53%\n", "#8665: 97.53%\n", "#8666: 97.53%\n", "#8667: 97.53%\n", "#8668: 97.53%\n", "#8669: 97.53%\n", "#8670: 97.53%\n", "#8671: 97.53%\n", "#8672: 97.53%\n", "#8673: 97.53%\n", "#8674: 97.53%\n", "#8675: 97.53%\n", "#8676: 97.53%\n", "#8677: 97.53%\n", "#8678: 97.53%\n", "#8679: 97.53%\n", "#8680: 97.53%\n", "#8681: 97.54%\n", "#8682: 97.54%\n", "#8683: 97.54%\n", "#8684: 97.54%\n", "#8685: 97.54%\n", "#8686: 97.54%\n", "#8687: 97.54%\n", "#8688: 97.54%\n", "#8689: 97.54%\n", "#8690: 97.54%\n", "#8691: 97.54%\n", "#8692: 97.54%\n", "#8693: 97.54%\n", "#8694: 97.54%\n", "#8695: 97.54%\n", "#8696: 97.54%\n", "#8697: 97.54%\n", "#8698: 97.54%\n", "#8699: 97.54%\n", "#8700: 97.54%\n", "#8701: 97.54%\n", "#8702: 97.54%\n", "#8703: 97.54%\n", "#8704: 97.54%\n", "#8705: 97.54%\n", "#8706: 97.54%\n", "#8707: 97.54%\n", "#8708: 97.54%\n", "#8709: 97.54%\n", "#8710: 97.54%\n", "#8711: 97.54%\n", "#8712: 97.54%\n", "#8713: 97.54%\n", "#8714: 97.54%\n", "#8715: 97.54%\n", "#8716: 97.55%\n", "#8717: 97.55%\n", "#8718: 97.55%\n", "#8719: 97.55%\n", "#8720: 97.55%\n", "#8721: 97.55%\n", "#8722: 97.55%\n", "#8723: 97.55%\n", "#8724: 97.55%\n", "#8725: 97.55%\n", "#8726: 97.55%\n", "#8727: 97.55%\n", "#8728: 97.55%\n", "#8729: 97.55%\n", "#8730: 97.55%\n", "#8731: 97.55%\n", "#8732: 97.55%\n", "#8733: 97.55%\n", "#8734: 97.55%\n", "#8735: 97.55%\n", "#8736: 97.55%\n", "#8737: 97.55%\n", "#8738: 97.55%\n", "#8739: 97.55%\n", "#8740: 97.55%\n", "#8741: 97.55%\n", "#8742: 97.55%\n", "#8743: 97.55%\n", "#8744: 97.55%\n", "#8745: 97.55%\n", "#8746: 97.55%\n", "#8747: 97.55%\n", "#8748: 97.55%\n", "#8749: 97.55%\n", "#8750: 97.55%\n", "#8751: 97.55%\n", "#8752: 97.56%\n", "#8753: 97.56%\n", "#8754: 97.56%\n", "#8755: 97.56%\n", "#8756: 97.56%\n", "#8757: 97.56%\n", "#8758: 97.56%\n", "#8759: 97.56%\n", "#8760: 97.56%\n", "#8761: 97.56%\n", "#8762: 97.56%\n", "#8763: 97.56%\n", "#8764: 97.56%\n", "#8765: 97.56%\n", "#8766: 97.56%\n", "#8767: 97.56%\n", "#8768: 97.56%\n", "#8769: 97.56%\n", "#8770: 97.56%\n", "#8771: 97.56%\n", "#8772: 97.56%\n", "#8773: 97.56%\n", "#8774: 97.56%\n", "#8775: 97.56%\n", "#8776: 97.56%\n", "#8777: 97.56%\n", "#8778: 97.56%\n", "#8779: 97.56%\n", "#8780: 97.56%\n", "#8781: 97.56%\n", "#8782: 97.56%\n", "#8783: 97.56%\n", "#8784: 97.56%\n", "#8785: 97.56%\n", "#8786: 97.56%\n", "#8787: 97.56%\n", "#8788: 97.57%\n", "#8789: 97.57%\n", "#8790: 97.57%\n", "#8791: 97.57%\n", "#8792: 97.57%\n", "#8793: 97.57%\n", "#8794: 97.57%\n", "#8795: 97.57%\n", "#8796: 97.57%\n", "#8797: 97.57%\n", "#8798: 97.57%\n", "#8799: 97.57%\n", "#8800: 97.57%\n", "#8801: 97.57%\n", "#8802: 97.57%\n", "#8803: 97.57%\n", "#8804: 97.57%\n", "#8805: 97.57%\n", "#8806: 97.57%\n", "#8807: 97.57%\n", "#8808: 97.57%\n", "#8809: 97.57%\n", "#8810: 97.57%\n", "#8811: 97.57%\n", "#8812: 97.57%\n", "#8813: 97.57%\n", "#8814: 97.57%\n", "#8815: 97.57%\n", "#8816: 97.57%\n", "#8817: 97.57%\n", "#8818: 97.57%\n", "#8819: 97.57%\n", "#8820: 97.57%\n", "#8821: 97.57%\n", "#8822: 97.57%\n", "#8823: 97.57%\n", "#8824: 97.58%\n", "#8825: 97.58%\n", "#8826: 97.58%\n", "#8827: 97.58%\n", "#8828: 97.58%\n", "#8829: 97.58%\n", "#8830: 97.58%\n", "#8831: 97.58%\n", "#8832: 97.58%\n", "#8833: 97.58%\n", "#8834: 97.58%\n", "#8835: 97.58%\n", "#8836: 97.58%\n", "#8837: 97.58%\n", "#8838: 97.58%\n", "#8839: 97.58%\n", "#8840: 97.58%\n", "#8841: 97.58%\n", "#8842: 97.58%\n", "#8843: 97.58%\n", "#8844: 97.58%\n", "#8845: 97.58%\n", "#8846: 97.58%\n", "#8847: 97.58%\n", "#8848: 97.58%\n", "#8849: 97.58%\n", "#8850: 97.58%\n", "#8851: 97.58%\n", "#8852: 97.58%\n", "#8853: 97.58%\n", "#8854: 97.58%\n", "#8855: 97.58%\n", "#8856: 97.58%\n", "#8857: 97.58%\n", "#8858: 97.58%\n", "#8859: 97.58%\n", "#8860: 97.58%\n", "#8861: 97.59%\n", "#8862: 97.59%\n", "#8863: 97.59%\n", "#8864: 97.59%\n", "#8865: 97.59%\n", "#8866: 97.59%\n", "#8867: 97.59%\n", "#8868: 97.59%\n", "#8869: 97.59%\n", "#8870: 97.59%\n", "#8871: 97.59%\n", "#8872: 97.59%\n", "#8873: 97.59%\n", "#8874: 97.59%\n", "#8875: 97.59%\n", "#8876: 97.59%\n", "#8877: 97.59%\n", "#8878: 97.59%\n", "#8879: 97.59%\n", "#8880: 97.59%\n", "#8881: 97.59%\n", "#8882: 97.59%\n", "#8883: 97.59%\n", "#8884: 97.59%\n", "#8885: 97.59%\n", "#8886: 97.59%\n", "#8887: 97.59%\n", "#8888: 97.59%\n", "#8889: 97.59%\n", "#8890: 97.59%\n", "#8891: 97.59%\n", "#8892: 97.59%\n", "#8893: 97.59%\n", "#8894: 97.59%\n", "#8895: 97.59%\n", "#8896: 97.59%\n", "#8897: 97.59%\n", "#8898: 97.60%\n", "#8899: 97.60%\n", "#8900: 97.60%\n", "#8901: 97.60%\n", "#8902: 97.60%\n", "#8903: 97.60%\n", "#8904: 97.60%\n", "#8905: 97.60%\n", "#8906: 97.60%\n", "#8907: 97.60%\n", "#8908: 97.60%\n", "#8909: 97.60%\n", "#8910: 97.60%\n", "#8911: 97.60%\n", "#8912: 97.60%\n", "#8913: 97.60%\n", "#8914: 97.60%\n", "#8915: 97.60%\n", "#8916: 97.60%\n", "#8917: 97.60%\n", "#8918: 97.60%\n", "#8919: 97.60%\n", "#8920: 97.60%\n", "#8921: 97.60%\n", "#8922: 97.60%\n", "#8923: 97.60%\n", "#8924: 97.60%\n", "#8925: 97.60%\n", "#8926: 97.60%\n", "#8927: 97.60%\n", "#8928: 97.60%\n", "#8929: 97.60%\n", "#8930: 97.60%\n", "#8931: 97.60%\n", "#8932: 97.60%\n", "#8933: 97.60%\n", "#8934: 97.60%\n", "#8935: 97.61%\n", "#8936: 97.61%\n", "#8937: 97.61%\n", "#8938: 97.61%\n", "#8939: 97.61%\n", "#8940: 97.61%\n", "#8941: 97.61%\n", "#8942: 97.61%\n", "#8943: 97.61%\n", "#8944: 97.61%\n", "#8945: 97.61%\n", "#8946: 97.61%\n", "#8947: 97.61%\n", "#8948: 97.61%\n", "#8949: 97.61%\n", "#8950: 97.61%\n", "#8951: 97.61%\n", "#8952: 97.61%\n", "#8953: 97.61%\n", "#8954: 97.61%\n", "#8955: 97.61%\n", "#8956: 97.61%\n", "#8957: 97.61%\n", "#8958: 97.61%\n", "#8959: 97.61%\n", "#8960: 97.61%\n", "#8961: 97.61%\n", "#8962: 97.61%\n", "#8963: 97.61%\n", "#8964: 97.61%\n", "#8965: 97.61%\n", "#8966: 97.61%\n", "#8967: 97.61%\n", "#8968: 97.61%\n", "#8969: 97.61%\n", "#8970: 97.61%\n", "#8971: 97.61%\n", "#8972: 97.62%\n", "#8973: 97.62%\n", "#8974: 97.62%\n", "#8975: 97.62%\n", "#8976: 97.62%\n", "#8977: 97.62%\n", "#8978: 97.62%\n", "#8979: 97.62%\n", "#8980: 97.62%\n", "#8981: 97.62%\n", "#8982: 97.62%\n", "#8983: 97.62%\n", "#8984: 97.62%\n", "#8985: 97.62%\n", "#8986: 97.62%\n", "#8987: 97.62%\n", "#8988: 97.62%\n", "#8989: 97.62%\n", "#8990: 97.62%\n", "#8991: 97.62%\n", "#8992: 97.62%\n", "#8993: 97.62%\n", "#8994: 97.62%\n", "#8995: 97.62%\n", "#8996: 97.62%\n", "#8997: 97.62%\n", "#8998: 97.62%\n", "#8999: 97.62%\n", "#9000: 97.62%\n", "#9001: 97.62%\n", "#9002: 97.62%\n", "#9003: 97.62%\n", "#9004: 97.62%\n", "#9005: 97.62%\n", "#9006: 97.62%\n", "#9007: 97.62%\n", "#9008: 97.62%\n", "#9009: 97.61%\n", "#9010: 97.61%\n", "#9011: 97.61%\n", "#9012: 97.61%\n", "#9013: 97.61%\n", "#9014: 97.62%\n", "#9015: 97.60%\n", "#9016: 97.60%\n", "#9017: 97.60%\n", "#9018: 97.61%\n", "#9019: 97.59%\n", "#9020: 97.59%\n", "#9021: 97.59%\n", "#9022: 97.60%\n", "#9023: 97.60%\n", "#9024: 97.58%\n", "#9025: 97.58%\n", "#9026: 97.59%\n", "#9027: 97.59%\n", "#9028: 97.59%\n", "#9029: 97.59%\n", "#9030: 97.59%\n", "#9031: 97.59%\n", "#9032: 97.59%\n", "#9033: 97.59%\n", "#9034: 97.59%\n", "#9035: 97.59%\n", "#9036: 97.58%\n", "#9037: 97.58%\n", "#9038: 97.58%\n", "#9039: 97.58%\n", "#9040: 97.58%\n", "#9041: 97.58%\n", "#9042: 97.58%\n", "#9043: 97.58%\n", "#9044: 97.58%\n", "#9045: 97.58%\n", "#9046: 97.58%\n", "#9047: 97.58%\n", "#9048: 97.58%\n", "#9049: 97.58%\n", "#9050: 97.58%\n", "#9051: 97.58%\n", "#9052: 97.58%\n", "#9053: 97.58%\n", "#9054: 97.58%\n", "#9055: 97.58%\n", "#9056: 97.58%\n", "#9057: 97.58%\n", "#9058: 97.58%\n", "#9059: 97.58%\n", "#9060: 97.58%\n", "#9061: 97.58%\n", "#9062: 97.58%\n", "#9063: 97.58%\n", "#9064: 97.58%\n", "#9065: 97.58%\n", "#9066: 97.58%\n", "#9067: 97.58%\n", "#9068: 97.59%\n", "#9069: 97.59%\n", "#9070: 97.59%\n", "#9071: 97.57%\n", "#9072: 97.58%\n", "#9073: 97.58%\n", "#9074: 97.58%\n", "#9075: 97.58%\n", "#9076: 97.58%\n", "#9077: 97.58%\n", "#9078: 97.58%\n", "#9079: 97.58%\n", "#9080: 97.58%\n", "#9081: 97.58%\n", "#9082: 97.58%\n", "#9083: 97.58%\n", "#9084: 97.58%\n", "#9085: 97.58%\n", "#9086: 97.58%\n", "#9087: 97.58%\n", "#9088: 97.58%\n", "#9089: 97.58%\n", "#9090: 97.58%\n", "#9091: 97.58%\n", "#9092: 97.58%\n", "#9093: 97.58%\n", "#9094: 97.58%\n", "#9095: 97.58%\n", "#9096: 97.58%\n", "#9097: 97.58%\n", "#9098: 97.58%\n", "#9099: 97.58%\n", "#9100: 97.58%\n", "#9101: 97.58%\n", "#9102: 97.58%\n", "#9103: 97.58%\n", "#9104: 97.58%\n", "#9105: 97.58%\n", "#9106: 97.58%\n", "#9107: 97.58%\n", "#9108: 97.58%\n", "#9109: 97.59%\n", "#9110: 97.59%\n", "#9111: 97.59%\n", "#9112: 97.59%\n", "#9113: 97.59%\n", "#9114: 97.59%\n", "#9115: 97.59%\n", "#9116: 97.59%\n", "#9117: 97.59%\n", "#9118: 97.59%\n", "#9119: 97.59%\n", "#9120: 97.59%\n", "#9121: 97.59%\n", "#9122: 97.59%\n", "#9123: 97.59%\n", "#9124: 97.59%\n", "#9125: 97.59%\n", "#9126: 97.59%\n", "#9127: 97.59%\n", "#9128: 97.59%\n", "#9129: 97.59%\n", "#9130: 97.59%\n", "#9131: 97.59%\n", "#9132: 97.59%\n", "#9133: 97.59%\n", "#9134: 97.59%\n", "#9135: 97.59%\n", "#9136: 97.59%\n", "#9137: 97.59%\n", "#9138: 97.59%\n", "#9139: 97.59%\n", "#9140: 97.59%\n", "#9141: 97.59%\n", "#9142: 97.59%\n", "#9143: 97.59%\n", "#9144: 97.59%\n", "#9145: 97.59%\n", "#9146: 97.59%\n", "#9147: 97.60%\n", "#9148: 97.60%\n", "#9149: 97.60%\n", "#9150: 97.60%\n", "#9151: 97.60%\n", "#9152: 97.60%\n", "#9153: 97.60%\n", "#9154: 97.60%\n", "#9155: 97.60%\n", "#9156: 97.60%\n", "#9157: 97.60%\n", "#9158: 97.60%\n", "#9159: 97.60%\n", "#9160: 97.60%\n", "#9161: 97.60%\n", "#9162: 97.60%\n", "#9163: 97.60%\n", "#9164: 97.60%\n", "#9165: 97.60%\n", "#9166: 97.60%\n", "#9167: 97.60%\n", "#9168: 97.60%\n", "#9169: 97.60%\n", "#9170: 97.60%\n", "#9171: 97.60%\n", "#9172: 97.60%\n", "#9173: 97.60%\n", "#9174: 97.60%\n", "#9175: 97.60%\n", "#9176: 97.60%\n", "#9177: 97.60%\n", "#9178: 97.60%\n", "#9179: 97.60%\n", "#9180: 97.60%\n", "#9181: 97.60%\n", "#9182: 97.60%\n", "#9183: 97.60%\n", "#9184: 97.60%\n", "#9185: 97.61%\n", "#9186: 97.61%\n", "#9187: 97.61%\n", "#9188: 97.61%\n", "#9189: 97.61%\n", "#9190: 97.61%\n", "#9191: 97.61%\n", "#9192: 97.61%\n", "#9193: 97.61%\n", "#9194: 97.61%\n", "#9195: 97.61%\n", "#9196: 97.61%\n", "#9197: 97.61%\n", "#9198: 97.61%\n", "#9199: 97.61%\n", "#9200: 97.61%\n", "#9201: 97.61%\n", "#9202: 97.60%\n", "#9203: 97.60%\n", "#9204: 97.60%\n", "#9205: 97.60%\n", "#9206: 97.60%\n", "#9207: 97.60%\n", "#9208: 97.60%\n", "#9209: 97.60%\n", "#9210: 97.60%\n", "#9211: 97.60%\n", "#9212: 97.60%\n", "#9213: 97.60%\n", "#9214: 97.60%\n", "#9215: 97.60%\n", "#9216: 97.60%\n", "#9217: 97.60%\n", "#9218: 97.60%\n", "#9219: 97.60%\n", "#9220: 97.60%\n", "#9221: 97.60%\n", "#9222: 97.60%\n", "#9223: 97.60%\n", "#9224: 97.60%\n", "#9225: 97.60%\n", "#9226: 97.60%\n", "#9227: 97.61%\n", "#9228: 97.61%\n", "#9229: 97.61%\n", "#9230: 97.61%\n", "#9231: 97.61%\n", "#9232: 97.61%\n", "#9233: 97.61%\n", "#9234: 97.61%\n", "#9235: 97.61%\n", "#9236: 97.61%\n", "#9237: 97.61%\n", "#9238: 97.61%\n", "#9239: 97.61%\n", "#9240: 97.61%\n", "#9241: 97.61%\n", "#9242: 97.61%\n", "#9243: 97.61%\n", "#9244: 97.61%\n", "#9245: 97.61%\n", "#9246: 97.61%\n", "#9247: 97.61%\n", "#9248: 97.61%\n", "#9249: 97.61%\n", "#9250: 97.61%\n", "#9251: 97.61%\n", "#9252: 97.61%\n", "#9253: 97.61%\n", "#9254: 97.61%\n", "#9255: 97.61%\n", "#9256: 97.61%\n", "#9257: 97.61%\n", "#9258: 97.61%\n", "#9259: 97.61%\n", "#9260: 97.61%\n", "#9261: 97.61%\n", "#9262: 97.61%\n", "#9263: 97.61%\n", "#9264: 97.61%\n", "#9265: 97.61%\n", "#9266: 97.62%\n", "#9267: 97.62%\n", "#9268: 97.62%\n", "#9269: 97.62%\n", "#9270: 97.62%\n", "#9271: 97.62%\n", "#9272: 97.62%\n", "#9273: 97.62%\n", "#9274: 97.62%\n", "#9275: 97.62%\n", "#9276: 97.62%\n", "#9277: 97.62%\n", "#9278: 97.62%\n", "#9279: 97.62%\n", "#9280: 97.62%\n", "#9281: 97.62%\n", "#9282: 97.62%\n", "#9283: 97.62%\n", "#9284: 97.62%\n", "#9285: 97.62%\n", "#9286: 97.62%\n", "#9287: 97.62%\n", "#9288: 97.62%\n", "#9289: 97.62%\n", "#9290: 97.62%\n", "#9291: 97.62%\n", "#9292: 97.62%\n", "#9293: 97.62%\n", "#9294: 97.62%\n", "#9295: 97.62%\n", "#9296: 97.62%\n", "#9297: 97.62%\n", "#9298: 97.62%\n", "#9299: 97.62%\n", "#9300: 97.62%\n", "#9301: 97.62%\n", "#9302: 97.62%\n", "#9303: 97.62%\n", "#9304: 97.62%\n", "#9305: 97.63%\n", "#9306: 97.63%\n", "#9307: 97.63%\n", "#9308: 97.63%\n", "#9309: 97.63%\n", "#9310: 97.63%\n", "#9311: 97.63%\n", "#9312: 97.63%\n", "#9313: 97.63%\n", "#9314: 97.63%\n", "#9315: 97.63%\n", "#9316: 97.63%\n", "#9317: 97.63%\n", "#9318: 97.63%\n", "#9319: 97.63%\n", "#9320: 97.63%\n", "#9321: 97.63%\n", "#9322: 97.63%\n", "#9323: 97.63%\n", "#9324: 97.63%\n", "#9325: 97.63%\n", "#9326: 97.63%\n", "#9327: 97.63%\n", "#9328: 97.63%\n", "#9329: 97.63%\n", "#9330: 97.63%\n", "#9331: 97.63%\n", "#9332: 97.63%\n", "#9333: 97.63%\n", "#9334: 97.63%\n", "#9335: 97.63%\n", "#9336: 97.63%\n", "#9337: 97.63%\n", "#9338: 97.63%\n", "#9339: 97.63%\n", "#9340: 97.63%\n", "#9341: 97.63%\n", "#9342: 97.63%\n", "#9343: 97.63%\n", "#9344: 97.64%\n", "#9345: 97.64%\n", "#9346: 97.64%\n", "#9347: 97.64%\n", "#9348: 97.64%\n", "#9349: 97.64%\n", "#9350: 97.64%\n", "#9351: 97.64%\n", "#9352: 97.64%\n", "#9353: 97.64%\n", "#9354: 97.64%\n", "#9355: 97.64%\n", "#9356: 97.64%\n", "#9357: 97.64%\n", "#9358: 97.64%\n", "#9359: 97.64%\n", "#9360: 97.64%\n", "#9361: 97.64%\n", "#9362: 97.64%\n", "#9363: 97.64%\n", "#9364: 97.64%\n", "#9365: 97.64%\n", "#9366: 97.64%\n", "#9367: 97.64%\n", "#9368: 97.64%\n", "#9369: 97.64%\n", "#9370: 97.64%\n", "#9371: 97.64%\n", "#9372: 97.64%\n", "#9373: 97.64%\n", "#9374: 97.64%\n", "#9375: 97.64%\n", "#9376: 97.64%\n", "#9377: 97.64%\n", "#9378: 97.64%\n", "#9379: 97.64%\n", "#9380: 97.64%\n", "#9381: 97.64%\n", "#9382: 97.64%\n", "#9383: 97.64%\n", "#9384: 97.65%\n", "#9385: 97.65%\n", "#9386: 97.65%\n", "#9387: 97.65%\n", "#9388: 97.65%\n", "#9389: 97.65%\n", "#9390: 97.65%\n", "#9391: 97.65%\n", "#9392: 97.65%\n", "#9393: 97.65%\n", "#9394: 97.65%\n", "#9395: 97.65%\n", "#9396: 97.65%\n", "#9397: 97.65%\n", "#9398: 97.65%\n", "#9399: 97.65%\n", "#9400: 97.65%\n", "#9401: 97.65%\n", "#9402: 97.65%\n", "#9403: 97.65%\n", "#9404: 97.65%\n", "#9405: 97.65%\n", "#9406: 97.65%\n", "#9407: 97.65%\n", "#9408: 97.65%\n", "#9409: 97.65%\n", "#9410: 97.65%\n", "#9411: 97.65%\n", "#9412: 97.65%\n", "#9413: 97.65%\n", "#9414: 97.65%\n", "#9415: 97.65%\n", "#9416: 97.65%\n", "#9417: 97.65%\n", "#9418: 97.65%\n", "#9419: 97.65%\n", "#9420: 97.65%\n", "#9421: 97.65%\n", "#9422: 97.65%\n", "#9423: 97.65%\n", "#9424: 97.66%\n", "#9425: 97.66%\n", "#9426: 97.66%\n", "#9427: 97.66%\n", "#9428: 97.66%\n", "#9429: 97.66%\n", "#9430: 97.66%\n", "#9431: 97.66%\n", "#9432: 97.66%\n", "#9433: 97.66%\n", "#9434: 97.66%\n", "#9435: 97.66%\n", "#9436: 97.66%\n", "#9437: 97.66%\n", "#9438: 97.66%\n", "#9439: 97.66%\n", "#9440: 97.66%\n", "#9441: 97.66%\n", "#9442: 97.66%\n", "#9443: 97.66%\n", "#9444: 97.66%\n", "#9445: 97.66%\n", "#9446: 97.66%\n", "#9447: 97.66%\n", "#9448: 97.66%\n", "#9449: 97.66%\n", "#9450: 97.66%\n", "#9451: 97.66%\n", "#9452: 97.66%\n", "#9453: 97.66%\n", "#9454: 97.66%\n", "#9455: 97.66%\n", "#9456: 97.66%\n", "#9457: 97.66%\n", "#9458: 97.66%\n", "#9459: 97.66%\n", "#9460: 97.66%\n", "#9461: 97.66%\n", "#9462: 97.66%\n", "#9463: 97.66%\n", "#9464: 97.67%\n", "#9465: 97.67%\n", "#9466: 97.67%\n", "#9467: 97.67%\n", "#9468: 97.67%\n", "#9469: 97.67%\n", "#9470: 97.67%\n", "#9471: 97.67%\n", "#9472: 97.67%\n", "#9473: 97.67%\n", "#9474: 97.67%\n", "#9475: 97.67%\n", "#9476: 97.67%\n", "#9477: 97.67%\n", "#9478: 97.67%\n", "#9479: 97.67%\n", "#9480: 97.67%\n", "#9481: 97.67%\n", "#9482: 97.67%\n", "#9483: 97.67%\n", "#9484: 97.67%\n", "#9485: 97.67%\n", "#9486: 97.67%\n", "#9487: 97.67%\n", "#9488: 97.67%\n", "#9489: 97.67%\n", "#9490: 97.67%\n", "#9491: 97.67%\n", "#9492: 97.67%\n", "#9493: 97.67%\n", "#9494: 97.67%\n", "#9495: 97.67%\n", "#9496: 97.67%\n", "#9497: 97.67%\n", "#9498: 97.67%\n", "#9499: 97.67%\n", "#9500: 97.67%\n", "#9501: 97.67%\n", "#9502: 97.67%\n", "#9503: 97.67%\n", "#9504: 97.67%\n", "#9505: 97.68%\n", "#9506: 97.68%\n", "#9507: 97.68%\n", "#9508: 97.68%\n", "#9509: 97.68%\n", "#9510: 97.68%\n", "#9511: 97.68%\n", "#9512: 97.68%\n", "#9513: 97.68%\n", "#9514: 97.68%\n", "#9515: 97.68%\n", "#9516: 97.68%\n", "#9517: 97.68%\n", "#9518: 97.68%\n", "#9519: 97.68%\n", "#9520: 97.68%\n", "#9521: 97.68%\n", "#9522: 97.68%\n", "#9523: 97.68%\n", "#9524: 97.68%\n", "#9525: 97.68%\n", "#9526: 97.68%\n", "#9527: 97.68%\n", "#9528: 97.68%\n", "#9529: 97.68%\n", "#9530: 97.67%\n", "#9531: 97.67%\n", "#9532: 97.67%\n", "#9533: 97.67%\n", "#9534: 97.67%\n", "#9535: 97.67%\n", "#9536: 97.67%\n", "#9537: 97.67%\n", "#9538: 97.67%\n", "#9539: 97.67%\n", "#9540: 97.66%\n", "#9541: 97.66%\n", "#9542: 97.66%\n", "#9543: 97.66%\n", "#9544: 97.66%\n", "#9545: 97.66%\n", "#9546: 97.66%\n", "#9547: 97.66%\n", "#9548: 97.66%\n", "#9549: 97.66%\n", "#9550: 97.67%\n", "#9551: 97.67%\n", "#9552: 97.67%\n", "#9553: 97.67%\n", "#9554: 97.67%\n", "#9555: 97.67%\n", "#9556: 97.67%\n", "#9557: 97.67%\n", "#9558: 97.67%\n", "#9559: 97.67%\n", "#9560: 97.67%\n", "#9561: 97.67%\n", "#9562: 97.67%\n", "#9563: 97.67%\n", "#9564: 97.67%\n", "#9565: 97.67%\n", "#9566: 97.67%\n", "#9567: 97.67%\n", "#9568: 97.67%\n", "#9569: 97.67%\n", "#9570: 97.67%\n", "#9571: 97.67%\n", "#9572: 97.67%\n", "#9573: 97.67%\n", "#9574: 97.67%\n", "#9575: 97.67%\n", "#9576: 97.67%\n", "#9577: 97.67%\n", "#9578: 97.67%\n", "#9579: 97.67%\n", "#9580: 97.67%\n", "#9581: 97.67%\n", "#9582: 97.67%\n", "#9583: 97.67%\n", "#9584: 97.67%\n", "#9585: 97.67%\n", "#9586: 97.67%\n", "#9587: 97.66%\n", "#9588: 97.66%\n", "#9589: 97.66%\n", "#9590: 97.66%\n", "#9591: 97.66%\n", "#9592: 97.66%\n", "#9593: 97.67%\n", "#9594: 97.67%\n", "#9595: 97.67%\n", "#9596: 97.67%\n", "#9597: 97.67%\n", "#9598: 97.67%\n", "#9599: 97.67%\n", "#9600: 97.67%\n", "#9601: 97.67%\n", "#9602: 97.67%\n", "#9603: 97.67%\n", "#9604: 97.67%\n", "#9605: 97.67%\n", "#9606: 97.67%\n", "#9607: 97.67%\n", "#9608: 97.67%\n", "#9609: 97.67%\n", "#9610: 97.67%\n", "#9611: 97.67%\n", "#9612: 97.67%\n", "#9613: 97.67%\n", "#9614: 97.66%\n", "#9615: 97.66%\n", "#9616: 97.66%\n", "#9617: 97.66%\n", "#9618: 97.66%\n", "#9619: 97.66%\n", "#9620: 97.66%\n", "#9621: 97.66%\n", "#9622: 97.66%\n", "#9623: 97.66%\n", "#9624: 97.66%\n", "#9625: 97.66%\n", "#9626: 97.66%\n", "#9627: 97.66%\n", "#9628: 97.66%\n", "#9629: 97.66%\n", "#9630: 97.66%\n", "#9631: 97.66%\n", "#9632: 97.66%\n", "#9633: 97.66%\n", "#9634: 97.66%\n", "#9635: 97.67%\n", "#9636: 97.67%\n", "#9637: 97.67%\n", "#9638: 97.67%\n", "#9639: 97.67%\n", "#9640: 97.67%\n", "#9641: 97.67%\n", "#9642: 97.66%\n", "#9643: 97.66%\n", "#9644: 97.66%\n", "#9645: 97.66%\n", "#9646: 97.66%\n", "#9647: 97.66%\n", "#9648: 97.66%\n", "#9649: 97.66%\n", "#9650: 97.66%\n", "#9651: 97.66%\n", "#9652: 97.66%\n", "#9653: 97.66%\n", "#9654: 97.66%\n", "#9655: 97.66%\n", "#9656: 97.66%\n", "#9657: 97.66%\n", "#9658: 97.66%\n", "#9659: 97.66%\n", "#9660: 97.66%\n", "#9661: 97.66%\n", "#9662: 97.66%\n", "#9663: 97.66%\n", "#9664: 97.66%\n", "#9665: 97.66%\n", "#9666: 97.66%\n", "#9667: 97.66%\n", "#9668: 97.66%\n", "#9669: 97.66%\n", "#9670: 97.66%\n", "#9671: 97.66%\n", "#9672: 97.66%\n", "#9673: 97.66%\n", "#9674: 97.66%\n", "#9675: 97.66%\n", "#9676: 97.66%\n", "#9677: 97.66%\n", "#9678: 97.67%\n", "#9679: 97.67%\n", "#9680: 97.67%\n", "#9681: 97.67%\n", "#9682: 97.67%\n", "#9683: 97.67%\n", "#9684: 97.67%\n", "#9685: 97.67%\n", "#9686: 97.67%\n", "#9687: 97.67%\n", "#9688: 97.67%\n", "#9689: 97.67%\n", "#9690: 97.67%\n", "#9691: 97.67%\n", "#9692: 97.67%\n", "#9693: 97.67%\n", "#9694: 97.67%\n", "#9695: 97.67%\n", "#9696: 97.67%\n", "#9697: 97.67%\n", "#9698: 97.66%\n", "#9699: 97.66%\n", "#9700: 97.66%\n", "#9701: 97.66%\n", "#9702: 97.66%\n", "#9703: 97.66%\n", "#9704: 97.66%\n", "#9705: 97.66%\n", "#9706: 97.66%\n", "#9707: 97.66%\n", "#9708: 97.66%\n", "#9709: 97.66%\n", "#9710: 97.66%\n", "#9711: 97.66%\n", "#9712: 97.66%\n", "#9713: 97.66%\n", "#9714: 97.66%\n", "#9715: 97.66%\n", "#9716: 97.66%\n", "#9717: 97.66%\n", "#9718: 97.66%\n", "#9719: 97.66%\n", "#9720: 97.66%\n", "#9721: 97.67%\n", "#9722: 97.67%\n", "#9723: 97.67%\n", "#9724: 97.67%\n", "#9725: 97.67%\n", "#9726: 97.67%\n", "#9727: 97.67%\n", "#9728: 97.67%\n", "#9729: 97.66%\n", "#9730: 97.66%\n", "#9731: 97.66%\n", "#9732: 97.66%\n", "#9733: 97.66%\n", "#9734: 97.66%\n", "#9735: 97.66%\n", "#9736: 97.66%\n", "#9737: 97.66%\n", "#9738: 97.66%\n", "#9739: 97.66%\n", "#9740: 97.66%\n", "#9741: 97.66%\n", "#9742: 97.66%\n", "#9743: 97.66%\n", "#9744: 97.66%\n", "#9745: 97.65%\n", "#9746: 97.65%\n", "#9747: 97.65%\n", "#9748: 97.65%\n", "#9749: 97.65%\n", "#9750: 97.65%\n", "#9751: 97.65%\n", "#9752: 97.65%\n", "#9753: 97.65%\n", "#9754: 97.65%\n", "#9755: 97.65%\n", "#9756: 97.65%\n", "#9757: 97.65%\n", "#9758: 97.65%\n", "#9759: 97.65%\n", "#9760: 97.65%\n", "#9761: 97.65%\n", "#9762: 97.64%\n", "#9763: 97.64%\n", "#9764: 97.64%\n", "#9765: 97.64%\n", "#9766: 97.65%\n", "#9767: 97.65%\n", "#9768: 97.64%\n", "#9769: 97.64%\n", "#9770: 97.63%\n", "#9771: 97.63%\n", "#9772: 97.63%\n", "#9773: 97.63%\n", "#9774: 97.63%\n", "#9775: 97.63%\n", "#9776: 97.63%\n", "#9777: 97.63%\n", "#9778: 97.63%\n", "#9779: 97.63%\n", "#9780: 97.63%\n", "#9781: 97.63%\n", "#9782: 97.62%\n", "#9783: 97.62%\n", "#9784: 97.62%\n", "#9785: 97.62%\n", "#9786: 97.62%\n", "#9787: 97.62%\n", "#9788: 97.62%\n", "#9789: 97.62%\n", "#9790: 97.62%\n", "#9791: 97.62%\n", "#9792: 97.61%\n", "#9793: 97.61%\n", "#9794: 97.61%\n", "#9795: 97.61%\n", "#9796: 97.61%\n", "#9797: 97.61%\n", "#9798: 97.61%\n", "#9799: 97.61%\n", "#9800: 97.61%\n", "#9801: 97.61%\n", "#9802: 97.61%\n", "#9803: 97.61%\n", "#9804: 97.61%\n", "#9805: 97.61%\n", "#9806: 97.61%\n", "#9807: 97.61%\n", "#9808: 97.61%\n", "#9809: 97.61%\n", "#9810: 97.61%\n", "#9811: 97.60%\n", "#9812: 97.61%\n", "#9813: 97.61%\n", "#9814: 97.61%\n", "#9815: 97.61%\n", "#9816: 97.61%\n", "#9817: 97.61%\n", "#9818: 97.61%\n", "#9819: 97.61%\n", "#9820: 97.61%\n", "#9821: 97.61%\n", "#9822: 97.61%\n", "#9823: 97.61%\n", "#9824: 97.61%\n", "#9825: 97.61%\n", "#9826: 97.61%\n", "#9827: 97.61%\n", "#9828: 97.61%\n", "#9829: 97.61%\n", "#9830: 97.61%\n", "#9831: 97.61%\n", "#9832: 97.61%\n", "#9833: 97.61%\n", "#9834: 97.61%\n", "#9835: 97.61%\n", "#9836: 97.61%\n", "#9837: 97.61%\n", "#9838: 97.61%\n", "#9839: 97.60%\n", "#9840: 97.60%\n", "#9841: 97.60%\n", "#9842: 97.60%\n", "#9843: 97.60%\n", "#9844: 97.60%\n", "#9845: 97.60%\n", "#9846: 97.60%\n", "#9847: 97.60%\n", "#9848: 97.60%\n", "#9849: 97.60%\n", "#9850: 97.60%\n", "#9851: 97.60%\n", "#9852: 97.60%\n", "#9853: 97.61%\n", "#9854: 97.61%\n", "#9855: 97.61%\n", "#9856: 97.60%\n", "#9857: 97.60%\n", "#9858: 97.60%\n", "#9859: 97.60%\n", "#9860: 97.60%\n", "#9861: 97.60%\n", "#9862: 97.60%\n", "#9863: 97.60%\n", "#9864: 97.60%\n", "#9865: 97.60%\n", "#9866: 97.60%\n", "#9867: 97.59%\n", "#9868: 97.59%\n", "#9869: 97.59%\n", "#9870: 97.59%\n", "#9871: 97.59%\n", "#9872: 97.59%\n", "#9873: 97.59%\n", "#9874: 97.59%\n", "#9875: 97.59%\n", "#9876: 97.59%\n", "#9877: 97.59%\n", "#9878: 97.59%\n", "#9879: 97.59%\n", "#9880: 97.59%\n", "#9881: 97.59%\n", "#9882: 97.59%\n", "#9883: 97.59%\n", "#9884: 97.59%\n", "#9885: 97.59%\n", "#9886: 97.59%\n", "#9887: 97.59%\n", "#9888: 97.59%\n", "#9889: 97.59%\n", "#9890: 97.59%\n", "#9891: 97.59%\n", "#9892: 97.58%\n", "#9893: 97.57%\n", "#9894: 97.57%\n", "#9895: 97.57%\n", "#9896: 97.58%\n", "#9897: 97.58%\n", "#9898: 97.58%\n", "#9899: 97.58%\n", "#9900: 97.58%\n", "#9901: 97.58%\n", "#9902: 97.58%\n", "#9903: 97.58%\n", "#9904: 97.58%\n", "#9905: 97.57%\n", "#9906: 97.57%\n", "#9907: 97.57%\n", "#9908: 97.57%\n", "#9909: 97.57%\n", "#9910: 97.57%\n", "#9911: 97.57%\n", "#9912: 97.57%\n", "#9913: 97.57%\n", "#9914: 97.57%\n", "#9915: 97.57%\n", "#9916: 97.57%\n", "#9917: 97.57%\n", "#9918: 97.57%\n", "#9919: 97.57%\n", "#9920: 97.57%\n", "#9921: 97.57%\n", "#9922: 97.57%\n", "#9923: 97.57%\n", "#9924: 97.57%\n", "#9925: 97.57%\n", "#9926: 97.57%\n", "#9927: 97.57%\n", "#9928: 97.57%\n", "#9929: 97.57%\n", "#9930: 97.57%\n", "#9931: 97.57%\n", "#9932: 97.57%\n", "#9933: 97.57%\n", "#9934: 97.57%\n", "#9935: 97.57%\n", "#9936: 97.57%\n", "#9937: 97.57%\n", "#9938: 97.58%\n", "#9939: 97.58%\n", "#9940: 97.58%\n", "#9941: 97.58%\n", "#9942: 97.57%\n", "#9943: 97.57%\n", "#9944: 97.57%\n", "#9945: 97.57%\n", "#9946: 97.57%\n", "#9947: 97.57%\n", "#9948: 97.57%\n", "#9949: 97.57%\n", "#9950: 97.57%\n", "#9951: 97.57%\n", "#9952: 97.57%\n", "#9953: 97.57%\n", "#9954: 97.57%\n", "#9955: 97.57%\n", "#9956: 97.57%\n", "#9957: 97.57%\n", "#9958: 97.57%\n", "#9959: 97.57%\n", "#9960: 97.57%\n", "#9961: 97.57%\n", "#9962: 97.57%\n", "#9963: 97.57%\n", "#9964: 97.57%\n", "#9965: 97.57%\n", "#9966: 97.57%\n", "#9967: 97.57%\n", "#9968: 97.57%\n", "#9969: 97.57%\n", "#9970: 97.57%\n", "#9971: 97.57%\n", "#9972: 97.57%\n", "#9973: 97.57%\n", "#9974: 97.57%\n", "#9975: 97.57%\n", "#9976: 97.57%\n", "#9977: 97.57%\n", "#9978: 97.57%\n", "#9979: 97.58%\n", "#9980: 97.58%\n", "#9981: 97.58%\n", "#9982: 97.57%\n", "#9983: 97.57%\n", "#9984: 97.57%\n", "#9985: 97.57%\n", "#9986: 97.57%\n", "#9987: 97.57%\n", "#9988: 97.57%\n", "#9989: 97.57%\n", "#9990: 97.57%\n", "#9991: 97.57%\n", "#9992: 97.57%\n", "#9993: 97.57%\n", "#9994: 97.57%\n", "#9995: 97.57%\n", "#9996: 97.57%\n", "#9997: 97.57%\n", "#9998: 97.57%\n", "#9999: 97.57%\n" ] } ], "source": [ "correct = 0\n", "for i in range(10000):\n", " with open(f\"X_test/{i}.json\", \"r\") as f:\n", " input = json.load(f)\n", " out, _ = inference(input, circuit)\n", " correct += 1 if out[0] == y_test[i] else 0\n", " print(f\"#{i}: {correct / (i + 1) * 100:.2f}%\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "keras2circom", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 2 }
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
test/circuit.js
const chai = require('chai'); const fs = require('fs'); const wasm_tester = require('circom_tester').wasm; const F1Field = require('ffjavascript').F1Field; const Scalar = require('ffjavascript').Scalar; exports.p = Scalar.fromString('21888242871839275222246405745257275088548364400416034343698204186575808495617'); const Fr = new F1Field(exports.p); const assert = chai.assert; const exec = require('await-exec'); const input = require('../test/X_test/0.json'); describe('keras2circom test', function () { this.timeout(100000000); describe('softmax output', async () => { it('softmax output test', async () => { await exec('python main.py models/model.h5 && python output/circuit.py output/circuit.json test/X_test/0.json'); const model = JSON.parse(fs.readFileSync('./output/circuit.json')); const output = JSON.parse(fs.readFileSync('./output/output.json')); const INPUT = {...model, ...input, ...output}; const circuit = await wasm_tester('./output/circuit.circom'); const witness = await circuit.calculateWitness(INPUT, true); assert(Fr.eq(Fr.e(witness[0]),Fr.e(1))); assert(Fr.eq(Fr.e(witness[1]),Fr.e(7))); }); }); describe('raw output', async () => { it('raw output test', async () => { await exec('python main.py models/model.h5 --raw && python output/circuit.py output/circuit.json test/X_test/0.json'); const model = JSON.parse(fs.readFileSync('./output/circuit.json')); const output = JSON.parse(fs.readFileSync('./output/output.json')); const INPUT = {...model, ...input, ...output}; const circuit = await wasm_tester('./output/circuit.circom'); const witness = await circuit.calculateWitness(INPUT, true); assert(Fr.eq(Fr.e(witness[0]),Fr.e(1))); }); }); });
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
test/load_input.ipynb
{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from tensorflow.keras.datasets import mnist\n", "import json\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# load MNIST dataset\n", "_, (X_test, y_test) = mnist.load_data()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#normalizing\n", "X_test = X_test.astype('float32')\n", "X_test /= 255.0" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "for i in range(len(X_test)):\n", " X = [str(int(x * float(10**18))) for x in X_test[i].flatten().tolist()]\n", " X = np.array(X).reshape(28, 28, 1).tolist()\n", " with open(f'X_test/{i}.json', 'w') as f:\n", " json.dump({\"in\": X}, f)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "with open('y_test.json', 'w') as f:\n", " json.dump(y_test.tolist(), f)" ] } ], "metadata": { "kernelspec": { "display_name": "keras2circom", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 2 }
https://github.com/Modulus-Labs/RockyBothttps://github.com/ora-io/keras2circom
3rdparty/cma/cma.h
/* cma.h * * The MIT License (MIT) * * COPYRIGHT (C) 2017 Institute of Electronics and Computer Science (EDI), Latvia. * AUTHOR: Rihards Novickis ([email protected]) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef VTA_DE10_NANO_KERNEL_MODULE_CMA_H_ #define VTA_DE10_NANO_KERNEL_MODULE_CMA_H_ /* Should be defined in settings.mk file */ #ifndef CMA_IOCTL_MAGIC #define CMA_IOCTL_MAGIC 0xf2 #endif #define CMA_ALLOC_CACHED _IOC(_IOC_WRITE | _IOC_READ, CMA_IOCTL_MAGIC, 1, 4) #define CMA_ALLOC_NONCACHED _IOC(_IOC_WRITE | _IOC_READ, CMA_IOCTL_MAGIC, 2, 4) #define CMA_FREE _IOC(_IOC_WRITE, CMA_IOCTL_MAGIC, 3, 4) #define CMA_GET_PHY_ADDR _IOC(_IOC_WRITE | _IOC_READ, CMA_IOCTL_MAGIC, 4, 4) #define CMA_GET_SIZE _IOC(_IOC_WRITE | _IOC_READ, CMA_IOCTL_MAGIC, 5, 4) #define CMA_IOCTL_MAXNR 5 #endif // VTA_DE10_NANO_KERNEL_MODULE_CMA_H_
https://github.com/zk-ml/tachikoma
3rdparty/cma/cma_api_impl.h
/* * The MIT License (MIT) * * COPYRIGHT (C) 2017 Institute of Electronics and Computer Science (EDI), Latvia. * AUTHOR: Rihards Novickis ([email protected]) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ /*! * Copyright (c) 2018 by Contributors * \file cma_api.cc * \brief Application layer implementation for contigous memory allocation. */ #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <sys/types.h> #include <unistd.h> #include "cma_api.h" #ifndef CMA_IOCTL_MAGIC #define CMA_IOCTL_MAGIC 0xf2 #endif #define CMA_ALLOC_CACHED _IOC(_IOC_WRITE | _IOC_READ, CMA_IOCTL_MAGIC, 1, 4) #define CMA_ALLOC_NONCACHED _IOC(_IOC_WRITE | _IOC_READ, CMA_IOCTL_MAGIC, 2, 4) #define CMA_FREE _IOC(_IOC_WRITE, CMA_IOCTL_MAGIC, 3, 4) #define CMA_GET_PHY_ADDR _IOC(_IOC_WRITE | _IOC_READ, CMA_IOCTL_MAGIC, 4, 4) #define CMA_GET_SIZE _IOC(_IOC_WRITE | _IOC_READ, CMA_IOCTL_MAGIC, 5, 4) #define CMA_IOCTL_MAXNR 5 #ifndef CMA_DEBUG #define CMA_DEBUG 0 #endif #ifndef DRIVER_NODE_NAME #define DRIVER_NODE_NAME "cma" #endif #if CMA_DEBUG == 1 #define __DEBUG(fmt, args...) printf("CMA_API_DEBUG: " fmt, ##args) #else #define __DEBUG(fmt, args...) #endif #define ROUND_UP(N, S) ((((N) + (S)-1) / (S)) * (S)) /* Private functions */ void* cma_alloc(size_t size, unsigned ioctl_cmd); /* Global file descriptor */ int cma_fd = 0; int cma_init(void) { __DEBUG("Opening \"/dev/" DRIVER_NODE_NAME "\" file\n"); cma_fd = open("/dev/" DRIVER_NODE_NAME, O_RDWR); if (cma_fd == -1) { __DEBUG("Failed to initialize api - \"%s\"\n", strerror(errno)); return -1; } return 0; } int cma_release(void) { __DEBUG("Closing \"/dev/" DRIVER_NODE_NAME "\" file\n"); if (close(cma_fd) == -1) { __DEBUG("Failed to finilize api - \"%s\"\n", strerror(errno)); return -1; } return 0; } void* cma_alloc_cached(size_t size) { return cma_alloc(size, CMA_ALLOC_CACHED); } void* cma_alloc_noncached(size_t size) { return cma_alloc(size, CMA_ALLOC_NONCACHED); } int cma_free(void* mem) { __DEBUG("Releasing contigous memory from 0x%x\n", (unsigned)mem); unsigned data, v_addr; /* save user space pointer value */ data = (unsigned)mem; v_addr = (unsigned)mem; if (ioctl(cma_fd, CMA_GET_SIZE, &data) == -1) { __DEBUG("cma_free - ioctl command unsuccsessful - 0\n"); return -1; } /* data now contains size */ /* unmap memory */ munmap(mem, data); /* free cma entry */ if (ioctl(cma_fd, CMA_FREE, &v_addr) == -1) { __DEBUG("cma_free - ioctl command unsuccsessful - 1\n"); return -1; } return 0; } unsigned cma_get_phy_addr(void* mem) { unsigned data; __DEBUG("Getting physical address from 0x%x\n", (unsigned)mem); /* save user space pointer value */ data = (unsigned)mem; /* get physical address */ if (ioctl(cma_fd, CMA_GET_PHY_ADDR, &data) == -1) { __DEBUG("cma_free - ioctl command unsuccsessful\n"); return 0; } /* data now contains physical address */ return data; } void* cma_alloc(size_t size, unsigned ioctl_cmd) { unsigned data; void* mem; __DEBUG("Allocating 0x%x bytes of contigous memory\n", size); /* Page align size */ size = ROUND_UP(size, getpagesize()); /* ioctl cmd to allocate contigous memory */ data = (unsigned)size; if (ioctl(cma_fd, ioctl_cmd, &data) == -1) { __DEBUG("cma_alloc - ioctl command unsuccsessful\n"); return NULL; } /* at this point phy_addr is written to data */ /* mmap memory */ mem = mmap(NULL, size, PROT_WRITE | PROT_READ, MAP_SHARED, cma_fd, data); if (mem == MAP_FAILED) { __DEBUG("cma_alloc - mmap unsuccsessful\n"); return NULL; } return mem; }
https://github.com/zk-ml/tachikoma
3rdparty/compiler-rt/builtin_fp16.h
/* * Copyright (c) 2009-2015 by llvm/compiler-rt contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * \file builtin_fp16.h * \brief Functions for conversion between fp32 and fp16, adopted from compiler-rt. */ #ifndef COMPILER_RT_BUILTIN_FP16_H_ #define COMPILER_RT_BUILTIN_FP16_H_ #ifdef _MSC_VER #pragma warning(disable : 4305 4805) #endif #include <cstdint> static inline uint32_t __clz(uint32_t x) { // count leading zeros int n = 32; uint32_t y; y = x >> 16; if (y) { n = n - 16; x = y; } y = x >> 8; if (y) { n = n - 8; x = y; } y = x >> 4; if (y) { n = n - 4; x = y; } y = x >> 2; if (y) { n = n - 2; x = y; } y = x >> 1; if (y) return n - 2; return n - x; } template <typename SRC_T, typename SRC_REP_T, int SRC_SIG_BITS, typename DST_T, typename DST_REP_T, int DST_SIG_BITS> static inline DST_T __truncXfYf2__(SRC_T a) { // Various constants whose values follow from the type parameters. // Any reasonable optimizer will fold and propagate all of these. const int srcBits = sizeof(SRC_T) * 8; const int srcExpBits = srcBits - SRC_SIG_BITS - 1; const int srcInfExp = (1 << srcExpBits) - 1; const int srcExpBias = srcInfExp >> 1; const SRC_REP_T srcMinNormal = SRC_REP_T(1) << SRC_SIG_BITS; const SRC_REP_T srcSignificandMask = srcMinNormal - 1; const SRC_REP_T srcInfinity = (SRC_REP_T)srcInfExp << SRC_SIG_BITS; const SRC_REP_T srcSignMask = SRC_REP_T(1) << (SRC_SIG_BITS + srcExpBits); const SRC_REP_T srcAbsMask = srcSignMask - 1; const SRC_REP_T roundMask = (SRC_REP_T(1) << (SRC_SIG_BITS - DST_SIG_BITS)) - 1; const SRC_REP_T halfway = SRC_REP_T(1) << (SRC_SIG_BITS - DST_SIG_BITS - 1); const SRC_REP_T srcQNaN = SRC_REP_T(1) << (SRC_SIG_BITS - 1); const SRC_REP_T srcNaNCode = srcQNaN - 1; const int dstBits = sizeof(DST_T) * 8; const int dstExpBits = dstBits - DST_SIG_BITS - 1; const int dstInfExp = (1 << dstExpBits) - 1; const int dstExpBias = dstInfExp >> 1; const int underflowExponent = srcExpBias + 1 - dstExpBias; const int overflowExponent = srcExpBias + dstInfExp - dstExpBias; const SRC_REP_T underflow = (SRC_REP_T)underflowExponent << SRC_SIG_BITS; const SRC_REP_T overflow = (SRC_REP_T)overflowExponent << SRC_SIG_BITS; const DST_REP_T dstQNaN = DST_REP_T(1) << (DST_SIG_BITS - 1); const DST_REP_T dstNaNCode = dstQNaN - 1; // Break a into a sign and representation of the absolute value union SrcExchangeType { SRC_T f; SRC_REP_T i; }; SrcExchangeType src_rep; src_rep.f = a; const SRC_REP_T aRep = src_rep.i; const SRC_REP_T aAbs = aRep & srcAbsMask; const SRC_REP_T sign = aRep & srcSignMask; DST_REP_T absResult; if (aAbs - underflow < aAbs - overflow) { // The exponent of a is within the range of normal numbers in the // destination format. We can convert by simply right-shifting with // rounding and adjusting the exponent. absResult = aAbs >> (SRC_SIG_BITS - DST_SIG_BITS); absResult -= (DST_REP_T)(srcExpBias - dstExpBias) << DST_SIG_BITS; const SRC_REP_T roundBits = aAbs & roundMask; // Round to nearest if (roundBits > halfway) absResult++; // Ties to even else if (roundBits == halfway) absResult += absResult & 1; } else if (aAbs > srcInfinity) { // a is NaN. // Conjure the result by beginning with infinity, setting the qNaN // bit and inserting the (truncated) trailing NaN field. absResult = (DST_REP_T)dstInfExp << DST_SIG_BITS; absResult |= dstQNaN; absResult |= ((aAbs & srcNaNCode) >> (SRC_SIG_BITS - DST_SIG_BITS)) & dstNaNCode; } else if (aAbs >= overflow) { // a overflows to infinity. absResult = (DST_REP_T)dstInfExp << DST_SIG_BITS; } else { // a underflows on conversion to the destination type or is an exact // zero. The result may be a denormal or zero. Extract the exponent // to get the shift amount for the denormalization. const int aExp = aAbs >> SRC_SIG_BITS; const int shift = srcExpBias - dstExpBias - aExp + 1; const SRC_REP_T significand = (aRep & srcSignificandMask) | srcMinNormal; // Right shift by the denormalization amount with sticky. if (shift > SRC_SIG_BITS) { absResult = 0; } else { const bool sticky = significand << (srcBits - shift); SRC_REP_T denormalizedSignificand = significand >> shift | sticky; absResult = denormalizedSignificand >> (SRC_SIG_BITS - DST_SIG_BITS); const SRC_REP_T roundBits = denormalizedSignificand & roundMask; // Round to nearest if (roundBits > halfway) absResult++; // Ties to even else if (roundBits == halfway) absResult += absResult & 1; } } // Apply the signbit to (DST_T)abs(a). const DST_REP_T result = absResult | sign >> (srcBits - dstBits); union DstExchangeType { DST_T f; DST_REP_T i; }; DstExchangeType dst_rep; dst_rep.i = result; return dst_rep.f; } template <typename SRC_T, typename SRC_REP_T, int SRC_SIG_BITS, typename DST_T, typename DST_REP_T, int DST_SIG_BITS> static inline DST_T __extendXfYf2__(SRC_T a) { // Various constants whose values follow from the type parameters. // Any reasonable optimizer will fold and propagate all of these. const int srcBits = sizeof(SRC_T) * 8; const int srcExpBits = srcBits - SRC_SIG_BITS - 1; const int srcInfExp = (1 << srcExpBits) - 1; const int srcExpBias = srcInfExp >> 1; const SRC_REP_T srcMinNormal = SRC_REP_T(1) << SRC_SIG_BITS; const SRC_REP_T srcInfinity = (SRC_REP_T)srcInfExp << SRC_SIG_BITS; const SRC_REP_T srcSignMask = SRC_REP_T(1) << (SRC_SIG_BITS + srcExpBits); const SRC_REP_T srcAbsMask = srcSignMask - 1; const SRC_REP_T srcQNaN = SRC_REP_T(1) << (SRC_SIG_BITS - 1); const SRC_REP_T srcNaNCode = srcQNaN - 1; const int dstBits = sizeof(DST_T) * 8; const int dstExpBits = dstBits - DST_SIG_BITS - 1; const int dstInfExp = (1 << dstExpBits) - 1; const int dstExpBias = dstInfExp >> 1; const DST_REP_T dstMinNormal = DST_REP_T(1) << DST_SIG_BITS; // Break a into a sign and representation of the absolute value union SrcExchangeType { SRC_T f; SRC_REP_T i; }; SrcExchangeType src_rep; src_rep.f = a; const SRC_REP_T aRep = src_rep.i; const SRC_REP_T aAbs = aRep & srcAbsMask; const SRC_REP_T sign = aRep & srcSignMask; DST_REP_T absResult; // If sizeof(SRC_REP_T) < sizeof(int), the subtraction result is promoted // to (signed) int. To avoid that, explicitly cast to SRC_REP_T. if ((SRC_REP_T)(aAbs - srcMinNormal) < srcInfinity - srcMinNormal) { // a is a normal number. // Extend to the destination type by shifting the significand and // exponent into the proper position and rebiasing the exponent. absResult = (DST_REP_T)aAbs << (DST_SIG_BITS - SRC_SIG_BITS); absResult += (DST_REP_T)(dstExpBias - srcExpBias) << DST_SIG_BITS; } else if (aAbs >= srcInfinity) { // a is NaN or infinity. // Conjure the result by beginning with infinity, then setting the qNaN // bit (if needed) and right-aligning the rest of the trailing NaN // payload field. absResult = (DST_REP_T)dstInfExp << DST_SIG_BITS; absResult |= (DST_REP_T)(aAbs & srcQNaN) << (DST_SIG_BITS - SRC_SIG_BITS); absResult |= (DST_REP_T)(aAbs & srcNaNCode) << (DST_SIG_BITS - SRC_SIG_BITS); } else if (aAbs) { // a is denormal. // renormalize the significand and clear the leading bit, then insert // the correct adjusted exponent in the destination type. const int scale = __clz(aAbs) - __clz(srcMinNormal); absResult = (DST_REP_T)aAbs << (DST_SIG_BITS - SRC_SIG_BITS + scale); absResult ^= dstMinNormal; const int resultExponent = dstExpBias - srcExpBias - scale + 1; absResult |= (DST_REP_T)resultExponent << DST_SIG_BITS; } else { // a is zero. absResult = 0; } // Apply the signbit to (DST_T)abs(a). const DST_REP_T result = absResult | (DST_REP_T)sign << (dstBits - srcBits); union DstExchangeType { DST_T f; DST_REP_T i; }; DstExchangeType dst_rep; dst_rep.i = result; return dst_rep.f; } #endif // COMPILER_RT_BUILTIN_FP16_H_
https://github.com/zk-ml/tachikoma
3rdparty/libcrc/include/checksum.h
/* * Library: libcrc * File: include/checksum.h * Author: Lammert Bies * * This file is licensed under the MIT License as stated below * * Copyright (c) 1999-2018 Lammert Bies * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Description * ----------- * The headerfile include/checksum.h contains the definitions and prototypes * for routines that can be used to calculate several kinds of checksums. */ #ifndef DEF_LIBCRC_CHECKSUM_H #define DEF_LIBCRC_CHECKSUM_H #ifdef __cplusplus extern "C" { #endif #include <stddef.h> #include <stdint.h> /* * #define CRC_POLY_xxxx * * The constants of the form CRC_POLY_xxxx define the polynomials for some well * known CRC calculations. */ #define CRC_POLY_16 0xA001 #define CRC_POLY_32 0xEDB88320ul #define CRC_POLY_64 0x42F0E1EBA9EA3693ull #define CRC_POLY_CCITT 0x1021 #define CRC_POLY_DNP 0xA6BC #define CRC_POLY_KERMIT 0x8408 #define CRC_POLY_SICK 0x8005 /* * #define CRC_START_xxxx * * The constants of the form CRC_START_xxxx define the values that are used for * initialization of a CRC value for common used calculation methods. */ #define CRC_START_8 0x00 #define CRC_START_16 0x0000 #define CRC_START_MODBUS 0xFFFF #define CRC_START_XMODEM 0x0000 #define CRC_START_CCITT_1D0F 0x1D0F #define CRC_START_CCITT_FFFF 0xFFFF #define CRC_START_KERMIT 0x0000 #define CRC_START_SICK 0x0000 #define CRC_START_DNP 0x0000 #define CRC_START_32 0xFFFFFFFFul #define CRC_START_64_ECMA 0x0000000000000000ull #define CRC_START_64_WE 0xFFFFFFFFFFFFFFFFull /* * Prototype list of global functions */ unsigned char* checksum_NMEA(const unsigned char* input_str, unsigned char* result); uint8_t crc_8(const unsigned char* input_str, size_t num_bytes); uint16_t crc_16(const unsigned char* input_str, size_t num_bytes); uint32_t crc_32(const unsigned char* input_str, size_t num_bytes); uint64_t crc_64_ecma(const unsigned char* input_str, size_t num_bytes); uint64_t crc_64_we(const unsigned char* input_str, size_t num_bytes); uint16_t crc_ccitt_1d0f(const unsigned char* input_str, size_t num_bytes); uint16_t crc_ccitt_ffff(const unsigned char* input_str, size_t num_bytes); uint16_t crc_dnp(const unsigned char* input_str, size_t num_bytes); uint16_t crc_kermit(const unsigned char* input_str, size_t num_bytes); uint16_t crc_modbus(const unsigned char* input_str, size_t num_bytes); uint16_t crc_sick(const unsigned char* input_str, size_t num_bytes); uint16_t crc_xmodem(const unsigned char* input_str, size_t num_bytes); uint8_t update_crc_8(uint8_t crc, unsigned char c); uint16_t update_crc_16(uint16_t crc, unsigned char c); uint32_t update_crc_32(uint32_t crc, unsigned char c); uint64_t update_crc_64_ecma(uint64_t crc, unsigned char c); uint16_t update_crc_ccitt(uint16_t crc, unsigned char c); uint16_t update_crc_dnp(uint16_t crc, unsigned char c); uint16_t update_crc_kermit(uint16_t crc, unsigned char c); uint16_t update_crc_sick(uint16_t crc, unsigned char c, unsigned char prev_byte); /* * Global CRC lookup tables */ extern const uint32_t crc_tab32[]; extern const uint64_t crc_tab64[]; #ifdef __cplusplus } // extern "C" #endif #endif // DEF_LIBCRC_CHECKSUM_H
https://github.com/zk-ml/tachikoma
3rdparty/libcrc/src/crcccitt.c
/* * Library: libcrc * File: src/crcccitt.c * Author: Lammert Bies * * This file is licensed under the MIT License as stated below * * Copyright (c) 1999-2016 Lammert Bies * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Description * ----------- * The module src/crcccitt.c contains routines which are used to calculate the * CCITT CRC values of a string of bytes. */ #include <inttypes.h> #include <stdbool.h> #include <stdlib.h> #include "../tab/gentab_ccitt.inc" #include "checksum.h" static uint16_t crc_ccitt_generic(const unsigned char* input_str, size_t num_bytes, uint16_t start_value); /* * uint16_t crc_xmodem( const unsigned char *input_str, size_t num_bytes ); * * The function crc_xmodem() performs a one-pass calculation of an X-Modem CRC * for a byte string that has been passed as a parameter. */ uint16_t crc_xmodem(const unsigned char* input_str, size_t num_bytes) { return crc_ccitt_generic(input_str, num_bytes, CRC_START_XMODEM); } /* crc_xmodem */ /* * uint16_t crc_ccitt_1d0f( const unsigned char *input_str, size_t num_bytes ); * * The function crc_ccitt_1d0f() performs a one-pass calculation of the CCITT * CRC for a byte string that has been passed as a parameter. The initial value * 0x1d0f is used for the CRC. */ uint16_t crc_ccitt_1d0f(const unsigned char* input_str, size_t num_bytes) { return crc_ccitt_generic(input_str, num_bytes, CRC_START_CCITT_1D0F); } /* crc_ccitt_1d0f */ /* * uint16_t crc_ccitt_ffff( const unsigned char *input_str, size_t num_bytes ); * * The function crc_ccitt_ffff() performs a one-pass calculation of the CCITT * CRC for a byte string that has been passed as a parameter. The initial value * 0xffff is used for the CRC. */ uint16_t crc_ccitt_ffff(const unsigned char* input_str, size_t num_bytes) { return crc_ccitt_generic(input_str, num_bytes, CRC_START_CCITT_FFFF); } /* crc_ccitt_ffff */ /* * static uint16_t crc_ccitt_generic( const unsigned char *input_str, size_t num_bytes, uint16_t * start_value ); * * The function crc_ccitt_generic() is a generic implementation of the CCITT * algorithm for a one-pass calculation of the CRC for a byte string. The * function accepts an initial start value for the crc. */ static uint16_t crc_ccitt_generic(const unsigned char* input_str, size_t num_bytes, uint16_t start_value) { uint16_t crc; const unsigned char* ptr; size_t a; crc = start_value; ptr = input_str; if (ptr != NULL) for (a = 0; a < num_bytes; a++) { crc = (crc << 8) ^ crc_tabccitt[((crc >> 8) ^ (uint16_t)*ptr++) & 0x00FF]; } return crc; } /* crc_ccitt_generic */ /* * uint16_t update_crc_ccitt( uint16_t crc, unsigned char c ); * * The function update_crc_ccitt() calculates a new CRC-CCITT value based on * the previous value of the CRC and the next byte of the data to be checked. */ uint16_t update_crc_ccitt(uint16_t crc, unsigned char c) { return (crc << 8) ^ crc_tabccitt[((crc >> 8) ^ (uint16_t)c) & 0x00FF]; } /* update_crc_ccitt */
https://github.com/zk-ml/tachikoma
3rdparty/picojson/picojson.h
/* * Copyright 2009-2010 Cybozu Labs, Inc. * Copyright 2011-2014 Kazuho Oku * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include <algorithm> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <iterator> #include <limits> #include <map> #include <stdexcept> #include <string> #include <unordered_map> #include <utility> #include <vector> // for isnan/isinf #if __cplusplus >= 201103L #include <cmath> #else extern "C" { #ifdef _MSC_VER #include <float.h> #elif defined(__INTEL_COMPILER) #include <mathimf.h> #else #include <math.h> #endif } #endif #ifndef PICOJSON_USE_RVALUE_REFERENCE #if (defined(__cpp_rvalue_references) && __cpp_rvalue_references >= 200610) || \ (defined(_MSC_VER) && _MSC_VER >= 1600) #define PICOJSON_USE_RVALUE_REFERENCE 1 #else #define PICOJSON_USE_RVALUE_REFERENCE 0 #endif #endif // PICOJSON_USE_RVALUE_REFERENCE #ifndef PICOJSON_NOEXCEPT #if PICOJSON_USE_RVALUE_REFERENCE #define PICOJSON_NOEXCEPT noexcept #else #define PICOJSON_NOEXCEPT throw() #endif #endif // experimental support for int64_t (see README.mkdn for detail) #ifdef PICOJSON_USE_INT64 #define __STDC_FORMAT_MACROS #include <errno.h> #include <inttypes.h> #endif // to disable the use of localeconv(3), set PICOJSON_USE_LOCALE to 0 #ifndef PICOJSON_USE_LOCALE #define PICOJSON_USE_LOCALE 1 #endif #if PICOJSON_USE_LOCALE extern "C" { #include <locale.h> } #endif #ifndef PICOJSON_ASSERT #ifndef PICOJSON_DISABLE_EXCEPTION #define PICOJSON_ASSERT(e) \ do { \ if (!(e)) throw std::runtime_error(#e); \ } while (0) #else #define PICOJSON_ASSERT(e) \ do { \ if (!(e)) std::abort(); \ } while (0) #endif // PICOJSON_DISABLE_EXCEPTION #endif #ifdef _MSC_VER #define SNPRINTF _snprintf_s #pragma warning(push) #pragma warning(disable : 4244) // conversion from int to char #pragma warning(disable : 4127) // conditional expression is constant #pragma warning(disable : 4702) // unreachable code #else #define SNPRINTF snprintf #endif namespace picojson { enum { null_type, boolean_type, number_type, string_type, array_type, object_type #ifdef PICOJSON_USE_INT64 , int64_type #endif }; enum { INDENT_WIDTH = 2 }; struct null {}; class value { public: typedef std::vector<value> array; typedef std::unordered_map<std::string, value> object; union _storage { bool boolean_; double number_; #ifdef PICOJSON_USE_INT64 int64_t int64_; #endif std::string* string_; array* array_; object* object_; }; protected: int type_; _storage u_; public: value(); value(int type, bool); explicit value(bool b); #ifdef PICOJSON_USE_INT64 explicit value(int64_t i); #endif explicit value(double n); explicit value(const std::string& s); explicit value(const array& a); explicit value(const object& o); #if PICOJSON_USE_RVALUE_REFERENCE explicit value(std::string&& s); explicit value(array&& a); explicit value(object&& o); #endif explicit value(const char* s); value(const char* s, size_t len); ~value(); value(const value& x); value& operator=(const value& x); #if PICOJSON_USE_RVALUE_REFERENCE value(value&& x) PICOJSON_NOEXCEPT; value& operator=(value&& x) PICOJSON_NOEXCEPT; #endif void swap(value& x) PICOJSON_NOEXCEPT; template <typename T> bool is() const; template <typename T> const T& get() const; template <typename T> T& get(); template <typename T> void set(const T&); #if PICOJSON_USE_RVALUE_REFERENCE template <typename T> void set(T&&); #endif bool evaluate_as_boolean() const; const value& get(const size_t idx) const; const value& get(const std::string& key) const; value& get(const size_t idx); value& get(const std::string& key); bool contains(const size_t idx) const; bool contains(const std::string& key) const; std::string to_str() const; template <typename Iter> void serialize(Iter os, bool prettify = false) const; std::string serialize(bool prettify = false) const; private: template <typename T> // NOLINTNEXTLINE(runtime/explicit) value(const T*); // intentionally defined to block implicit conversion of // pointer to bool template <typename Iter> static void _indent(Iter os, int indent); template <typename Iter> void _serialize(Iter os, int indent) const; std::string _serialize(int indent) const; void clear(); }; typedef value::array array; typedef value::object object; inline value::value() : type_(null_type), u_() {} inline value::value(int type, bool) : type_(type), u_() { switch (type) { #define INIT(p, v) \ case p##type: \ u_.p = v; \ break INIT(boolean_, false); INIT(number_, 0.0); #ifdef PICOJSON_USE_INT64 INIT(int64_, 0); #endif INIT(string_, new std::string()); INIT(array_, new array()); INIT(object_, new object()); #undef INIT default: break; } } inline value::value(bool b) : type_(boolean_type), u_() { u_.boolean_ = b; } #ifdef PICOJSON_USE_INT64 inline value::value(int64_t i) : type_(int64_type), u_() { u_.int64_ = i; } #endif inline value::value(double n) : type_(number_type), u_() { if ( #ifdef _MSC_VER !_finite(n) #elif __cplusplus >= 201103L std::isnan(n) || std::isinf(n) #else isnan(n) || isinf(n) #endif ) { #ifndef PICOJSON_DISABLE_EXCEPTION throw std::overflow_error(""); #else std::abort(); #endif } u_.number_ = n; } inline value::value(const std::string& s) : type_(string_type), u_() { u_.string_ = new std::string(s); } inline value::value(const array& a) : type_(array_type), u_() { u_.array_ = new array(a); } inline value::value(const object& o) : type_(object_type), u_() { u_.object_ = new object(o); } #if PICOJSON_USE_RVALUE_REFERENCE inline value::value(std::string&& s) : type_(string_type), u_() { u_.string_ = new std::string(std::move(s)); } inline value::value(array&& a) : type_(array_type), u_() { u_.array_ = new array(std::move(a)); } inline value::value(object&& o) : type_(object_type), u_() { u_.object_ = new object(std::move(o)); } #endif inline value::value(const char* s) : type_(string_type), u_() { u_.string_ = new std::string(s); } inline value::value(const char* s, size_t len) : type_(string_type), u_() { u_.string_ = new std::string(s, len); } inline void value::clear() { switch (type_) { #define DEINIT(p) \ case p##type: \ delete u_.p; \ break DEINIT(string_); DEINIT(array_); DEINIT(object_); #undef DEINIT default: break; } } inline value::~value() { clear(); } inline value::value(const value& x) : type_(x.type_), u_() { switch (type_) { #define INIT(p, v) \ case p##type: \ u_.p = v; \ break INIT(string_, new std::string(*x.u_.string_)); INIT(array_, new array(*x.u_.array_)); INIT(object_, new object(*x.u_.object_)); #undef INIT default: u_ = x.u_; break; } } inline value& value::operator=(const value& x) { if (this != &x) { value t(x); swap(t); } return *this; } #if PICOJSON_USE_RVALUE_REFERENCE inline value::value(value&& x) PICOJSON_NOEXCEPT : type_(null_type), u_() { swap(x); } inline value& value::operator=(value&& x) PICOJSON_NOEXCEPT { swap(x); return *this; } #endif inline void value::swap(value& x) PICOJSON_NOEXCEPT { std::swap(type_, x.type_); std::swap(u_, x.u_); } #define IS(ctype, jtype) \ template <> \ inline bool value::is<ctype>() const { \ return type_ == jtype##_type; \ } IS(null, null) IS(bool, boolean) #ifdef PICOJSON_USE_INT64 IS(int64_t, int64) #endif IS(std::string, string) IS(array, array) IS(object, object) #undef IS template <> inline bool value::is<double>() const { return type_ == number_type #ifdef PICOJSON_USE_INT64 || type_ == int64_type #endif // NOLINTNEXTLINE(whitespace/semicolon) ; } #define GET(ctype, var) \ template <> \ inline const ctype& value::get<ctype>() const { \ PICOJSON_ASSERT("type mismatch! call is<type>() before get<type>()" && is<ctype>()); \ return var; \ } \ template <> \ inline ctype& value::get<ctype>() { \ PICOJSON_ASSERT("type mismatch! call is<type>() before get<type>()" && is<ctype>()); \ return var; \ } GET(bool, u_.boolean_) GET(std::string, *u_.string_) GET(array, *u_.array_) GET(object, *u_.object_) #ifdef PICOJSON_USE_INT64 GET(double, (type_ == int64_type && (const_cast<value*>(this)->type_ = number_type, const_cast<value*>(this)->u_.number_ = u_.int64_), u_.number_)) GET(int64_t, u_.int64_) #else GET(double, u_.number_) #endif #undef GET #define SET(ctype, jtype, setter) \ template <> \ inline void value::set<ctype>(const ctype& _val) { \ clear(); \ type_ = jtype##_type; \ setter \ } SET(bool, boolean, u_.boolean_ = _val;) SET(std::string, string, u_.string_ = new std::string(_val);) SET(array, array, u_.array_ = new array(_val);) SET(object, object, u_.object_ = new object(_val);) SET(double, number, u_.number_ = _val;) #ifdef PICOJSON_USE_INT64 SET(int64_t, int64, u_.int64_ = _val;) #endif #undef SET #if PICOJSON_USE_RVALUE_REFERENCE #define MOVESET(ctype, jtype, setter) \ template <> \ inline void value::set<ctype>(ctype && _val) { \ clear(); \ type_ = jtype##_type; \ setter \ } MOVESET(std::string, string, u_.string_ = new std::string(std::move(_val));) MOVESET(array, array, u_.array_ = new array(std::move(_val));) MOVESET(object, object, u_.object_ = new object(std::move(_val));) #undef MOVESET #endif inline bool value::evaluate_as_boolean() const { switch (type_) { case null_type: return false; case boolean_type: return u_.boolean_; case number_type: return u_.number_ != 0; #ifdef PICOJSON_USE_INT64 case int64_type: return u_.int64_ != 0; #endif case string_type: return !u_.string_->empty(); default: return true; } } inline const value& value::get(const size_t idx) const { static value s_null; PICOJSON_ASSERT(is<array>()); return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null; } inline value& value::get(const size_t idx) { static value s_null; PICOJSON_ASSERT(is<array>()); return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null; } inline const value& value::get(const std::string& key) const { static value s_null; PICOJSON_ASSERT(is<object>()); object::const_iterator i = u_.object_->find(key); return i != u_.object_->end() ? i->second : s_null; } inline value& value::get(const std::string& key) { static value s_null; PICOJSON_ASSERT(is<object>()); object::iterator i = u_.object_->find(key); return i != u_.object_->end() ? i->second : s_null; } inline bool value::contains(const size_t idx) const { PICOJSON_ASSERT(is<array>()); return idx < u_.array_->size(); } inline bool value::contains(const std::string& key) const { PICOJSON_ASSERT(is<object>()); object::const_iterator i = u_.object_->find(key); return i != u_.object_->end(); } inline std::string value::to_str() const { switch (type_) { case null_type: return "null"; case boolean_type: return u_.boolean_ ? "true" : "false"; #ifdef PICOJSON_USE_INT64 case int64_type: { char buf[sizeof("-9223372036854775808")]; SNPRINTF(buf, sizeof(buf), "%" PRId64, u_.int64_); return buf; } #endif case number_type: { char buf[256]; double tmp; SNPRINTF(buf, sizeof(buf), fabs(u_.number_) < (1ULL << 53) && modf(u_.number_, &tmp) == 0 ? "%.f" : "%.17g", u_.number_); #if PICOJSON_USE_LOCALE char* decimal_point = localeconv()->decimal_point; if (strcmp(decimal_point, ".") != 0) { size_t decimal_point_len = strlen(decimal_point); for (char* p = buf; *p != '\0'; ++p) { if (strncmp(p, decimal_point, decimal_point_len) == 0) { return std::string(buf, p) + "." + (p + decimal_point_len); } } } #endif return buf; } case string_type: return *u_.string_; case array_type: return "array"; case object_type: return "object"; default: PICOJSON_ASSERT(0); #ifdef _MSC_VER __assume(0); #endif } return std::string(); } template <typename Iter> void copy(const std::string& s, Iter oi) { std::copy(s.begin(), s.end(), oi); } template <typename Iter> struct serialize_str_char { Iter oi; void operator()(char c) { switch (c) { #define MAP(val, sym) \ case val: \ copy(sym, oi); \ break MAP('"', "\\\""); MAP('\\', "\\\\"); MAP('/', "\\/"); MAP('\b', "\\b"); MAP('\f', "\\f"); MAP('\n', "\\n"); MAP('\r', "\\r"); MAP('\t', "\\t"); #undef MAP default: if (static_cast<unsigned char>(c) < 0x20 || c == 0x7f) { char buf[7]; SNPRINTF(buf, sizeof(buf), "\\u%04x", c & 0xff); copy(buf, buf + 6, oi); } else { *oi++ = c; } break; } } }; template <typename Iter> void serialize_str(const std::string& s, Iter oi) { *oi++ = '"'; serialize_str_char<Iter> process_char = {oi}; std::for_each(s.begin(), s.end(), process_char); *oi++ = '"'; } template <typename Iter> void value::serialize(Iter oi, bool prettify) const { return _serialize(oi, prettify ? 0 : -1); } inline std::string value::serialize(bool prettify) const { return _serialize(prettify ? 0 : -1); } template <typename Iter> void value::_indent(Iter oi, int indent) { *oi++ = '\n'; for (int i = 0; i < indent * INDENT_WIDTH; ++i) { *oi++ = ' '; } } template <typename Iter> void value::_serialize(Iter oi, int indent) const { switch (type_) { case string_type: serialize_str(*u_.string_, oi); break; case array_type: { *oi++ = '['; if (indent != -1) { ++indent; } for (array::const_iterator i = u_.array_->begin(); i != u_.array_->end(); ++i) { if (i != u_.array_->begin()) { *oi++ = ','; } if (indent != -1) { _indent(oi, indent); } i->_serialize(oi, indent); } if (indent != -1) { --indent; if (!u_.array_->empty()) { _indent(oi, indent); } } *oi++ = ']'; break; } case object_type: { *oi++ = '{'; if (indent != -1) { ++indent; } for (object::const_iterator i = u_.object_->begin(); i != u_.object_->end(); ++i) { if (i != u_.object_->begin()) { *oi++ = ','; } if (indent != -1) { _indent(oi, indent); } serialize_str(i->first, oi); *oi++ = ':'; if (indent != -1) { *oi++ = ' '; } i->second._serialize(oi, indent); } if (indent != -1) { --indent; if (!u_.object_->empty()) { _indent(oi, indent); } } *oi++ = '}'; break; } default: copy(to_str(), oi); break; } if (indent == 0) { *oi++ = '\n'; } } inline std::string value::_serialize(int indent) const { std::string s; _serialize(std::back_inserter(s), indent); return s; } template <typename Iter> class input { protected: Iter cur_, end_; bool consumed_; int line_; public: input(const Iter& first, const Iter& last) : cur_(first), end_(last), consumed_(false), line_(1) {} int getc() { if (consumed_) { if (*cur_ == '\n') { ++line_; } ++cur_; } if (cur_ == end_) { consumed_ = false; return -1; } consumed_ = true; return *cur_ & 0xff; } void ungetc() { consumed_ = false; } Iter cur() const { if (consumed_) { input<Iter>* self = const_cast<input<Iter>*>(this); self->consumed_ = false; ++self->cur_; } return cur_; } int line() const { return line_; } void skip_ws() { while (1) { int ch = getc(); if (!(ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) { ungetc(); break; } } } bool expect(const int expected) { skip_ws(); if (getc() != expected) { ungetc(); return false; } return true; } bool match(const std::string& pattern) { for (std::string::const_iterator pi(pattern.begin()); pi != pattern.end(); ++pi) { if (getc() != *pi) { ungetc(); return false; } } return true; } }; template <typename Iter> // NOLINTNEXTLINE(runtime/references) inline int _parse_quadhex(input<Iter>& in) { int uni_ch = 0, hex; for (int i = 0; i < 4; i++) { if ((hex = in.getc()) == -1) { return -1; } if ('0' <= hex && hex <= '9') { hex -= '0'; } else if ('A' <= hex && hex <= 'F') { hex -= 'A' - 0xa; } else if ('a' <= hex && hex <= 'f') { hex -= 'a' - 0xa; } else { in.ungetc(); return -1; } uni_ch = uni_ch * 16 + hex; } return uni_ch; } template <typename String, typename Iter> // NOLINTNEXTLINE(runtime/references) inline bool _parse_codepoint(String& out, input<Iter>& in) { int uni_ch; if ((uni_ch = _parse_quadhex(in)) == -1) { return false; } if (0xd800 <= uni_ch && uni_ch <= 0xdfff) { if (0xdc00 <= uni_ch) { // a second 16-bit of a surrogate pair appeared return false; } // first 16-bit of surrogate pair, get the next one if (in.getc() != '\\' || in.getc() != 'u') { in.ungetc(); return false; } int second = _parse_quadhex(in); if (!(0xdc00 <= second && second <= 0xdfff)) { return false; } uni_ch = ((uni_ch - 0xd800) << 10) | ((second - 0xdc00) & 0x3ff); uni_ch += 0x10000; } if (uni_ch < 0x80) { out.push_back(static_cast<char>(uni_ch)); } else { if (uni_ch < 0x800) { out.push_back(static_cast<char>(0xc0 | (uni_ch >> 6))); } else { if (uni_ch < 0x10000) { out.push_back(static_cast<char>(0xe0 | (uni_ch >> 12))); } else { out.push_back(static_cast<char>(0xf0 | (uni_ch >> 18))); out.push_back(static_cast<char>(0x80 | ((uni_ch >> 12) & 0x3f))); } out.push_back(static_cast<char>(0x80 | ((uni_ch >> 6) & 0x3f))); } out.push_back(static_cast<char>(0x80 | (uni_ch & 0x3f))); } return true; } template <typename String, typename Iter> // NOLINTNEXTLINE(runtime/references) inline bool _parse_string(String& out, input<Iter>& in) { while (1) { int ch = in.getc(); if (ch < ' ') { in.ungetc(); return false; } else if (ch == '"') { return true; } else if (ch == '\\') { if ((ch = in.getc()) == -1) { return false; } switch (ch) { #define MAP(sym, val) \ case sym: \ out.push_back(val); \ break MAP('"', '\"'); MAP('\\', '\\'); MAP('/', '/'); MAP('b', '\b'); MAP('f', '\f'); MAP('n', '\n'); MAP('r', '\r'); MAP('t', '\t'); #undef MAP case 'u': if (!_parse_codepoint(out, in)) { return false; } break; default: return false; } } else { out.push_back(static_cast<char>(ch)); } } return false; } template <typename Context, typename Iter> // NOLINTNEXTLINE(runtime/references) inline bool _parse_array(Context& ctx, input<Iter>& in) { if (!ctx.parse_array_start()) { return false; } size_t idx = 0; if (in.expect(']')) { return ctx.parse_array_stop(idx); } do { if (!ctx.parse_array_item(in, idx)) { return false; } idx++; } while (in.expect(',')); return in.expect(']') && ctx.parse_array_stop(idx); } template <typename Context, typename Iter> // NOLINTNEXTLINE(runtime/references) inline bool _parse_object(Context& ctx, input<Iter>& in) { if (!ctx.parse_object_start()) { return false; } if (in.expect('}')) { return true; } do { std::string key; if (!in.expect('"') || !_parse_string(key, in) || !in.expect(':')) { return false; } if (!ctx.parse_object_item(in, key)) { return false; } } while (in.expect(',')); return in.expect('}'); } template <typename Iter> // NOLINTNEXTLINE(runtime/references) inline std::string _parse_number(input<Iter>& in) { std::string num_str; while (1) { int ch = in.getc(); if (('0' <= ch && ch <= '9') || ch == '+' || ch == '-' || ch == 'e' || ch == 'E') { num_str.push_back(static_cast<char>(ch)); } else if (ch == '.') { #if PICOJSON_USE_LOCALE num_str += localeconv()->decimal_point; #else num_str.push_back('.'); #endif } else { in.ungetc(); break; } } return num_str; } template <typename Context, typename Iter> // NOLINTNEXTLINE(runtime/references) inline bool _parse(Context& ctx, input<Iter>& in) { in.skip_ws(); int ch = in.getc(); switch (ch) { #define IS(ch, text, op) \ case ch: \ if (in.match(text) && op) { \ return true; \ } else { \ return false; \ } IS('n', "ull", ctx.set_null()); IS('f', "alse", ctx.set_bool(false)); IS('t', "rue", ctx.set_bool(true)); #undef IS case '"': return ctx.parse_string(in); case '[': return _parse_array(ctx, in); case '{': return _parse_object(ctx, in); default: if (('0' <= ch && ch <= '9') || ch == '-') { double f; char* endp; in.ungetc(); std::string num_str(_parse_number(in)); if (num_str.empty()) { return false; } #ifdef PICOJSON_USE_INT64 { errno = 0; intmax_t ival = strtoimax(num_str.c_str(), &endp, 10); if (errno == 0 && std::numeric_limits<int64_t>::min() <= ival && ival <= std::numeric_limits<int64_t>::max() && endp == num_str.c_str() + num_str.size()) { ctx.set_int64(ival); return true; } } #endif f = strtod(num_str.c_str(), &endp); if (endp == num_str.c_str() + num_str.size()) { ctx.set_number(f); return true; } return false; } break; } in.ungetc(); return false; } class deny_parse_context { public: bool set_null() { return false; } bool set_bool(bool) { return false; } #ifdef PICOJSON_USE_INT64 bool set_int64(int64_t) { return false; } #endif bool set_number(double) { return false; } template <typename Iter> bool parse_string(input<Iter>&) { return false; } bool parse_array_start() { return false; } template <typename Iter> bool parse_array_item(input<Iter>&, size_t) { return false; } bool parse_array_stop(size_t) { return false; } bool parse_object_start() { return false; } template <typename Iter> bool parse_object_item(input<Iter>&, const std::string&) { return false; } }; class default_parse_context { protected: value* out_; public: // NOLINTNEXTLINE(runtime/explicit) default_parse_context(value* out) : out_(out) {} bool set_null() { *out_ = value(); return true; } bool set_bool(bool b) { *out_ = value(b); return true; } #ifdef PICOJSON_USE_INT64 bool set_int64(int64_t i) { *out_ = value(i); return true; } #endif bool set_number(double f) { *out_ = value(f); return true; } template <typename Iter> // NOLINTNEXTLINE(runtime/references) bool parse_string(input<Iter>& in) { *out_ = value(string_type, false); return _parse_string(out_->get<std::string>(), in); } bool parse_array_start() { *out_ = value(array_type, false); return true; } template <typename Iter> // NOLINTNEXTLINE(runtime/references) bool parse_array_item(input<Iter>& in, size_t) { array& a = out_->get<array>(); a.push_back(value()); default_parse_context ctx(&a.back()); return _parse(ctx, in); } bool parse_array_stop(size_t) { return true; } bool parse_object_start() { *out_ = value(object_type, false); return true; } template <typename Iter> // NOLINTNEXTLINE(runtime/references) bool parse_object_item(input<Iter>& in, const std::string& key) { object& o = out_->get<object>(); default_parse_context ctx(&o[key]); return _parse(ctx, in); } private: default_parse_context(const default_parse_context&); default_parse_context& operator=(const default_parse_context&); }; class null_parse_context { public: struct dummy_str { void push_back(int) {} }; public: null_parse_context() {} bool set_null() { return true; } bool set_bool(bool) { return true; } #ifdef PICOJSON_USE_INT64 bool set_int64(int64_t) { return true; } #endif bool set_number(double) { return true; } template <typename Iter> // NOLINTNEXTLINE(runtime/references) bool parse_string(input<Iter>& in) { dummy_str s; return _parse_string(s, in); } bool parse_array_start() { return true; } template <typename Iter> // NOLINTNEXTLINE(runtime/references) bool parse_array_item(input<Iter>& in, size_t) { return _parse(*this, in); } bool parse_array_stop(size_t) { return true; } bool parse_object_start() { return true; } template <typename Iter> // NOLINTNEXTLINE(runtime/references) bool parse_object_item(input<Iter>& in, const std::string&) { return _parse(*this, in); } private: null_parse_context(const null_parse_context&); null_parse_context& operator=(const null_parse_context&); }; // obsolete, use the version below template <typename Iter> // NOLINTNEXTLINE(runtime/references) inline std::string parse(value& out, Iter& pos, const Iter& last) { std::string err; pos = parse(out, pos, last, &err); return err; } template <typename Context, typename Iter> // NOLINTNEXTLINE(runtime/references) inline Iter _parse(Context& ctx, const Iter& first, const Iter& last, std::string* err) { input<Iter> in(first, last); if (!_parse(ctx, in) && err != NULL) { char buf[64]; SNPRINTF(buf, sizeof(buf), "syntax error at line %d near: ", in.line()); *err = buf; while (1) { int ch = in.getc(); if (ch == -1 || ch == '\n') { break; } else if (ch >= ' ') { err->push_back(static_cast<char>(ch)); } } } return in.cur(); } template <typename Iter> // NOLINTNEXTLINE(runtime/references) inline Iter parse(value& out, const Iter& first, const Iter& last, std::string* err) { default_parse_context ctx(&out); return _parse(ctx, first, last, err); } // NOLINTNEXTLINE(runtime/references) inline std::string parse(value& out, const std::string& s) { std::string err; parse(out, s.begin(), s.end(), &err); return err; } // NOLINTNEXTLINE(runtime/references) inline std::string parse(value& out, std::istream& is) { std::string err; parse(out, std::istreambuf_iterator<char>(is.rdbuf()), std::istreambuf_iterator<char>(), &err); return err; } template <typename T> struct last_error_t { static std::string s; }; template <typename T> // NOLINTNEXTLINE(runtime/string) std::string last_error_t<T>::s; inline void set_last_error(const std::string& s) { last_error_t<bool>::s = s; } inline const std::string& get_last_error() { return last_error_t<bool>::s; } inline bool operator==(const value& x, const value& y) { if (x.is<null>()) return y.is<null>(); #define PICOJSON_CMP(type) \ if (x.is<type>()) return y.is<type>() && x.get<type>() == y.get<type>() PICOJSON_CMP(bool); PICOJSON_CMP(double); PICOJSON_CMP(std::string); PICOJSON_CMP(array); PICOJSON_CMP(object); #undef PICOJSON_CMP PICOJSON_ASSERT(0); #ifdef _MSC_VER __assume(0); #endif return false; } inline bool operator!=(const value& x, const value& y) { return !(x == y); } } // namespace picojson #if !PICOJSON_USE_RVALUE_REFERENCE namespace std { template <> inline void swap(picojson::value& x, picojson::value& y) { x.swap(y); } } // namespace std #endif inline std::istream& operator>>(std::istream& is, picojson::value& x) { picojson::set_last_error(std::string()); const std::string err(picojson::parse(x, is)); if (!err.empty()) { picojson::set_last_error(err); is.setstate(std::ios::failbit); } return is; } inline std::ostream& operator<<(std::ostream& os, const picojson::value& x) { x.serialize(std::ostream_iterator<char>(os)); return os; } #ifdef _MSC_VER #pragma warning(pop) #endif
https://github.com/zk-ml/tachikoma
apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/Camera2BasicFragment.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ package org.apache.tvm.android.androidcamerademo; import android.annotation.SuppressLint; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.media.Image; import android.os.AsyncTask; import android.os.Bundle; import android.os.SystemClock; import android.util.Log; import android.util.Size; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; import androidx.camera.core.Camera; import androidx.camera.core.CameraSelector; import androidx.camera.core.ImageAnalysis; import androidx.camera.core.ImageProxy; import androidx.camera.core.Preview; import androidx.camera.lifecycle.ProcessCameraProvider; import androidx.camera.view.PreviewView; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.renderscript.Allocation; import androidx.renderscript.Element; import androidx.renderscript.RenderScript; import androidx.renderscript.Script; import androidx.renderscript.Type; import com.google.common.util.concurrent.ListenableFuture; import org.apache.tvm.Function; import org.apache.tvm.Module; import org.apache.tvm.NDArray; import org.apache.tvm.Device; import org.apache.tvm.TVMType; import org.apache.tvm.TVMValue; import org.json.JSONException; import org.json.JSONObject; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.util.PriorityQueue; import java.util.concurrent.ExecutionException; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; public class Camera2BasicFragment extends Fragment { private static final String TAG = Camera2BasicFragment.class.getSimpleName(); // TVM constants private static final int OUTPUT_INDEX = 0; private static final int IMG_CHANNEL = 3; private static final boolean EXE_GPU = false; private static final int MODEL_INPUT_SIZE = 224; private static final String MODEL_CL_LIB_FILE = "deploy_lib_opencl.so"; private static final String MODEL_CPU_LIB_FILE = "deploy_lib_cpu.so"; private static final String MODEL_GRAPH_FILE = "deploy_graph.json"; private static final String MODEL_PARAM_FILE = "deploy_param.params"; private static final String MODEL_LABEL_FILE = "image_net_labels.json"; private static final String MODELS = "models"; private static String INPUT_NAME = "input_1"; private static String[] models; private static String mCurModel = ""; private final float[] mCHW = new float[MODEL_INPUT_SIZE * MODEL_INPUT_SIZE * IMG_CHANNEL]; private final float[] mCHW2 = new float[MODEL_INPUT_SIZE * MODEL_INPUT_SIZE * IMG_CHANNEL]; private final Semaphore isProcessingDone = new Semaphore(1); private final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( 3, 3, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<>() ); // rs creation just for demo. Create rs just once in onCreate and use it again. private RenderScript rs; private ScriptC_yuv420888 mYuv420; private boolean mRunClassifier = false; private AppCompatTextView mResultView; private AppCompatTextView mInfoView; private ListView mModelView; private AssetManager assetManager; private Module graphExecutorModule; private JSONObject labels; private ListenableFuture<ProcessCameraProvider> cameraProviderFuture; private PreviewView previewView; private ImageAnalysis imageAnalysis; static Camera2BasicFragment newInstance() { return new Camera2BasicFragment(); } private static Matrix getTransformationMatrix( final int srcWidth, final int srcHeight, final int dstWidth, final int dstHeight, final int applyRotation, final boolean maintainAspectRatio) { final Matrix matrix = new Matrix(); if (applyRotation != 0) { if (applyRotation % 90 != 0) { Log.w(TAG, "Rotation of %d % 90 != 0 " + applyRotation); } // Translate so center of image is at origin. matrix.postTranslate(-srcWidth / 2.0f, -srcHeight / 2.0f); // Rotate around origin. matrix.postRotate(applyRotation); } // Account for the already applied rotation, if any, and then determine how // much scaling is needed for each axis. final boolean transpose = (Math.abs(applyRotation) + 90) % 180 == 0; final int inWidth = transpose ? srcHeight : srcWidth; final int inHeight = transpose ? srcWidth : srcHeight; // Apply scaling if necessary. if (inWidth != dstWidth || inHeight != dstHeight) { final float scaleFactorX = dstWidth / (float) inWidth; final float scaleFactorY = dstHeight / (float) inHeight; if (maintainAspectRatio) { // Scale by minimum factor so that dst is filled completely while // maintaining the aspect ratio. Some image may fall off the edge. final float scaleFactor = Math.max(scaleFactorX, scaleFactorY); matrix.postScale(scaleFactor, scaleFactor); } else { // Scale exactly to fill dst from src. matrix.postScale(scaleFactorX, scaleFactorY); } } if (applyRotation != 0) { // Translate back from origin centered reference to destination frame. matrix.postTranslate(dstWidth / 2.0f, dstHeight / 2.0f); } return matrix; } private String[] getModels() { String[] models; try { models = getActivity().getAssets().list(MODELS); } catch (IOException e) { return null; } return models; } @SuppressLint("DefaultLocale") private String[] inference(float[] chw) { NDArray inputNdArray = NDArray.empty(new long[]{1, IMG_CHANNEL, MODEL_INPUT_SIZE, MODEL_INPUT_SIZE}, new TVMType("float32")); inputNdArray.copyFrom(chw); Function setInputFunc = graphExecutorModule.getFunction("set_input"); setInputFunc.pushArg(INPUT_NAME).pushArg(inputNdArray).invoke(); // release tvm local variables inputNdArray.release(); setInputFunc.release(); // get the function from the module(run it) Function runFunc = graphExecutorModule.getFunction("run"); runFunc.invoke(); // release tvm local variables runFunc.release(); // get the function from the module(get output data) NDArray outputNdArray = NDArray.empty(new long[]{1, 1000}, new TVMType("float32")); Function getOutputFunc = graphExecutorModule.getFunction("get_output"); getOutputFunc.pushArg(OUTPUT_INDEX).pushArg(outputNdArray).invoke(); float[] output = outputNdArray.asFloatArray(); // release tvm local variables outputNdArray.release(); getOutputFunc.release(); if (null != output) { String[] results = new String[5]; // top-5 PriorityQueue<Integer> pq = new PriorityQueue<>(1000, (Integer idx1, Integer idx2) -> output[idx1] > output[idx2] ? -1 : 1); // display the result from extracted output data for (int j = 0; j < output.length; ++j) { pq.add(j); } for (int l = 0; l < 5; l++) { //noinspection ConstantConditions int idx = pq.poll(); if (idx < labels.length()) { try { results[l] = String.format("%.2f", output[idx]) + " : " + labels.getString(Integer.toString(idx)); } catch (JSONException e) { Log.e(TAG, "index out of range", e); } } else { results[l] = "???: unknown"; } } return results; } return new String[5]; } private void updateActiveModel() { Log.i(TAG, "updating active model..."); new LoadModelAsyncTask().execute(); } @Override public void onViewCreated(final View view, Bundle savedInstanceState) { mResultView = view.findViewById(R.id.resultTextView); mInfoView = view.findViewById(R.id.infoTextView); mModelView = view.findViewById(R.id.modelListView); if (assetManager == null) { assetManager = getActivity().getAssets(); } mModelView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); models = getModels(); ArrayAdapter<String> modelAdapter = new ArrayAdapter<>( getContext(), R.layout.listview_row, R.id.listview_row_text, models); mModelView.setAdapter(modelAdapter); mModelView.setItemChecked(0, true); mModelView.setOnItemClickListener( (parent, view1, position, id) -> updateActiveModel()); new LoadModelAsyncTask().execute(); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); } @Override public void onDestroy() { // release tvm local variables if (null != graphExecutorModule) graphExecutorModule.release(); super.onDestroy(); } /** * Read file from assets and return byte array. * * @param assets The asset manager to be used to load assets. * @param fileName The filepath of read file. * @return byte[] file content * @throws IOException */ private byte[] getBytesFromFile(AssetManager assets, String fileName) throws IOException { InputStream is = assets.open(fileName); int length = is.available(); byte[] bytes = new byte[length]; // Read in the bytes int offset = 0; int numRead; try { while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; } } finally { is.close(); } // Ensure all the bytes have been read in if (offset < bytes.length) { throw new IOException("Could not completely read file " + fileName); } return bytes; } /** * Get application cache path where to place compiled functions. * * @param fileName library file name. * @return String application cache folder path * @throws IOException */ private String getTempLibFilePath(String fileName) throws IOException { File tempDir = File.createTempFile("tvm4j_demo_", ""); if (!tempDir.delete() || !tempDir.mkdir()) { throw new IOException("Couldn't create directory " + tempDir.getAbsolutePath()); } return (tempDir + File.separator + fileName); } private Bitmap YUV_420_888_toRGB(Image image, int width, int height) { // Get the three image planes Image.Plane[] planes = image.getPlanes(); ByteBuffer buffer = planes[0].getBuffer(); byte[] y = new byte[buffer.remaining()]; buffer.get(y); buffer = planes[1].getBuffer(); byte[] u = new byte[buffer.remaining()]; buffer.get(u); buffer = planes[2].getBuffer(); byte[] v = new byte[buffer.remaining()]; buffer.get(v); int yRowStride = planes[0].getRowStride(); int uvRowStride = planes[1].getRowStride(); int uvPixelStride = planes[1].getPixelStride(); // Y,U,V are defined as global allocations, the out-Allocation is the Bitmap. // Note also that uAlloc and vAlloc are 1-dimensional while yAlloc is 2-dimensional. Type.Builder typeUcharY = new Type.Builder(rs, Element.U8(rs)); typeUcharY.setX(yRowStride).setY(height); Allocation yAlloc = Allocation.createTyped(rs, typeUcharY.create()); yAlloc.copyFrom(y); mYuv420.set_ypsIn(yAlloc); Type.Builder typeUcharUV = new Type.Builder(rs, Element.U8(rs)); // note that the size of the u's and v's are as follows: // ( (width/2)*PixelStride + padding ) * (height/2) // = (RowStride ) * (height/2) typeUcharUV.setX(u.length); Allocation uAlloc = Allocation.createTyped(rs, typeUcharUV.create()); uAlloc.copyFrom(u); mYuv420.set_uIn(uAlloc); Allocation vAlloc = Allocation.createTyped(rs, typeUcharUV.create()); vAlloc.copyFrom(v); mYuv420.set_vIn(vAlloc); // handover parameters mYuv420.set_picWidth(width); mYuv420.set_uvRowStride(uvRowStride); mYuv420.set_uvPixelStride(uvPixelStride); Bitmap outBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Allocation outAlloc = Allocation.createFromBitmap(rs, outBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); Script.LaunchOptions lo = new Script.LaunchOptions(); lo.setX(0, width); // by this we ignore the y’s padding zone, i.e. the right side of x between width and yRowStride lo.setY(0, height); mYuv420.forEach_doConvert(outAlloc, lo); outAlloc.copyTo(outBitmap); return outBitmap; } private float[] getFrame(ImageProxy imageProxy) { @SuppressLint("UnsafeOptInUsageError") Image image = imageProxy.getImage(); // extract the jpeg content if (image == null) { return null; } Bitmap imageBitmap = YUV_420_888_toRGB(image, image.getWidth(), image.getHeight()); imageProxy.close(); // crop input image at centre to model input size Bitmap cropImageBitmap = Bitmap.createBitmap(MODEL_INPUT_SIZE, MODEL_INPUT_SIZE, Bitmap.Config.ARGB_8888); Matrix frameToCropTransform = getTransformationMatrix(imageBitmap.getWidth(), imageBitmap.getHeight(), MODEL_INPUT_SIZE, MODEL_INPUT_SIZE, 0, true); Canvas canvas = new Canvas(cropImageBitmap); canvas.drawBitmap(imageBitmap, frameToCropTransform, null); // image pixel int values int[] pixelValues = new int[MODEL_INPUT_SIZE * MODEL_INPUT_SIZE]; // image RGB float values // pre-process the image data from 0-255 int to normalized float based on the // provided parameters. cropImageBitmap.getPixels(pixelValues, 0, MODEL_INPUT_SIZE, 0, 0, MODEL_INPUT_SIZE, MODEL_INPUT_SIZE); for (int j = 0; j < pixelValues.length; ++j) { mCHW2[j * 3 + 0] = ((pixelValues[j] >> 16) & 0xFF) / 255.0f; mCHW2[j * 3 + 1] = ((pixelValues[j] >> 8) & 0xFF) / 255.0f; mCHW2[j * 3 + 2] = (pixelValues[j] & 0xFF) / 255.0f; } // pre-process the image rgb data transpose based on the provided parameters. for (int k = 0; k < IMG_CHANNEL; ++k) { for (int l = 0; l < MODEL_INPUT_SIZE; ++l) { for (int m = 0; m < MODEL_INPUT_SIZE; ++m) { int dst_index = m + MODEL_INPUT_SIZE * l + MODEL_INPUT_SIZE * MODEL_INPUT_SIZE * k; int src_index = k + IMG_CHANNEL * m + IMG_CHANNEL * MODEL_INPUT_SIZE * l; mCHW[dst_index] = mCHW2[src_index]; } } } return mCHW; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); cameraProviderFuture = ProcessCameraProvider.getInstance(getActivity()); } @SuppressLint({"RestrictedApi", "UnsafeExperimentalUsageError"}) @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_camera2_basic, container, false); previewView = v.findViewById(R.id.textureView); rs = RenderScript.create(getActivity()); mYuv420 = new ScriptC_yuv420888(rs); cameraProviderFuture.addListener(() -> { try { ProcessCameraProvider cameraProvider = cameraProviderFuture.get(); bindPreview(cameraProvider); } catch (ExecutionException | InterruptedException e) { // No errors need to be handled for this Future. This should never be reached } }, ContextCompat.getMainExecutor(getActivity())); imageAnalysis = new ImageAnalysis.Builder() .setTargetResolution(new Size(224, 224)) .setMaxResolution(new Size(300, 300)) .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) .build(); imageAnalysis.setAnalyzer(threadPoolExecutor, image -> { Log.e(TAG, "w: " + image.getWidth() + " h: " + image.getHeight()); if (mRunClassifier && isProcessingDone.tryAcquire()) { long t1 = SystemClock.uptimeMillis(); //float[] chw = getFrame(image); //float[] chw = YUV_420_888_toRGBPixels(image); float[] chw = getFrame(image); if (chw != null) { long t2 = SystemClock.uptimeMillis(); String[] results = inference(chw); long t3 = SystemClock.uptimeMillis(); StringBuilder msgBuilder = new StringBuilder(); for (int l = 1; l < 5; l++) { msgBuilder.append(results[l]).append("\n"); } String msg = msgBuilder.toString(); msg += "getFrame(): " + (t2 - t1) + "ms" + "\n"; msg += "inference(): " + (t3 - t2) + "ms" + "\n"; String finalMsg = msg; this.getActivity().runOnUiThread(() -> { mResultView.setText(String.format("model: %s \n %s", mCurModel, results[0])); mInfoView.setText(finalMsg); }); } isProcessingDone.release(); } image.close(); }); return v; } private void bindPreview(@NonNull ProcessCameraProvider cameraProvider) { @SuppressLint("RestrictedApi") Preview preview = new Preview.Builder() .setMaxResolution(new Size(800, 800)) .setTargetName("Preview") .build(); preview.setSurfaceProvider(previewView.getPreviewSurfaceProvider()); CameraSelector cameraSelector = new CameraSelector.Builder() .requireLensFacing(CameraSelector.LENS_FACING_BACK) .build(); Camera camera = cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageAnalysis); } @Override public void onDestroyView() { threadPoolExecutor.shutdownNow(); super.onDestroyView(); } private void setInputName(String modelName) { if (modelName.equals("mobilenet_v2")) { INPUT_NAME = "input_1"; } else if (modelName.equals("resnet18_v1")) { INPUT_NAME = "data"; } else { throw new RuntimeException("Model input may not be right. Please set INPUT_NAME here explicitly."); } } /* Load precompiled model on TVM graph executor and init the system. */ private class LoadModelAsyncTask extends AsyncTask<Void, Void, Integer> { @Override protected Integer doInBackground(Void... args) { mRunClassifier = false; // load synset name int modelIndex = mModelView.getCheckedItemPosition(); setInputName(models[modelIndex]); String model = MODELS + "/" + models[modelIndex]; String labelFilename = MODEL_LABEL_FILE; Log.i(TAG, "Reading labels from: " + model + "/" + labelFilename); try { labels = new JSONObject(new String(getBytesFromFile(assetManager, model + "/" + labelFilename))); } catch (IOException | JSONException e) { Log.e(TAG, "Problem reading labels name file!", e); return -1;//failure } // load json graph String modelGraph; String graphFilename = MODEL_GRAPH_FILE; Log.i(TAG, "Reading json graph from: " + model + "/" + graphFilename); try { modelGraph = new String(getBytesFromFile(assetManager, model + "/" + graphFilename)); } catch (IOException e) { Log.e(TAG, "Problem reading json graph file!", e); return -1;//failure } // upload tvm compiled function on application cache folder String libCacheFilePath; String libFilename = EXE_GPU ? MODEL_CL_LIB_FILE : MODEL_CPU_LIB_FILE; Log.i(TAG, "Uploading compiled function to cache folder"); try { libCacheFilePath = getTempLibFilePath(libFilename); byte[] modelLibByte = getBytesFromFile(assetManager, model + "/" + libFilename); FileOutputStream fos = new FileOutputStream(libCacheFilePath); fos.write(modelLibByte); fos.close(); } catch (IOException e) { Log.e(TAG, "Problem uploading compiled function!", e); return -1;//failure } // load parameters byte[] modelParams; try { modelParams = getBytesFromFile(assetManager, model + "/" + MODEL_PARAM_FILE); } catch (IOException e) { Log.e(TAG, "Problem reading params file!", e); return -1;//failure } Log.i(TAG, "creating java tvm device..."); // create java tvm device Device tvmDev = EXE_GPU ? Device.opencl() : Device.cpu(); Log.i(TAG, "loading compiled functions..."); Log.i(TAG, libCacheFilePath); // tvm module for compiled functions Module modelLib = Module.load(libCacheFilePath); // get global function module for graph executor Log.i(TAG, "getting graph executor create handle..."); Function runtimeCreFun = Function.getFunction("tvm.graph_executor.create"); Log.i(TAG, "creating graph executor..."); Log.i(TAG, "device type: " + tvmDev.deviceType); Log.i(TAG, "device id: " + tvmDev.deviceId); TVMValue runtimeCreFunRes = runtimeCreFun.pushArg(modelGraph) .pushArg(modelLib) .pushArg(tvmDev.deviceType) .pushArg(tvmDev.deviceId) .invoke(); Log.i(TAG, "as module..."); graphExecutorModule = runtimeCreFunRes.asModule(); Log.i(TAG, "getting graph executor load params handle..."); // get the function from the module(load parameters) Function loadParamFunc = graphExecutorModule.getFunction("load_params"); Log.i(TAG, "loading params..."); loadParamFunc.pushArg(modelParams).invoke(); // release tvm local variables modelLib.release(); loadParamFunc.release(); runtimeCreFun.release(); mCurModel = model; mRunClassifier = true; return 0;//success } } }
https://github.com/zk-ml/tachikoma
apps/android_camera/app/src/main/java/org/apache/tvm/android/androidcamerademo/MainActivity.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ package org.apache.tvm.android.androidcamerademo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; public class MainActivity extends AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCallback { private static final int PERMISSIONS_REQUEST_CODE = 1; private String[] getRequiredPermissions() { try { PackageInfo info = getPackageManager() .getPackageInfo(getPackageName(), PackageManager.GET_PERMISSIONS); String[] ps = info.requestedPermissions; if (ps != null && ps.length > 0) { return ps; } else { return new String[0]; } } catch (Exception e) { return new String[0]; } } private boolean allPermissionsGranted() { for (String permission : getRequiredPermissions()) { if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) { return false; } } return true; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (!allPermissionsGranted()) { requestPermissions(getRequiredPermissions(), PERMISSIONS_REQUEST_CODE); return; } startFragment(); } private void startFragment() { getSupportFragmentManager() .beginTransaction() .replace(R.id.container, Camera2BasicFragment.newInstance()) .commit(); } @Override public void onRequestPermissionsResult( int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (allPermissionsGranted()) { startFragment(); } else { Toast.makeText(this, "Required permissions are not granted. App may not run", Toast.LENGTH_SHORT).show(); finish(); } } }
https://github.com/zk-ml/tachikoma
apps/android_camera/app/src/main/jni/tvm_runtime.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file tvm_runtime.h * \brief Pack all tvm runtime source files */ #include <sys/stat.h> #include <fstream> #define DMLC_USE_LOGGING_LIBRARY <tvm/runtime/logging.h> #define TVM_USE_LIBBACKTRACE 0 /* Enable custom logging - this will cause TVM to use a custom implementation * of tvm::runtime::detail::LogMessage. We use this to pass TVM log messages to * Android logcat. */ #define TVM_LOG_CUSTOMIZE 1 #include "../src/runtime/c_runtime_api.cc" #include "../src/runtime/cpu_device_api.cc" #include "../src/runtime/dso_library.cc" #include "../src/runtime/file_utils.cc" #include "../src/runtime/graph_executor/graph_executor.cc" #include "../src/runtime/library_module.cc" #include "../src/runtime/logging.cc" #include "../src/runtime/minrpc/minrpc_logger.cc" #include "../src/runtime/module.cc" #include "../src/runtime/ndarray.cc" #include "../src/runtime/object.cc" #include "../src/runtime/profiling.cc" #include "../src/runtime/registry.cc" #include "../src/runtime/rpc/rpc_channel.cc" #include "../src/runtime/rpc/rpc_endpoint.cc" #include "../src/runtime/rpc/rpc_event_impl.cc" #include "../src/runtime/rpc/rpc_local_session.cc" #include "../src/runtime/rpc/rpc_module.cc" #include "../src/runtime/rpc/rpc_server_env.cc" #include "../src/runtime/rpc/rpc_session.cc" #include "../src/runtime/rpc/rpc_socket_impl.cc" #include "../src/runtime/system_library.cc" #include "../src/runtime/thread_pool.cc" #include "../src/runtime/threading_backend.cc" #include "../src/runtime/workspace_pool.cc" #ifdef TVM_OPENCL_RUNTIME #include "../src/runtime/opencl/opencl_device_api.cc" #include "../src/runtime/opencl/opencl_module.cc" #include "../src/runtime/source_utils.cc" #endif #ifdef TVM_VULKAN_RUNTIME #include "../src/runtime/vulkan/vulkan.cc" #endif #ifdef USE_SORT #include "../src/runtime/contrib/sort/sort.cc" #endif #include <android/log.h> namespace tvm { namespace runtime { namespace detail { // Override logging mechanism [[noreturn]] void LogFatalImpl(const std::string& file, int lineno, const std::string& message) { std::string m = file + ":" + std::to_string(lineno) + ": " + message; __android_log_write(ANDROID_LOG_FATAL, "TVM_RUNTIME", m.c_str()); throw InternalError(file, lineno, message); } void LogMessageImpl(const std::string& file, int lineno, int level, const std::string& message) { std::string m = file + ":" + std::to_string(lineno) + ": " + message; __android_log_write(ANDROID_LOG_DEBUG + level, "TVM_RUNTIME", m.c_str()); } } // namespace detail } // namespace runtime } // namespace tvm
https://github.com/zk-ml/tachikoma
apps/android_camera/app/src/main/rs/yuv420888.rs
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ // Source: https://stackoverflow.com/questions/36212904/yuv-420-888-interpretation-on-samsung-galaxy-s7-camera2 #pragma version(1) #pragma rs java_package_name(org.apache.tvm.android.androidcamerademo); #pragma rs_fp_relaxed int32_t width; int32_t height; uint picWidth, uvPixelStride, uvRowStride ; rs_allocation ypsIn,uIn,vIn; // The LaunchOptions ensure that the Kernel does not enter the padding zone of Y, so yRowStride can be ignored WITHIN the Kernel. uchar4 __attribute__((kernel)) doConvert(uint32_t x, uint32_t y) { // index for accessing the uIn's and vIn's uint uvIndex= uvPixelStride * (x/2) + uvRowStride*(y/2); // get the y,u,v values uchar yps= rsGetElementAt_uchar(ypsIn, x, y); uchar u= rsGetElementAt_uchar(uIn, uvIndex); uchar v= rsGetElementAt_uchar(vIn, uvIndex); // calc argb int4 argb; argb.r = yps + v * 1436 / 1024 - 179; argb.g = yps -u * 46549 / 131072 + 44 -v * 93604 / 131072 + 91; argb.b = yps +u * 1814 / 1024 - 227; argb.a = 255; uchar4 out = convert_uchar4(clamp(argb, 0, 255)); return out; }
https://github.com/zk-ml/tachikoma
apps/android_camera/models/prepare_model.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import logging import pathlib from pathlib import Path from typing import Union import os from os import environ import json import tvm import tvm.relay as relay from tvm.contrib import utils, ndk, graph_executor as runtime from tvm.contrib.download import download_testdata, download target = "llvm -mtriple=arm64-linux-android" target_host = None def del_dir(target: Union[Path, str], only_if_empty: bool = False): target = Path(target).expanduser() assert target.is_dir() for p in sorted(target.glob("**/*"), reverse=True): if not p.exists(): continue p.chmod(0o666) if p.is_dir(): p.rmdir() else: if only_if_empty: raise RuntimeError(f"{p.parent} is not empty!") p.unlink() target.rmdir() def get_model(model_name, batch_size=1): if model_name == "resnet18_v1": import mxnet as mx from mxnet import gluon from mxnet.gluon.model_zoo import vision gluon_model = vision.get_model(model_name, pretrained=True) img_size = 224 data_shape = (batch_size, 3, img_size, img_size) net, params = relay.frontend.from_mxnet(gluon_model, {"data": data_shape}) return (net, params) elif model_name == "mobilenet_v2": import keras from keras.applications.mobilenet_v2 import MobileNetV2 keras.backend.clear_session() # Destroys the current TF graph and creates a new one. weights_url = "".join( [ "https://github.com/JonathanCMitchell/", "mobilenet_v2_keras/releases/download/v1.1/", "mobilenet_v2_weights_tf_dim_ordering_tf_kernels_0.5_224.h5", ] ) weights_file = "mobilenet_v2_weights.h5" weights_path = download_testdata(weights_url, weights_file, module="keras") keras_mobilenet_v2 = MobileNetV2( alpha=0.5, include_top=True, weights=None, input_shape=(224, 224, 3), classes=1000 ) keras_mobilenet_v2.load_weights(weights_path) img_size = 224 data_shape = (batch_size, 3, img_size, img_size) mod, params = relay.frontend.from_keras(keras_mobilenet_v2, {"input_1": data_shape}) return (mod, params) def main(model_str, output_path): if output_path.exists(): del_dir(output_path) output_path.mkdir() output_path_str = os.fspath(output_path) print(model_str) print("getting model...") net, params = get_model(model_str) try: os.mkdir(model_str) except FileExistsError: pass print("building...") with tvm.transform.PassContext(opt_level=3): graph, lib, params = relay.build(net, tvm.target.Target(target, target_host), params=params) print("dumping lib...") lib.export_library(output_path_str + "/" + "deploy_lib_cpu.so", ndk.create_shared) print("dumping graph...") with open(output_path_str + "/" + "deploy_graph.json", "w") as f: f.write(graph) print("dumping params...") with open(output_path_str + "/" + "deploy_param.params", "wb") as f: f.write(tvm.runtime.save_param_dict(params)) print("dumping labels...") synset_url = "".join( [ "https://gist.githubusercontent.com/zhreshold/", "4d0b62f3d01426887599d4f7ede23ee5/raw/", "596b27d23537e5a1b5751d2b0481ef172f58b539/", "imagenet1000_clsid_to_human.txt", ] ) synset_path = output_path_str + "/image_net_labels" download(synset_url, output_path_str + "/image_net_labels") with open(synset_path) as fi: synset = eval(fi.read()) with open(output_path_str + "/image_net_labels.json", "w") as fo: json.dump(synset, fo, indent=4) os.remove(synset_path) if __name__ == "__main__": if environ.get("TVM_NDK_CC") is None: raise RuntimeError("Require environment variable TVM_NDK_CC") models_path = Path().absolute().parent.joinpath("app/src/main/assets/models/") if not models_path.exists(): models_path.mkdir() models = { "mobilenet_v2": models_path.joinpath("mobilenet_v2"), "resnet18_v1": models_path.joinpath("resnet18_v1"), } for model, output_path in models.items(): main(model, output_path)
https://github.com/zk-ml/tachikoma
apps/android_deploy/app/src/main/java/org/apache/tvm/android/demo/MainActivity.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ package org.apache.tvm.android.demo; import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.SystemClock; import android.provider.MediaStore; import androidx.core.content.FileProvider; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Vector; import org.apache.tvm.Function; import org.apache.tvm.Module; import org.apache.tvm.NDArray; import org.apache.tvm.Device; import org.apache.tvm.TVMValue; import org.apache.tvm.TVMType; public class MainActivity extends AppCompatActivity { private static final String TAG = MainActivity.class.getSimpleName(); private static final int PERMISSIONS_REQUEST = 100; private static final int PICTURE_FROM_GALLERY = 101; private static final int PICTURE_FROM_CAMERA = 102; private static final int IMAGE_PREVIEW_WIDTH = 960; private static final int IMAGE_PREVIEW_HEIGHT = 720; // TVM constants private static final int OUTPUT_INDEX = 0; private static final int IMG_CHANNEL = 3; private static final String INPUT_NAME = "data"; // Configuration values for extraction model. Note that the graph, lib and params is not // included with TVM and must be manually placed in the assets/ directory by the user. // Graphs and models downloaded from https://github.com/pjreddie/darknet/blob/ may be // converted e.g. via define_and_compile_model.py. private static final boolean EXE_GPU = false; private static final int MODEL_INPUT_SIZE = 224; private static final String MODEL_CL_LIB_FILE = "file:///android_asset/deploy_lib_opencl.so"; private static final String MODEL_CPU_LIB_FILE = "file:///android_asset/deploy_lib_cpu.so"; private static final String MODEL_GRAPH_FILE = "file:///android_asset/deploy_graph.json"; private static final String MODEL_PARAM_FILE = "file:///android_asset/deploy_param.params"; private static final String MODEL_LABEL_FILE = "file:///android_asset/imagenet.shortnames.list"; private Uri mCameraImageUri; private ImageView mImageView; private TextView mResultView; private AssetManager assetManager; private Module graphExecutorModule; private Vector<String> labels = new Vector<String>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); assetManager = getAssets(); mImageView = (ImageView) findViewById(R.id.imageView); mResultView = (TextView) findViewById(R.id.resultTextView); findViewById(R.id.btnPickImage).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showPictureDialog(); } }); if (hasPermission()) { // instantiate tvm runtime and setup environment on background after application begin new LoadModleAsyncTask().execute(); } else { requestPermission(); } } /* Load precompiled model on TVM graph executor and init the system. */ private class LoadModleAsyncTask extends AsyncTask<Void, Void, Integer> { ProgressDialog dialog = new ProgressDialog(MainActivity.this); @Override protected Integer doInBackground(Void... args) { // load synset name String lableFilename = MODEL_LABEL_FILE.split("file:///android_asset/")[1]; Log.i(TAG, "Reading synset name from: " + lableFilename); try { String labelsContent = new String(getBytesFromFile(assetManager, lableFilename)); for (String line : labelsContent.split("\\r?\\n")) { labels.add(line); } } catch (IOException e) { Log.e(TAG, "Problem reading synset name file!" + e); return -1;//failure } // load json graph String modelGraph = null; String graphFilename = MODEL_GRAPH_FILE.split("file:///android_asset/")[1]; Log.i(TAG, "Reading json graph from: " + graphFilename); try { modelGraph = new String(getBytesFromFile(assetManager, graphFilename)); } catch (IOException e) { Log.e(TAG, "Problem reading json graph file!" + e); return -1;//failure } // upload tvm compiled function on application cache folder String libCacheFilePath = null; String libFilename = EXE_GPU ? MODEL_CL_LIB_FILE.split("file:///android_asset/")[1] : MODEL_CPU_LIB_FILE.split("file:///android_asset/")[1]; Log.i(TAG, "Uploading compiled function to cache folder"); try { libCacheFilePath = getTempLibFilePath(libFilename); byte[] modelLibByte = getBytesFromFile(assetManager, libFilename); FileOutputStream fos = new FileOutputStream(libCacheFilePath); fos.write(modelLibByte); fos.close(); } catch (IOException e) { Log.e(TAG, "Problem uploading compiled function!" + e); return -1;//failure } // load parameters byte[] modelParams = null; String paramFilename = MODEL_PARAM_FILE.split("file:///android_asset/")[1]; try { modelParams = getBytesFromFile(assetManager, paramFilename); } catch (IOException e) { Log.e(TAG, "Problem reading params file!" + e); return -1;//failure } // create java tvm device Device tvmDev = EXE_GPU ? Device.opencl() : Device.cpu(); // tvm module for compiled functions Module modelLib = Module.load(libCacheFilePath); // get global function module for graph executor Function runtimeCreFun = Function.getFunction("tvm.graph_executor.create"); TVMValue runtimeCreFunRes = runtimeCreFun.pushArg(modelGraph) .pushArg(modelLib) .pushArg(tvmDev.deviceType) .pushArg(tvmDev.deviceId) .invoke(); graphExecutorModule = runtimeCreFunRes.asModule(); // get the function from the module(load parameters) Function loadParamFunc = graphExecutorModule.getFunction("load_params"); loadParamFunc.pushArg(modelParams).invoke(); // release tvm local variables modelLib.release(); loadParamFunc.release(); runtimeCreFun.release(); return 0;//success } @Override protected void onPreExecute() { dialog.setCancelable(false); dialog.setMessage("Loading Model..."); dialog.show(); super.onPreExecute(); } @Override protected void onPostExecute(Integer status) { if (dialog != null && dialog.isShowing()) { dialog.dismiss(); } if (status != 0) { showDialog("Error", "Fail to initialized model, check compiled model"); } } } /* Execute prediction for processed decode input bitmap image content on TVM graph executor. */ private class ModelRunAsyncTask extends AsyncTask<Bitmap, Void, Integer> { ProgressDialog dialog = new ProgressDialog(MainActivity.this); @Override protected Integer doInBackground(Bitmap... bitmaps) { if (null != graphExecutorModule) { int count = bitmaps.length; for (int i = 0 ; i < count ; i++) { long processingTimeMs = SystemClock.uptimeMillis(); Log.i(TAG, "Decode JPEG image content"); // extract the jpeg content ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmaps[i].compress(Bitmap.CompressFormat.JPEG,100,stream); byte[] byteArray = stream.toByteArray(); Bitmap imageBitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); // crop input image at centre to model input size // commecial deploy note:: instead of cropying image do resize // image to model input size so we never lost the image content Bitmap cropImageBitmap = Bitmap.createBitmap(MODEL_INPUT_SIZE, MODEL_INPUT_SIZE, Bitmap.Config.ARGB_8888); Matrix frameToCropTransform = getTransformationMatrix(imageBitmap.getWidth(), imageBitmap.getHeight(), MODEL_INPUT_SIZE, MODEL_INPUT_SIZE, 0, true); Canvas canvas = new Canvas(cropImageBitmap); canvas.drawBitmap(imageBitmap, frameToCropTransform, null); // image pixel int values int[] pixelValues = new int[MODEL_INPUT_SIZE * MODEL_INPUT_SIZE]; // image RGB float values float[] imgRgbValues = new float[MODEL_INPUT_SIZE * MODEL_INPUT_SIZE * IMG_CHANNEL]; // image RGB transpose float values float[] imgRgbTranValues = new float[MODEL_INPUT_SIZE * MODEL_INPUT_SIZE * IMG_CHANNEL]; // pre-process the image data from 0-255 int to normalized float based on the // provided parameters. cropImageBitmap.getPixels(pixelValues, 0, MODEL_INPUT_SIZE, 0, 0, MODEL_INPUT_SIZE, MODEL_INPUT_SIZE); for (int j = 0; j < pixelValues.length; ++j) { imgRgbValues[j * 3 + 0] = ((pixelValues[j] >> 16) & 0xFF)/255.0f; imgRgbValues[j * 3 + 1] = ((pixelValues[j] >> 8) & 0xFF)/255.0f; imgRgbValues[j * 3 + 2] = (pixelValues[j] & 0xFF)/255.0f; } // pre-process the image rgb data transpose based on the provided parameters. for (int k = 0; k < IMG_CHANNEL; ++k) { for (int l = 0; l < MODEL_INPUT_SIZE; ++l) { for (int m = 0; m < MODEL_INPUT_SIZE; ++m) { int dst_index = m + MODEL_INPUT_SIZE*l + MODEL_INPUT_SIZE*MODEL_INPUT_SIZE*k; int src_index = k + IMG_CHANNEL*m + IMG_CHANNEL*MODEL_INPUT_SIZE*l; imgRgbTranValues[dst_index] = imgRgbValues[src_index]; } } } // get the function from the module(set input data) Log.i(TAG, "set input data"); NDArray inputNdArray = NDArray.empty(new long[]{1, IMG_CHANNEL, MODEL_INPUT_SIZE, MODEL_INPUT_SIZE}, new TVMType("float32"));; inputNdArray.copyFrom(imgRgbTranValues); Function setInputFunc = graphExecutorModule.getFunction("set_input"); setInputFunc.pushArg(INPUT_NAME).pushArg(inputNdArray).invoke(); // release tvm local variables inputNdArray.release(); setInputFunc.release(); // get the function from the module(run it) Log.i(TAG, "run function on target"); Function runFunc = graphExecutorModule.getFunction("run"); runFunc.invoke(); // release tvm local variables runFunc.release(); // get the function from the module(get output data) Log.i(TAG, "get output data"); NDArray outputNdArray = NDArray.empty(new long[]{1, 1000}, new TVMType("float32")); Function getOutputFunc = graphExecutorModule.getFunction("get_output"); getOutputFunc.pushArg(OUTPUT_INDEX).pushArg(outputNdArray).invoke(); float[] output = outputNdArray.asFloatArray(); // release tvm local variables outputNdArray.release(); getOutputFunc.release(); // display the result from extracted output data if (null != output) { int maxPosition = -1; float maxValue = 0; for (int j = 0; j < output.length; ++j) { if (output[j] > maxValue) { maxValue = output[j]; maxPosition = j; } } processingTimeMs = SystemClock.uptimeMillis() - processingTimeMs; String label = "Prediction Result : "; label += labels.size() > maxPosition ? labels.get(maxPosition) : "unknown"; label += "\nPrediction Time : " + processingTimeMs + "ms"; mResultView.setText(label); } Log.i(TAG, "prediction finished"); } return 0; } return -1; } @Override protected void onPreExecute() { dialog.setCancelable(false); dialog.setMessage("Prediction running on image..."); dialog.show(); super.onPreExecute(); } @Override protected void onPostExecute(Integer status) { if (dialog != null && dialog.isShowing()) { dialog.dismiss(); } if (status != 0) { showDialog("Error", "Fail to predict image, GraphExecutor exception"); } } } @Override protected void onDestroy() { // release tvm local variables if (null != graphExecutorModule) graphExecutorModule.release(); super.onDestroy(); } /** * Read file from assets and return byte array. * * @param assets The asset manager to be used to load assets. * @param fileName The filepath of read file. * @return byte[] file content * @throws IOException */ private byte[] getBytesFromFile(AssetManager assets, String fileName) throws IOException { InputStream is = assets.open(fileName); int length = is.available(); byte[] bytes = new byte[length]; // Read in the bytes int offset = 0; int numRead = 0; try { while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; } } finally { is.close(); } // Ensure all the bytes have been read in if (offset < bytes.length) { throw new IOException("Could not completely read file " + fileName); } return bytes; } /** * Dialog show pick option for select image from Gallery or Camera. */ private void showPictureDialog(){ AlertDialog.Builder pictureDialog = new AlertDialog.Builder(this); pictureDialog.setTitle("Select Action"); String[] pictureDialogItems = { "Select photo from gallery", "Capture photo from camera" }; pictureDialog.setItems(pictureDialogItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: choosePhotoFromGallery(); break; case 1: takePhotoFromCamera(); break; } } }); pictureDialog.show(); } /** * Request to pick image from Gallery. */ public void choosePhotoFromGallery() { Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, PICTURE_FROM_GALLERY); } /** * Request to capture image from Camera. */ private void takePhotoFromCamera() { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { mCameraImageUri = Uri.fromFile(createImageFile()); } else { File file = new File(createImageFile().getPath()); mCameraImageUri = FileProvider.getUriForFile(getApplicationContext(), getApplicationContext().getPackageName() + ".provider", file); } intent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraImageUri); startActivityForResult(intent, PICTURE_FROM_CAMERA); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == this.RESULT_CANCELED) { return; } Uri contentURI = null; if (requestCode == PICTURE_FROM_GALLERY) { if (data != null) { contentURI = data.getData(); } } else if (requestCode == PICTURE_FROM_CAMERA) { contentURI = mCameraImageUri; } if (null != contentURI) { try { Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), contentURI); Bitmap scaled = Bitmap.createScaledBitmap(bitmap, IMAGE_PREVIEW_HEIGHT, IMAGE_PREVIEW_WIDTH, true); mImageView.setImageBitmap(scaled); new ModelRunAsyncTask().execute(scaled); } catch (IOException e) { e.printStackTrace(); } } } /** * Get application cache path where to place compiled functions. * * @param fileName library file name. * @return String application cache folder path * @throws IOException */ private final String getTempLibFilePath(String fileName) throws IOException { File tempDir = File.createTempFile("tvm4j_demo_", ""); if (!tempDir.delete() || !tempDir.mkdir()) { throw new IOException("Couldn't create directory " + tempDir.getAbsolutePath()); } return (tempDir + File.separator + fileName); } /** * Create image file under storage where camera application save captured image. * * @return File image file under sdcard where camera can save image */ private File createImageFile() { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES); try { File image = File.createTempFile( imageFileName, // prefix ".jpg", // suffix storageDir // directory ); return image; } catch (IOException e) { e.printStackTrace(); } return null; } /** * Show dialog to user. * * @param title dialog display title * @param msg dialog display message */ private void showDialog(String title, String msg) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); builder.setMessage(msg); builder.setCancelable(true); builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); finish(); } }); builder.create().show(); } @Override public void onRequestPermissionsResult (final int requestCode, final String[] permissions, final int[] grantResults){ super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == PERMISSIONS_REQUEST) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) { // instantiate tvm runtime and setup environment on background after application begin new LoadModleAsyncTask().execute(); } else { requestPermission(); } } } /** * Whether application has required mandatory permissions to run. */ private boolean hasPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; } else { return true; } } /** * Request required mandatory permission for application to run. */ private void requestPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (shouldShowRequestPermissionRationale(Manifest.permission.CAMERA) || shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { Toast.makeText(this, "Camera AND storage permission are required for this demo", Toast.LENGTH_LONG).show(); } requestPermissions(new String[] {Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST); } } /** * Returns a transformation matrix from one reference frame into another. * Handles cropping (if maintaining aspect ratio is desired) and rotation. * * @param srcWidth Width of source frame. * @param srcHeight Height of source frame. * @param dstWidth Width of destination frame. * @param dstHeight Height of destination frame. * @param applyRotation Amount of rotation to apply from one frame to another. * Must be a multiple of 90. * @param maintainAspectRatio If true, will ensure that scaling in x and y remains constant, * cropping the image if necessary. * @return The transformation fulfilling the desired requirements. */ public static Matrix getTransformationMatrix( final int srcWidth, final int srcHeight, final int dstWidth, final int dstHeight, final int applyRotation, final boolean maintainAspectRatio) { final Matrix matrix = new Matrix(); if (applyRotation != 0) { if (applyRotation % 90 != 0) { Log.w(TAG, "Rotation of %d % 90 != 0 " + applyRotation); } // Translate so center of image is at origin. matrix.postTranslate(-srcWidth / 2.0f, -srcHeight / 2.0f); // Rotate around origin. matrix.postRotate(applyRotation); } // Account for the already applied rotation, if any, and then determine how // much scaling is needed for each axis. final boolean transpose = (Math.abs(applyRotation) + 90) % 180 == 0; final int inWidth = transpose ? srcHeight : srcWidth; final int inHeight = transpose ? srcWidth : srcHeight; // Apply scaling if necessary. if (inWidth != dstWidth || inHeight != dstHeight) { final float scaleFactorX = dstWidth / (float) inWidth; final float scaleFactorY = dstHeight / (float) inHeight; if (maintainAspectRatio) { // Scale by minimum factor so that dst is filled completely while // maintaining the aspect ratio. Some image may fall off the edge. final float scaleFactor = Math.max(scaleFactorX, scaleFactorY); matrix.postScale(scaleFactor, scaleFactor); } else { // Scale exactly to fill dst from src. matrix.postScale(scaleFactorX, scaleFactorY); } } if (applyRotation != 0) { // Translate back from origin centered reference to destination frame. matrix.postTranslate(dstWidth / 2.0f, dstHeight / 2.0f); } return matrix; } }
https://github.com/zk-ml/tachikoma
apps/android_deploy/app/src/main/jni/tvm_runtime.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file tvm_runtime.h * \brief Pack all tvm runtime source files */ #include <sys/stat.h> #include <fstream> #define DMLC_USE_LOGGING_LIBRARY <tvm/runtime/logging.h> #define TVM_USE_LIBBACKTRACE 0 #include "../src/runtime/c_runtime_api.cc" #include "../src/runtime/cpu_device_api.cc" #include "../src/runtime/dso_library.cc" #include "../src/runtime/file_utils.cc" #include "../src/runtime/graph_executor/graph_executor.cc" #include "../src/runtime/library_module.cc" #include "../src/runtime/logging.cc" #include "../src/runtime/module.cc" #include "../src/runtime/ndarray.cc" #include "../src/runtime/object.cc" #include "../src/runtime/registry.cc" #include "../src/runtime/system_library.cc" #include "../src/runtime/thread_pool.cc" #include "../src/runtime/threading_backend.cc" #include "../src/runtime/workspace_pool.cc" #ifdef TVM_OPENCL_RUNTIME #include "../src/runtime/opencl/opencl_device_api.cc" #include "../src/runtime/opencl/opencl_module.cc" #endif
https://github.com/zk-ml/tachikoma
apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/MainActivity.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ package org.apache.tvm.tvmrpc; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import android.widget.CompoundButton; import android.widget.EditText; import androidx.appcompat.widget.SwitchCompat; import android.content.Intent; public class MainActivity extends AppCompatActivity { // wait time before automatic restart of RPC Activity public static final int HANDLER_RESTART_DELAY = 5000; private void showDialog(String title, String msg) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); builder.setMessage(msg); builder.setCancelable(true); builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.create().show(); } public Intent updateRPCPrefs() { System.err.println("updating preferences..."); EditText edProxyAddress = findViewById(R.id.input_address); EditText edProxyPort = findViewById(R.id.input_port); EditText edAppKey = findViewById(R.id.input_key); SwitchCompat inputSwitch = findViewById(R.id.switch_persistent); final String proxyHost = edProxyAddress.getText().toString(); final int proxyPort = Integer.parseInt(edProxyPort.getText().toString()); final String key = edAppKey.getText().toString(); final boolean isChecked = inputSwitch.isChecked(); SharedPreferences pref = getApplicationContext().getSharedPreferences("RPCProxyPreference", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.putString("input_address", proxyHost); editor.putString("input_port", edProxyPort.getText().toString()); editor.putString("input_key", key); editor.putBoolean("input_switch", isChecked); editor.commit(); Intent intent = new Intent(this, RPCActivity.class); intent.putExtra("host", proxyHost); intent.putExtra("port", proxyPort); intent.putExtra("key", key); return intent; } private void setupRelaunch() { final Context context = this; final SwitchCompat switchPersistent = findViewById(R.id.switch_persistent); final Runnable rPCStarter = new Runnable() { public void run() { if (switchPersistent.isChecked()) { System.err.println("relaunching RPC activity..."); Intent intent = ((MainActivity) context).updateRPCPrefs(); startActivity(intent); } } }; Handler handler = new Handler(Looper.getMainLooper()); handler.postDelayed(rPCStarter, HANDLER_RESTART_DELAY); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); final Context context = this; SwitchCompat switchPersistent = findViewById(R.id.switch_persistent); switchPersistent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { System.err.println("automatic RPC restart enabled..."); updateRPCPrefs(); setupRelaunch(); } else { System.err.println("automatic RPC restart disabled..."); updateRPCPrefs(); } } }); enableInputView(true); } @Override protected void onResume() { System.err.println("MainActivity onResume..."); enableInputView(true); setupRelaunch(); super.onResume(); } @Override protected void onDestroy() { super.onDestroy(); } private void enableInputView(boolean enable) { EditText edProxyAddress = findViewById(R.id.input_address); EditText edProxyPort = findViewById(R.id.input_port); EditText edAppKey = findViewById(R.id.input_key); SwitchCompat input_switch = findViewById(R.id.switch_persistent); edProxyAddress.setEnabled(enable); edProxyPort.setEnabled(enable); edAppKey.setEnabled(enable); if (enable) { SharedPreferences pref = getApplicationContext().getSharedPreferences("RPCProxyPreference", Context.MODE_PRIVATE); String inputAddress = pref.getString("input_address", null); if (null != inputAddress) edProxyAddress.setText(inputAddress); String inputPort = pref.getString("input_port", null); if (null != inputPort) edProxyPort.setText(inputPort); String inputKey = pref.getString("input_key", null); if (null != inputKey) edAppKey.setText(inputKey); boolean isChecked = pref.getBoolean("input_switch", false); input_switch.setChecked(isChecked); } } }
https://github.com/zk-ml/tachikoma
apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCActivity.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ package org.apache.tvm.tvmrpc; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.widget.Button; import android.view.View; public class RPCActivity extends AppCompatActivity { private RPCProcessor tvmServerWorker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rpc); Button stopRPC = findViewById(R.id.button_stop_rpc); stopRPC.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { System.err.println(tvmServerWorker == null); if (tvmServerWorker != null) { // currently will raise a socket closed exception tvmServerWorker.disconnect(); } finish(); // prevent Android from recycling the process System.exit(0); } }); System.err.println("rpc activity onCreate..."); Intent intent = getIntent(); String host = intent.getStringExtra("host"); int port = intent.getIntExtra("port", 9090); String key = intent.getStringExtra("key"); tvmServerWorker = new RPCProcessor(this); tvmServerWorker.setDaemon(true); tvmServerWorker.start(); tvmServerWorker.connect(host, port, key); } @Override protected void onDestroy() { System.err.println("rpc activity onDestroy"); tvmServerWorker.disconnect(); super.onDestroy(); android.os.Process.killProcess(android.os.Process.myPid()); } }
https://github.com/zk-ml/tachikoma
apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCAndroidWatchdog.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ package org.apache.tvm.tvmrpc; import android.app.Activity; import org.apache.tvm.rpc.RPCWatchdog; /** * Watchdog for Android RPC. */ public class RPCAndroidWatchdog extends RPCWatchdog { public Activity rpc_activity = null; public RPCAndroidWatchdog(Activity activity) { super(); rpc_activity = activity; } /** * Method to non-destructively terminate the running thread on Android */ @Override protected void terminate() { rpc_activity.finish(); } }
https://github.com/zk-ml/tachikoma
apps/android_rpc/app/src/main/java/org/apache/tvm/tvmrpc/RPCProcessor.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ package org.apache.tvm.tvmrpc; import android.app.Activity; import android.os.ParcelFileDescriptor; import java.net.Socket; import org.apache.tvm.rpc.ConnectTrackerServerProcessor; /** * Connect to RPC proxy and deal with requests. */ class RPCProcessor extends Thread { private String host; private int port; private String key; private boolean running = false; private long startTime; private ConnectTrackerServerProcessor currProcessor; private boolean first = true; private Activity rpc_activity = null; public RPCProcessor(Activity activity) { super(); rpc_activity = activity; } @Override public void run() { RPCAndroidWatchdog watchdog = new RPCAndroidWatchdog(rpc_activity); watchdog.start(); while (true) { synchronized (this) { currProcessor = null; while (!running) { try { this.wait(); } catch (InterruptedException e) { } } try { currProcessor = new ConnectTrackerServerProcessor(host, port, key, watchdog); } catch (Throwable e) { e.printStackTrace(); // kill if creating a new processor failed System.exit(0); } } if (currProcessor != null) currProcessor.run(); watchdog.finishTimeout(); } } /** * Disconnect from the proxy server. */ synchronized void disconnect() { if (running) { running = false; if (currProcessor != null) { currProcessor.terminate(); } } } /** * Start rpc processor and connect to the proxy server. * @param host proxy server host. * @param port proxy server port. * @param key proxy server key. */ synchronized void connect(String host, int port, String key) { this.host = host; this.port = port; this.key = key; running = true; this.notify(); } }
https://github.com/zk-ml/tachikoma
apps/android_rpc/app/src/main/jni/tvm_runtime.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file tvm_runtime.h * \brief Pack all tvm runtime source files */ #include <sys/stat.h> #include <fstream> #define DMLC_USE_LOGGING_LIBRARY <tvm/runtime/logging.h> #define TVM_USE_LIBBACKTRACE 0 /* Enable custom logging - this will cause TVM to use a custom implementation * of tvm::runtime::detail::LogMessage. We use this to pass TVM log messages to * Android logcat. */ #define TVM_LOG_CUSTOMIZE 1 #include "../src/runtime/c_runtime_api.cc" #include "../src/runtime/container.cc" #include "../src/runtime/cpu_device_api.cc" #include "../src/runtime/dso_library.cc" #include "../src/runtime/file_utils.cc" #include "../src/runtime/graph_executor/graph_executor.cc" #include "../src/runtime/graph_executor/graph_executor_factory.cc" #include "../src/runtime/library_module.cc" #include "../src/runtime/logging.cc" #include "../src/runtime/minrpc/minrpc_logger.cc" #include "../src/runtime/module.cc" #include "../src/runtime/ndarray.cc" #include "../src/runtime/object.cc" #include "../src/runtime/profiling.cc" #include "../src/runtime/registry.cc" #include "../src/runtime/rpc/rpc_channel.cc" #include "../src/runtime/rpc/rpc_endpoint.cc" #include "../src/runtime/rpc/rpc_event_impl.cc" #include "../src/runtime/rpc/rpc_local_session.cc" #include "../src/runtime/rpc/rpc_module.cc" #include "../src/runtime/rpc/rpc_server_env.cc" #include "../src/runtime/rpc/rpc_session.cc" #include "../src/runtime/rpc/rpc_socket_impl.cc" #include "../src/runtime/system_library.cc" #include "../src/runtime/thread_pool.cc" #include "../src/runtime/threading_backend.cc" #include "../src/runtime/workspace_pool.cc" #ifdef TVM_OPENCL_RUNTIME #include "../src/runtime/opencl/opencl_device_api.cc" #include "../src/runtime/opencl/opencl_module.cc" #include "../src/runtime/opencl/texture_pool.cc" #include "../src/runtime/source_utils.cc" #endif #ifdef TVM_VULKAN_RUNTIME #include "../src/runtime/vulkan/vulkan_buffer.cc" #include "../src/runtime/vulkan/vulkan_common.cc" #include "../src/runtime/vulkan/vulkan_device.cc" #include "../src/runtime/vulkan/vulkan_device_api.cc" #include "../src/runtime/vulkan/vulkan_instance.cc" #include "../src/runtime/vulkan/vulkan_module.cc" #include "../src/runtime/vulkan/vulkan_stream.cc" #include "../src/runtime/vulkan/vulkan_wrapped_func.cc" #endif #ifdef USE_SORT #include "../src/runtime/contrib/sort/sort.cc" #endif #ifdef USE_RANDOM #include "../src/runtime/contrib/random/random.cc" #endif #include <android/log.h> namespace tvm { namespace runtime { namespace detail { // Override logging mechanism [[noreturn]] void LogFatalImpl(const std::string& file, int lineno, const std::string& message) { std::string m = file + ":" + std::to_string(lineno) + ": " + message; __android_log_write(ANDROID_LOG_FATAL, "TVM_RUNTIME", m.c_str()); throw InternalError(file, lineno, message); } void LogMessageImpl(const std::string& file, int lineno, int level, const std::string& message) { std::string m = file + ":" + std::to_string(lineno) + ": " + message; __android_log_write(ANDROID_LOG_DEBUG + level, "TVM_RUNTIME", m.c_str()); } } // namespace detail } // namespace runtime } // namespace tvm
https://github.com/zk-ml/tachikoma
apps/android_rpc/tests/android_rpc_test.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Testcode for Android RPC. To use it, start an RPC tracker with "python -m tvm.exec.rpc_tracker". Use the tracker's address and port when configuring the RPC app. Use "android" as the key if you wish to avoid modifying this script. """ import tvm from tvm import te import os from tvm import rpc from tvm.contrib import utils, ndk import numpy as np # Set to be address of tvm proxy. tracker_host = os.environ["TVM_TRACKER_HOST"] tracker_port = int(os.environ["TVM_TRACKER_PORT"]) key = "android" # Change target configuration. # Run `adb shell cat /proc/cpuinfo` to find the arch. arch = "arm64" target = "llvm -mtriple=%s-linux-android" % arch # whether enable to execute test on OpenCL target test_opencl = False # whether enable to execute test on Vulkan target test_vulkan = False def test_rpc_module(): # graph n = tvm.runtime.convert(1024) A = te.placeholder((n,), name="A") B = te.compute(A.shape, lambda *i: A(*i) + 1.0, name="B") a_np = np.random.uniform(size=1024).astype(A.dtype) temp = utils.tempdir() # Establish remote connection with target hardware tracker = rpc.connect_tracker(tracker_host, tracker_port) remote = tracker.request(key, priority=0, session_timeout=60) # Compile the Graph for CPU target s = te.create_schedule(B.op) xo, xi = s[B].split(B.op.axis[0], factor=64) s[B].parallel(xi) s[B].pragma(xo, "parallel_launch_point") s[B].pragma(xi, "parallel_barrier_when_finish") f = tvm.build(s, [A, B], target, name="myadd_cpu") path_dso_cpu = temp.relpath("cpu_lib.so") f.export_library(path_dso_cpu, ndk.create_shared) # Execute the portable graph on cpu target print("Run CPU test ...") dev = remote.cpu(0) remote.upload(path_dso_cpu) f2 = remote.load_module("cpu_lib.so") a = tvm.nd.array(a_np, dev) b = tvm.nd.array(np.zeros(1024, dtype=A.dtype), dev) time_f = f2.time_evaluator(f2.entry_name, dev, number=10) cost = time_f(a, b).mean print("%g secs/op\n" % cost) np.testing.assert_equal(b.numpy(), a.numpy() + 1) # Compile the Graph for OpenCL target if test_opencl: s = te.create_schedule(B.op) xo, xi = s[B].split(B.op.axis[0], factor=64) s[B].bind(xi, te.thread_axis("threadIdx.x")) s[B].bind(xo, te.thread_axis("blockIdx.x")) # Build the dynamic lib. # If we don't want to do metal and only use cpu, just set target to be target f = tvm.build(s, [A, B], tvm.target.Target("opencl", host=target), name="myadd") path_dso_cl = temp.relpath("dev_lib_cl.so") f.export_library(path_dso_cl, ndk.create_shared) print("Run GPU(OpenCL Flavor) test ...") dev = remote.cl(0) remote.upload(path_dso_cl) f1 = remote.load_module("dev_lib_cl.so") a = tvm.nd.array(a_np, dev) b = tvm.nd.array(np.zeros(1024, dtype=A.dtype), dev) time_f = f1.time_evaluator(f1.entry_name, dev, number=10) cost = time_f(a, b).mean print("%g secs/op\n" % cost) np.testing.assert_equal(b.numpy(), a.numpy() + 1) # Compile the Graph for Vulkan target if test_vulkan: s = te.create_schedule(B.op) xo, xi = s[B].split(B.op.axis[0], factor=64) s[B].bind(xi, te.thread_axis("threadIdx.x")) s[B].bind(xo, te.thread_axis("blockIdx.x")) # Build the dynamic lib. # If we don't want to do metal and only use cpu, just set target to be target f = tvm.build(s, [A, B], tvm.target.Target("vulkan", host=target), name="myadd") path_dso_vulkan = temp.relpath("dev_lib_vulkan.so") f.export_library(path_dso_vulkan, ndk.create_shared) print("Run GPU(Vulkan Flavor) test ...") dev = remote.vulkan(0) remote.upload(path_dso_vulkan) f1 = remote.load_module("dev_lib_vulkan.so") a = tvm.nd.array(a_np, dev) b = tvm.nd.array(np.zeros(1024, dtype=A.dtype), dev) time_f = f1.time_evaluator(f1.entry_name, dev, number=10) cost = time_f(a, b).mean print("%g secs/op\n" % cost) np.testing.assert_equal(b.numpy(), a.numpy() + 1) if __name__ == "__main__": test_rpc_module()
https://github.com/zk-ml/tachikoma
apps/benchmark/arm_cpu_imagenet_bench.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Benchmark script for ImageNet models on ARM CPU. see README.md for the usage and results of this script. """ import argparse import numpy as np import tvm from tvm import te from tvm.contrib.utils import tempdir import tvm.contrib.graph_executor as runtime from tvm import relay from util import get_network, print_progress def evaluate_network(network, target, target_host, repeat): # connect to remote device tracker = tvm.rpc.connect_tracker(args.host, args.port) remote = tracker.request(args.rpc_key) print_progress(network) net, params, input_shape, output_shape = get_network(network, batch_size=1) print_progress("%-20s building..." % network) with tvm.transform.PassContext(opt_level=3): lib = relay.build(net, target=tvm.target.Target(target, host=target_host), params=params) tmp = tempdir() if "android" in str(target): from tvm.contrib import ndk filename = "%s.so" % network lib.export_library(tmp.relpath(filename), ndk.create_shared) else: filename = "%s.tar" % network lib.export_library(tmp.relpath(filename)) # upload library and params print_progress("%-20s uploading..." % network) dev = remote.device(str(target), 0) remote.upload(tmp.relpath(filename)) rlib = remote.load_module(filename) module = runtime.GraphModule(rlib["default"](dev)) data_tvm = tvm.nd.array((np.random.uniform(size=input_shape)).astype(dtype)) module.set_input("data", data_tvm) # evaluate print_progress("%-20s evaluating..." % network) ftimer = module.module.time_evaluator("run", dev, number=1, repeat=repeat) prof_res = np.array(ftimer().results) * 1000 # multiply 1000 for converting to millisecond print( "%-20s %-19s (%s)" % (network, "%.2f ms" % np.mean(prof_res), "%.2f ms" % np.std(prof_res)) ) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--network", type=str, choices=[ "resnet-18", "resnet-34", "resnet-50", "vgg-16", "vgg-19", "densenet-121", "inception_v3", "mobilenet", "squeezenet_v1.0", "squeezenet_v1.1", ], help="The name of neural network", ) parser.add_argument( "--model", type=str, choices=["rk3399", "mate10", "mate10pro", "p20", "p20pro", "pixel2", "rasp3b", "pynq"], default="rk3399", help="The model of the test device. If your device is not listed in " "the choices list, pick the most similar one as argument.", ) parser.add_argument("--host", type=str, default="127.0.0.1") parser.add_argument("--port", type=int, default=9190) parser.add_argument("--rpc-key", type=str, required=True) parser.add_argument("--repeat", type=int, default=10) args = parser.parse_args() dtype = "float32" if args.network is None: networks = ["squeezenet_v1.1", "mobilenet", "resnet-18", "vgg-16"] else: networks = [args.network] target = tvm.target.arm_cpu(model=args.model) target_host = None print("--------------------------------------------------") print("%-20s %-20s" % ("Network Name", "Mean Inference Time (std dev)")) print("--------------------------------------------------") for network in networks: evaluate_network(network, target, target_host, args.repeat)
https://github.com/zk-ml/tachikoma
apps/benchmark/gpu_imagenet_bench.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Benchmark script for ImageNet models on GPU. see README.md for the usage and results of this script. """ import argparse import threading import numpy as np import tvm from tvm import te import tvm.contrib.graph_executor as runtime from tvm import relay from util import get_network def benchmark(network, target): net, params, input_shape, output_shape = get_network(network, batch_size=1) with tvm.transform.PassContext(opt_level=3): lib = relay.build(net, target=target, params=params) # create runtime dev = tvm.device(str(target), 0) module = runtime.GraphModule(lib["default"](dev)) data_tvm = tvm.nd.array((np.random.uniform(size=input_shape)).astype(dtype)) module.set_input("data", data_tvm) # evaluate ftimer = module.module.time_evaluator("run", dev, number=1, repeat=args.repeat) prof_res = np.array(ftimer().results) * 1000 # multiply 1000 for converting to millisecond print( "%-20s %-19s (%s)" % (network, "%.2f ms" % np.mean(prof_res), "%.2f ms" % np.std(prof_res)) ) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--network", type=str, choices=[ "resnet-18", "resnet-34", "resnet-50", "vgg-16", "vgg-19", "densenet-121", "inception_v3", "mobilenet", "squeezenet_v1.0", "squeezenet_v1.1", ], help="The name of neural network", ) parser.add_argument( "--device", type=str, choices=["amd_apu"], default="amd_apu", help="The name of the test device. If your device is not listed in " "the choices list, pick the most similar one as argument.", ) parser.add_argument( "--model", type=str, choices=["1080ti", "titanx", "tx2", "gfx900", "v1000"], default="1080ti", help="The model of the test device. If your device is not listed in " "the choices list, pick the most similar one as argument.", ) parser.add_argument("--repeat", type=int, default=600) parser.add_argument( "--target", type=str, choices=["cuda", "opencl", "rocm", "nvptx", "metal", "vulkan"], default="cuda", help="The tvm compilation target", ) parser.add_argument("--thread", type=int, default=1, help="The number of threads to be run.") args = parser.parse_args() dtype = "float32" if args.network is None: networks = ["resnet-50", "mobilenet", "vgg-19", "inception_v3"] else: networks = [args.network] target = tvm.target.Target("%s -device=%s -model=%s" % (args.target, args.device, args.model)) print("--------------------------------------------------") print("%-20s %-20s" % ("Network Name", "Mean Inference Time (std dev)")) print("--------------------------------------------------") for network in networks: if args.thread == 1: benchmark(network, target) else: threads = list() for n in range(args.thread): thread = threading.Thread( target=benchmark, args=([network, target]), name="thread%d" % n ) threads.append(thread) for thread in threads: thread.start() for thread in threads: thread.join()
https://github.com/zk-ml/tachikoma
apps/benchmark/mobile_gpu_imagenet_bench.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Benchmark script for ImageNet models on mobile GPU. see README.md for the usage and results of this script. """ import argparse import numpy as np import tvm from tvm import te from tvm.contrib.utils import tempdir import tvm.contrib.graph_executor as runtime from tvm import relay from util import get_network, print_progress def evaluate_network(network, target, target_host, dtype, repeat): # connect to remote device tracker = tvm.rpc.connect_tracker(args.host, args.port) remote = tracker.request(args.rpc_key) print_progress(network) net, params, input_shape, output_shape = get_network(network, batch_size=1, dtype=dtype) print_progress("%-20s building..." % network) with tvm.transform.PassContext(opt_level=3): lib = relay.build(net, target=tvm.target.Target(target, host=target_host), params=params) tmp = tempdir() if "android" in str(target) or "android" in str(target_host): from tvm.contrib import ndk filename = "%s.so" % network lib.export_library(tmp.relpath(filename), ndk.create_shared) else: filename = "%s.tar" % network lib.export_library(tmp.relpath(filename)) # upload library and params print_progress("%-20s uploading..." % network) dev = remote.device(str(target), 0) remote.upload(tmp.relpath(filename)) rlib = remote.load_module(filename) module = runtime.GraphModule(rlib["default"](dev)) data_tvm = tvm.nd.array((np.random.uniform(size=input_shape)).astype(dtype)) module.set_input("data", data_tvm) # evaluate print_progress("%-20s evaluating..." % network) ftimer = module.module.time_evaluator("run", dev, number=1, repeat=repeat) prof_res = np.array(ftimer().results) * 1000 # multiply 1000 for converting to millisecond print( "%-20s %-19s (%s)" % (network, "%.2f ms" % np.mean(prof_res), "%.2f ms" % np.std(prof_res)) ) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--network", type=str, choices=[ "resnet-18", "resnet-34", "resnet-50", "vgg-16", "vgg-19", "densenet-121", "inception_v3", "mobilenet", "squeezenet_v1.0", "squeezenet_v1.1", ], help="The name of neural network", ) parser.add_argument( "--model", type=str, choices=["rk3399"], default="rk3399", help="The model of the test device. If your device is not listed in " "the choices list, pick the most similar one as argument.", ) parser.add_argument("--host", type=str, default="127.0.0.1") parser.add_argument("--port", type=int, default=9190) parser.add_argument("--rpc-key", type=str, required=True) parser.add_argument("--repeat", type=int, default=30) parser.add_argument("--dtype", type=str, default="float32") args = parser.parse_args() if args.network is None: networks = ["squeezenet_v1.1", "mobilenet", "resnet-18", "vgg-16"] else: networks = [args.network] target = tvm.target.mali(model=args.model) target_host = tvm.target.arm_cpu(model=args.model) print("--------------------------------------------------") print("%-20s %-20s" % ("Network Name", "Mean Inference Time (std dev)")) print("--------------------------------------------------") for network in networks: evaluate_network(network, target, target_host, args.dtype, args.repeat)
https://github.com/zk-ml/tachikoma
apps/benchmark/util.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Utility for benchmark""" import sys from tvm import relay from tvm.relay import testing def get_network(name, batch_size, dtype="float32"): """Get the symbol definition and random weight of a network Parameters ---------- name: str The name of the network, can be 'resnet-18', 'resnet-50', 'vgg-16', 'inception_v3', 'mobilenet', ... batch_size: int batch size dtype: str Data type Returns ------- net: tvm.IRModule The relay function of network definition params: dict The random parameters for benchmark input_shape: tuple The shape of input tensor output_shape: tuple The shape of output tensor """ input_shape = (batch_size, 3, 224, 224) output_shape = (batch_size, 1000) if name == "mobilenet": net, params = testing.mobilenet.get_workload(batch_size=batch_size, dtype=dtype) elif name == "inception_v3": input_shape = (batch_size, 3, 299, 299) net, params = testing.inception_v3.get_workload(batch_size=batch_size, dtype=dtype) elif "resnet" in name: n_layer = int(name.split("-")[1]) net, params = testing.resnet.get_workload( num_layers=n_layer, batch_size=batch_size, dtype=dtype ) elif "vgg" in name: n_layer = int(name.split("-")[1]) net, params = testing.vgg.get_workload( num_layers=n_layer, batch_size=batch_size, dtype=dtype ) elif "densenet" in name: n_layer = int(name.split("-")[1]) net, params = testing.densenet.get_workload( densenet_size=n_layer, batch_size=batch_size, dtype=dtype ) elif "squeezenet" in name: version = name.split("_v")[1] net, params = testing.squeezenet.get_workload( batch_size=batch_size, version=version, dtype=dtype ) elif name == "mxnet": # an example for mxnet model from mxnet.gluon.model_zoo.vision import get_model block = get_model("resnet18_v1", pretrained=True) net, params = relay.frontend.from_mxnet(block, shape={"data": input_shape}, dtype=dtype) net = net["main"] net = relay.Function( net.params, relay.nn.softmax(net.body), None, net.type_params, net.attrs ) net = tvm.IRModule.from_expr(net) else: raise ValueError("Unsupported network: " + name) return net, params, input_shape, output_shape def print_progress(msg): """print progress message Parameters ---------- msg: str The message to print """ sys.stdout.write(msg + "\r") sys.stdout.flush()
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/backtrace.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ #define _GNU_SOURCE #include "backtrace.h" #include <dlfcn.h> #include <execinfo.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> const char* g_argv0 = NULL; void tvm_platform_abort_backtrace() { void* trace[200]; int nptrs = backtrace(trace, sizeof(trace) / sizeof(void*)); fprintf(stderr, "backtrace: %d\n", nptrs); if (nptrs < 0) { perror("backtracing"); } else { backtrace_symbols_fd(trace, nptrs, STDOUT_FILENO); char cmd_buf[1024]; for (int i = 0; i < nptrs; i++) { Dl_info info; if (dladdr(trace[i], &info)) { fprintf(stderr, "symbol %d: %s %s %p (%p)\n", i, info.dli_sname, info.dli_fname, info.dli_fbase, (void*)(trace[i] - info.dli_fbase)); snprintf(cmd_buf, sizeof(cmd_buf), "addr2line --exe=%s -p -i -a -f %p", g_argv0, (void*)(trace[i] - info.dli_fbase)); int result = system(cmd_buf); if (result < 0) { perror("invoking backtrace command"); } } else { fprintf(stderr, "symbol %d: %p (unmapped)\n", i, trace[i]); } } } }
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/backtrace.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ #ifdef __cplusplus extern "C" { #endif extern const char* g_argv0; void tvm_platform_abort_backtrace(void); #ifdef __cplusplus } #endif
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/build_model.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Creates a simple TVM modules.""" import argparse import os from tvm import relay import tvm from tvm import runtime as tvm_runtime import logging from tvm.relay.backend import Runtime from tvm.contrib import cc as _cc RUNTIMES = [ (Runtime("crt", {"system-lib": True}), "{name}_c.{ext}"), (Runtime("cpp", {"system-lib": True}), "{name}_cpp.{ext}"), ] def build_module(opts): dshape = (1, 3, 224, 224) from mxnet.gluon.model_zoo.vision import get_model block = get_model("mobilenet0.25", pretrained=True) shape_dict = {"data": dshape} mod, params = relay.frontend.from_mxnet(block, shape_dict) func = mod["main"] func = relay.Function( func.params, relay.nn.softmax(func.body), None, func.type_params, func.attrs ) for runtime, file_format_str in RUNTIMES: with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}): graph, lib, params = relay.build(func, "llvm", runtime=runtime, params=params) build_dir = os.path.abspath(opts.out_dir) if not os.path.isdir(build_dir): os.makedirs(build_dir) ext = "tar" if str(runtime) == "crt" else "o" lib_file_name = os.path.join(build_dir, file_format_str.format(name="model", ext=ext)) if str(runtime) == "crt": lib.export_library(lib_file_name) else: # NOTE: at present, export_libarary will always create _another_ shared object, and you # can't stably combine two shared objects together (in this case, init_array is not # populated correctly when you do that). So for now, must continue to use save() with the # C++ library. # TODO(areusch): Obliterate runtime.cc and replace with libtvm_runtime.so. lib.save(lib_file_name) with open( os.path.join(build_dir, file_format_str.format(name="graph", ext="json")), "w" ) as f_graph_json: f_graph_json.write(graph) with open( os.path.join(build_dir, file_format_str.format(name="params", ext="bin")), "wb" ) as f_params: f_params.write(tvm_runtime.save_param_dict(params)) def build_test_module(opts): import numpy as np x = relay.var("x", shape=(10, 5)) y = relay.var("y", shape=(1, 5)) z = relay.add(x, y) func = relay.Function([x, y], z) x_data = np.random.rand(10, 5).astype("float32") y_data = np.random.rand(1, 5).astype("float32") params = {"y": y_data} for runtime, file_format_str in RUNTIMES: with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}): graph, lib, lowered_params = relay.build( tvm.IRModule.from_expr(func), "llvm", runtime=runtime, params=params, ) build_dir = os.path.abspath(opts.out_dir) if not os.path.isdir(build_dir): os.makedirs(build_dir) ext = "tar" if str(runtime) == "crt" else "o" lib_file_name = os.path.join(build_dir, file_format_str.format(name="test_model", ext=ext)) if str(runtime) == "crt": lib.export_library(lib_file_name) else: # NOTE: at present, export_libarary will always create _another_ shared object, and you # can't stably combine two shared objects together (in this case, init_array is not # populated correctly when you do that). So for now, must continue to use save() with the # C++ library. # TODO(areusch): Obliterate runtime.cc and replace with libtvm_runtime.so. lib.save(lib_file_name) with open( os.path.join(build_dir, file_format_str.format(name="test_graph", ext="json")), "w" ) as f_graph_json: f_graph_json.write(graph) with open( os.path.join(build_dir, file_format_str.format(name="test_params", ext="bin")), "wb" ) as f_params: f_params.write(tvm_runtime.save_param_dict(lowered_params)) with open( os.path.join(build_dir, file_format_str.format(name="test_data", ext="bin")), "wb" ) as fp: fp.write(x_data.astype(np.float32).tobytes()) x_output = x_data + y_data with open( os.path.join(build_dir, file_format_str.format(name="test_output", ext="bin")), "wb" ) as fp: fp.write(x_output.astype(np.float32).tobytes()) def build_inputs(opts): from tvm.contrib import download from PIL import Image import numpy as np build_dir = os.path.abspath(opts.out_dir) # Download test image image_url = "https://homes.cs.washington.edu/~moreau/media/vta/cat.jpg" image_fn = os.path.join(build_dir, "cat.png") download.download(image_url, image_fn) image = Image.open(image_fn).resize((224, 224)) def transform_image(image): image = np.array(image) - np.array([123.0, 117.0, 104.0]) image /= np.array([58.395, 57.12, 57.375]) image = image.transpose((2, 0, 1)) image = image[np.newaxis, :] return image x = transform_image(image) print("x", x.shape) with open(os.path.join(build_dir, "cat.bin"), "wb") as fp: fp.write(x.astype(np.float32).tobytes()) if __name__ == "__main__": logging.basicConfig(level=logging.INFO) parser = argparse.ArgumentParser() parser.add_argument("-o", "--out-dir", default=".") parser.add_argument("-t", "--test", action="store_true") opts = parser.parse_args() if opts.test: build_test_module(opts) else: build_module(opts) build_inputs(opts)
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/bundle.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <tvm/runtime/c_runtime_api.h> #include <tvm/runtime/crt/crt.h> #include <tvm/runtime/crt/graph_executor.h> #include <tvm/runtime/crt/packed_func.h> #include <tvm/runtime/crt/page_allocator.h> #ifdef ENABLE_TVM_ABORT_BACKTRACE #include "backtrace.h" #endif #define CRT_MEMORY_NUM_PAGES 16384 #define CRT_MEMORY_PAGE_SIZE_LOG2 10 static uint8_t g_crt_memory[CRT_MEMORY_NUM_PAGES * (1 << CRT_MEMORY_PAGE_SIZE_LOG2)]; static MemoryManagerInterface* g_memory_manager; /*! \brief macro to do C API call */ #define TVM_CCALL(func) \ do { \ int ret = (func); \ if (ret != 0) { \ fprintf(stderr, "%s: %d: error: %s\n", __FILE__, __LINE__, TVMGetLastError()); \ exit(ret); \ } \ } while (0) TVM_DLL void* tvm_runtime_create(const char* json_data, const char* params_data, const uint64_t params_size, const char* argv0) { #ifdef ENABLE_TVM_ABORT_BACKTRACE g_argv0 = argv0; #endif int64_t device_type = kDLCPU; int64_t device_id = 0; TVMByteArray params; params.data = params_data; params.size = params_size; DLDevice dev; dev.device_type = (DLDeviceType)device_type; dev.device_id = device_id; // declare pointers TVM_CCALL(PageMemoryManagerCreate(&g_memory_manager, g_crt_memory, sizeof(g_crt_memory), CRT_MEMORY_PAGE_SIZE_LOG2)); TVM_CCALL(TVMInitializeRuntime()); TVMPackedFunc pf; TVMArgs args = TVMArgs_Create(NULL, NULL, 0); TVM_CCALL(TVMPackedFunc_InitGlobalFunc(&pf, "runtime.SystemLib", &args)); TVM_CCALL(TVMPackedFunc_Call(&pf)); TVMModuleHandle mod_syslib = TVMArgs_AsModuleHandle(&pf.ret_value, 0); // run modules TVMGraphExecutor* graph_executor = NULL; TVM_CCALL(TVMGraphExecutor_Create(json_data, mod_syslib, &dev, &graph_executor)); TVM_CCALL(TVMGraphExecutor_LoadParams(graph_executor, params.data, params.size)); return graph_executor; } TVM_DLL void tvm_runtime_destroy(void* executor) { TVMGraphExecutor_Release((TVMGraphExecutor**)&executor); } TVM_DLL void tvm_runtime_set_input(void* executor, const char* name, DLTensor* tensor) { TVMGraphExecutor* graph_executor = (TVMGraphExecutor*)executor; TVMGraphExecutor_SetInput(graph_executor, name, tensor); } TVM_DLL void tvm_runtime_run(void* executor) { TVMGraphExecutor* graph_executor = (TVMGraphExecutor*)executor; TVMGraphExecutor_Run(graph_executor); } TVM_DLL void tvm_runtime_get_output(void* executor, int32_t index, DLTensor* tensor) { TVMGraphExecutor* graph_executor = (TVMGraphExecutor*)executor; TVMGraphExecutor_GetOutput(graph_executor, index, tensor); } void TVMLogf(const char* msg, ...) { va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); } void __attribute__((noreturn)) TVMPlatformAbort(tvm_crt_error_t error_code) { fprintf(stderr, "TVMPlatformAbort: %d\n", error_code); #ifdef ENABLE_TVM_ABORT_BACKTRACE tvm_platform_abort_backtrace(); #endif exit(-1); } tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { return g_memory_manager->Allocate(g_memory_manager, num_bytes, dev, out_ptr); } tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { return g_memory_manager->Free(g_memory_manager, ptr, dev); } tvm_crt_error_t TVMPlatformTimerStart() { return kTvmErrorFunctionCallNotImplemented; } tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) { return kTvmErrorFunctionCallNotImplemented; }
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/bundle.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_APPS_BUNDLE_DEPLOY_BUNDLE_H_ #define TVM_APPS_BUNDLE_DEPLOY_BUNDLE_H_ #include <tvm/runtime/c_runtime_api.h> TVM_DLL void* tvm_runtime_create(const char* json_data, const char* params_data, const uint64_t params_size, const char* argv); TVM_DLL void tvm_runtime_destroy(void* runtime); TVM_DLL void tvm_runtime_set_input(void* runtime, const char* name, DLTensor* tensor); TVM_DLL void tvm_runtime_run(void* runtime); TVM_DLL void tvm_runtime_get_output(void* runtime, int32_t index, DLTensor* tensor); #endif /* TVM_APPS_BUNDLE_DEPLOY_BUNDLE_H_ */
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/bundle_static.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <tvm/runtime/crt/crt.h> #include <tvm/runtime/crt/graph_executor.h> #include <tvm/runtime/crt/packed_func.h> #include <tvm/runtime/crt/page_allocator.h> #include <unistd.h> #ifdef ENABLE_TVM_PLATFORM_ABORT_BACKTRACE #include "backtrace.h" #endif #include "bundle.h" #define CRT_MEMORY_NUM_PAGES 16384 #define CRT_MEMORY_PAGE_SIZE_LOG2 10 static uint8_t g_crt_memory[CRT_MEMORY_NUM_PAGES * (1 << CRT_MEMORY_PAGE_SIZE_LOG2)]; static MemoryManagerInterface* g_memory_manager; /*! \brief macro to do C API call */ #define TVM_CCALL(func) \ do { \ tvm_crt_error_t ret = (func); \ if (ret != kTvmErrorNoError) { \ fprintf(stderr, "%s: %d: error: %s\n", __FILE__, __LINE__, TVMGetLastError()); \ exit(ret); \ } \ } while (0) TVM_DLL void* tvm_runtime_create(const char* json_data, const char* params_data, const uint64_t params_size, const char* argv0) { #ifdef ENABLE_TVM_PLATFORM_ABORT_BACKTRACE g_argv0 = argv0; #endif int64_t device_type = kDLCPU; int64_t device_id = 0; TVMByteArray params; params.data = params_data; params.size = params_size; DLDevice dev; dev.device_type = (DLDeviceType)device_type; dev.device_id = device_id; // get pointers TVM_CCALL(PageMemoryManagerCreate(&g_memory_manager, g_crt_memory, sizeof(g_crt_memory), CRT_MEMORY_PAGE_SIZE_LOG2)); TVM_CCALL(TVMInitializeRuntime()); TVMPackedFunc pf; TVMArgs args = TVMArgs_Create(NULL, NULL, 0); TVM_CCALL(TVMPackedFunc_InitGlobalFunc(&pf, "runtime.SystemLib", &args)); TVM_CCALL(TVMPackedFunc_Call(&pf)); TVMModuleHandle mod_syslib = TVMArgs_AsModuleHandle(&pf.ret_value, 0); // run modules TVMGraphExecutor* graph_executor = NULL; TVM_CCALL(TVMGraphExecutor_Create(json_data, mod_syslib, &dev, &graph_executor)); TVM_CCALL(TVMGraphExecutor_LoadParams(graph_executor, params.data, params.size)); return graph_executor; } TVM_DLL void tvm_runtime_destroy(void* executor) { TVMGraphExecutor* graph_executor = (TVMGraphExecutor*)executor; TVMGraphExecutor_Release(&graph_executor); } TVM_DLL void tvm_runtime_set_input(void* executor, const char* name, DLTensor* tensor) { TVMGraphExecutor* graph_executor = (TVMGraphExecutor*)executor; TVMGraphExecutor_SetInput(graph_executor, name, tensor); } TVM_DLL void tvm_runtime_run(void* executor) { TVMGraphExecutor* graph_executor = (TVMGraphExecutor*)executor; TVMGraphExecutor_Run(graph_executor); } TVM_DLL void tvm_runtime_get_output(void* executor, int32_t index, DLTensor* tensor) { TVMGraphExecutor* graph_executor = (TVMGraphExecutor*)executor; TVMGraphExecutor_GetOutput(graph_executor, index, tensor); } void TVMLogf(const char* msg, ...) { va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); } void __attribute__((noreturn)) TVMPlatformAbort(tvm_crt_error_t error_code) { fprintf(stderr, "TVMPlatformAbort: %d\n", error_code); #ifdef ENABLE_TVM_PLATFORM_ABORT_BACKTRACE tvm_platform_abort_backtrace(); #endif exit(-1); } tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { return g_memory_manager->Allocate(g_memory_manager, num_bytes, dev, out_ptr); } tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { return g_memory_manager->Free(g_memory_manager, ptr, dev); } tvm_crt_error_t TVMPlatformTimerStart() { return kTvmErrorFunctionCallNotImplemented; } tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) { return kTvmErrorFunctionCallNotImplemented; }
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/crt_config/crt_config.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file apps/bundle_deploy/crt_config.h * \brief CRT configuration for bundle_deploy app. */ #ifndef TVM_RUNTIME_CRT_CONFIG_H_ #define TVM_RUNTIME_CRT_CONFIG_H_ /*! Log level of the CRT runtime */ #define TVM_CRT_LOG_LEVEL TVM_CRT_LOG_LEVEL_DEBUG /*! Support low-level debugging in MISRA-C runtime */ #define TVM_CRT_DEBUG 0 /*! Maximum supported dimension in NDArray */ #define TVM_CRT_MAX_NDIM 6 /*! Maximum supported arguments in generated functions */ #define TVM_CRT_MAX_ARGS 10 /*! Maximum supported string length in dltype, e.g. "int8", "int16", "float32" */ #define TVM_CRT_MAX_STRLEN_DLTYPE 10 /*! Maximum supported string length in function names */ #define TVM_CRT_MAX_STRLEN_FUNCTION_NAME 120 /*! Maximum supported string length in parameter names */ #define TVM_CRT_MAX_STRLEN_PARAM_NAME 80 /*! Maximum number of registered modules. */ #define TVM_CRT_MAX_REGISTERED_MODULES 2 /*! Size of the global function registry, in bytes. */ #define TVM_CRT_GLOBAL_FUNC_REGISTRY_SIZE_BYTES 512 /*! Maximum packet size, in bytes, including the length header. */ #define TVM_CRT_MAX_PACKET_SIZE_BYTES 512 #endif // TVM_RUNTIME_CRT_CONFIG_H_
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/demo_static.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <assert.h> #include <float.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <tvm/runtime/c_runtime_api.h> #include "bundle.h" extern const char build_graph_c_json[]; extern unsigned int build_graph_c_json_len; extern const char build_params_c_bin[]; extern unsigned int build_params_c_bin_len; #define OUTPUT_LEN 1000 int main(int argc, char** argv) { assert(argc == 2 && "Usage: demo_static <cat.bin>"); char* json_data = (char*)(build_graph_c_json); char* params_data = (char*)(build_params_c_bin); uint64_t params_size = build_params_c_bin_len; struct timeval t0, t1, t2, t3, t4, t5; gettimeofday(&t0, 0); void* handle = tvm_runtime_create(json_data, params_data, params_size, argv[0]); gettimeofday(&t1, 0); float input_storage[1 * 3 * 224 * 224]; FILE* fp = fopen(argv[1], "rb"); (void)fread(input_storage, 3 * 224 * 224, 4, fp); fclose(fp); DLTensor input; input.data = input_storage; DLDevice dev = {kDLCPU, 0}; input.device = dev; input.ndim = 4; DLDataType dtype = {kDLFloat, 32, 1}; input.dtype = dtype; int64_t shape[4] = {1, 3, 224, 224}; input.shape = shape; input.strides = NULL; input.byte_offset = 0; tvm_runtime_set_input(handle, "data", &input); gettimeofday(&t2, 0); tvm_runtime_run(handle); gettimeofday(&t3, 0); float output_storage[OUTPUT_LEN]; DLTensor output; output.data = output_storage; DLDevice out_dev = {kDLCPU, 0}; output.device = out_dev; output.ndim = 2; DLDataType out_dtype = {kDLFloat, 32, 1}; output.dtype = out_dtype; int64_t out_shape[2] = {1, OUTPUT_LEN}; output.shape = out_shape; output.strides = NULL; output.byte_offset = 0; tvm_runtime_get_output(handle, 0, &output); gettimeofday(&t4, 0); float max_iter = -FLT_MAX; int32_t max_index = -1; for (int i = 0; i < OUTPUT_LEN; ++i) { if (output_storage[i] > max_iter) { max_iter = output_storage[i]; max_index = i; } } tvm_runtime_destroy(handle); gettimeofday(&t5, 0); printf("The maximum position in output vector is: %d, with max-value %f.\n", max_index, max_iter); printf( "timing: %.2f ms (create), %.2f ms (set_input), %.2f ms (run), " "%.2f ms (get_output), %.2f ms (destroy)\n", (t1.tv_sec - t0.tv_sec) * 1000 + (t1.tv_usec - t0.tv_usec) / 1000.f, (t2.tv_sec - t1.tv_sec) * 1000 + (t2.tv_usec - t1.tv_usec) / 1000.f, (t3.tv_sec - t2.tv_sec) * 1000 + (t3.tv_usec - t2.tv_usec) / 1000.f, (t4.tv_sec - t3.tv_sec) * 1000 + (t4.tv_usec - t3.tv_usec) / 1000.f, (t5.tv_sec - t4.tv_sec) * 1000 + (t5.tv_usec - t4.tv_usec) / 1000.f); return 0; }
https://github.com/zk-ml/tachikoma
apps/bundle_deploy/test_static.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/time.h> #include <tvm/runtime/c_runtime_api.h> #include "bundle.h" int main(int argc, char** argv) { assert(argc == 5 && "Usage: test_static <data.bin> <output.bin> <graph.json> <params.bin>"); struct stat st; char* json_data; char* params_data; uint64_t params_size; FILE* fp = fopen(argv[3], "rb"); stat(argv[3], &st); json_data = (char*)malloc(st.st_size); fread(json_data, st.st_size, 1, fp); fclose(fp); fp = fopen(argv[4], "rb"); stat(argv[4], &st); params_data = (char*)malloc(st.st_size); fread(params_data, st.st_size, 1, fp); params_size = st.st_size; fclose(fp); struct timeval t0, t1, t2, t3, t4, t5; gettimeofday(&t0, 0); void* handle = tvm_runtime_create(json_data, params_data, params_size, argv[0]); gettimeofday(&t1, 0); float input_storage[10 * 5]; fp = fopen(argv[1], "rb"); fread(input_storage, 10 * 5, 4, fp); fclose(fp); float result_storage[10 * 5]; fp = fopen(argv[2], "rb"); fread(result_storage, 10 * 5, 4, fp); fclose(fp); DLTensor input; input.data = input_storage; DLDevice dev = {kDLCPU, 0}; input.device = dev; input.ndim = 2; DLDataType dtype = {kDLFloat, 32, 1}; input.dtype = dtype; int64_t shape[2] = {10, 5}; input.shape = shape; input.strides = NULL; input.byte_offset = 0; tvm_runtime_set_input(handle, "x", &input); gettimeofday(&t2, 0); tvm_runtime_run(handle); gettimeofday(&t3, 0); float output_storage[10 * 5]; DLTensor output; output.data = output_storage; DLDevice out_dev = {kDLCPU, 0}; output.device = out_dev; output.ndim = 2; DLDataType out_dtype = {kDLFloat, 32, 1}; output.dtype = out_dtype; int64_t out_shape[2] = {10, 5}; output.shape = out_shape; output.strides = NULL; output.byte_offset = 0; tvm_runtime_get_output(handle, 0, &output); gettimeofday(&t4, 0); for (int i = 0; i < 10 * 5; ++i) { assert(fabs(output_storage[i] - result_storage[i]) < 1e-5f); if (fabs(output_storage[i] - result_storage[i]) >= 1e-5f) { printf("got %f, expected %f\n", output_storage[i], result_storage[i]); } } tvm_runtime_destroy(handle); gettimeofday(&t5, 0); printf( "timing: %.2f ms (create), %.2f ms (set_input), %.2f ms (run), " "%.2f ms (get_output), %.2f ms (destroy)\n", (t1.tv_sec - t0.tv_sec) * 1000 + (t1.tv_usec - t0.tv_usec) / 1000.f, (t2.tv_sec - t1.tv_sec) * 1000 + (t2.tv_usec - t1.tv_usec) / 1000.f, (t3.tv_sec - t2.tv_sec) * 1000 + (t3.tv_usec - t2.tv_usec) / 1000.f, (t4.tv_sec - t3.tv_sec) * 1000 + (t4.tv_usec - t3.tv_usec) / 1000.f, (t5.tv_sec - t4.tv_sec) * 1000 + (t5.tv_usec - t4.tv_usec) / 1000.f); free(json_data); free(params_data); return 0; }
https://github.com/zk-ml/tachikoma
apps/cpp_rpc/rpc_env.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file rpc_env.h * \brief Server environment of the RPC. */ #ifndef TVM_APPS_CPP_RPC_ENV_H_ #define TVM_APPS_CPP_RPC_ENV_H_ #include <tvm/runtime/registry.h> #include <string> namespace tvm { namespace runtime { /*! * \brief RPCEnv The RPC Environment parameters for c++ rpc server */ struct RPCEnv { public: /*! * \brief Constructor Init The RPC Environment initialize function */ RPCEnv(const std::string& word_dir = ""); /*! * \brief GetPath To get the workpath from packed function * \param name The file name * \return The full path of file. */ std::string GetPath(const std::string& file_name) const; /*! * \brief The RPC Environment cleanup function */ void CleanUp() const; private: /*! * \brief Holds the environment path. */ std::string base_; }; // RPCEnv } // namespace runtime } // namespace tvm #endif // TVM_APPS_CPP_RPC_ENV_H_
https://github.com/zk-ml/tachikoma
apps/cpp_rpc/rpc_server.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file rpc_server.h * \brief RPC Server implementation. */ #ifndef TVM_APPS_CPP_RPC_SERVER_H_ #define TVM_APPS_CPP_RPC_SERVER_H_ #include <string> #include "tvm/runtime/c_runtime_api.h" namespace tvm { namespace runtime { #if defined(WIN32) /*! * \brief ServerLoopFromChild The Server loop process. * \param sock The socket information * \param addr The socket address information */ void ServerLoopFromChild(SOCKET socket); #endif /*! * \brief RPCServerCreate Creates the RPC Server. * \param host The hostname of the server, Default=0.0.0.0 * \param port The port of the RPC, Default=9090 * \param port_end The end search port of the RPC, Default=9099 * \param tracker The address of RPC tracker in host:port format e.g. 10.77.1.234:9190 Default="" * \param key The key used to identify the device type in tracker. Default="" * \param custom_addr Custom IP Address to Report to RPC Tracker. Default="" * \param work_dir Custom work directory. Default="" * \param silent Whether run in silent mode. Default=True */ void RPCServerCreate(std::string host = "", int port = 9090, int port_end = 9099, std::string tracker_addr = "", std::string key = "", std::string custom_addr = "", std::string work_dir = "", bool silent = true); } // namespace runtime } // namespace tvm #endif // TVM_APPS_CPP_RPC_SERVER_H_
https://github.com/zk-ml/tachikoma
apps/cpp_rpc/rpc_tracker_client.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file rpc_tracker_client.h * \brief RPC Tracker client to report resources. */ #ifndef TVM_APPS_CPP_RPC_TRACKER_CLIENT_H_ #define TVM_APPS_CPP_RPC_TRACKER_CLIENT_H_ #include <chrono> #include <iostream> #include <random> #include <set> #include <string> #include <vector> #include "../../src/runtime/rpc/rpc_endpoint.h" #include "../../src/support/socket.h" namespace tvm { namespace runtime { /*! * \brief TrackerClient Tracker client class. * \param tracker The address of RPC tracker in host:port format e.g. 10.77.1.234:9190 Default="" * \param key The key used to identify the device type in tracker. Default="" * \param custom_addr Custom IP Address to Report to RPC Tracker. Default="" */ class TrackerClient { public: /*! * \brief Constructor. */ TrackerClient(const std::string& tracker_addr, const std::string& key, const std::string& custom_addr, int port) : tracker_addr_(tracker_addr), key_(key), custom_addr_(custom_addr), port_(port), gen_(std::random_device{}()), dis_(0.0, 1.0) { if (custom_addr_.empty()) { custom_addr_ = "null"; } else { // Since custom_addr_ can be either the json value null which is not surrounded by quotes // or a string containing the custom value which json does required to be quoted then we // need to set custom_addr_ to be a string containing the quotes here. custom_addr_ = "\"" + custom_addr_ + "\""; } } /*! * \brief Destructor. */ ~TrackerClient() { // Free the resources Close(); } /*! * \brief IsValid Check tracker is valid. */ bool IsValid() { return (!tracker_addr_.empty() && !tracker_sock_.IsClosed()); } /*! * \brief TryConnect Connect to tracker if the tracker address is valid. */ void TryConnect() { if (!tracker_addr_.empty() && (tracker_sock_.IsClosed())) { tracker_sock_ = ConnectWithRetry(); int code = kRPCTrackerMagic; ICHECK_EQ(tracker_sock_.SendAll(&code, sizeof(code)), sizeof(code)); ICHECK_EQ(tracker_sock_.RecvAll(&code, sizeof(code)), sizeof(code)); ICHECK_EQ(code, kRPCTrackerMagic) << tracker_addr_.c_str() << " is not RPC Tracker"; std::ostringstream ss; ss << "[" << static_cast<int>(TrackerCode::kUpdateInfo) << ", {\"key\": \"server:" << key_ << "\", \"addr\": [" << custom_addr_ << ", \"" << port_ << "\"]}]"; tracker_sock_.SendBytes(ss.str()); // Receive status and validate std::string remote_status = tracker_sock_.RecvBytes(); ICHECK_EQ(std::stoi(remote_status), static_cast<int>(TrackerCode::kSuccess)); } } /*! * \brief Close Clean up tracker resources. */ void Close() { // close tracker resource if (!tracker_sock_.IsClosed()) { tracker_sock_.Close(); } } /*! * \brief ReportResourceAndGetKey Report resource to tracker. * \param port listening port. * \param matchkey Random match key output. */ void ReportResourceAndGetKey(int port, std::string* matchkey) { if (!tracker_sock_.IsClosed()) { *matchkey = RandomKey(key_ + ":", old_keyset_); std::ostringstream ss; ss << "[" << static_cast<int>(TrackerCode::kPut) << ", \"" << key_ << "\", [" << port << ", \"" << *matchkey << "\"], " << custom_addr_ << "]"; tracker_sock_.SendBytes(ss.str()); // Receive status and validate std::string remote_status = tracker_sock_.RecvBytes(); ICHECK_EQ(std::stoi(remote_status), static_cast<int>(TrackerCode::kSuccess)); } else { *matchkey = key_; } } /*! * \brief ReportResourceAndGetKey Report resource to tracker. * \param listen_sock Listen socket details for select. * \param port listening port. * \param ping_period Select wait time. * \param matchkey Random match key output. */ void WaitConnectionAndUpdateKey(support::TCPSocket listen_sock, int port, int ping_period, std::string* matchkey) { int unmatch_period_count = 0; int unmatch_timeout = 4; while (true) { if (!tracker_sock_.IsClosed()) { support::PollHelper poller; poller.WatchRead(listen_sock.sockfd); poller.Poll(ping_period * 1000); if (!poller.CheckRead(listen_sock.sockfd)) { std::ostringstream ss; ss << "[" << int(TrackerCode::kGetPendingMatchKeys) << "]"; tracker_sock_.SendBytes(ss.str()); // Receive status and validate std::string pending_keys = tracker_sock_.RecvBytes(); old_keyset_.insert(*matchkey); // if match key not in pending key set // it means the key is acquired by a client but not used. if (pending_keys.find(*matchkey) == std::string::npos) { unmatch_period_count += 1; } else { unmatch_period_count = 0; } // regenerate match key if key is acquired but not used for a while if (unmatch_period_count * ping_period > unmatch_timeout + ping_period) { LOG(INFO) << "no incoming connections, regenerate key ..."; *matchkey = RandomKey(key_ + ":", old_keyset_); std::ostringstream ss; ss << "[" << static_cast<int>(TrackerCode::kPut) << ", \"" << key_ << "\", [" << port << ", \"" << *matchkey << "\"], " << custom_addr_ << "]"; tracker_sock_.SendBytes(ss.str()); std::string remote_status = tracker_sock_.RecvBytes(); ICHECK_EQ(std::stoi(remote_status), static_cast<int>(TrackerCode::kSuccess)); unmatch_period_count = 0; } continue; } } break; } } private: /*! * \brief Connect to a RPC address with retry. This function is only reliable to short period of server restart. * \param timeout Timeout during retry * \param retry_period Number of seconds before we retry again. * \return TCPSocket The socket information if connect is success. */ support::TCPSocket ConnectWithRetry(int timeout = 60, int retry_period = 5) { auto tbegin = std::chrono::system_clock::now(); while (true) { support::SockAddr addr(tracker_addr_); support::TCPSocket sock; sock.Create(); LOG(INFO) << "Tracker connecting to " << addr.AsString(); if (sock.Connect(addr)) { return sock; } auto period = (std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now() - tbegin)) .count(); ICHECK(period < timeout) << "Failed to connect to server" << addr.AsString(); LOG(WARNING) << "Cannot connect to tracker " << addr.AsString() << " retry in " << retry_period << " seconds."; std::this_thread::sleep_for(std::chrono::seconds(retry_period)); } } /*! * \brief Random Generate a random number between 0 and 1. * \return random float value. */ float Random() { return dis_(gen_); } /*! * \brief Generate a random key. * \param prefix The string prefix. * \return cmap The conflict map set. */ std::string RandomKey(const std::string& prefix, const std::set<std::string>& cmap) { if (!cmap.empty()) { while (true) { std::string key = prefix + std::to_string(Random()); if (cmap.find(key) == cmap.end()) { return key; } } } return prefix + std::to_string(Random()); } std::string tracker_addr_; std::string key_; std::string custom_addr_; int port_; support::TCPSocket tracker_sock_; std::set<std::string> old_keyset_; std::mt19937 gen_; std::uniform_real_distribution<float> dis_; }; } // namespace runtime } // namespace tvm #endif // TVM_APPS_CPP_RPC_TRACKER_CLIENT_H_
https://github.com/zk-ml/tachikoma
apps/cpp_rpc/win32_process.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file win32_process.h * \brief Win32 process code to mimic a POSIX fork() */ #ifndef TVM_APPS_CPP_RPC_WIN32_PROCESS_H_ #define TVM_APPS_CPP_RPC_WIN32_PROCESS_H_ #include <chrono> #include <string> #include "../../src/support/socket.h" namespace tvm { namespace runtime { /*! * \brief SpawnRPCChild Spawns a child process with a given timeout to run * \param fd The client socket to duplicate in the child * \param timeout The time in seconds to wait for the child to complete before termination */ void SpawnRPCChild(SOCKET fd, std::chrono::seconds timeout); /*! * \brief ChildProcSocketHandler Ran from the child process and runs server to handle the client * socket \param mmap_path The memory mapped file path that will contain the information to * duplicate the client socket from the parent */ void ChildProcSocketHandler(const std::string& mmap_path); } // namespace runtime } // namespace tvm #endif // TVM_APPS_CPP_RPC_WIN32_PROCESS_H_
https://github.com/zk-ml/tachikoma
apps/dso_plugin_module/test_plugin_module.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import tvm from tvm import te import os def test_plugin_module(): curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) mod = tvm.runtime.load_module(os.path.join(curr_path, "lib", "plugin_module.so")) # NOTE: we need to make sure all managed resources returned # from mod get destructed before mod get unloaded. # # Failure mode we want to prevent from: # We retain an object X whose destructor is within mod. # The program will segfault if X get destructed after mod, # because the destructor function has already been unloaded. # # The easiest way to achieve this is to wrap the # logics related to mod inside a function. def run_module(mod): # normal functions assert mod["AddOne"](10) == 11 assert mod["SubOne"](10) == 9 # advanced usecase: return a module mymod = mod["CreateMyModule"](10) fadd = mymod["add"] assert fadd(10) == 20 assert mymod["mul"](10) == 100 run_module(mod) if __name__ == "__main__": test_plugin_module()
https://github.com/zk-ml/tachikoma
apps/extension/python/tvm_ext/__init__.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Example extension package of TVM.""" from __future__ import absolute_import import os import ctypes # Import TVM first to get library symbols import tvm from tvm import te def load_lib(): """Load library, the functions will be registered into TVM""" curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) # load in as global so the global extern symbol is visible to other dll. lib = ctypes.CDLL(os.path.join(curr_path, "../../lib/libtvm_ext.so"), ctypes.RTLD_GLOBAL) return lib _LIB = load_lib() # Expose two functions into python bind_add = tvm.get_global_func("tvm_ext.bind_add") sym_add = tvm.get_global_func("tvm_ext.sym_add") ivec_create = tvm.get_global_func("tvm_ext.ivec_create") ivec_get = tvm.get_global_func("tvm_ext.ivec_get") @tvm.register_object("tvm_ext.IntVector") class IntVec(tvm.Object): """Example for using extension class in c++""" @property def _tvm_handle(self): return self.handle.value def __getitem__(self, idx): return ivec_get(self, idx) nd_create = tvm.get_global_func("tvm_ext.nd_create") nd_add_two = tvm.get_global_func("tvm_ext.nd_add_two") nd_get_additional_info = tvm.get_global_func("tvm_ext.nd_get_additional_info") @tvm.register_object("tvm_ext.NDSubClass") class NDSubClass(tvm.nd.NDArrayBase): """Example for subclassing TVM's NDArray infrastructure. By inheriting TVM's NDArray, external libraries could leverage TVM's FFI without any modification. """ @staticmethod def create(additional_info): return nd_create(additional_info) @property def additional_info(self): return nd_get_additional_info(self) def __add__(self, other): return nd_add_two(self, other)
https://github.com/zk-ml/tachikoma
apps/extension/tests/test_ext.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import tvm_ext import tvm import tvm._ffi.registry import tvm.testing from tvm import te import numpy as np def test_bind_add(): def add(a, b): return a + b f = tvm_ext.bind_add(add, 1) assert f(2) == 3 def test_ext_dev(): n = 10 A = te.placeholder((n,), name="A") B = te.compute((n,), lambda *i: A(*i) + 1.0, name="B") s = te.create_schedule(B.op) def check_llvm(): if not tvm.testing.device_enabled("llvm"): return f = tvm.build(s, [A, B], "ext_dev", "llvm") dev = tvm.ext_dev(0) # launch the kernel. a = tvm.nd.array(np.random.uniform(size=n).astype(A.dtype), dev) b = tvm.nd.array(np.zeros(n, dtype=B.dtype), dev) f(a, b) tvm.testing.assert_allclose(b.numpy(), a.numpy() + 1) check_llvm() def test_sym_add(): a = te.var("a") b = te.var("b") c = tvm_ext.sym_add(a, b) assert c.a == a and c.b == b def test_ext_vec(): ivec = tvm_ext.ivec_create(1, 2, 3) assert isinstance(ivec, tvm_ext.IntVec) assert ivec[0] == 1 assert ivec[1] == 2 def ivec_cb(v2): assert isinstance(v2, tvm_ext.IntVec) assert v2[2] == 3 tvm.runtime.convert(ivec_cb)(ivec) def test_extract_ext(): fdict = tvm._ffi.registry.extract_ext_funcs(tvm_ext._LIB.TVMExtDeclare) assert fdict["mul"](3, 4) == 12 def test_extern_call(): n = 10 A = te.placeholder((n,), name="A") B = te.compute( (n,), lambda *i: tvm.tir.call_extern("float32", "TVMTestAddOne", A(*i)), name="B" ) s = te.create_schedule(B.op) def check_llvm(): if not tvm.testing.device_enabled("llvm"): return f = tvm.build(s, [A, B], "llvm") dev = tvm.cpu(0) # launch the kernel. a = tvm.nd.array(np.random.uniform(size=n).astype(A.dtype), dev) b = tvm.nd.array(np.zeros(n, dtype=B.dtype), dev) f(a, b) tvm.testing.assert_allclose(b.numpy(), a.numpy() + 1) check_llvm() def test_nd_subclass(): a = tvm_ext.NDSubClass.create(additional_info=3) b = tvm_ext.NDSubClass.create(additional_info=5) assert isinstance(a, tvm_ext.NDSubClass) c = a + b d = a + a e = b + b assert a.additional_info == 3 assert b.additional_info == 5 assert c.additional_info == 8 assert d.additional_info == 6 assert e.additional_info == 10 if __name__ == "__main__": test_nd_subclass() test_extern_call() test_ext_dev() test_ext_vec() test_bind_add() test_sym_add() test_extract_ext()
https://github.com/zk-ml/tachikoma
apps/hexagon_launcher/launcher_core.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_RUNTIME_HEXAGON_LAUNCHER_LAUNCHER_CORE_H_ #define TVM_RUNTIME_HEXAGON_LAUNCHER_LAUNCHER_CORE_H_ #include <dlpack/dlpack.h> #include <dmlc/json.h> #include <tvm/runtime/data_type.h> #include <tvm/runtime/module.h> #include <tvm/runtime/ndarray.h> #include <tvm/runtime/packed_func.h> #include <string> #include <vector> struct tensor_meta { int ndim; DLDataType dtype; int64_t shape[]; int meta_size() const { return meta_size(ndim); } int data_size() const { int size = tvm::runtime::DataType(dtype).bytes(); for (int d = 0; d != ndim; ++d) { size *= shape[d]; } return size; } static int meta_size(int ndim) { return sizeof(tensor_meta) + ndim * sizeof(int64_t); } std::string to_string() const; }; struct TensorConfig { static const std::string file_key; static const std::string shape_key; static const std::string dtype_key; std::string file_name; std::vector<int> shape; std::string dtype; bool bad = false; void Load(dmlc::JSONReader* reader); void Save(dmlc::JSONWriter* writer) const; }; struct ModelConfig { std::string model_library; std::string model_json; std::vector<TensorConfig> inputs; bool bad = false; void Load(dmlc::JSONReader* reader); }; struct OutputConfig { uint64_t pcycles; uint64_t usecs; std::vector<TensorConfig> outputs; void Save(dmlc::JSONWriter* writer) const; }; struct Model { Model(tvm::runtime::Module executor, tvm::runtime::Module module, std::string json); tvm::runtime::Module model_executor; tvm::runtime::Module graph_module; std::string graph_json; static tvm::Device device() { return tvm::Device{static_cast<DLDeviceType>(kDLHexagon), 0}; } static tvm::Device external() { return tvm::Device{static_cast<DLDeviceType>(kDLCPU), 0}; } tvm::runtime::PackedFunc run; }; struct ExecutionSession { explicit ExecutionSession(bool lwp_json = false) : gen_lwp_json(lwp_json) {} template <typename T> T* alloc(size_t bytes, size_t align = 1) { return reinterpret_cast<T*>(alloc_mem(bytes, align)); } void free(void* ptr) { free_mem(ptr); } virtual void* alloc_mem(size_t bytes, size_t align) = 0; virtual void free_mem(void* ptr) = 0; virtual bool load_model(const std::string& model_path, const std::string& model_json) = 0; virtual bool unload_model() = 0; virtual bool set_input(int input_idx, const tensor_meta* input_meta, const void* input_data) = 0; virtual bool run(uint64_t* pcycles, uint64_t* usecs) = 0; virtual bool get_num_outputs(int* num_outputs) = 0; virtual bool get_output(int output_idx, tensor_meta* output_meta, int meta_size, void* output_data, int data_size) = 0; bool gen_lwp_json = false; }; bool read_model_config(const std::string& file_name, ModelConfig* model_config); bool write_output_config(const std::string& file_name, OutputConfig* output_config); void reset_device_api(); tvm::runtime::Module load_module(const std::string& file_name); const tvm::runtime::PackedFunc get_runtime_func(const std::string& name); const tvm::runtime::PackedFunc get_module_func(tvm::runtime::Module module, const std::string& name); tvm::runtime::Module create_aot_executor(tvm::runtime::Module factory_module, tvm::Device device); tvm::runtime::Module create_graph_executor(const std::string& graph_json, tvm::runtime::Module graph_module, tvm::Device device); #endif // TVM_RUNTIME_HEXAGON_LAUNCHER_LAUNCHER_CORE_H_
https://github.com/zk-ml/tachikoma
apps/hexagon_launcher/launcher_util.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_RUNTIME_HEXAGON_LAUNCHER_LAUNCHER_UTIL_H_ #define TVM_RUNTIME_HEXAGON_LAUNCHER_LAUNCHER_UTIL_H_ #include <cstddef> #include <fstream> #include <string> size_t get_file_size(std::ifstream& in_file); size_t get_file_size(std::ifstream&& in_file); std::string load_text_file(const std::string& file_name); void* load_binary_file(const std::string& file_name, void* buffer, size_t buffer_size); void write_binary_file(const std::string& file_name, void* buffer, size_t buffer_size); #endif // TVM_RUNTIME_HEXAGON_LAUNCHER_LAUNCHER_UTIL_H_
https://github.com/zk-ml/tachikoma
apps/howto_deploy/prepare_test_libs.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Script to prepare test_addone.so""" import tvm import numpy as np from tvm import te from tvm import relay import os def prepare_test_libs(base_path): n = te.var("n") A = te.placeholder((n,), name="A") B = te.compute(A.shape, lambda *i: A(*i) + 1.0, name="B") s = te.create_schedule(B.op) # Compile library as dynamic library fadd_dylib = tvm.build(s, [A, B], "llvm", name="addone") dylib_path = os.path.join(base_path, "test_addone_dll.so") fadd_dylib.export_library(dylib_path) # Compile library in system library mode fadd_syslib = tvm.build(s, [A, B], "llvm", name="addonesys") syslib_path = os.path.join(base_path, "test_addone_sys.o") fadd_syslib.save(syslib_path) def prepare_graph_lib(base_path): x = relay.var("x", shape=(2, 2), dtype="float32") y = relay.var("y", shape=(2, 2), dtype="float32") params = {"y": np.ones((2, 2), dtype="float32")} mod = tvm.IRModule.from_expr(relay.Function([x, y], x + y)) # build a module compiled_lib = relay.build(mod, tvm.target.create("llvm"), params=params) # export it as a shared library # If you are running cross compilation, you can also consider export # to tar and invoke host compiler later. dylib_path = os.path.join(base_path, "test_relay_add.so") compiled_lib.export_library(dylib_path) if __name__ == "__main__": curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) prepare_test_libs(os.path.join(curr_path, "lib")) prepare_graph_lib(os.path.join(curr_path, "lib"))
https://github.com/zk-ml/tachikoma
apps/howto_deploy/python_deploy.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. # brief Example code on load and run TVM module.s # file python_deploy.py import tvm from tvm import te import numpy as np def verify(mod, fname): # Get the function from the module f = mod.get_function(fname) # Use tvm.nd.array to convert numpy ndarray to tvm # NDArray type, so that function can be invoked normally N = 10 x = tvm.nd.array(np.arange(N, dtype=np.float32)) y = tvm.nd.array(np.zeros(N, dtype=np.float32)) # Invoke the function f(x, y) np_x = x.numpy() np_y = y.numpy() # Verify correctness of function assert np.all([xi + 1 == yi for xi, yi in zip(np_x, np_y)]) print("Finish verification...") if __name__ == "__main__": # The normal dynamic loading method for deployment mod_dylib = tvm.runtime.load_module("lib/test_addone_dll.so") print("Verify dynamic loading from test_addone_dll.so") verify(mod_dylib, "addone") # There might be methods to use the system lib way in # python, but dynamic loading is good enough for now.
https://github.com/zk-ml/tachikoma
apps/ios_rpc/init_proj.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import argparse import re default_team_id = "3FR42MXLK9" default_tvm_build_dir = "path-to-tvm-ios-build-folder" parser = argparse.ArgumentParser( description="Update tvmrpc.xcodeproj\ developer information" ) parser.add_argument( "--team_id", type=str, required=True, help="Apple Developer Team ID.\n\ Can be found here:\n\ \n\ https://developer.apple.com/account/#/membership\n\ (example: {})".format( default_team_id ), ) parser.add_argument( "--tvm_build_dir", type=str, required=True, help="Path to directory with libtvm_runtime.dylib", ) args = parser.parse_args() team_id = args.team_id tvm_build_dir = args.tvm_build_dir fi = open("tvmrpc.xcodeproj/project.pbxproj") proj_config = fi.read() fi.close() proj_config = proj_config.replace(default_team_id, team_id) proj_config = proj_config.replace(default_tvm_build_dir, tvm_build_dir) fo = open("tvmrpc.xcodeproj/project.pbxproj", "w") fo.write(proj_config) fo.close()
https://github.com/zk-ml/tachikoma
apps/ios_rpc/tests/ios_rpc_mobilenet.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import tvm from tvm import rpc, relay from tvm.contrib.download import download_testdata from tvm.relay.expr_functor import ExprMutator from tvm.relay import transform from tvm.relay.op.annotation import compiler_begin, compiler_end from tvm.relay.quantize.quantize import prerequisite_optimize from tvm.contrib import utils, xcode, graph_executor, coreml_runtime from tvm.contrib.target import coreml as _coreml import os import re import sys import numpy as np from mxnet import gluon from PIL import Image import coremltools import argparse # Change target configuration, this is setting for iphone6s # arch = "x86_64" # sdk = "iphonesimulator" arch = "arm64" sdk = "iphoneos" target_host = "llvm -mtriple=%s-apple-darwin" % arch MODES = {"proxy": rpc.connect, "tracker": rpc.connect_tracker, "standalone": rpc.connect} # override metal compiler to compile to iphone @tvm.register_func("tvm_callback_metal_compile") def compile_metal(src): return xcode.compile_metal(src, sdk=sdk) def prepare_input(): img_url = "https://github.com/dmlc/mxnet.js/blob/main/data/cat.png?raw=true" img_name = "cat.png" synset_url = "".join( [ "https://gist.githubusercontent.com/zhreshold/", "4d0b62f3d01426887599d4f7ede23ee5/raw/", "596b27d23537e5a1b5751d2b0481ef172f58b539/", "imagenet1000_clsid_to_human.txt", ] ) synset_name = "imagenet1000_clsid_to_human.txt" img_path = download_testdata(img_url, "cat.png", module="data") synset_path = download_testdata(synset_url, synset_name, module="data") with open(synset_path) as f: synset = eval(f.read()) image = Image.open(img_path).resize((224, 224)) image = np.array(image) - np.array([123.0, 117.0, 104.0]) image /= np.array([58.395, 57.12, 57.375]) image = image.transpose((2, 0, 1)) image = image[np.newaxis, :] return image.astype("float32"), synset def get_model(model_name, data_shape): gluon_model = gluon.model_zoo.vision.get_model(model_name, pretrained=True) mod, params = relay.frontend.from_mxnet(gluon_model, {"data": data_shape}) # we want a probability so add a softmax operator func = mod["main"] func = relay.Function( func.params, relay.nn.softmax(func.body), None, func.type_params, func.attrs ) return func, params def test_mobilenet(host, port, key, mode): temp = utils.tempdir() image, synset = prepare_input() model, params = get_model("mobilenetv2_1.0", image.shape) def run(mod, target): with relay.build_config(opt_level=3): lib = relay.build( mod, target=tvm.target.Target(target, host=target_host), params=params ) path_dso = temp.relpath("deploy.dylib") lib.export_library(path_dso, xcode.create_dylib, arch=arch, sdk=sdk) # connect to the proxy if mode == "tracker": remote = MODES[mode](host, port).request(key) else: remote = MODES[mode](host, port, key=key) remote.upload(path_dso) if target == "metal": dev = remote.metal(0) else: dev = remote.cpu(0) lib = remote.load_module("deploy.dylib") m = graph_executor.GraphModule(lib["default"](dev)) m.set_input("data", tvm.nd.array(image, dev)) m.run() tvm_output = m.get_output(0) top1 = np.argmax(tvm_output.numpy()[0]) print("TVM prediction top-1:", top1, synset[top1]) # evaluate ftimer = m.module.time_evaluator("run", dev, number=3, repeat=10) prof_res = np.array(ftimer().results) * 1000 print("%-19s (%s)" % ("%.2f ms" % np.mean(prof_res), "%.2f ms" % np.std(prof_res))) def annotate(func, compiler): """ An annotator for Core ML. """ # Bind free variables to the constant values. bind_dict = {} for arg in func.params: name = arg.name_hint if name in params: bind_dict[arg] = relay.const(params[name]) func = relay.bind(func, bind_dict) # Annotate the entire graph for Core ML mod = tvm.IRModule() mod["main"] = func seq = tvm.transform.Sequential( [ transform.SimplifyInference(), transform.FoldConstant(), transform.FoldScaleAxis(), transform.AnnotateTarget(compiler), transform.MergeCompilerRegions(), transform.PartitionGraph(), ] ) with relay.build_config(opt_level=3): mod = seq(mod) return mod # CPU run(model, target_host) # Metal run(model, "metal") # CoreML run(annotate(model, "coremlcompiler"), target_host) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Demo app demonstrates how ios_rpc works.") parser.add_argument("--host", required=True, type=str, help="Adress of rpc server") parser.add_argument("--port", type=int, default=9090, help="rpc port (default: 9090)") parser.add_argument("--key", type=str, default="iphone", help="device key (default: iphone)") parser.add_argument( "--mode", type=str, default="tracker", help="type of RPC connection (default: tracker), possible values: {}".format( ", ".join(MODES.keys()) ), ) args = parser.parse_args() assert args.mode in MODES.keys() test_mobilenet(args.host, args.port, args.key, args.mode)
https://github.com/zk-ml/tachikoma
apps/ios_rpc/tests/ios_rpc_test.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Testcode for iOS RPC. To use it, start a rpc proxy with "python -m tvm.exec.rpc_proxy". And configure the proxy host field as commented. """ import tvm from tvm import te import os import re import sys from tvm import rpc from tvm.contrib import utils, xcode import numpy as np import argparse # Change target configuration, this is setting for iphone6s arch = "arm64" sdk = "iphoneos" target = "llvm -mtriple=%s-apple-darwin" % arch MODES = {"proxy": rpc.connect, "tracker": rpc.connect_tracker, "standalone": rpc.connect} # override metal compiler to compile to iphone @tvm.register_func("tvm_callback_metal_compile") def compile_metal(src): return xcode.compile_metal(src, sdk=sdk) def test_rpc_module(host, port, key, mode): # graph n = tvm.runtime.convert(1024) A = te.placeholder((n,), name="A") B = te.compute(A.shape, lambda *i: A(*i) + 1.0, name="B") temp = utils.tempdir() s = te.create_schedule(B.op) xo, xi = s[B].split(B.op.axis[0], factor=64) s[B].bind(xi, te.thread_axis("threadIdx.x")) s[B].bind(xo, te.thread_axis("blockIdx.x")) # Build the dynamic lib. # If we don't want to do metal and only use cpu, just set target to be target f = tvm.build(s, [A, B], tvm.target.Target("metal", host=target), name="myadd") path_dso1 = temp.relpath("dev_lib.dylib") f.export_library(path_dso1, xcode.create_dylib, arch=arch, sdk=sdk) s = te.create_schedule(B.op) xo, xi = s[B].split(B.op.axis[0], factor=64) s[B].parallel(xi) s[B].pragma(xo, "parallel_launch_point") s[B].pragma(xi, "parallel_barrier_when_finish") f = tvm.build(s, [A, B], target, name="myadd_cpu") path_dso2 = temp.relpath("cpu_lib.dylib") f.export_library(path_dso2, xcode.create_dylib, arch=arch, sdk=sdk) # connect to the proxy if mode == "tracker": remote = MODES[mode](host, port).request(key) else: remote = MODES[mode](host, port, key=key) remote.upload(path_dso1) dev = remote.metal(0) f1 = remote.load_module("dev_lib.dylib") a_np = np.random.uniform(size=1024).astype(A.dtype) a = tvm.nd.array(a_np, dev) b = tvm.nd.array(np.zeros(1024, dtype=A.dtype), dev) time_f = f1.time_evaluator(f1.entry_name, dev, number=10) cost = time_f(a, b).mean print("Metal: %g secs/op" % cost) np.testing.assert_equal(b.numpy(), a.numpy() + 1) # CPU dev = remote.cpu(0) remote.upload(path_dso2) f2 = remote.load_module("cpu_lib.dylib") a_np = np.random.uniform(size=1024).astype(A.dtype) a = tvm.nd.array(a_np, dev) b = tvm.nd.array(np.zeros(1024, dtype=A.dtype), dev) time_f = f2.time_evaluator(f2.entry_name, dev, number=10) cost = time_f(a, b).mean print("CPU: %g secs/op" % cost) np.testing.assert_equal(b.numpy(), a.numpy() + 1) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Demo app demonstrates how ios_rpc works.") parser.add_argument("--host", required=True, type=str, help="Adress of rpc server") parser.add_argument("--port", type=int, default=9090, help="rpc port (default: 9090)") parser.add_argument("--key", type=str, default="iphone", help="device key (default: iphone)") parser.add_argument( "--mode", type=str, default="tracker", help="type of RPC connection (default: tracker), possible values: {}".format( ", ".join(MODES.keys()) ), ) args = parser.parse_args() assert args.mode in MODES.keys() test_rpc_module(args.host, args.port, args.key, args.mode)
https://github.com/zk-ml/tachikoma
apps/ios_rpc/tvmrpc/AppDelegate.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file AppDelegate.h */ #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property(strong, nonatomic) UIWindow* window; @end
https://github.com/zk-ml/tachikoma
apps/ios_rpc/tvmrpc/RPCArgs.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_APPS_IOS_RPC_ARGS_H_ #define TVM_APPS_IOS_RPC_ARGS_H_ #import "RPCServer.h" #ifdef __cplusplus extern "C" { #endif /*! * \brief Struct representing arguments of iOS RPC app */ typedef struct RPCArgs_t { /// Tracker or Proxy address (actually ip) const char* host_url; /// Tracker or Proxy port int host_port; /// device key to report const char* key; /// custom adress to report into Tracker. Ignored for other server modes. const char* custom_addr; /// Verbose mode. Will print status messages to std out. /// 0 - no prints , 1 - print state to output bool verbose; /// Immediate server launch. No UI interaction. /// 0 - UI interaction, 1 - automatically connect on launch bool immediate_connect; /// Server mode RPCServerMode server_mode; } RPCArgs; /*! * \brief Get current global RPC args */ RPCArgs get_current_rpc_args(void); /*! * \brief Set current global RPC args and update values in app cache */ void set_current_rpc_args(RPCArgs args); /*! * \brief Pars command line args and update current global RPC args * Also updates values in app cache */ void update_rpc_args(int argc, char* argv[]); #ifdef __cplusplus } // extern "C" #endif #endif // TVM_APPS_IOS_RPC_ARGS_H_
https://github.com/zk-ml/tachikoma
apps/ios_rpc/tvmrpc/RPCServer.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file Provide interfaces to launch and control RPC Service routine */ #import <Foundation/Foundation.h> /*! * \brief Enum with possible status of RPC server * Used to report state to listener */ typedef enum { RPCServerStatus_Launched, // Worker thread is launched RPCServerStatus_Stopped, // Worker thread stopped RPCServerStatus_Connected, // Connected to Proxy/Tracker RPCServerStatus_Disconnected, // Disconnected from Proxy/Tracker RPCServerStatus_RPCSessionStarted, // RPC session is started RPCServerStatus_RPCSessionFinished // RPC session is finished } RPCServerStatus; /*! * \brief Enum with modes of servicing supported by RPCServer */ typedef enum { /// Tracker mode. Same as Standalone Server plus register it into Tracker. RPCServerMode_Tracker, /// Proxy mode. Connect to proxy server and wait response. RPCServerMode_Proxy, /// Standalone RPC server mode. Open port with RPC server and wait incoming connection. RPCServerMode_Standalone } RPCServerMode; /*! * \brief Listener for events happened with RPCServer */ @protocol RPCServerEventListener <NSObject> /// Callback to notifying about new status - (void)onError:(NSString*)msg; /// Callback to notifying about error - (void)onStatusChanged:(RPCServerStatus)status; @end /*! * \brief RPC Server instance * Contains internal worker thread plus */ @interface RPCServer : NSObject <NSStreamDelegate> /// Event listener delegate to set @property(retain) id<RPCServerEventListener> delegate; /// Device key to report during RPC session @property(retain) NSString* key; /// Host address of Proxy/Tracker server (generally IPv4). Ignored for Standalone mode. @property(retain) NSString* host; /// Port of Proxy/Tracker server. Ignored for Standalone mode. @property int port; /// Custom address to report into tracker server (optional). Ignored for Standalone/Proxy modes @property(retain) NSString* custom_addr; /// Triger to enable printing of server state info @property BOOL verbose; /// RPC port opened on the device. Ignored for Proxy/Tracker modes @property int actual_port; /// IP address of the device. Ignored for Proxy/Tracker modes @property(retain) NSString* device_addr; /*! * \brief Create server with specified sevicing mode * \param mode Mode of server */ + (instancetype)serverWithMode:(RPCServerMode)mode; /*! * \brief Start RPC server with options. Non blocking method */ - (void)start; /*! * \brief Stop RPC server. Non blocking method */ - (void)stop; @end
https://github.com/zk-ml/tachikoma
apps/ios_rpc/tvmrpc/ViewController.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file ViewController.h */ #import <UIKit/UIKit.h> #import "RPCServer.h" @interface ViewController : UIViewController <RPCServerEventListener, UITextFieldDelegate> @property(weak, nonatomic) IBOutlet UITextField* proxyURL; @property(weak, nonatomic) IBOutlet UITextField* proxyPort; @property(weak, nonatomic) IBOutlet UITextField* proxyKey; @property(weak, nonatomic) IBOutlet UILabel* statusLabel; @property(weak, nonatomic) IBOutlet UITextView* infoText; - (IBAction)connect:(id)sender; @property(retain, nonatomic) IBOutlet UIButton* ConnectButton; @property(retain, nonatomic) IBOutlet UISegmentedControl* ModeSelector; @end
https://github.com/zk-ml/tachikoma
apps/lldb/tvm.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Pretty Printers for lldb debugger. Install the pretty printers by loading this file from .lldbinit: command script import ~/bin/lldb/tvm.py Update the list of nodes for which debug information is displayed by adding to the list below. """ import lldb import lldb.formatters g_indent = 0 def __lldb_init_module(debugger, _): # Only types that are supported by PrettyPrint() will be printed. for node in [ "tvm::Array", "tvm::AttrFieldInfo", "tvm::Attrs", "tvm::BijectiveLayout", "tvm::Buffer", "tvm::Channel", "tvm::EnvFunc", "tvm::Expr", "tvm::GenericFunc", "tvm::Integer", "tvm::IterVar", "tvm::IterVarAttr", "tvm::IterVarRelation", "tvm::Layout", "tvm::Map", "tvm::Map", "tvm::MemoryInfo", "tvm::Operation", "tvm::Range", "tvm::Schedule", "tvm::Stage", "tvm::Stmt", "tvm::Target", "tvm::Tensor", "tvm::TensorIntrin", "tvm::TensorIntrinCall", "tvm::TypedEnvFunc", "tvm::tir::Var", "tvm::ir::CommReducer", "tvm::ir::FunctionRef", "tvm::relay::BaseTensorType", "tvm::relay::CCacheKey", "tvm::relay::CCacheValue", "tvm::relay::CachedFunc", "tvm::relay::Call", "tvm::relay::Clause", "tvm::relay::Closure", "tvm::relay::CompileEngine", "tvm::relay::Constant", "tvm::relay::Constructor", "tvm::relay::ConstructorValue", "tvm::relay::Expr", "tvm::relay::FuncType", "tvm::relay::Function", "tvm::relay::GlobalTypeVar", "tvm::relay::GlobalVar", "tvm::relay::Id", "tvm::relay::If", "tvm::relay::IncompleteType", "tvm::relay::InterpreterState", "tvm::relay::Let", "tvm::relay::Match", "tvm::relay::Module", "tvm::relay::NamedNDArray", "tvm::relay::Op", "tvm::relay::Pattern", "tvm::relay::PatternConstructor", "tvm::relay::PatternTuple", "tvm::relay::PatternVar", "tvm::relay::PatternWildcard", "tvm::relay::RecClosure", "tvm::relay::RefCreate", "tvm::relay::RefRead", "tvm::relay::RefType", "tvm::relay::RefValue", "tvm::relay::RefWrite", "tvm::relay::SourceName", "tvm::relay::Span", "tvm::relay::TempExpr", "tvm::relay::TensorType", "tvm::relay::Tuple", "tvm::relay::TupleGetItem", "tvm::relay::TupleType", "tvm::relay::Type", "tvm::relay::TypeCall", "tvm::relay::TypeConstraint", "tvm::relay::TypeData", "tvm::relay::TypeRelation", "tvm::relay::TypeReporter", "tvm::relay::TypeVar", "tvm::relay::Value", "tvm::relay::Var", "tvm::relay::alter_op_layout::LayoutAlternatedExpr", "tvm::relay::alter_op_layout::TransformMemorizer", "tvm::relay::fold_scale_axis::Message", "tvm::relay::fold_scale_axis:BackwardTransformer", ]: debugger.HandleCommand( "type summary add -F tvm.NodeRef_SummaryProvider {node} -w tvm".format(node=node) ) debugger.HandleCommand("command script add -f tvm.PrettyPrint pp") debugger.HandleCommand("type category enable tvm") def _log(logger, fmt, *args, **kwargs): global g_indent logger >> " " * g_indent + fmt.format(*args, **kwargs) def _GetContext(debugger): target = debugger.GetSelectedTarget() process = target.GetProcess() thread = process.GetThreadAtIndex(0) return thread.GetSelectedFrame() def PrettyPrint(debugger, command, result, internal_dict): ctx = _GetContext(debugger) rc = ctx.EvaluateExpression("tvm::PrettyPrint({command})".format(command=command)) result.AppendMessage(str(rc)) class EvaluateError(Exception): def __init__(self, error): super(Exception, self).__init__(str(error)) def _EvalExpression(logger, ctx, expr, value_name): _log(logger, "Evaluating {expr}".format(expr=expr)) rc = ctx.EvaluateExpression(expr) err = rc.GetError() if err.Fail(): _log(logger, "_EvalExpression failed: {err}".format(err=err)) raise EvaluateError(err) _log(logger, "_EvalExpression success: {typename}".format(typename=rc.GetTypeName())) return rc def _EvalExpressionAsString(logger, ctx, expr): result = _EvalExpression(logger, ctx, expr, None) return result.GetSummary() or result.GetValue() or "--" def _EvalAsNodeRef(logger, ctx, value): return _EvalExpressionAsString(logger, ctx, "tvm::PrettyPrint({name})".format(name=value.name)) def NodeRef_SummaryProvider(value, _): global g_indent g_indent += 2 try: if not value or not value.IsValid(): return "<invalid>" lldb.formatters.Logger._lldb_formatters_debug_level = 0 logger = lldb.formatters.Logger.Logger() ctx = _GetContext(lldb.debugger) return _EvalAsNodeRef(logger, ctx, value) except EvaluateError as e: return str(e) finally: g_indent -= 2
https://github.com/zk-ml/tachikoma
apps/microtvm/arduino/template_project/crt_config/crt_config.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \brief CRT configuration for the host-linked CRT. */ #ifndef TVM_RUNTIME_MICRO_CRT_CONFIG_H_ #define TVM_RUNTIME_MICRO_CRT_CONFIG_H_ /*! Log level of the CRT runtime */ #define TVM_CRT_LOG_LEVEL TVM_CRT_LOG_LEVEL_DEBUG /*! Support low-level debugging in MISRA-C runtime */ #define TVM_CRT_DEBUG 0 /*! Maximum supported dimension in NDArray */ #define TVM_CRT_MAX_NDIM 6 /*! Maximum supported arguments in generated functions */ #define TVM_CRT_MAX_ARGS 10 /*! Maximum supported string length in dltype, e.g. "int8", "int16", "float32" */ #define TVM_CRT_MAX_STRLEN_DLTYPE 10 /*! Maximum supported string length in function names */ #define TVM_CRT_MAX_STRLEN_FUNCTION_NAME 120 /*! Maximum supported string length in parameter names */ #define TVM_CRT_MAX_STRLEN_PARAM_NAME 80 /*! Maximum number of registered modules. */ #define TVM_CRT_MAX_REGISTERED_MODULES 2 /*! Size of the global function registry, in bytes. */ #define TVM_CRT_GLOBAL_FUNC_REGISTRY_SIZE_BYTES 512 /*! Maximum packet size, in bytes, including the length header. */ #define TVM_CRT_MAX_PACKET_SIZE_BYTES 8 * 1024 /*! \brief Maximum length of a PackedFunc function name. */ #define TVM_CRT_MAX_FUNCTION_NAME_LENGTH_BYTES 30 // #define TVM_CRT_FRAMER_ENABLE_LOGS #endif // TVM_RUNTIME_MICRO_CRT_CONFIG_H_
https://github.com/zk-ml/tachikoma
apps/microtvm/arduino/template_project/microtvm_api_server.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import json import logging import os.path import pathlib import re import shutil import subprocess import tarfile import tempfile import time from string import Template from packaging import version from tvm.micro.project_api import server _LOG = logging.getLogger(__name__) MODEL_LIBRARY_FORMAT_RELPATH = pathlib.Path("src") / "model" / "model.tar" API_SERVER_DIR = pathlib.Path(os.path.dirname(__file__) or os.path.getcwd()) BUILD_DIR = API_SERVER_DIR / "build" MODEL_LIBRARY_FORMAT_PATH = API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH IS_TEMPLATE = not (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH).exists() MIN_ARDUINO_CLI_VERSION = version.parse("0.18.0") BOARDS = API_SERVER_DIR / "boards.json" ARDUINO_CLI_CMD = shutil.which("arduino-cli") MAKEFILE_FILENAME = "Makefile" # Data structure to hold the information microtvm_api_server.py needs # to communicate with each of these boards. try: with open(BOARDS) as boards: BOARD_PROPERTIES = json.load(boards) except FileNotFoundError: raise FileNotFoundError(f"Board file {{{BOARDS}}} does not exist.") def get_cmsis_path(cmsis_path: pathlib.Path) -> pathlib.Path: """Returns CMSIS dependency path""" if cmsis_path: return pathlib.Path(cmsis_path) if os.environ.get("CMSIS_PATH"): return pathlib.Path(os.environ.get("CMSIS_PATH")) assert False, "'cmsis_path' option not passed!" class BoardAutodetectFailed(Exception): """Raised when no attached hardware is found matching the requested board""" PROJECT_TYPES = ["example_project", "host_driven"] PROJECT_OPTIONS = server.default_project_options( project_type={"choices": tuple(PROJECT_TYPES)}, board={"choices": list(BOARD_PROPERTIES), "optional": ["flash", "open_transport"]}, warning_as_error={"optional": ["build", "flash"]}, ) + [ server.ProjectOption( "arduino_cli_cmd", required=(["generate_project", "flash", "open_transport"] if not ARDUINO_CLI_CMD else None), optional=( ["generate_project", "build", "flash", "open_transport"] if ARDUINO_CLI_CMD else None ), type="str", default=ARDUINO_CLI_CMD, help="Path to the arduino-cli tool.", ), server.ProjectOption( "port", optional=["flash", "open_transport"], type="int", default=None, help="Port to use for connecting to hardware.", ), ] class Handler(server.ProjectAPIHandler): def __init__(self): super(Handler, self).__init__() self._proc = None self._port = None self._serial = None self._version = None def server_info_query(self, tvm_version): return server.ServerInfo( platform_name="arduino", is_template=IS_TEMPLATE, model_library_format_path="" if IS_TEMPLATE else MODEL_LIBRARY_FORMAT_PATH, project_options=PROJECT_OPTIONS, ) def _copy_project_files(self, api_server_dir, project_dir, project_type): """Copies the files for project_type into project_dir. Notes ----- template_dir is NOT a project type, and that directory is never copied in this function. template_dir only holds this file and its unit tests, so this file is copied separately in generate_project. """ for item in (API_SERVER_DIR / "src" / project_type).iterdir(): if item.name == "project.ino": continue dest = project_dir / "src" / item.name if item.is_dir(): shutil.copytree(item, dest) else: shutil.copy2(item, dest) # Arduino requires the .ino file have the same filename as its containing folder shutil.copy2( API_SERVER_DIR / "src" / project_type / "project.ino", project_dir / f"{project_dir.stem}.ino", ) CRT_COPY_ITEMS = ("include", "src") def _copy_standalone_crt(self, source_dir, standalone_crt_dir): output_crt_dir = source_dir / "standalone_crt" for item in self.CRT_COPY_ITEMS: src_path = os.path.join(standalone_crt_dir, item) dst_path = output_crt_dir / item if os.path.isdir(src_path): shutil.copytree(src_path, dst_path) else: shutil.copy2(src_path, dst_path) # Example project is the "minimum viable project", # and doesn't need a fancy RPC server EXAMPLE_PROJECT_UNUSED_COMPONENTS = [ "include/dmlc", "src/support", "src/runtime/minrpc", "src/runtime/crt/graph_executor", "src/runtime/crt/microtvm_rpc_common", "src/runtime/crt/microtvm_rpc_server", "src/runtime/crt/tab", ] def _remove_unused_components(self, source_dir, project_type): unused_components = [] if project_type == "example_project": unused_components = self.EXAMPLE_PROJECT_UNUSED_COMPONENTS for component in unused_components: shutil.rmtree(source_dir / "standalone_crt" / component) def _disassemble_mlf(self, mlf_tar_path, source_dir): with tempfile.TemporaryDirectory() as mlf_unpacking_dir_str: mlf_unpacking_dir = pathlib.Path(mlf_unpacking_dir_str) with tarfile.open(mlf_tar_path, "r:") as tar: tar.extractall(mlf_unpacking_dir) model_dir = source_dir / "model" model_dir.mkdir() # Copy C files from model. The filesnames and quantity # depend on the target string, so we just copy all c files source_dir = mlf_unpacking_dir / "codegen" / "host" / "src" for file in source_dir.rglob("*.c"): shutil.copy(file, model_dir) # Return metadata.json for use in templating with open(os.path.join(mlf_unpacking_dir, "metadata.json")) as f: metadata = json.load(f) return metadata def _template_model_header(self, source_dir, metadata): with open(source_dir / "model.h", "r") as f: model_h_template = Template(f.read()) all_module_names = [] for name in metadata["modules"].keys(): all_module_names.append(name) assert all( metadata["modules"][mod_name]["style"] == "full-model" for mod_name in all_module_names ), "when generating AOT, expect only full-model Model Library Format" workspace_size_bytes = 0 for mod_name in all_module_names: workspace_size_bytes += metadata["modules"][mod_name]["memory"]["functions"]["main"][0][ "workspace_size_bytes" ] template_values = { "workspace_size_bytes": workspace_size_bytes, } with open(source_dir / "model.h", "w") as f: f.write(model_h_template.substitute(template_values)) # Arduino ONLY recognizes .ino, .ccp, .c, .h CPP_FILE_EXTENSION_SYNONYMS = ("cc", "cxx") def _change_cpp_file_extensions(self, source_dir): for ext in self.CPP_FILE_EXTENSION_SYNONYMS: for filename in source_dir.rglob(f"*.{ext}"): filename.rename(filename.with_suffix(".cpp")) for filename in source_dir.rglob("*.inc"): filename.rename(filename.with_suffix(".h")) def _convert_includes(self, project_dir, source_dir): """Changes all #include statements in project_dir to be relevant to their containing file's location. Arduino only supports includes relative to a file's location, so this function finds each time we #include a file and changes the path to be relative to the file location. Does not do this for standard C libraries. Also changes angle brackets syntax to double quotes syntax. See Also ----- https://www.arduino.cc/reference/en/language/structure/further-syntax/include/ """ for ext in ("c", "h", "cpp"): for filename in source_dir.rglob(f"*.{ext}"): with filename.open("rb") as src_file: lines = src_file.readlines() with filename.open("wb") as dst_file: for line in lines: line_str = str(line, "utf-8") # Check if line has an include result = re.search(r"#include\s*[<\"]([^>]*)[>\"]", line_str) if not result: dst_file.write(line) else: new_include = self._find_modified_include_path( project_dir, filename, result.groups()[0] ) updated_line = f'#include "{new_include}"\n' dst_file.write(updated_line.encode("utf-8")) # Most of the files we used to be able to point to directly are under "src/standalone_crt/include/". # Howver, crt_config.h lives under "src/standalone_crt/crt_config/", and more exceptions might # be added in the future. POSSIBLE_BASE_PATHS = ["src/standalone_crt/include/", "src/standalone_crt/crt_config/"] def _find_modified_include_path(self, project_dir, file_path, include_path): """Takes a single #include path, and returns the location it should point to. Examples -------- >>> _find_modified_include_path( ... "/path/to/project/dir" ... "/path/to/project/dir/src/standalone_crt/src/runtime/crt/common/ndarray.c" ... "tvm/runtime/crt/platform.h" ... ) "../../../../../../src/standalone_crt/include/tvm/runtime/crt/platform.h" """ if include_path.endswith(".inc"): include_path = re.sub(r"\.[a-z]+$", ".h", include_path) # Change includes referencing .cc and .cxx files to point to the renamed .cpp file if include_path.endswith(self.CPP_FILE_EXTENSION_SYNONYMS): include_path = re.sub(r"\.[a-z]+$", ".cpp", include_path) # If the include already works, don't modify it if (file_path.parents[0] / include_path).exists(): return include_path relative_path = file_path.relative_to(project_dir) up_dirs_path = "../" * str(relative_path).count("/") for base_path in self.POSSIBLE_BASE_PATHS: full_potential_path = project_dir / base_path / include_path if full_potential_path.exists(): return up_dirs_path + base_path + include_path # If we can't find the file, just leave it untouched # It's probably a standard C/C++ header return include_path CMSIS_INCLUDE_HEADERS = [ "arm_nn_math_types.h", "arm_nn_tables.h", "arm_nn_types.h", "arm_nnfunctions.h", "arm_nnsupportfunctions.h", ] def _cmsis_required(self, project_path: pathlib.Path) -> bool: """Check if CMSIS dependency is required.""" project_path = pathlib.Path(project_path) for path in (project_path / "src" / "model").iterdir(): if path.is_file(): # Encoding is for reading C generated code which also includes hex numbers with open(path, "r", encoding="ISO-8859-1") as lib_f: lib_content = lib_f.read() if any(header in lib_content for header in self.CMSIS_INCLUDE_HEADERS): return True return False def _copy_cmsis(self, project_path: pathlib.Path, cmsis_path: str): """Copy CMSIS header files to project. Note: We use this CMSIS package:https://www.arduino.cc/reference/en/libraries/arduino_cmsis-dsp/ However, the latest release does not include header files that are copied in this function. """ (project_path / "include" / "cmsis").mkdir() cmsis_path = get_cmsis_path(cmsis_path) for item in self.CMSIS_INCLUDE_HEADERS: shutil.copy2( cmsis_path / "CMSIS" / "NN" / "Include" / item, project_path / "include" / "cmsis" / item, ) def _populate_makefile( self, makefile_template_path: pathlib.Path, makefile_path: pathlib.Path, board: str, verbose: bool, arduino_cli_cmd: str, build_extra_flags: str, ): """Generate Makefile from template.""" flags = { "FQBN": self._get_fqbn(board), "VERBOSE_FLAG": "--verbose" if verbose else "", "ARUINO_CLI_CMD": self._get_arduino_cli_cmd(arduino_cli_cmd), "BOARD": board, "BUILD_EXTRA_FLAGS": build_extra_flags, } with open(makefile_path, "w") as makefile_f: with open(makefile_template_path, "r") as makefile_template_f: for line in makefile_template_f: SUBST_TOKEN_RE = re.compile(r"<([A-Z_]+)>") outs = [] for i, m in enumerate(re.split(SUBST_TOKEN_RE, line)): if i % 2 == 1: m = flags[m] outs.append(m) line = "".join(outs) makefile_f.write(line) def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options): # List all used project options board = options["board"] verbose = options.get("verbose") project_type = options["project_type"] arduino_cli_cmd = options.get("arduino_cli_cmd") cmsis_path = options.get("cmsis_path") compile_definitions = options.get("compile_definitions") extra_files_tar = options.get("extra_files_tar") # Reference key directories with pathlib project_dir = pathlib.Path(project_dir) project_dir.mkdir() source_dir = project_dir / "src" source_dir.mkdir() # Copies files from the template folder to project_dir shutil.copy2(API_SERVER_DIR / "microtvm_api_server.py", project_dir) shutil.copy2(BOARDS, project_dir / BOARDS.name) self._copy_project_files(API_SERVER_DIR, project_dir, project_type) # Copy standalone_crt into src folder self._copy_standalone_crt(source_dir, standalone_crt_dir) self._remove_unused_components(source_dir, project_type) # Populate crt-config.h crt_config_dir = project_dir / "src" / "standalone_crt" / "crt_config" crt_config_dir.mkdir() shutil.copy2( API_SERVER_DIR / "crt_config" / "crt_config.h", crt_config_dir / "crt_config.h" ) # Unpack the MLF and copy the relevant files metadata = self._disassemble_mlf(model_library_format_path, source_dir) shutil.copy2(model_library_format_path, project_dir / MODEL_LIBRARY_FORMAT_RELPATH) # For AOT, template model.h with metadata to minimize space usage if project_type == "example_project": self._template_model_header(source_dir, metadata) self._change_cpp_file_extensions(source_dir) # Recursively change includes self._convert_includes(project_dir, source_dir) # create include directory (project_dir / "include").mkdir() # Populate extra_files if extra_files_tar: with tarfile.open(extra_files_tar, mode="r:*") as tf: tf.extractall(project_dir) build_extra_flags = '"build.extra_flags=' if extra_files_tar: build_extra_flags += "-I./include " if compile_definitions: for item in compile_definitions: build_extra_flags += f"{item} " if self._cmsis_required(project_dir): build_extra_flags += f"-I./include/cmsis " self._copy_cmsis(project_dir, cmsis_path) build_extra_flags += '"' # Check if build_extra_flags is empty if build_extra_flags == '"build.extra_flags="': build_extra_flags = '""' # Populate Makefile self._populate_makefile( API_SERVER_DIR / f"{MAKEFILE_FILENAME}.template", project_dir / MAKEFILE_FILENAME, board, verbose, arduino_cli_cmd, build_extra_flags, ) def _get_arduino_cli_cmd(self, arduino_cli_cmd: str): if not arduino_cli_cmd: arduino_cli_cmd = ARDUINO_CLI_CMD assert arduino_cli_cmd, "'arduino_cli_cmd' command not passed and not found by default!" return arduino_cli_cmd def _get_platform_version(self, arduino_cli_path: str) -> float: # sample output of this command: # 'arduino-cli alpha Version: 0.18.3 Commit: d710b642 Date: 2021-05-14T12:36:58Z\n' version_output = subprocess.run( [arduino_cli_path, "version"], check=True, stdout=subprocess.PIPE ).stdout.decode("utf-8") str_version = re.search(r"Version: ([\.0-9]*)", version_output).group(1) # Using too low a version should raise an error. Note that naively # comparing floats will fail here: 0.7 > 0.21, but 0.21 is a higher # version (hence we need version.parse) return version.parse(str_version) # This will only be run for build and upload def _check_platform_version(self, cli_command: str, warning_as_error: bool): if not self._version: self._version = self._get_platform_version(cli_command) if self._version < MIN_ARDUINO_CLI_VERSION: message = ( f"Arduino CLI version too old: found {self._version}, " f"need at least {str(MIN_ARDUINO_CLI_VERSION)}." ) if warning_as_error is not None and warning_as_error: raise server.ServerError(message=message) _LOG.warning(message) def _get_fqbn(self, board: str): o = BOARD_PROPERTIES[board] return f"{o['package']}:{o['architecture']}:{o['board']}" def build(self, options): # List all used project options arduino_cli_cmd = options.get("arduino_cli_cmd") warning_as_error = options.get("warning_as_error") cli_command = self._get_arduino_cli_cmd(arduino_cli_cmd) self._check_platform_version(cli_command, warning_as_error) compile_cmd = ["make", "build"] # Specify project to compile subprocess.run(compile_cmd, check=True, cwd=API_SERVER_DIR) POSSIBLE_BOARD_LIST_HEADERS = ("Port", "Protocol", "Type", "Board Name", "FQBN", "Core") def _parse_connected_boards(self, tabular_str): """Parses the tabular output from `arduino-cli board list` into a 2D array Examples -------- >>> list(_parse_connected_boards(bytes( ... "Port Type Board Name FQBN Core \n" ... "/dev/ttyS4 Serial Port Unknown \n" ... "/dev/ttyUSB0 Serial Port (USB) Spresense SPRESENSE:spresense:spresense SPRESENSE:spresense\n" ... "\n", ... "utf-8"))) [['/dev/ttys4', 'Serial Port', 'Unknown', '', ''], ['/dev/ttyUSB0', 'Serial Port (USB)', 'Spresense', 'SPRESENSE:spresense:spresense', 'SPRESENSE:spresense']] """ # Which column headers are present depends on the version of arduino-cli column_regex = r"\s*|".join(self.POSSIBLE_BOARD_LIST_HEADERS) + r"\s*" str_rows = tabular_str.split("\n") column_headers = list(re.finditer(column_regex, str_rows[0])) assert len(column_headers) > 0 for str_row in str_rows[1:]: if not str_row.strip(): continue device = {} for column in column_headers: col_name = column.group(0).strip().lower() device[col_name] = str_row[column.start() : column.end()].strip() yield device def _auto_detect_port(self, arduino_cli_cmd: str, board: str) -> str: list_cmd = [self._get_arduino_cli_cmd(arduino_cli_cmd), "board", "list"] list_cmd_output = subprocess.run( list_cmd, check=True, stdout=subprocess.PIPE ).stdout.decode("utf-8") desired_fqbn = self._get_fqbn(board) for device in self._parse_connected_boards(list_cmd_output): if device["fqbn"] == desired_fqbn: return device["port"] # If no compatible boards, raise an error raise BoardAutodetectFailed() def _get_arduino_port(self, arduino_cli_cmd: str, board: str, port: int): if not self._port: if port: self._port = port else: self._port = self._auto_detect_port(arduino_cli_cmd, board) return self._port def _get_board_from_makefile(self, makefile_path: pathlib.Path) -> str: """Get Board from generated Makefile.""" with open(makefile_path) as makefile_f: line = makefile_f.readline() if "BOARD" in line: board = re.sub(r"\s", "", line).split(":=")[1] return board raise RuntimeError("Board was not found in Makefile: {}".format(makefile_path)) FLASH_TIMEOUT_SEC = 60 FLASH_MAX_RETRIES = 5 def flash(self, options): # List all used project options arduino_cli_cmd = options.get("arduino_cli_cmd") warning_as_error = options.get("warning_as_error") port = options.get("port") board = options.get("board") if not board: board = self._get_board_from_makefile(API_SERVER_DIR / MAKEFILE_FILENAME) cli_command = self._get_arduino_cli_cmd(arduino_cli_cmd) self._check_platform_version(cli_command, warning_as_error) port = self._get_arduino_port(cli_command, board, port) upload_cmd = ["make", "flash", f"PORT={port}"] for _ in range(self.FLASH_MAX_RETRIES): try: subprocess.run( upload_cmd, check=True, timeout=self.FLASH_TIMEOUT_SEC, cwd=API_SERVER_DIR ) break # We only catch timeout errors - a subprocess.CalledProcessError # (caused by subprocess.run returning non-zero code) will not # be caught. except subprocess.TimeoutExpired: _LOG.warning( f"Upload attempt to port {port} timed out after {self.FLASH_TIMEOUT_SEC} seconds" ) else: raise RuntimeError( f"Unable to flash Arduino board after {self.FLASH_MAX_RETRIES} attempts" ) def open_transport(self, options): import serial import serial.tools.list_ports # List all used project options arduino_cli_cmd = options.get("arduino_cli_cmd") port = options.get("port") board = options.get("board") if not board: board = self._get_board_from_makefile(API_SERVER_DIR / MAKEFILE_FILENAME) # Zephyr example doesn't throw an error in this case if self._serial is not None: return port = self._get_arduino_port(arduino_cli_cmd, board, port) # It takes a moment for the Arduino code to finish initializing # and start communicating over serial for _ in range(10): if any(serial.tools.list_ports.grep(port)): break time.sleep(0.5) self._serial = serial.Serial(port, baudrate=115200, timeout=10) return server.TransportTimeouts( session_start_retry_timeout_sec=2.0, session_start_timeout_sec=5.0, session_established_timeout_sec=5.0, ) def close_transport(self): if self._serial is None: return self._serial.close() self._serial = None def read_transport(self, n, timeout_sec): self._serial.timeout = timeout_sec if self._serial is None: raise server.TransportClosedError() return self._serial.read(n) def write_transport(self, data, timeout_sec): self._serial.write_timeout = timeout_sec if self._serial is None: raise server.TransportClosedError() return self._serial.write(data) if __name__ == "__main__": server.main(Handler())
https://github.com/zk-ml/tachikoma
apps/microtvm/arduino/template_project/src/example_project/model.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 "model.h" #include "Arduino.h" #include "standalone_crt/include/dlpack/dlpack.h" #include "standalone_crt/include/tvm/runtime/crt/stack_allocator.h" // AOT memory array, stack allocator wants it aligned static uint8_t g_aot_memory[WORKSPACE_SIZE] __attribute__((aligned(TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES))); tvm_workspace_t app_workspace; // Blink code for debugging purposes void TVMPlatformAbort(tvm_crt_error_t error) { TVMLogf("TVMPlatformAbort: 0x%08x\n", error); for (;;) { #ifdef LED_BUILTIN digitalWrite(LED_BUILTIN, HIGH); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(250); digitalWrite(LED_BUILTIN, HIGH); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(750); #endif } } void TVMLogf(const char* msg, ...) {} tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { return StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr); } tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { return StackMemoryManager_Free(&app_workspace, ptr); } unsigned long g_utvm_start_time_micros; int g_utvm_timer_running = 0; tvm_crt_error_t TVMPlatformTimerStart() { if (g_utvm_timer_running) { return kTvmErrorPlatformTimerBadState; } g_utvm_timer_running = 1; g_utvm_start_time_micros = micros(); return kTvmErrorNoError; } tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) { if (!g_utvm_timer_running) { return kTvmErrorPlatformTimerBadState; } g_utvm_timer_running = 0; unsigned long g_utvm_stop_time = micros() - g_utvm_start_time_micros; *elapsed_time_seconds = ((double)g_utvm_stop_time) / 1e6; return kTvmErrorNoError; } tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) { for (size_t i = 0; i < num_bytes; i++) { buffer[i] = rand(); } return kTvmErrorNoError; } void TVMInitialize() { StackMemoryManager_Init(&app_workspace, g_aot_memory, WORKSPACE_SIZE); } void TVMExecute(void* input_data, void* output_data) { int ret_val = tvmgen_default___tvm_main__(input_data, output_data); if (ret_val != 0) { TVMPlatformAbort(kTvmErrorPlatformCheckFailure); } }
https://github.com/zk-ml/tachikoma
apps/microtvm/arduino/template_project/src/example_project/model.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ #define WORKSPACE_SIZE $workspace_size_bytes #ifdef __cplusplus extern "C" { #endif void TVMInitialize(); /* TODO template this function signature with the input and output * data types and sizes. For example: * * void TVMExecute(uint8_t input_data[9216], uint8_t output_data[3]); * * Note this can only be done once MLF has JSON metadata describing * inputs and outputs. */ void TVMExecute(void* input_data, void* output_data); #ifdef __cplusplus } // extern "C" #endif
https://github.com/zk-ml/tachikoma
apps/microtvm/arduino/template_project/src/host_driven/model_support.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 "standalone_crt/include/dlpack/dlpack.h" #include "standalone_crt/include/tvm/runtime/crt/error_codes.h" #include "stdarg.h" // Blink code for debugging purposes void TVMPlatformAbort(tvm_crt_error_t error) { TVMLogf("TVMPlatformAbort: 0x%08x\n", error); for (;;) ; } size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt, va_list args) { return vsnprintf(out_buf, out_buf_size_bytes, fmt, args); } tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { if (num_bytes == 0) { num_bytes = sizeof(int); } *out_ptr = malloc(num_bytes); return (*out_ptr == NULL) ? kTvmErrorPlatformNoMemory : kTvmErrorNoError; } tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { free(ptr); return kTvmErrorNoError; } unsigned long g_utvm_start_time_micros; int g_utvm_timer_running = 0; tvm_crt_error_t TVMPlatformTimerStart() { if (g_utvm_timer_running) { return kTvmErrorPlatformTimerBadState; } g_utvm_timer_running = 1; g_utvm_start_time_micros = micros(); return kTvmErrorNoError; } tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) { if (!g_utvm_timer_running) { return kTvmErrorPlatformTimerBadState; } g_utvm_timer_running = 0; unsigned long g_utvm_stop_time = micros() - g_utvm_start_time_micros; *elapsed_time_seconds = ((double)g_utvm_stop_time) / 1e6; return kTvmErrorNoError; } tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) { for (size_t i = 0; i < num_bytes; i++) { buffer[i] = rand(); } return kTvmErrorNoError; }
https://github.com/zk-ml/tachikoma
apps/microtvm/cmsisnn/convert_image.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import os import pathlib import re import sys from PIL import Image import numpy as np def create_header_file(name, tensor_name, tensor_data, output_path): """ This function generates a header file containing the data from the numpy array provided. """ file_path = pathlib.Path(f"{output_path}/" + name).resolve() # Create header file with npy_data as a C array raw_path = file_path.with_suffix(".h").resolve() with open(raw_path, "w") as header_file: header_file.write( "\n" + f"const size_t {tensor_name}_len = {tensor_data.size};\n" + f'__attribute__((section(".data.tvm"), aligned(16))) int8_t {tensor_name}[] = "' ) data_hexstr = tensor_data.tobytes().hex() for i in range(0, len(data_hexstr), 2): header_file.write(f"\\x{data_hexstr[i:i+2]}") header_file.write('";\n\n') def create_headers(image_name): """ This function generates C header files for the input and output arrays required to run inferences """ img_path = os.path.join("./", f"{image_name}") # Resize image to 224x224 resized_image = Image.open(img_path).resize((224, 224)) img_data = np.asarray(resized_image).astype("float32") # # Add the batch dimension, as we are expecting 4-dimensional input: NCHW. img_data = np.expand_dims(img_data, axis=0) # Create input header file input_data = img_data - 128 input_data = input_data.astype(np.int8) create_header_file("inputs", "input", input_data, "./include") # Create output header file output_data = np.zeros([2], np.int8) create_header_file( "outputs", "output", output_data, "./include", ) if __name__ == "__main__": create_headers(sys.argv[1])
https://github.com/zk-ml/tachikoma
apps/microtvm/cmsisnn/include/crt_config.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_RUNTIME_CRT_CONFIG_H_ #define TVM_RUNTIME_CRT_CONFIG_H_ /*! Log level of the CRT runtime */ #define TVM_CRT_LOG_LEVEL TVM_CRT_LOG_LEVEL_DEBUG #endif // TVM_RUNTIME_CRT_CONFIG_H_
https://github.com/zk-ml/tachikoma
apps/microtvm/cmsisnn/include/tvm_runtime.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <tvm/runtime/c_runtime_api.h> #include <tvm/runtime/crt/stack_allocator.h> #ifdef __cplusplus extern "C" { #endif void __attribute__((noreturn)) TVMPlatformAbort(tvm_crt_error_t error_code) { printf("TVMPlatformAbort: %d\n", error_code); printf("EXITTHESIM\n"); exit(-1); } tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { return kTvmErrorFunctionCallNotImplemented; } tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { return kTvmErrorFunctionCallNotImplemented; } void TVMLogf(const char* msg, ...) { va_list args; va_start(args, msg); vfprintf(stdout, msg, args); va_end(args); } TVM_DLL int TVMFuncRegisterGlobal(const char* name, TVMFunctionHandle f, int override) { return 0; } #ifdef __cplusplus } #endif
https://github.com/zk-ml/tachikoma
apps/microtvm/cmsisnn/src/demo_bare_metal.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <stdio.h> #include <tvm_runtime.h> #include <tvmgen_detection.h> #include "uart.h" // Header files generated by convert_image.py #include "inputs.h" #include "outputs.h" int main(int argc, char** argv) { uart_init(); printf("Starting Demo\n"); printf("Running detection inference\n"); struct tvmgen_detection_outputs detection_outputs = { .MobilenetV1_Predictions_Reshape_1 = output, }; struct tvmgen_detection_inputs detection_inputs = { .input = input, }; tvmgen_detection_run(&detection_inputs, &detection_outputs); // Report result if (output[1] > output[0]) { printf("Person detected.\n"); } else { printf("No person detected.\n"); } // The FVP will shut down when it receives "EXITTHESIM" on the UART printf("EXITTHESIM\n"); while (1 == 1) ; return 0; }
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/convert_image.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import os import pathlib import re import sys from PIL import Image import numpy as np def create_header_file(name, section, tensor_name, tensor_data, output_path): """ This function generates a header file containing the data from the numpy array provided. """ file_path = pathlib.Path(f"{output_path}/" + name).resolve() # Create header file with npy_data as a C array raw_path = file_path.with_suffix(".h").resolve() with open(raw_path, "w") as header_file: header_file.write( "#include <tvmgen_default.h>\n" + f"const size_t {tensor_name}_len = {tensor_data.size};\n" + f'int8_t {tensor_name}[] __attribute__((section("{section}"), aligned(16))) = "' ) data_hexstr = tensor_data.tobytes().hex() for i in range(0, len(data_hexstr), 2): header_file.write(f"\\x{data_hexstr[i:i+2]}") header_file.write('";\n\n') def create_headers(image_name): """ This function generates C header files for the input and output arrays required to run inferences """ img_path = os.path.join("./", f"{image_name}") # Resize image to 224x224 resized_image = Image.open(img_path).resize((224, 224)) img_data = np.asarray(resized_image).astype("float32") # # Add the batch dimension, as we are expecting 4-dimensional input: NCHW. img_data = np.expand_dims(img_data, axis=0) # Create input header file input_data = img_data - 128 input_data = input_data.astype(np.int8) create_header_file("inputs", "ethosu_scratch", "input", input_data, "./include") # Create output header file output_data = np.zeros([1001], np.int8) create_header_file( "outputs", "output_data_sec", "output", output_data, "./include", ) if __name__ == "__main__": create_headers(sys.argv[1])
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/convert_labels.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import os import pathlib import sys def create_labels_header(labels_file, section, output_path): """ This function generates a header file containing the ImageNet labels as an array of strings """ labels_path = pathlib.Path(labels_file).resolve() file_path = pathlib.Path(f"{output_path}/labels.h").resolve() with open(labels_path) as f: labels = f.readlines() with open(file_path, "w") as header_file: header_file.write(f'char* labels[] __attribute__((section("{section}"), aligned(16))) = {{') for _, label in enumerate(labels): header_file.write(f'"{label.rstrip()}",') header_file.write("};\n") if __name__ == "__main__": create_labels_header(sys.argv[1], "ethosu_scratch", "./include")
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/include/FreeRTOSConfig.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /* Please refer to http://www.freertos.org/a00110.html for refernce. */ #ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H /****************************************************************************** * Defines **********SYSTEM_CORE_CLOCK********************************************************************/ /* Hardware features */ #define configENABLE_MPU 0 #define configENABLE_FPU 0 #define configENABLE_TRUSTZONE 0 /* Scheduling */ #define configCPU_CLOCK_HZ 25000000 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 #define configUSE_PREEMPTION 1 #define configUSE_TIME_SLICING 0 #define configMAX_PRIORITIES 5 #define configIDLE_SHOULD_YIELD 1 #define configUSE_16_BIT_TICKS 0 #define configRUN_FREERTOS_SECURE_ONLY 1 /* Stack and heap */ #define configMINIMAL_STACK_SIZE (uint16_t)128 #define configMINIMAL_SECURE_STACK_SIZE 1024 #define configTOTAL_HEAP_SIZE (size_t)(50 * 1024) #define configMAX_TASK_NAME_LEN 12 /* OS features */ #define configUSE_MUTEXES 1 #define configUSE_TICKLESS_IDLE 1 #define configUSE_APPLICATION_TASK_TAG 0 #define configUSE_NEWLIB_REENTRANT 0 #define configUSE_CO_ROUTINES 0 #define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_QUEUE_SETS 0 #define configUSE_TASK_NOTIFICATIONS 1 #define configUSE_TRACE_FACILITY 1 /* Hooks */ #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configUSE_MALLOC_FAILED_HOOK 0 /* Debug features */ #define configCHECK_FOR_STACK_OVERFLOW 0 #define configASSERT(x) \ if ((x) == 0) { \ taskDISABLE_INTERRUPTS(); \ for (;;) \ ; \ } #define configQUEUE_REGISTRY_SIZE 0 /* Timers and queues */ #define configUSE_TIMERS 1 #define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) #define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE #define configTIMER_QUEUE_LENGTH 5 /* Task settings */ #define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_vTaskDelete 1 #define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_uxTaskGetStackHighWaterMark 0 #define INCLUDE_xTaskGetIdleTaskHandle 0 #define INCLUDE_eTaskGetState 1 #define INCLUDE_xTaskResumeFromISR 0 #define INCLUDE_xTaskGetCurrentTaskHandle 1 #define INCLUDE_xTaskGetSchedulerState 0 #define INCLUDE_xSemaphoreGetMutexHolder 0 #define INCLUDE_xTimerPendFunctionCall 1 #define configUSE_STATS_FORMATTING_FUNCTIONS 1 #define configCOMMAND_INT_MAX_OUTPUT_SIZE 2048 #ifdef __NVIC_PRIO_BITS #define configPRIO_BITS __NVIC_PRIO_BITS #else #define configPRIO_BITS 3 #endif /* Interrupt settings */ #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x07 #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 #define configKERNEL_INTERRUPT_PRIORITY \ (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) #define configMAX_SYSCALL_INTERRUPT_PRIORITY \ (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) #ifndef __IASMARM__ #define configGENERATE_RUN_TIME_STATS 0 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() #define portGET_RUN_TIME_COUNTER_VALUE() 0 #define configTICK_RATE_HZ (TickType_t)1000 #endif /* __IASMARM__ */ #define xPortPendSVHandler PendSV_Handler #define vPortSVCHandler SVC_Handler #define xPortSysTickHandler SysTick_Handler #endif /* FREERTOS_CONFIG_H */
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/include/crt_config.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_RUNTIME_CRT_CONFIG_H_ #define TVM_RUNTIME_CRT_CONFIG_H_ /*! Log level of the CRT runtime */ #define TVM_CRT_LOG_LEVEL TVM_CRT_LOG_LEVEL_DEBUG #endif // TVM_RUNTIME_CRT_CONFIG_H_
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/include/ethosu_55.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_APPS_MICROTVM_ETHOS_U_ETHOSU_55_H_ #define TVM_APPS_MICROTVM_ETHOS_U_ETHOSU_55_H_ /* Define Arm(R) Ethos(TM)-U55 specific IRQs & base address */ #define ETHOSU_NPU_FAIL (1 << 4) #define ETHOSU_IRQ ((IRQn_Type)56) #define ETHOSU_BASE_ADDRESS ((void*)0x48102000) #endif // TVM_APPS_MICROTVM_ETHOS_U_ETHOSU_55_H_
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/include/ethosu_mod.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_APPS_MICROTVM_ETHOS_U_ETHOSU_MOD_H_ #define TVM_APPS_MICROTVM_ETHOS_U_ETHOSU_MOD_H_ #include <ARMCM55.h> // TODO: Remove device specific information once RTOS support is available #include <ethosu_driver.h> #include <stdio.h> #include "ethosu_55.h" struct ethosu_driver ethosu0_driver; void ethosuIrqHandler0() { ethosu_irq_handler(&ethosu0_driver); } // Initialize Arm(R) Ethos(TM)-U NPU driver int EthosuInit() { if (ethosu_init(&ethosu0_driver, (void*)ETHOSU_BASE_ADDRESS, NULL, 0, 1, 1)) { printf("Failed to initialize NPU.\n"); return -1; } // Assumes SCB->VTOR points to RW memory NVIC_SetVector(ETHOSU_IRQ, (uint32_t)&ethosuIrqHandler0); NVIC_EnableIRQ(ETHOSU_IRQ); return 0; } #endif // TVM_APPS_MICROTVM_ETHOS_U_ETHOSU_MOD_H_
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/include/tvm_ethosu_runtime.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_RUNTIME_CONTRIB_ETHOSU_ETHOSU_RUNTIME_H_ #define TVM_RUNTIME_CONTRIB_ETHOSU_ETHOSU_RUNTIME_H_ #include <ethosu_driver.h> #include <stddef.h> #include <stdint.h> typedef void tvm_device_ethos_u_t; int32_t TVMEthosULaunch(tvm_device_ethos_u_t* resource_handle, void* cms_data, size_t cms_data_size, uint64_t* base_addrs, size_t* base_addrs_size, int num_tensors); int32_t TVMDeviceEthosUActivate(tvm_device_ethos_u_t* context); int32_t TVMDeviceEthosUOpen(tvm_device_ethos_u_t* context); int32_t TVMDeviceEthosUClose(tvm_device_ethos_u_t* context); int32_t TVMDeviceEthosUDeactivate(tvm_device_ethos_u_t* context); #endif // TVM_RUNTIME_CONTRIB_ETHOSU_ETHOSU_RUNTIME_H_
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/include/tvm_runtime.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <tvm/runtime/c_runtime_api.h> #include <tvm/runtime/crt/stack_allocator.h> #ifdef __cplusplus extern "C" { #endif void __attribute__((noreturn)) TVMPlatformAbort(tvm_crt_error_t error_code) { printf("TVMPlatformAbort: %d\n", error_code); printf("EXITTHESIM\n"); exit(-1); } tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { return kTvmErrorFunctionCallNotImplemented; } tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { return kTvmErrorFunctionCallNotImplemented; } void TVMLogf(const char* msg, ...) { va_list args; va_start(args, msg); vfprintf(stdout, msg, args); va_end(args); } TVM_DLL int TVMFuncRegisterGlobal(const char* name, TVMFunctionHandle f, int override) { return 0; } #ifdef __cplusplus } #endif
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/src/demo_bare_metal.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <stdio.h> #include <tvm_runtime.h> #include "ethosu_mod.h" #include "uart.h" // Header files generated by convert_image.py and convert_labels.py #include "inputs.h" #include "labels.h" #include "outputs.h" int abs(int v) { return v * ((v > 0) - (v < 0)); } int main(int argc, char** argv) { uart_init(); printf("Starting Demo\n"); EthosuInit(); printf("Running inference\n"); struct tvmgen_default_outputs outputs = { .MobilenetV2_Predictions_Reshape_11 = output, }; struct tvmgen_default_inputs inputs = { .tfl_quantize = input, }; struct ethosu_driver* driver = ethosu_reserve_driver(); struct tvmgen_default_devices devices = { .ethos_u = driver, }; tvmgen_default_run(&inputs, &outputs, &devices); ethosu_release_driver(driver); // Calculate index of max value int8_t max_value = -128; int32_t max_index = -1; for (unsigned int i = 0; i < output_len; ++i) { if (output[i] > max_value) { max_value = output[i]; max_index = i; } } printf("The image has been classified as '%s'\n", labels[max_index]); // The FVP will shut down when it receives "EXITTHESIM" on the UART printf("EXITTHESIM\n"); while (1 == 1) ; return 0; }
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/src/demo_freertos.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <FreeRTOS.h> #include <queue.h> #include <stdio.h> #include <task.h> #include <tvm_runtime.h> #include "ethosu_mod.h" #include "uart.h" // Header files generated by convert_image.py and convert_labels.py #include "inputs.h" #include "labels.h" #include "outputs.h" static void prvInferenceTask(void* pvParameters); static void prvDataCollectionTask(void* pvParameters); #define mainQUEUE_INFERENCE_TASK_PRIORITY (tskIDLE_PRIORITY + 3) #define mainQUEUE_INFERENCE_TASK_STACK_SIZE 4096 #define mainQUEUE_DATA_TASK_PRIORITY (tskIDLE_PRIORITY + 2) #define mainQUEUE_DATA_TASK_STACK_SIZE configMINIMAL_STACK_SIZE #define mainQUEUE_LENGTH (1) #define mainQUEUE_SEND_FREQUENCY_MS (100 / portTICK_PERIOD_MS) /* The queue used to pass data to run through our model */ static QueueHandle_t xQueue = NULL; int main(void) { // Platform UART uart_init(); // NPU EthosuInit(); // Queue for inferences xQueue = xQueueCreate(mainQUEUE_LENGTH, sizeof(uint8_t*)); if (xQueue != NULL) { // Inference task xTaskCreate(prvInferenceTask, "Inference", mainQUEUE_INFERENCE_TASK_STACK_SIZE, NULL, mainQUEUE_INFERENCE_TASK_PRIORITY, NULL); // Data collector task xTaskCreate(prvDataCollectionTask, "Data", mainQUEUE_DATA_TASK_STACK_SIZE, NULL, mainQUEUE_DATA_TASK_PRIORITY, NULL); // Start the task scheduling vTaskStartScheduler(); } // The task scheduler should take over before this is reached printf("Unreachable code reached!\n"); } /* * This task emulates collection of data and sending it to another inference task * for processing */ static void prvDataCollectionTask(void* pvParameters) { // Unused (void)pvParameters; // Working vTaskDelay(mainQUEUE_SEND_FREQUENCY_MS); // Construct pointer to copy to queue uint8_t** pucInputData = &input; xQueueSend(xQueue, &pucInputData, 0U); } /* * This task emulates the inference of data sent by the collector task */ static void prvInferenceTask(void* pvParameters) { uint8_t* pucReceivedData; // Unused (void)pvParameters; // Wait for data collection xQueueReceive(xQueue, &pucReceivedData, portMAX_DELAY); // Print output of inference and exit task printf("Running inference\n"); struct tvmgen_default_inputs xInputs = { .tfl_quantize = pucReceivedData, }; struct tvmgen_default_outputs xOutputs = { .MobilenetV2_Predictions_Reshape_11 = output, }; struct ethosu_driver* xDriver = ethosu_reserve_driver(); struct tvmgen_default_devices xDevices = { .ethos_u = xDriver, }; tvmgen_default_run(&xInputs, &xOutputs, &xDevices); ethosu_release_driver(xDriver); // Calculate index of max value int8_t ucMaxValue = -128; int32_t lMaxIndex = -1; for (unsigned int i = 0; i < output_len; ++i) { if (output[i] > ucMaxValue) { ucMaxValue = output[i]; lMaxIndex = i; } } printf("The image has been classified as '%s'\n", labels[lMaxIndex]); // The FVP will shut down when it receives "EXITTHESIM" on the UART printf("EXITTHESIM\n"); }
https://github.com/zk-ml/tachikoma
apps/microtvm/ethosu/src/tvm_ethosu_runtime.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 "tvm_ethosu_runtime.h" #include <ethosu_driver.h> int32_t TVMEthosULaunch(tvm_device_ethos_u_t* context, void* cms_data, size_t cms_data_size, uint64_t* base_addrs, size_t* base_addrs_size, int num_tensors) { struct ethosu_driver* driver = (struct ethosu_driver*)context; int32_t result = ethosu_invoke(driver, cms_data, cms_data_size, base_addrs, base_addrs_size, num_tensors); // Map errors in invoke to TVM errors if (result != 0) { return -1; } return 0; } int32_t TVMDeviceEthosUActivate(tvm_device_ethos_u_t* context) { return 0; } int32_t TVMDeviceEthosUOpen(tvm_device_ethos_u_t* context) { return 0; } int32_t TVMDeviceEthosUClose(tvm_device_ethos_u_t* context) { return 0; } int32_t TVMDeviceEthosUDeactivate(tvm_device_ethos_u_t* context) { return 0; }
https://github.com/zk-ml/tachikoma
apps/microtvm/reference-vm/base-box-tool.py
#!/usr/bin/env python3 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import argparse import copy import json import logging import pathlib import os import re import shlex import shutil import subprocess import sys import pathlib _LOG = logging.getLogger(__name__) THIS_DIR = pathlib.Path(os.path.realpath(os.path.dirname(__file__))) # List of vagrant providers supported by this tool ALL_PROVIDERS = ( "parallels", "virtualbox", "vmware_desktop", ) # List of supported electronics platforms. Each must correspond # to a sub-directory of this directory. ALL_PLATFORMS = ( "arduino", "zephyr", ) # Extra scripts required to execute on provisioning # in [platform]/base-box/base_box_provision.sh EXTRA_SCRIPTS = [ "apps/microtvm/reference-vm/base-box/base_box_setup_common.sh", "docker/install/ubuntu_install_core.sh", "docker/install/ubuntu_install_python.sh", "docker/utils/apt-install-and-clear.sh", "docker/install/ubuntu1804_install_llvm.sh", # Zephyr "docker/install/ubuntu_init_zephyr_project.sh", "docker/install/ubuntu_install_zephyr_sdk.sh", "docker/install/ubuntu_install_cmsis.sh", "docker/install/ubuntu_install_nrfjprog.sh", ] PACKER_FILE_NAME = "packer.json" # List of identifying strings for microTVM boards for testing. with open(THIS_DIR / ".." / "zephyr" / "template_project" / "boards.json") as f: zephyr_boards = json.load(f) with open(THIS_DIR / ".." / "arduino" / "template_project" / "boards.json") as f: arduino_boards = json.load(f) ALL_MICROTVM_BOARDS = { "arduino": arduino_boards.keys(), "zephyr": zephyr_boards.keys(), } def parse_virtualbox_devices(): output = subprocess.check_output(["VBoxManage", "list", "usbhost"], encoding="utf-8") devices = [] current_dev = {} for line in output.split("\n"): if not line.strip(): if current_dev: if "VendorId" in current_dev and "ProductId" in current_dev: devices.append(current_dev) current_dev = {} continue key, value = line.split(":", 1) value = value.lstrip(" ") current_dev[key] = value if current_dev: devices.append(current_dev) return devices VIRTUALBOX_USB_DEVICE_RE = ( "USBAttachVendorId[0-9]+=0x([0-9a-z]{4})\n" + "USBAttachProductId[0-9]+=0x([0-9a-z]{4})" ) def parse_virtualbox_attached_usb_devices(vm_uuid): output = subprocess.check_output( ["VBoxManage", "showvminfo", "--machinereadable", vm_uuid], encoding="utf-8" ) r = re.compile(VIRTUALBOX_USB_DEVICE_RE) attached_usb_devices = r.findall(output, re.MULTILINE) # List of couples (VendorId, ProductId) for all attached USB devices return attached_usb_devices VIRTUALBOX_VID_PID_RE = re.compile(r"0x([0-9A-Fa-f]{4}).*") def attach_virtualbox(vm_uuid, vid_hex=None, pid_hex=None, serial=None): usb_devices = parse_virtualbox_devices() for dev in usb_devices: m = VIRTUALBOX_VID_PID_RE.match(dev["VendorId"]) if not m: _LOG.warning("Malformed VendorId: %s", dev["VendorId"]) continue dev_vid_hex = m.group(1).lower() m = VIRTUALBOX_VID_PID_RE.match(dev["ProductId"]) if not m: _LOG.warning("Malformed ProductId: %s", dev["ProductId"]) continue dev_pid_hex = m.group(1).lower() if ( vid_hex == dev_vid_hex and pid_hex == dev_pid_hex and (serial is None or serial == dev["SerialNumber"]) ): attached_devices = parse_virtualbox_attached_usb_devices(vm_uuid) for vid, pid in parse_virtualbox_attached_usb_devices(vm_uuid): if vid_hex == vid and pid_hex == pid: print(f"USB dev {vid_hex}:{pid_hex} already attached. Skipping attach.") return rule_args = [ "VBoxManage", "usbfilter", "add", "0", "--action", "hold", "--name", "test device", "--target", vm_uuid, "--vendorid", vid_hex, "--productid", pid_hex, ] if serial is not None: rule_args.extend(["--serialnumber", serial]) subprocess.check_call(rule_args) subprocess.check_call(["VBoxManage", "controlvm", vm_uuid, "usbattach", dev["UUID"]]) return raise Exception( f"Device with vid={vid_hex}, pid={pid_hex}, serial={serial!r} not found:\n{usb_devices!r}" ) def attach_parallels(uuid, vid_hex=None, pid_hex=None, serial=None): usb_devices = json.loads( subprocess.check_output(["prlsrvctl", "usb", "list", "-j"], encoding="utf-8") ) for dev in usb_devices: _, dev_vid_hex, dev_pid_hex, _, _, dev_serial = dev["System name"].split("|") dev_vid_hex = dev_vid_hex.lower() dev_pid_hex = dev_pid_hex.lower() if ( vid_hex == dev_vid_hex and pid_hex == dev_pid_hex and (serial is None or serial == dev_serial) ): subprocess.check_call(["prlsrvctl", "usb", "set", dev["Name"], uuid]) if "Used-By-Vm-Name" in dev: subprocess.check_call( ["prlctl", "set", dev["Used-By-Vm-Name"], "--device-disconnect", dev["Name"]] ) subprocess.check_call(["prlctl", "set", uuid, "--device-connect", dev["Name"]]) return raise Exception( f"Device with vid={vid_hex}, pid={pid_hex}, serial={serial!r} not found:\n{usb_devices!r}" ) def attach_vmware(uuid, vid_hex=None, pid_hex=None, serial=None): print("NOTE: vmware doesn't seem to support automatic attaching of devices :(") print("The VMWare VM UUID is {uuid}") print("Please attach the following usb device using the VMWare GUI:") if vid_hex is not None: print(f" - VID: {vid_hex}") if pid_hex is not None: print(f" - PID: {pid_hex}") if serial is not None: print(f" - Serial: {serial}") if vid_hex is None and pid_hex is None and serial is None: print(" - (no specifications given for USB device)") print() print("Press [Enter] when the USB device is attached") input() ATTACH_USB_DEVICE = { "parallels": attach_parallels, "virtualbox": attach_virtualbox, "vmware_desktop": attach_vmware, } def generate_packer_config(file_path, providers): builders = [] provisioners = [] for provider_name in providers: builders.append( { "name": f"{provider_name}", "type": "vagrant", "box_name": f"microtvm-base-{provider_name}", "output_dir": f"output-packer-{provider_name}", "communicator": "ssh", "source_path": "generic/ubuntu1804", "provider": provider_name, "template": "Vagrantfile.packer-template", } ) repo_root = subprocess.check_output( ["git", "rev-parse", "--show-toplevel"], encoding="utf-8" ).strip() scripts_to_copy = EXTRA_SCRIPTS for script in scripts_to_copy: script_path = os.path.join(repo_root, script) filename = os.path.basename(script_path) provisioners.append({"type": "file", "source": script_path, "destination": f"~/{filename}"}) provisioners.append( { "type": "shell", "script": "base_box_setup.sh", } ) provisioners.append( { "type": "shell", "script": "base_box_provision.sh", } ) with open(file_path, "w") as f: json.dump( { "builders": builders, "provisioners": provisioners, }, f, sort_keys=True, indent=2, ) def build_command(args): base_box_dir = THIS_DIR / "base-box" generate_packer_config( os.path.join(base_box_dir, PACKER_FILE_NAME), args.provider or ALL_PROVIDERS, ) env = copy.copy(os.environ) packer_args = ["packer", "build", "-force"] env["PACKER_LOG"] = "1" env["PACKER_LOG_PATH"] = "packer.log" if args.debug_packer: packer_args += ["-debug"] packer_args += [PACKER_FILE_NAME] box_package_exists = False if not args.force: box_package_dirs = [(base_box_dir / f"output-packer-{p}") for p in args.provider] for box_package_dir in box_package_dirs: if box_package_dir.exists(): print(f"A box package {box_package_dir} already exists. Refusing to overwrite it!") box_package_exists = True if box_package_exists: sys.exit("One or more box packages exist (see list above). To rebuild use '--force'") subprocess.check_call(packer_args, cwd=THIS_DIR / "base-box", env=env) REQUIRED_TEST_CONFIG_KEYS = { "vid_hex": str, "pid_hex": str, } VM_BOX_RE = re.compile(r'(.*\.vm\.box) = "(.*)"') VM_TVM_HOME_RE = re.compile(r'(.*tvm_home) = "(.*)"') # Paths, relative to the platform box directory, which will not be copied to release-test dir. SKIP_COPY_PATHS = [".vagrant", "base-box", "scripts"] def do_build_release_test_vm( release_test_dir, user_box_dir: pathlib.Path, base_box_dir: pathlib.Path, provider_name ): if os.path.exists(release_test_dir): try: subprocess.check_call(["vagrant", "destroy", "-f"], cwd=release_test_dir) except subprocess.CalledProcessError: _LOG.warning("vagrant destroy failed--removing dirtree anyhow", exc_info=True) shutil.rmtree(release_test_dir) for dirpath, _, filenames in os.walk(user_box_dir): rel_path = os.path.relpath(dirpath, user_box_dir) if any( rel_path == scp or rel_path.startswith(f"{scp}{os.path.sep}") for scp in SKIP_COPY_PATHS ): continue dest_dir = os.path.join(release_test_dir, rel_path) os.makedirs(dest_dir) for filename in filenames: shutil.copy2(os.path.join(dirpath, filename), os.path.join(dest_dir, filename)) release_test_vagrantfile = os.path.join(release_test_dir, "Vagrantfile") with open(release_test_vagrantfile) as f: lines = list(f) found_box_line = False with open(release_test_vagrantfile, "w") as f: for line in lines: # Skip setting version if "config.vm.box_version" in line: continue m = VM_BOX_RE.match(line) tvm_home_m = VM_TVM_HOME_RE.match(line) if tvm_home_m: # Adjust tvm home for testing step f.write(f'{tvm_home_m.group(1)} = "../../../.."\n') continue if not m: f.write(line) continue box_package = os.path.join( base_box_dir, f"output-packer-{provider_name}", "package.box" ) box_relpath = os.path.relpath(box_package, release_test_dir) f.write(f'{m.group(1)} = "{box_relpath}"\n') found_box_line = True if not found_box_line: _LOG.error( "testing provider %s: couldn't find config.box.vm = line in Vagrantfile; unable to test", provider_name, ) return False # Delete the old box registered with Vagrant, which may lead to a falsely-passing release test. remove_args = ["vagrant", "box", "remove", box_relpath] return_code = subprocess.call(remove_args, cwd=release_test_dir) assert return_code in (0, 1), f'{" ".join(remove_args)} returned exit code {return_code}' subprocess.check_call(["vagrant", "up", f"--provider={provider_name}"], cwd=release_test_dir) return True def do_run_release_test(release_test_dir, provider_name, test_config, test_device_serial): with open( os.path.join(release_test_dir, ".vagrant", "machines", "default", provider_name, "id") ) as f: machine_uuid = f.read() # Check if target is not QEMU if test_config["vid_hex"] and test_config["pid_hex"]: ATTACH_USB_DEVICE[provider_name]( machine_uuid, vid_hex=test_config["vid_hex"], pid_hex=test_config["pid_hex"], serial=test_device_serial, ) tvm_home = os.path.realpath(THIS_DIR / ".." / ".." / "..") def _quote_cmd(cmd): return " ".join(shlex.quote(a) for a in cmd) test_cmd = ( _quote_cmd(["cd", tvm_home]) + " && " + _quote_cmd( [ f"apps/microtvm/reference-vm/base-box/base_box_test.sh", test_config["microtvm_board"], ] ) ) subprocess.check_call(["vagrant", "ssh", "-c", f"bash -ec '{test_cmd}'"], cwd=release_test_dir) def test_command(args): user_box_dir = THIS_DIR base_box_dir = user_box_dir / "base-box" boards_file = THIS_DIR / ".." / args.platform / "template_project" / "boards.json" with open(boards_file) as f: test_config = json.load(f) # select microTVM test config microtvm_test_config = test_config[args.microtvm_board] for key, expected_type in REQUIRED_TEST_CONFIG_KEYS.items(): assert key in microtvm_test_config and isinstance( microtvm_test_config[key], expected_type ), f"Expected key {key} of type {expected_type} in {boards_file}: {test_config!r}" microtvm_test_config["vid_hex"] = microtvm_test_config["vid_hex"].lower() microtvm_test_config["pid_hex"] = microtvm_test_config["pid_hex"].lower() microtvm_test_config["microtvm_board"] = args.microtvm_board providers = args.provider release_test_dir = THIS_DIR / f"release-test" if args.skip_build or args.skip_destroy: assert ( len(providers) == 1 ), "--skip-build and/or --skip-destroy was given, but >1 provider specified" test_failed = False for provider_name in providers: try: if not args.skip_build: do_build_release_test_vm( release_test_dir, user_box_dir, base_box_dir, provider_name ) do_run_release_test( release_test_dir, provider_name, microtvm_test_config, args.test_device_serial, ) except subprocess.CalledProcessError: test_failed = True sys.exit( f"\n\nERROR: Provider '{provider_name}' failed the release test. " "You can re-run it to reproduce the issue without building everything " "again by passing the --skip-build and specifying only the provider that failed. " "The VM is still running in case you want to connect it via SSH to " "investigate further the issue, thus it's necessary to destroy it manually " "to release the resources back to the host, like a USB device attached to the VM." ) finally: # if we reached out here do_run_release_test() succeeded, hence we can # destroy the VM and release the resources back to the host if user haven't # requested to not destroy it. if not (args.skip_destroy or test_failed): subprocess.check_call(["vagrant", "destroy", "-f"], cwd=release_test_dir) shutil.rmtree(release_test_dir) print(f'\n\nThe release tests passed on all specified providers: {", ".join(providers)}.') def release_command(args): if args.release_full_name: vm_name = args.release_full_name else: vm_name = "tlcpack/microtvm" if not args.skip_creating_release_version: subprocess.check_call( [ "vagrant", "cloud", "version", "create", vm_name, args.release_version, ] ) if not args.release_version: sys.exit(f"--release-version must be specified") for provider_name in args.provider: subprocess.check_call( [ "vagrant", "cloud", "publish", "-f", vm_name, args.release_version, provider_name, str(THIS_DIR / "base-box" / f"output-packer-{provider_name}/package.box"), ] ) def parse_args(): parser = argparse.ArgumentParser( description="Automates building, testing, and releasing a base box" ) subparsers = parser.add_subparsers(help="Action to perform.") subparsers.required = True subparsers.dest = "action" parser.add_argument( "--provider", choices=ALL_PROVIDERS, action="append", required=True, help="Name of the provider or providers to act on", ) # "test" has special options for different platforms, and "build", "release" might # in the future, so we'll add the platform argument to each one individually. platform_help_str = "Platform to use (e.g. Arduino, Zephyr)" # Options for build subcommand parser_build = subparsers.add_parser("build", help="Build a base box.") parser_build.set_defaults(func=build_command) parser_build.add_argument( "--debug-packer", action="store_true", help=("Run packer in debug mode, and write log to the base-box directory."), ) parser_build.add_argument( "--force", action="store_true", help=("Force rebuilding a base box from scratch if one already exists."), ) # Options for test subcommand parser_test = subparsers.add_parser("test", help="Test a base box before release.") parser_test.set_defaults(func=test_command) parser_test.add_argument( "--skip-build", action="store_true", help=( "If given, assume a box has already been built in the release-test subdirectory, " "so use that box to execute the release test script. If the tests fail the VM used " "for testing will be left running for further investigation and will need to be " "destroyed manually. If all tests pass on all specified providers no VM is left running, " "unless --skip-destroy is given too." ), ) parser_test.add_argument( "--skip-destroy", action="store_true", help=( "Skip destroying the test VM even if all tests pass. Can only be used if a single " "provider is specified. Default is to destroy the VM if all tests pass (and always " "skip destroying it if a test fails)." ), ) parser_test.add_argument( "--test-device-serial", help=( "If given, attach the test device with this USB serial number. Corresponds to the " "iSerial field from `lsusb -v` output." ), ) parser_test_platform_subparsers = parser_test.add_subparsers(help=platform_help_str) for platform in ALL_PLATFORMS: platform_specific_parser = parser_test_platform_subparsers.add_parser(platform) platform_specific_parser.set_defaults(platform=platform) platform_specific_parser.add_argument( "--microtvm-board", choices=ALL_MICROTVM_BOARDS[platform], required=True, help="MicroTVM board used for testing.", ) # Options for release subcommand parser_release = subparsers.add_parser("release", help="Release base box to cloud.") parser_release.set_defaults(func=release_command) parser_release.add_argument( "--release-version", required=True, help="Version to release, in the form 'x.y.z'. Must be specified with release.", ) parser_release.add_argument( "--skip-creating-release-version", action="store_true", help="Skip creating the version and just upload for this provider.", ) parser_release.add_argument( "--release-full-name", required=False, type=str, default=None, help=( "If set, it will use this as the full release name and version for the box. " "If this set, it will ignore `--release-version`." ), ) args = parser.parse_args() return args def main(): args = parse_args() args.func(args) if __name__ == "__main__": main()
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr/template_project/crt_config/crt_config.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file tvm/runtime/crt_config.h.template * \brief Template for CRT configuration, to be modified on each target. */ #ifndef TVM_RUNTIME_CRT_CONFIG_H_ #define TVM_RUNTIME_CRT_CONFIG_H_ #include <tvm/runtime/crt/logging.h> /*! Log level of the CRT runtime */ #define TVM_CRT_LOG_LEVEL TVM_CRT_LOG_LEVEL_DEBUG /*! Maximum supported dimension in NDArray */ #define TVM_CRT_MAX_NDIM 6 /*! Maximum supported arguments in generated functions */ #define TVM_CRT_MAX_ARGS 10 /*! Size of the global function registry, in bytes. */ #define TVM_CRT_GLOBAL_FUNC_REGISTRY_SIZE_BYTES 512 /*! Maximum number of registered modules. */ #define TVM_CRT_MAX_REGISTERED_MODULES 2 /*! Maximum packet size, in bytes, including the length header. */ #define TVM_CRT_MAX_PACKET_SIZE_BYTES 8192 /*! Maximum supported string length in dltype, e.g. "int8", "int16", "float32" */ #define TVM_CRT_MAX_STRLEN_DLTYPE 10 /*! Maximum supported string length in function names */ #define TVM_CRT_MAX_STRLEN_FUNCTION_NAME 120 /*! Maximum supported string length in parameter names */ #define TVM_CRT_MAX_STRLEN_PARAM_NAME 80 /*! \brief Maximum length of a PackedFunc function name. */ #define TVM_CRT_MAX_FUNCTION_NAME_LENGTH_BYTES 30 /*! \brief Log2 of the page size (bytes) for a virtual memory page. */ #define TVM_CRT_PAGE_BITS 10 // 1 kB /*! \brief Number of pages on device. */ #define TVM_CRT_MAX_PAGES 300 // #define TVM_CRT_FRAMER_ENABLE_LOGS #endif // TVM_RUNTIME_CRT_CONFIG_H_
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr/template_project/microtvm_api_server.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import atexit import collections import collections.abc import enum import fcntl import json import logging import os import os.path import pathlib import queue import re import shlex import shutil import struct import subprocess import sys import tarfile import tempfile import threading from typing import Union import usb import psutil import stat import serial import serial.tools.list_ports import yaml from tvm.micro.project_api import server _LOG = logging.getLogger(__name__) API_SERVER_DIR = pathlib.Path(os.path.dirname(__file__) or os.path.getcwd()) BUILD_DIR = API_SERVER_DIR / "build" MODEL_LIBRARY_FORMAT_RELPATH = "model.tar" IS_TEMPLATE = not (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH).exists() BOARDS = API_SERVER_DIR / "boards.json" CMAKELIST_FILENAME = "CMakeLists.txt" # Used to check Zephyr version installed on the host. # We only check two levels of the version. ZEPHYR_VERSION = 2.7 WEST_CMD = default = sys.executable + " -m west" if sys.executable else None ZEPHYR_BASE = os.getenv("ZEPHYR_BASE") # Data structure to hold the information microtvm_api_server.py needs # to communicate with each of these boards. try: with open(BOARDS) as boards: BOARD_PROPERTIES = json.load(boards) except FileNotFoundError: raise FileNotFoundError(f"Board file {{{BOARDS}}} does not exist.") def check_call(cmd_args, *args, **kwargs): cwd_str = "" if "cwd" not in kwargs else f" (in cwd: {kwargs['cwd']})" _LOG.info("run%s: %s", cwd_str, " ".join(shlex.quote(a) for a in cmd_args)) return subprocess.check_call(cmd_args, *args, **kwargs) CACHE_ENTRY_RE = re.compile(r"(?P<name>[^:]+):(?P<type>[^=]+)=(?P<value>.*)") CMAKE_BOOL_MAP = dict( [(k, True) for k in ("1", "ON", "YES", "TRUE", "Y")] + [(k, False) for k in ("0", "OFF", "NO", "FALSE", "N", "IGNORE", "NOTFOUND", "")] ) class CMakeCache(collections.abc.Mapping): def __init__(self, path): self._path = path self._dict = None def __iter__(self): return iter(self._dict) def __getitem__(self, key): if self._dict is None: self._dict = self._read_cmake_cache() return self._dict[key] def __len__(self): return len(self._dict) def _read_cmake_cache(self): """Read a CMakeCache.txt-like file and return a dictionary of values.""" entries = collections.OrderedDict() with open(self._path, encoding="utf-8") as f: for line in f: m = CACHE_ENTRY_RE.match(line.rstrip("\n")) if not m: continue if m.group("type") == "BOOL": value = CMAKE_BOOL_MAP[m.group("value").upper()] else: value = m.group("value") entries[m.group("name")] = value return entries CMAKE_CACHE = CMakeCache(BUILD_DIR / "CMakeCache.txt") class BoardError(Exception): """Raised when an attached board cannot be opened (i.e. missing /dev nodes, etc).""" class BoardAutodetectFailed(Exception): """Raised when no attached hardware is found matching the board= given to ZephyrCompiler.""" def _get_flash_runner(): flash_runner = CMAKE_CACHE.get("ZEPHYR_BOARD_FLASH_RUNNER") if flash_runner is not None: return flash_runner with open(CMAKE_CACHE["ZEPHYR_RUNNERS_YAML"]) as f: doc = yaml.load(f, Loader=yaml.FullLoader) return doc["flash-runner"] def _find_board_from_cmake_file(cmake_file: Union[str, pathlib.Path]) -> str: """Find Zephyr board from generated CMakeLists.txt""" zephyr_board = None with open(cmake_file) as cmake_f: for line in cmake_f: if line.startswith("set(BOARD"): zephyr_board = line.strip("\n").strip("\r").strip(")").split(" ")[1] break if not zephyr_board: raise RuntimeError(f"No Zephyr board set in the {cmake_file}.") return zephyr_board def _find_platform_from_cmake_file(cmake_file: Union[str, pathlib.Path]) -> str: emu_platform = None with open(API_SERVER_DIR / CMAKELIST_FILENAME) as cmake_f: for line in cmake_f: set_platform = re.match("set\(EMU_PLATFORM (.*)\)", line) if set_platform: emu_platform = set_platform.group(1) break return emu_platform def _get_device_args(options): flash_runner = _get_flash_runner() if flash_runner == "nrfjprog": return _get_nrf_device_args(options) if flash_runner == "openocd": return _get_openocd_device_args(options) raise BoardError( f"Don't know how to find serial terminal for board {_find_board_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME)} with flash " f"runner {flash_runner}" ) def _get_board_mem_size_bytes(options): board_file_path = ( pathlib.Path(get_zephyr_base(options)) / "boards" / "arm" / options["board"] / (options["board"] + ".yaml") ) try: with open(board_file_path) as f: board_data = yaml.load(f, Loader=yaml.FullLoader) return int(board_data["ram"]) * 1024 except: _LOG.warning("Board memory information is not available.") return None DEFAULT_HEAP_SIZE_BYTES = 216 * 1024 def _get_recommended_heap_size_bytes(options): prop = BOARD_PROPERTIES[options["board"]] if "recommended_heap_size_bytes" in prop: return prop["recommended_heap_size_bytes"] return DEFAULT_HEAP_SIZE_BYTES def generic_find_serial_port(serial_number=None): """Find a USB serial port based on its serial number or its VID:PID. This method finds a USB serial port device path based on the port's serial number (if given) or based on the board's idVendor and idProduct ids. Parameters ---------- serial_number : str The serial number associated to the USB serial port which the board is attached to. This is the same number as shown by 'lsusb -v' in the iSerial field. Returns ------- Path to the USB serial port device, for example /dev/ttyACM1. """ if serial_number: regex = serial_number else: prop = BOARD_PROPERTIES[_find_board_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME)] device_id = ":".join([prop["vid_hex"], prop["pid_hex"]]) regex = device_id serial_ports = list(serial.tools.list_ports.grep(regex)) if len(serial_ports) == 0: raise Exception(f"No serial port found for board {prop['board']}!") if len(serial_ports) != 1: ports_lst = "" for port in serial_ports: ports_lst += f"Serial port: {port.device}, serial number: {port.serial_number}\n" raise Exception("Expected 1 serial port, found multiple ports:\n {ports_lst}") return serial_ports[0].device def _get_openocd_device_args(options): serial_number = options.get("openocd_serial") return ["--serial", generic_find_serial_port(serial_number)] def _get_nrf_device_args(options): nrfjprog_args = ["nrfjprog", "--ids"] nrfjprog_ids = subprocess.check_output(nrfjprog_args, encoding="utf-8") if not nrfjprog_ids.strip("\n"): raise BoardAutodetectFailed(f'No attached boards recognized by {" ".join(nrfjprog_args)}') boards = nrfjprog_ids.split("\n")[:-1] if len(boards) > 1: if options["nrfjprog_snr"] is None: raise BoardError( "Multiple boards connected; specify one with nrfjprog_snr=: " f'{", ".join(boards)}' ) if str(options["nrfjprog_snr"]) not in boards: raise BoardError( f"nrfjprog_snr ({options['nrfjprog_snr']}) not found in {nrfjprog_args}: {boards}" ) return ["--snr", options["nrfjprog_snr"]] if not boards: return [] return ["--snr", boards[0]] PROJECT_TYPES = [] if IS_TEMPLATE: for d in (API_SERVER_DIR / "src").iterdir(): if d.is_dir(): PROJECT_TYPES.append(d.name) PROJECT_OPTIONS = server.default_project_options( project_type={"choices": tuple(PROJECT_TYPES)}, board={"choices": list(BOARD_PROPERTIES)}, verbose={"optional": ["generate_project"]}, ) + [ server.ProjectOption( "gdbserver_port", optional=["open_transport"], type="int", default=None, help=("If given, port number to use when running the local gdbserver."), ), server.ProjectOption( "nrfjprog_snr", optional=["open_transport"], type="int", default=None, help=("When used with nRF targets, serial # of the attached board to use, from nrfjprog."), ), server.ProjectOption( "openocd_serial", optional=["open_transport"], type="int", default=None, help=("When used with OpenOCD targets, serial # of the attached board to use."), ), server.ProjectOption( "west_cmd", optional=["generate_project"], type="str", default=WEST_CMD, help=( "Path to the west tool. If given, supersedes both the zephyr_base " "option and ZEPHYR_BASE environment variable." ), ), server.ProjectOption( "zephyr_base", required=(["generate_project", "open_transport"] if not ZEPHYR_BASE else None), optional=(["generate_project", "open_transport"] if ZEPHYR_BASE else ["build"]), type="str", default=ZEPHYR_BASE, help="Path to the zephyr base directory.", ), server.ProjectOption( "config_main_stack_size", optional=["generate_project"], type="int", default=None, help="Sets CONFIG_MAIN_STACK_SIZE for Zephyr board.", ), server.ProjectOption( "arm_fvp_path", optional=["generate_project", "open_transport"], type="str", default=None, help="Path to the FVP binary to invoke.", ), server.ProjectOption( "use_fvp", optional=["generate_project"], type="bool", default=False, help="Run on the FVP emulator instead of hardware.", ), server.ProjectOption( "heap_size_bytes", optional=["generate_project"], type="int", default=None, help="Sets the value for HEAP_SIZE_BYTES passed to K_HEAP_DEFINE() to service TVM memory allocation requests.", ), ] def get_zephyr_base(options: dict): """Returns Zephyr base path""" zephyr_base = options.get("zephyr_base", ZEPHYR_BASE) assert zephyr_base, "'zephyr_base' option not passed and not found by default!" return zephyr_base def get_cmsis_path(options: dict) -> pathlib.Path: """Returns CMSIS dependency path""" cmsis_path = options.get("cmsis_path") assert cmsis_path, "'cmsis_path' option not passed!" return pathlib.Path(cmsis_path) class Handler(server.ProjectAPIHandler): def __init__(self): super(Handler, self).__init__() self._proc = None def server_info_query(self, tvm_version): return server.ServerInfo( platform_name="zephyr", is_template=IS_TEMPLATE, model_library_format_path="" if IS_TEMPLATE else (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH), project_options=PROJECT_OPTIONS, ) # These files and directories will be recursively copied into generated projects from the CRT. CRT_COPY_ITEMS = ("include", "Makefile", "src") # Maps extra line added to prj.conf to a tuple or list of zephyr_board for which it is needed. EXTRA_PRJ_CONF_DIRECTIVES = { "CONFIG_TIMER_RANDOM_GENERATOR=y": ( "qemu_x86", "qemu_riscv32", "qemu_cortex_r5", "qemu_riscv64", ), "CONFIG_ENTROPY_GENERATOR=y": ( "mps2_an521", "nrf5340dk_nrf5340_cpuapp", "nucleo_f746zg", "nucleo_l4r5zi", "stm32f746g_disco", ), } def _create_prj_conf(self, project_dir, options): zephyr_board = options["board"] with open(project_dir / "prj.conf", "w") as f: f.write( "# For UART used from main().\n" "CONFIG_RING_BUFFER=y\n" "CONFIG_UART_CONSOLE=n\n" "CONFIG_UART_INTERRUPT_DRIVEN=y\n" "\n" ) f.write("# For TVMPlatformAbort().\n" "CONFIG_REBOOT=y\n" "\n") if options["project_type"] == "host_driven": f.write( "CONFIG_TIMING_FUNCTIONS=y\n" "# For RPC server C++ bindings.\n" "CONFIG_CPLUSPLUS=y\n" "CONFIG_LIB_CPLUSPLUS=y\n" "\n" ) f.write("# For math routines\n" "CONFIG_NEWLIB_LIBC=y\n" "\n") if self._has_fpu(zephyr_board): f.write("# For models with floating point.\n" "CONFIG_FPU=y\n" "\n") # Set main stack size, if needed. if options.get("config_main_stack_size") is not None: f.write(f"CONFIG_MAIN_STACK_SIZE={options['config_main_stack_size']}\n") f.write("# For random number generation.\n" "CONFIG_TEST_RANDOM_GENERATOR=y\n") f.write("\n# Extra prj.conf directives\n") for line, board_list in self.EXTRA_PRJ_CONF_DIRECTIVES.items(): if zephyr_board in board_list: f.write(f"{line}\n") # TODO(mehrdadh): due to https://github.com/apache/tvm/issues/12721 if zephyr_board not in ["qemu_riscv64"]: f.write("# For setting -O2 in compiler.\n" "CONFIG_SPEED_OPTIMIZATIONS=y\n") f.write("\n") API_SERVER_CRT_LIBS_TOKEN = "<API_SERVER_CRT_LIBS>" CMAKE_ARGS_TOKEN = "<CMAKE_ARGS>" QEMU_PIPE_TOKEN = "<QEMU_PIPE>" CMSIS_PATH_TOKEN = "<CMSIS_PATH>" CRT_LIBS_BY_PROJECT_TYPE = { "host_driven": "microtvm_rpc_server microtvm_rpc_common aot_executor_module aot_executor common", "aot_standalone_demo": "memory microtvm_rpc_common common", } def _get_platform_version(self, zephyr_base: str) -> float: with open(pathlib.Path(zephyr_base) / "VERSION", "r") as f: lines = f.readlines() for line in lines: line = line.replace(" ", "").replace("\n", "").replace("\r", "") if "VERSION_MAJOR" in line: version_major = line.split("=")[1] if "VERSION_MINOR" in line: version_minor = line.split("=")[1] return float(f"{version_major}.{version_minor}") def _cmsis_required(self, project_path: Union[str, pathlib.Path]) -> bool: """Check if CMSIS dependency is required.""" project_path = pathlib.Path(project_path) for path in (project_path / "codegen" / "host" / "src").iterdir(): if path.is_file(): with open(path, "r") as lib_f: lib_content = lib_f.read() if any( header in lib_content for header in [ "<arm_nnsupportfunctions.h>", "arm_nn_types.h", "arm_nnfunctions.h", ] ): return True return False def _generate_cmake_args(self, mlf_extracted_path, options) -> str: cmake_args = "\n# cmake args\n" if options.get("verbose"): cmake_args += "set(CMAKE_VERBOSE_MAKEFILE TRUE)\n" if options.get("zephyr_base"): cmake_args += f"set(ZEPHYR_BASE {options['zephyr_base']})\n" if options.get("west_cmd"): cmake_args += f"set(WEST {options['west_cmd']})\n" if self._is_qemu(options["board"], options.get("use_fvp")): # Some boards support more than one emulator, so ensure QEMU is set. cmake_args += f"set(EMU_PLATFORM qemu)\n" if self._is_fvp(options["board"], options.get("use_fvp")): cmake_args += "set(EMU_PLATFORM armfvp)\n" cmake_args += "set(ARMFVP_FLAGS -I)\n" cmake_args += f"set(BOARD {options['board']})\n" enable_cmsis = self._cmsis_required(mlf_extracted_path) if enable_cmsis: assert os.environ.get("CMSIS_PATH"), "CMSIS_PATH is not defined." cmake_args += f"set(ENABLE_CMSIS {str(enable_cmsis).upper()})\n" return cmake_args def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options): zephyr_board = options["board"] # Check Zephyr version version = self._get_platform_version(get_zephyr_base(options)) if version != ZEPHYR_VERSION: message = f"Zephyr version found is not supported: found {version}, expected {ZEPHYR_VERSION}." if options.get("warning_as_error") is not None and options["warning_as_error"]: raise server.ServerError(message=message) _LOG.warning(message) project_dir = pathlib.Path(project_dir) # Make project directory. project_dir.mkdir() # Copy ourselves to the generated project. TVM may perform further build steps on the generated project # by launching the copy. shutil.copy2(__file__, project_dir / os.path.basename(__file__)) # Copy boards.json file to generated project. shutil.copy2(BOARDS, project_dir / BOARDS.name) # Copy overlay files board_overlay_path = API_SERVER_DIR / "app-overlay" / f"{zephyr_board}.overlay" if board_overlay_path.exists(): shutil.copy2(board_overlay_path, project_dir / f"{zephyr_board}.overlay") # Place Model Library Format tarball in the special location, which this script uses to decide # whether it's being invoked in a template or generated project. project_model_library_format_tar_path = project_dir / MODEL_LIBRARY_FORMAT_RELPATH shutil.copy2(model_library_format_path, project_model_library_format_tar_path) # Extract Model Library Format tarball.into <project_dir>/model. extract_path = os.path.splitext(project_model_library_format_tar_path)[0] with tarfile.TarFile(project_model_library_format_tar_path) as tf: os.makedirs(extract_path) tf.extractall(path=extract_path) if self._is_qemu(zephyr_board, options.get("use_fvp")): shutil.copytree(API_SERVER_DIR / "qemu-hack", project_dir / "qemu-hack") elif self._is_fvp(zephyr_board, options.get("use_fvp")): shutil.copytree(API_SERVER_DIR / "fvp-hack", project_dir / "fvp-hack") # Populate CRT. crt_path = project_dir / "crt" crt_path.mkdir() for item in self.CRT_COPY_ITEMS: src_path = os.path.join(standalone_crt_dir, item) dst_path = crt_path / item if os.path.isdir(src_path): shutil.copytree(src_path, dst_path) else: shutil.copy2(src_path, dst_path) # Populate Makefile. with open(project_dir / CMAKELIST_FILENAME, "w") as cmake_f: with open(API_SERVER_DIR / f"{CMAKELIST_FILENAME}.template", "r") as cmake_template_f: for line in cmake_template_f: if self.API_SERVER_CRT_LIBS_TOKEN in line: crt_libs = self.CRT_LIBS_BY_PROJECT_TYPE[options["project_type"]] line = line.replace("<API_SERVER_CRT_LIBS>", crt_libs) if self.CMAKE_ARGS_TOKEN in line: line = self._generate_cmake_args(extract_path, options) if self.QEMU_PIPE_TOKEN in line: self.qemu_pipe_dir = pathlib.Path(tempfile.mkdtemp()) line = line.replace(self.QEMU_PIPE_TOKEN, str(self.qemu_pipe_dir / "fifo")) if self.CMSIS_PATH_TOKEN in line and self._cmsis_required(extract_path): line = line.replace(self.CMSIS_PATH_TOKEN, str(os.environ["CMSIS_PATH"])) cmake_f.write(line) heap_size = _get_recommended_heap_size_bytes(options) if options.get("heap_size_bytes"): board_mem_size = _get_board_mem_size_bytes(options) heap_size = options["heap_size_bytes"] if board_mem_size is not None: assert ( heap_size < board_mem_size ), f"Heap size {heap_size} is larger than memory size {board_mem_size} on this board." cmake_f.write( f"target_compile_definitions(app PUBLIC -DHEAP_SIZE_BYTES={heap_size})\n" ) if options.get("compile_definitions"): flags = options.get("compile_definitions") for item in flags: cmake_f.write(f"target_compile_definitions(app PUBLIC {item})\n") if self._is_fvp(zephyr_board, options.get("use_fvp")): cmake_f.write(f"target_compile_definitions(app PUBLIC -DFVP=1)\n") self._create_prj_conf(project_dir, options) # Populate crt-config.h crt_config_dir = project_dir / "crt_config" crt_config_dir.mkdir() shutil.copy2( API_SERVER_DIR / "crt_config" / "crt_config.h", crt_config_dir / "crt_config.h" ) # Populate src/ src_dir = project_dir / "src" if options["project_type"] != "host_driven" or self._is_fvp( zephyr_board, options.get("use_fvp") ): shutil.copytree(API_SERVER_DIR / "src" / options["project_type"], src_dir) else: src_dir.mkdir() shutil.copy2(API_SERVER_DIR / "src" / options["project_type"] / "main.c", src_dir) # Populate extra_files if options.get("extra_files_tar"): with tarfile.open(options["extra_files_tar"], mode="r:*") as tf: tf.extractall(project_dir) def build(self, options): if BUILD_DIR.exists(): shutil.rmtree(BUILD_DIR) BUILD_DIR.mkdir() zephyr_board = _find_board_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME) emu_platform = _find_platform_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME) env = os.environ if self._is_fvp(zephyr_board, emu_platform == "armfvp"): env["ARMFVP_BIN_PATH"] = str((API_SERVER_DIR / "fvp-hack").resolve()) # Note: We need to explicitly modify the file permissions and make it an executable to pass CI tests. # [To Do]: Move permission change to Build.groovy.j2 st = os.stat(env["ARMFVP_BIN_PATH"] + "/FVP_Corstone_SSE-300_Ethos-U55") os.chmod( env["ARMFVP_BIN_PATH"] + "/FVP_Corstone_SSE-300_Ethos-U55", st.st_mode | stat.S_IEXEC, ) check_call(["cmake", "-GNinja", ".."], cwd=BUILD_DIR, env=env) args = ["ninja"] if options.get("verbose"): args.append("-v") check_call(args, cwd=BUILD_DIR, env=env) # A list of all zephyr_board values which are known to launch using QEMU. Many platforms which # launch through QEMU by default include "qemu" in their name. However, not all do. This list # includes those tested platforms which do not include qemu. _KNOWN_QEMU_ZEPHYR_BOARDS = ["mps2_an521", "mps3_an547"] # A list of all zephyr_board values which are known to launch using ARM FVP (this script configures # Zephyr to use that launch method). _KNOWN_FVP_ZEPHYR_BOARDS = ["mps3_an547"] @classmethod def _is_fvp(cls, board, use_fvp): if use_fvp: assert ( board in cls._KNOWN_FVP_ZEPHYR_BOARDS ), "FVP can't be used to emulate this board on Zephyr" return True return False @classmethod def _is_qemu(cls, board, use_fvp=False): return "qemu" in board or ( board in cls._KNOWN_QEMU_ZEPHYR_BOARDS and not cls._is_fvp(board, use_fvp) ) @classmethod def _has_fpu(cls, zephyr_board): fpu_boards = [name for name, board in BOARD_PROPERTIES.items() if board["fpu"]] return zephyr_board in fpu_boards def flash(self, options): if _find_platform_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME): return # NOTE: qemu requires no flash step--it is launched from open_transport. # The nRF5340DK requires an additional `nrfjprog --recover` before each flash cycle. # This is because readback protection is enabled by default when this device is flashed. # Otherwise, flashing may fail with an error such as the following: # ERROR: The operation attempted is unavailable due to readback protection in # ERROR: your device. Please use --recover to unlock the device. zephyr_board = _find_board_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME) if zephyr_board.startswith("nrf5340dk") and _get_flash_runner() == "nrfjprog": recover_args = ["nrfjprog", "--recover"] recover_args.extend(_get_nrf_device_args(options)) check_call(recover_args, cwd=API_SERVER_DIR / "build") check_call(["ninja", "flash"], cwd=API_SERVER_DIR / "build") def open_transport(self, options): zephyr_board = _find_board_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME) emu_platform = _find_platform_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME) if self._is_fvp(zephyr_board, emu_platform == "armfvp"): transport = ZephyrFvpTransport(options) elif self._is_qemu(zephyr_board): transport = ZephyrQemuTransport(options) else: transport = ZephyrSerialTransport(options) to_return = transport.open() self._transport = transport atexit.register(lambda: self.close_transport()) return to_return def close_transport(self): if self._transport is not None: self._transport.close() self._transport = None def read_transport(self, n, timeout_sec): if self._transport is None: raise server.TransportClosedError() return self._transport.read(n, timeout_sec) def write_transport(self, data, timeout_sec): if self._transport is None: raise server.TransportClosedError() return self._transport.write(data, timeout_sec) def _set_nonblock(fd): flag = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, flag | os.O_NONBLOCK) new_flag = fcntl.fcntl(fd, fcntl.F_GETFL) assert (new_flag & os.O_NONBLOCK) != 0, "Cannot set file descriptor {fd} to non-blocking" class ZephyrSerialTransport: NRF5340_VENDOR_ID = 0x1366 # NRF5340_DK v1.0.0 uses VCOM2 # NRF5340_DK v2.0.0 uses VCOM1 NRF5340_DK_BOARD_VCOM_BY_PRODUCT_ID = {0x1055: "VCOM2", 0x1051: "VCOM1"} @classmethod def _lookup_baud_rate(cls, options): # TODO(mehrdadh): remove this hack once dtlib.py is a standalone project # https://github.com/zephyrproject-rtos/zephyr/blob/v2.7-branch/scripts/dts/README.txt sys.path.insert( 0, os.path.join( get_zephyr_base(options), "scripts", "dts", "python-devicetree", "src", "devicetree" ), ) try: import dtlib # pylint: disable=import-outside-toplevel finally: sys.path.pop(0) dt_inst = dtlib.DT(BUILD_DIR / "zephyr" / "zephyr.dts") uart_baud = ( dt_inst.get_node("/chosen") .props["zephyr,console"] .to_path() .props["current-speed"] .to_num() ) _LOG.debug("zephyr transport: found UART baudrate from devicetree: %d", uart_baud) return uart_baud @classmethod def _find_nrf_serial_port(cls, options): com_ports = subprocess.check_output( ["nrfjprog", "--com"] + _get_device_args(options), encoding="utf-8" ) ports_by_vcom = {} for line in com_ports.split("\n")[:-1]: parts = line.split() ports_by_vcom[parts[2]] = parts[1] nrf_board = usb.core.find(idVendor=cls.NRF5340_VENDOR_ID) if nrf_board == None: raise Exception("_find_nrf_serial_port: unable to find NRF5340DK") if nrf_board.idProduct in cls.NRF5340_DK_BOARD_VCOM_BY_PRODUCT_ID: vcom_port = cls.NRF5340_DK_BOARD_VCOM_BY_PRODUCT_ID[nrf_board.idProduct] else: raise Exception("_find_nrf_serial_port: unable to find known NRF5340DK product ID") return ports_by_vcom[vcom_port] @classmethod def _find_openocd_serial_port(cls, options): serial_number = options.get("openocd_serial") return generic_find_serial_port(serial_number) @classmethod def _find_jlink_serial_port(cls, options): return generic_find_serial_port() @classmethod def _find_stm32cubeprogrammer_serial_port(cls, options): return generic_find_serial_port() @classmethod def _find_serial_port(cls, options): flash_runner = _get_flash_runner() if flash_runner == "nrfjprog": return cls._find_nrf_serial_port(options) if flash_runner == "openocd": return cls._find_openocd_serial_port(options) if flash_runner == "jlink": return cls._find_jlink_serial_port(options) if flash_runner == "stm32cubeprogrammer": return cls._find_stm32cubeprogrammer_serial_port(options) raise RuntimeError(f"Don't know how to deduce serial port for flash runner {flash_runner}") def __init__(self, options): self._options = options self._port = None def open(self): port_path = self._find_serial_port(self._options) self._port = serial.Serial(port_path, baudrate=self._lookup_baud_rate(self._options)) return server.TransportTimeouts( session_start_retry_timeout_sec=2.0, session_start_timeout_sec=5.0, session_established_timeout_sec=5.0, ) def close(self): self._port.close() self._port = None def read(self, n, timeout_sec): self._port.timeout = timeout_sec to_return = self._port.read(n) if not to_return: raise server.IoTimeoutError() return to_return def write(self, data, timeout_sec): self._port.write_timeout = timeout_sec bytes_written = 0 while bytes_written < len(data): n = self._port.write(data) data = data[n:] bytes_written += n class ZephyrQemuMakeResult(enum.Enum): QEMU_STARTED = "qemu_started" MAKE_FAILED = "make_failed" EOF = "eof" class ZephyrQemuTransport: """The user-facing Zephyr QEMU transport class.""" def __init__(self, options): self.options = options self.proc = None self.pipe_dir = None self.read_fd = None self.write_fd = None self._queue = queue.Queue() def open(self): with open(BUILD_DIR / "CMakeCache.txt", "r") as cmake_cache_f: for line in cmake_cache_f: if "QEMU_PIPE:" in line: self.pipe = pathlib.Path(line[line.find("=") + 1 :]) break self.pipe_dir = self.pipe.parents[0] self.write_pipe = self.pipe_dir / "fifo.in" self.read_pipe = self.pipe_dir / "fifo.out" os.mkfifo(self.write_pipe) os.mkfifo(self.read_pipe) env = None if self.options.get("gdbserver_port"): env = os.environ.copy() env["TVM_QEMU_GDBSERVER_PORT"] = self.options["gdbserver_port"] self.proc = subprocess.Popen( ["ninja", "run"], cwd=BUILD_DIR, env=env, stdout=subprocess.PIPE, ) self._wait_for_qemu() # NOTE: although each pipe is unidirectional, open both as RDWR to work around a select # limitation on linux. Without this, non-blocking I/O can't use timeouts because named # FIFO are always considered ready to read when no one has opened them for writing. self.read_fd = os.open(self.read_pipe, os.O_RDWR | os.O_NONBLOCK) self.write_fd = os.open(self.write_pipe, os.O_RDWR | os.O_NONBLOCK) _set_nonblock(self.read_fd) _set_nonblock(self.write_fd) return server.TransportTimeouts( session_start_retry_timeout_sec=2.0, session_start_timeout_sec=10.0, session_established_timeout_sec=10.0, ) def close(self): did_write = False if self.write_fd is not None: try: server.write_with_timeout( self.write_fd, b"\x01x", 1.0 ) # Use a short timeout since we will kill the process did_write = True except server.IoTimeoutError: pass os.close(self.write_fd) self.write_fd = None if self.proc: if not did_write: self.proc.terminate() try: self.proc.wait(5.0) except subprocess.TimeoutExpired: self.proc.kill() if self.read_fd: os.close(self.read_fd) self.read_fd = None if self.pipe_dir is not None: shutil.rmtree(self.pipe_dir) self.pipe_dir = None def read(self, n, timeout_sec): return server.read_with_timeout(self.read_fd, n, timeout_sec) def write(self, data, timeout_sec): to_write = bytearray() escape_pos = [] for i, b in enumerate(data): if b == 0x01: to_write.append(b) escape_pos.append(i) to_write.append(b) while to_write: num_written = server.write_with_timeout(self.write_fd, to_write, timeout_sec) to_write = to_write[num_written:] def _qemu_check_stdout(self): for line in self.proc.stdout: line = str(line) _LOG.info("%s", line) if "[QEMU] CPU" in line: self._queue.put(ZephyrQemuMakeResult.QEMU_STARTED) else: line = re.sub("[^a-zA-Z0-9 \n]", "", line) pattern = r"recipe for target (\w*) failed" if re.search(pattern, line, re.IGNORECASE): self._queue.put(ZephyrQemuMakeResult.MAKE_FAILED) self._queue.put(ZephyrQemuMakeResult.EOF) def _wait_for_qemu(self): threading.Thread(target=self._qemu_check_stdout, daemon=True).start() while True: try: item = self._queue.get(timeout=120) except Exception: raise TimeoutError("QEMU setup timeout.") if item == ZephyrQemuMakeResult.QEMU_STARTED: break if item in [ZephyrQemuMakeResult.MAKE_FAILED, ZephyrQemuMakeResult.EOF]: raise RuntimeError("QEMU setup failed.") raise ValueError(f"{item} not expected.") class ZephyrFvpMakeResult(enum.Enum): FVP_STARTED = "fvp_started" MICROTVM_API_SERVER_INIT = "fvp_initialized" MAKE_FAILED = "make_failed" EOF = "eof" class BlockingStream: """Reimplementation of Stream class from Iris with blocking semantics.""" def __init__(self): self.q = queue.Queue() self.unread = None def read(self, n=-1, timeout_sec=None): assert ( n != -1 ), "expect firmware to open stdin using raw mode, and therefore expect sized read requests" data = b"" if self.unread: data = data + self.unread self.unread = None while len(data) < n: try: # When there is some data to return, fetch as much as possible, then return what we can. # When there is no data yet to return, block. data += self.q.get(block=not len(data), timeout=timeout_sec) except queue.Empty: break if len(data) > n: self.unread = data[n:] data = data[:n] return data readline = read def write(self, data): self.q.put(data) class ZephyrFvpTransport: """A transport class that communicates with the ARM FVP via Iris server.""" def __init__(self, options): self.options = options self.proc = None self._queue = queue.Queue() self._import_iris() def _import_iris(self): assert "arm_fvp_path" in self.options, "arm_fvp_path is not defined." # Location as seen in the FVP_Corstone_SSE-300_11.15_24 tar. iris_lib_path = ( pathlib.Path(self.options["arm_fvp_path"]).parent.parent.parent / "Iris" / "Python" / "iris" ) sys.path.insert(0, str(iris_lib_path.parent)) try: import iris.NetworkModelInitializer finally: sys.path.pop(0) self._iris_lib = iris def _convertStringToU64Array(strValue): numBytes = len(strValue) if numBytes == 0: return [] numU64 = (numBytes + 7) // 8 # Extend the string ending with '\0', so that the string length is multiple of 8. # E.g. 'hello' is extended to: 'hello'+\0\0\0 strExt = strValue.ljust(8 * numU64, b"\0") # Convert the string to a list of uint64_t in little endian return struct.unpack("<{}Q".format(numU64), strExt) iris.iris.convertStringToU64Array = _convertStringToU64Array def open(self): args = ["ninja"] if self.options.get("verbose"): args.append("-v") args.append("run") env = dict(os.environ) env["ARMFVP_BIN_PATH"] = str(API_SERVER_DIR / "fvp-hack") self.proc = subprocess.Popen( args, cwd=BUILD_DIR, env=env, stdout=subprocess.PIPE, ) threading.Thread(target=self._fvp_check_stdout, daemon=True).start() self.iris_port = self._wait_for_fvp() _LOG.info("IRIS started on port %d", self.iris_port) NetworkModelInitializer = self._iris_lib.NetworkModelInitializer.NetworkModelInitializer self._model_init = NetworkModelInitializer( host="localhost", port=self.iris_port, timeout_in_ms=1000 ) self._model = self._model_init.start() self._target = self._model.get_target("component.FVP_MPS3_Corstone_SSE_300.cpu0") self._target.handle_semihost_io() self._target._stdout = BlockingStream() self._target._stdin = BlockingStream() self._model.run(blocking=False, timeout=100) self._wait_for_semihost_init() _LOG.info("IRIS semihosting initialized.") return server.TransportTimeouts( session_start_retry_timeout_sec=2.0, session_start_timeout_sec=10.0, session_established_timeout_sec=10.0, ) def _fvp_check_stdout(self): START_MSG = "Iris server started listening to port" INIT_MSG = "microTVM Zephyr runtime - running" for line in self.proc.stdout: line = str(line, "utf-8") _LOG.info("%s", line) start_msg = re.match(START_MSG + r" ([0-9]+)\n", line) init_msg = re.match(INIT_MSG, line) if start_msg: self._queue.put((ZephyrFvpMakeResult.FVP_STARTED, int(start_msg.group(1)))) elif init_msg: self._queue.put((ZephyrFvpMakeResult.MICROTVM_API_SERVER_INIT, None)) break else: line = re.sub("[^a-zA-Z0-9 \n]", "", line) pattern = r"recipe for target (\w*) failed" if re.search(pattern, line, re.IGNORECASE): self._queue.put((ZephyrFvpMakeResult.MAKE_FAILED, None)) self._queue.put((ZephyrFvpMakeResult.EOF, None)) def _wait_for_fvp(self): """waiting for the START_MSG to appear on the stdout""" while True: try: item = self._queue.get(timeout=120) except Exception: raise TimeoutError("FVP setup timeout.") if item[0] == ZephyrFvpMakeResult.FVP_STARTED: return item[1] if item[0] in [ZephyrFvpMakeResult.MAKE_FAILED, ZephyrFvpMakeResult.EOF]: raise RuntimeError("FVP setup failed.") raise ValueError(f"{item} not expected.") def _wait_for_semihost_init(self): """waiting for the INIT_MSG to appear on the stdout""" while True: try: item = self._queue.get(timeout=240) except Exception: raise TimeoutError("semihost init timeout.") if item[0] == ZephyrFvpMakeResult.MICROTVM_API_SERVER_INIT: return raise ValueError(f"{item} not expected.") def close(self): self._model._shutdown_model() self._model.client.disconnect(force=True) parent = psutil.Process(self.proc.pid) if parent: for child in parent.children(recursive=True): child.terminate() parent.terminate() def read(self, n, timeout_sec): return self._target.stdout.read(n, timeout_sec) def write(self, data, timeout_sec): self._target.stdin.write(data) if __name__ == "__main__": server.main(Handler())
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr/template_project/src/aot_standalone_demo/main.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <assert.h> #include <float.h> #include <kernel.h> #include <stdio.h> #include <string.h> #include <sys/reboot.h> #include <tvm/runtime/c_runtime_api.h> #include <tvm/runtime/crt/logging.h> #include <tvm/runtime/crt/stack_allocator.h> #include <unistd.h> #include <zephyr.h> #include "input_data.h" #include "output_data.h" #include "tvmgen_default.h" #include "zephyr_uart.h" #ifdef CONFIG_ARCH_POSIX #include "posix_board_if.h" #endif // WORKSPACE_SIZE defined in Project API Makefile static uint8_t g_aot_memory[WORKSPACE_SIZE]; tvm_workspace_t app_workspace; // Transport Commands. // Commands on host end with `\n` // Commands on microTVM device end with `%` const unsigned char CMD_WAKEUP[] = "wakeup\n"; const unsigned char CMD_READY[] = "ready\n"; const unsigned char CMD_INIT[] = "init"; const unsigned char CMD_INFER[] = "infer"; #define CMD_SIZE 80u #define CMD_TERMINATOR '%' size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt, va_list args) { return vsnprintk(out_buf, out_buf_size_bytes, fmt, args); } void TVMLogf(const char* msg, ...) { char buffer[256]; int size; va_list args; va_start(args, msg); size = vsprintf(buffer, msg, args); va_end(args); TVMPlatformWriteSerial(buffer, (uint32_t)size); } void TVMPlatformAbort(tvm_crt_error_t error) { TVMLogf("TVMPlatformAbort: %08x\n", error); sys_reboot(SYS_REBOOT_COLD); for (;;) ; } tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { return StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr); } tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { return StackMemoryManager_Free(&app_workspace, ptr); } void timer_expiry_function(struct k_timer* timer_id) { return; } #define MILLIS_TIL_EXPIRY 200 #define TIME_TIL_EXPIRY (K_MSEC(MILLIS_TIL_EXPIRY)) struct k_timer g_microtvm_timer; uint32_t g_microtvm_start_time; int g_microtvm_timer_running = 0; // Called to start system timer. tvm_crt_error_t TVMPlatformTimerStart() { if (g_microtvm_timer_running) { TVMLogf("timer already running"); return kTvmErrorPlatformTimerBadState; } k_timer_start(&g_microtvm_timer, TIME_TIL_EXPIRY, TIME_TIL_EXPIRY); g_microtvm_start_time = k_cycle_get_32(); g_microtvm_timer_running = 1; return kTvmErrorNoError; } // Called to stop system timer. tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) { if (!g_microtvm_timer_running) { TVMLogf("timer not running"); return kTvmErrorSystemErrorMask | 2; } uint32_t stop_time = k_cycle_get_32(); // compute how long the work took uint32_t cycles_spent = stop_time - g_microtvm_start_time; if (stop_time < g_microtvm_start_time) { // we rolled over *at least* once, so correct the rollover it was *only* // once, because we might still use this result cycles_spent = ~((uint32_t)0) - (g_microtvm_start_time - stop_time); } uint32_t ns_spent = (uint32_t)k_cyc_to_ns_floor64(cycles_spent); double hw_clock_res_us = ns_spent / 1000.0; // need to grab time remaining *before* stopping. when stopped, this function // always returns 0. int32_t time_remaining_ms = k_timer_remaining_get(&g_microtvm_timer); k_timer_stop(&g_microtvm_timer); // check *after* stopping to prevent extra expiries on the happy path if (time_remaining_ms < 0) { return kTvmErrorSystemErrorMask | 3; } uint32_t num_expiries = k_timer_status_get(&g_microtvm_timer); uint32_t timer_res_ms = ((num_expiries * MILLIS_TIL_EXPIRY) + time_remaining_ms); double approx_num_cycles = (double)k_ticks_to_cyc_floor32(1) * (double)k_ms_to_ticks_ceil32(timer_res_ms); // if we approach the limits of the HW clock datatype (uint32_t), use the // coarse-grained timer result instead if (approx_num_cycles > (0.5 * (~((uint32_t)0)))) { *elapsed_time_seconds = timer_res_ms / 1000.0; } else { *elapsed_time_seconds = hw_clock_res_us / 1e6; } g_microtvm_timer_running = 0; return kTvmErrorNoError; } void* TVMBackendAllocWorkspace(int device_type, int device_id, uint64_t nbytes, int dtype_code_hint, int dtype_bits_hint) { tvm_crt_error_t err = kTvmErrorNoError; void* ptr = 0; DLDevice dev = {device_type, device_id}; assert(nbytes > 0); err = TVMPlatformMemoryAllocate(nbytes, dev, &ptr); CHECK_EQ(err, kTvmErrorNoError, "TVMBackendAllocWorkspace(%d, %d, %" PRIu64 ", %d, %d) -> %" PRId32, device_type, device_id, nbytes, dtype_code_hint, dtype_bits_hint, err); return ptr; } int TVMBackendFreeWorkspace(int device_type, int device_id, void* ptr) { tvm_crt_error_t err = kTvmErrorNoError; DLDevice dev = {device_type, device_id}; err = TVMPlatformMemoryFree(ptr, dev); return err; } static uint8_t main_rx_buf[128]; static uint8_t g_cmd_buf[128]; static size_t g_cmd_buf_ind; void TVMInfer() { struct tvmgen_default_inputs inputs = { .input_1 = input_data, }; struct tvmgen_default_outputs outputs = { .Identity = output_data, }; StackMemoryManager_Init(&app_workspace, g_aot_memory, WORKSPACE_SIZE); double elapsed_time = 0; TVMPlatformTimerStart(); int ret_val = tvmgen_default_run(&inputs, &outputs); TVMPlatformTimerStop(&elapsed_time); if (ret_val != 0) { TVMLogf("Error: %d\n", ret_val); TVMPlatformAbort(kTvmErrorPlatformCheckFailure); } size_t max_ind = -1; float max_val = -FLT_MAX; for (size_t i = 0; i < output_data_len; i++) { if (output_data[i] >= max_val) { max_ind = i; max_val = output_data[i]; } } TVMLogf("result:%d:%d\n", max_ind, (uint32_t)(elapsed_time * 1000)); } // Execute functions based on received command void command_ready(char* command) { if (strncmp(command, CMD_INIT, CMD_SIZE) == 0) { TVMPlatformWriteSerial(CMD_WAKEUP, sizeof(CMD_WAKEUP)); } else if (strncmp(command, CMD_INFER, CMD_SIZE) == 0) { TVMInfer(); } else { TVMPlatformWriteSerial(CMD_READY, sizeof(CMD_READY)); } } // Append received characters to buffer and check for termination character. void serial_callback(char* message, int len_bytes) { for (int i = 0; i < len_bytes; i++) { if (message[i] == CMD_TERMINATOR) { g_cmd_buf[g_cmd_buf_ind] = (char)0; command_ready(g_cmd_buf); g_cmd_buf_ind = 0; } else { g_cmd_buf[g_cmd_buf_ind] = message[i]; g_cmd_buf_ind += 1; } } } void main(void) { g_cmd_buf_ind = 0; memset((char*)g_cmd_buf, 0, sizeof(g_cmd_buf)); TVMPlatformUARTInit(); k_timer_init(&g_microtvm_timer, NULL, NULL); while (true) { int bytes_read = TVMPlatformUartRxRead(main_rx_buf, sizeof(main_rx_buf)); if (bytes_read > 0) { serial_callback(main_rx_buf, bytes_read); } } #ifdef CONFIG_ARCH_POSIX posix_exit(0); #endif }
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr/template_project/src/aot_standalone_demo/zephyr_uart.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 "zephyr_uart.h" #include <drivers/uart.h> #include <sys/ring_buffer.h> #include "crt_config.h" static const struct device* g_microtvm_uart; #define RING_BUF_SIZE_BYTES (TVM_CRT_MAX_PACKET_SIZE_BYTES + 100) // Ring buffer used to store data read from the UART on rx interrupt. RING_BUF_DECLARE(uart_rx_rbuf, RING_BUF_SIZE_BYTES); static uint8_t uart_data[8]; // UART interrupt callback. void uart_irq_cb(const struct device* dev, void* user_data) { while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { struct ring_buf* rbuf = (struct ring_buf*)user_data; if (uart_irq_rx_ready(dev) != 0) { for (;;) { // Read a small chunk of data from the UART. int bytes_read = uart_fifo_read(dev, uart_data, sizeof(uart_data)); if (bytes_read < 0) { TVMPlatformAbort((tvm_crt_error_t)(0xbeef1)); } else if (bytes_read == 0) { break; } // Write it into the ring buffer. int bytes_written = ring_buf_put(rbuf, uart_data, bytes_read); if (bytes_read != bytes_written) { TVMPlatformAbort((tvm_crt_error_t)(0xbeef2)); } } } } } // Used to initialize the UART receiver. void uart_rx_init(struct ring_buf* rbuf, const struct device* dev) { uart_irq_callback_user_data_set(dev, uart_irq_cb, (void*)rbuf); uart_irq_rx_enable(dev); } uint32_t TVMPlatformUartRxRead(uint8_t* data, uint32_t data_size_bytes) { unsigned int key = irq_lock(); uint32_t bytes_read = ring_buf_get(&uart_rx_rbuf, data, data_size_bytes); irq_unlock(key); return bytes_read; } uint32_t TVMPlatformWriteSerial(const char* data, uint32_t size) { for (uint32_t i = 0; i < size; i++) { uart_poll_out(g_microtvm_uart, data[i]); } return size; } // Initialize UART void TVMPlatformUARTInit() { // Claim console device. g_microtvm_uart = device_get_binding(DT_LABEL(DT_CHOSEN(zephyr_console))); const struct uart_config config = {.baudrate = 115200, .parity = UART_CFG_PARITY_NONE, .stop_bits = UART_CFG_STOP_BITS_1, .data_bits = UART_CFG_DATA_BITS_8, .flow_ctrl = UART_CFG_FLOW_CTRL_NONE}; uart_configure(g_microtvm_uart, &config); uart_rx_init(&uart_rx_rbuf, g_microtvm_uart); }
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr/template_project/src/aot_standalone_demo/zephyr_uart.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 TVM_APPS_MICROTVM_ZEPHYR_AOT_STANDALONE_DEMO_ZEPHYR_UART_H_ #define TVM_APPS_MICROTVM_ZEPHYR_AOT_STANDALONE_DEMO_ZEPHYR_UART_H_ #include <stdint.h> // Used to read data from the UART. /*! * \brief Read Uart Rx buffer. * \param data Pointer to read data. * \param data_size_bytes Read request size in bytes. * * \return Number of data read in bytes. */ uint32_t TVMPlatformUartRxRead(uint8_t* data, uint32_t data_size_bytes); /*! * \brief Write data in serial. * \param data Pointer to data to write. * \param size Size of data in bytes. * * \return Number of write in bytes. */ uint32_t TVMPlatformWriteSerial(const char* data, uint32_t size); /*! * \brief Initialize Uart. */ void TVMPlatformUARTInit(); #endif /* TVM_APPS_MICROTVM_ZEPHYR_AOT_STANDALONE_DEMO_ZEPHYR_UART_H_ */
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr/template_project/src/host_driven/fvp/semihost.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /* * * SPDX-License-Identifier: Apache-2.0 */ #include "semihost.h" int32_t stdout_fd; int32_t stdin_fd; uint32_t semihost_cmd(uint32_t opcode, void* arg) { uint32_t ret_val; __asm__ volatile( "mov r0, %[opcode]\n\t" "mov r1, %[arg]\n\t" "bkpt #0xab\n\r" "mov %[ret_val], r0" : [ ret_val ] "=r"(ret_val) : [ opcode ] "r"(opcode), [ arg ] "r"(arg) : "r1", "memory"); return ret_val; } int32_t stdout_fd; int32_t stdin_fd; void init_semihosting() { // https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst#sys-open-0x01 struct { const char* file_name; uint32_t mode; uint32_t file_name_len; } params; params.file_name = ":tt"; params.mode = 5; // "wb" params.file_name_len = 3; stdout_fd = semihost_cmd(0x01, &params); params.mode = 0; stdin_fd = semihost_cmd(0x01, &params); } ssize_t semihost_read(uint8_t* data, size_t size) { struct { uint32_t file_handle; const uint8_t* data; uint32_t size; } read_req; read_req.file_handle = stdin_fd; read_req.data = data; read_req.size = size; uint32_t ret_val = semihost_cmd(0x06, &read_req); return size - ret_val; } ssize_t semihost_write(void* unused_context, const uint8_t* data, size_t size) { struct { uint32_t file_handle; const uint8_t* data; uint32_t size; } write_req; write_req.file_handle = stdout_fd; write_req.data = data; write_req.size = size; uint32_t ret_val = semihost_cmd(0x05, &write_req); return size - ret_val; }
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr/template_project/src/host_driven/fvp/semihost.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /* * * SPDX-License-Identifier: Apache-2.0 */ #ifndef TVM_APPS_MICROTVM_ZEPHYR_HOST_DRIVEN_SEMIHOST_H_ #define TVM_APPS_MICROTVM_ZEPHYR_HOST_DRIVEN_SEMIHOST_H_ #include <kernel.h> #include <unistd.h> #include <zephyr.h> void init_semihosting(); ssize_t semihost_read(uint8_t* data, size_t size); ssize_t semihost_write(void* unused_context, const uint8_t* data, size_t size); #endif /* TVM_APPS_MICROTVM_ZEPHYR_HOST_DRIVEN_SEMIHOST_H_ */
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr/template_project/src/host_driven/main.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /* * * SPDX-License-Identifier: Apache-2.0 */ /* * This is a sample Zephyr-based application that contains the logic * needed to control a microTVM-based model via the UART. This is only * intended to be a demonstration, since typically you will want to incorporate * this logic into your own application. */ #include <drivers/gpio.h> #include <drivers/uart.h> #include <fatal.h> #include <kernel.h> #include <random/rand32.h> #include <stdio.h> #include <sys/printk.h> #include <sys/reboot.h> #include <sys/ring_buffer.h> #include <timing/timing.h> #include <tvm/runtime/crt/logging.h> #include <tvm/runtime/crt/microtvm_rpc_server.h> #include <unistd.h> #include <zephyr.h> #ifdef FVP #include "fvp/semihost.h" #endif #ifdef CONFIG_ARCH_POSIX #include "posix_board_if.h" #endif #include "crt_config.h" static const struct device* tvm_uart; #ifdef CONFIG_LED #define LED0_NODE DT_ALIAS(led0) #define LED0 DT_GPIO_LABEL(LED0_NODE, gpios) #define LED0_PIN DT_GPIO_PIN(LED0_NODE, gpios) #define LED0_FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios) static const struct device* led0_pin; #endif // CONFIG_LED static size_t g_num_bytes_requested = 0; static size_t g_num_bytes_written = 0; static size_t g_num_bytes_in_rx_buffer = 0; // Called by TVM to write serial data to the UART. ssize_t uart_write(void* unused_context, const uint8_t* data, size_t size) { #ifdef CONFIG_LED gpio_pin_set(led0_pin, LED0_PIN, 1); #endif g_num_bytes_requested += size; for (size_t i = 0; i < size; i++) { uart_poll_out(tvm_uart, data[i]); g_num_bytes_written++; } #ifdef CONFIG_LED gpio_pin_set(led0_pin, LED0_PIN, 0); #endif return size; } ssize_t serial_write(void* unused_context, const uint8_t* data, size_t size) { #ifdef FVP return semihost_write(unused_context, data, size); #else return uart_write(unused_context, data, size); #endif } // This is invoked by Zephyr from an exception handler, which will be invoked // if the device crashes. Here, we turn on the LED and spin. void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t* esf) { #ifdef CONFIG_LED gpio_pin_set(led0_pin, LED0_PIN, 1); #endif for (;;) ; } // Called by TVM when a message needs to be formatted. size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt, va_list args) { return vsnprintk(out_buf, out_buf_size_bytes, fmt, args); } // Called by TVM when an internal invariant is violated, and execution cannot continue. void TVMPlatformAbort(tvm_crt_error_t error) { TVMLogf("TVMError: 0x%x", error); sys_reboot(SYS_REBOOT_COLD); #ifdef CONFIG_LED gpio_pin_set(led0_pin, LED0_PIN, 1); #endif for (;;) ; } // Called by TVM to generate random data. tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) { uint32_t random; // one unit of random data. // Fill parts of `buffer` which are as large as `random`. size_t num_full_blocks = num_bytes / sizeof(random); for (int i = 0; i < num_full_blocks; ++i) { random = sys_rand32_get(); memcpy(&buffer[i * sizeof(random)], &random, sizeof(random)); } // Fill any leftover tail which is smaller than `random`. size_t num_tail_bytes = num_bytes % sizeof(random); if (num_tail_bytes > 0) { random = sys_rand32_get(); memcpy(&buffer[num_bytes - num_tail_bytes], &random, num_tail_bytes); } return kTvmErrorNoError; } // Heap for use by TVMPlatformMemoryAllocate. K_HEAP_DEFINE(tvm_heap, HEAP_SIZE_BYTES); // Called by TVM to allocate memory. tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { *out_ptr = k_heap_alloc(&tvm_heap, num_bytes, K_NO_WAIT); return (*out_ptr == NULL) ? kTvmErrorPlatformNoMemory : kTvmErrorNoError; } // Called by TVM to deallocate memory. tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { k_heap_free(&tvm_heap, ptr); return kTvmErrorNoError; } volatile timing_t g_microtvm_start_time, g_microtvm_end_time; int g_microtvm_timer_running = 0; // Called to start system timer. tvm_crt_error_t TVMPlatformTimerStart() { if (g_microtvm_timer_running) { TVMLogf("timer already running"); return kTvmErrorPlatformTimerBadState; } #ifdef CONFIG_LED gpio_pin_set(led0_pin, LED0_PIN, 1); #endif g_microtvm_start_time = timing_counter_get(); g_microtvm_timer_running = 1; return kTvmErrorNoError; } // Called to stop system timer. tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) { if (!g_microtvm_timer_running) { TVMLogf("timer not running"); return kTvmErrorSystemErrorMask | 2; } #ifdef CONFIG_LED gpio_pin_set(led0_pin, LED0_PIN, 0); #endif g_microtvm_end_time = timing_counter_get(); uint64_t cycles = timing_cycles_get(&g_microtvm_start_time, &g_microtvm_end_time); uint64_t ns_spent = timing_cycles_to_ns(cycles); *elapsed_time_seconds = ns_spent / (double)1e9; g_microtvm_timer_running = 0; return kTvmErrorNoError; } // Ring buffer used to store data read from the UART on rx interrupt. // This ring buffer size is only required for testing with QEMU and not for physical hardware. #define RING_BUF_SIZE_BYTES (TVM_CRT_MAX_PACKET_SIZE_BYTES + 100) RING_BUF_ITEM_DECLARE_SIZE(uart_rx_rbuf, RING_BUF_SIZE_BYTES); // UART interrupt callback. void uart_irq_cb(const struct device* dev, void* user_data) { uart_irq_update(dev); if (uart_irq_is_pending(dev)) { struct ring_buf* rbuf = (struct ring_buf*)user_data; if (uart_irq_rx_ready(dev) != 0) { uint8_t* data; uint32_t size; size = ring_buf_put_claim(rbuf, &data, RING_BUF_SIZE_BYTES); int rx_size = uart_fifo_read(dev, data, size); // Write it into the ring buffer. g_num_bytes_in_rx_buffer += rx_size; if (g_num_bytes_in_rx_buffer > RING_BUF_SIZE_BYTES) { TVMPlatformAbort((tvm_crt_error_t)0xbeef3); } if (rx_size < 0) { TVMPlatformAbort((tvm_crt_error_t)0xbeef1); } int err = ring_buf_put_finish(rbuf, rx_size); if (err != 0) { TVMPlatformAbort((tvm_crt_error_t)0xbeef2); } // CHECK_EQ(bytes_read, bytes_written, "bytes_read: %d; bytes_written: %d", bytes_read, // bytes_written); } } } // Used to initialize the UART receiver. void uart_rx_init(struct ring_buf* rbuf, const struct device* dev) { uart_irq_callback_user_data_set(dev, uart_irq_cb, (void*)rbuf); uart_irq_rx_enable(dev); } // The main function of this application. extern void __stdout_hook_install(int (*hook)(int)); void main(void) { #ifdef CONFIG_LED int ret; led0_pin = device_get_binding(LED0); if (led0_pin == NULL) { for (;;) ; } ret = gpio_pin_configure(led0_pin, LED0_PIN, GPIO_OUTPUT_ACTIVE | LED0_FLAGS); if (ret < 0) { TVMPlatformAbort((tvm_crt_error_t)0xbeef4); } gpio_pin_set(led0_pin, LED0_PIN, 1); #endif // Claim console device. tvm_uart = device_get_binding(DT_LABEL(DT_CHOSEN(zephyr_console))); uart_rx_init(&uart_rx_rbuf, tvm_uart); // Initialize system timing. We could stop and start it every time, but we'll // be using it enough we should just keep it enabled. timing_init(); timing_start(); #ifdef FVP init_semihosting(); // send some dummy log to speed up the initialization for (int i = 0; i < 100; ++i) { uart_write(NULL, "dummy log...\n", 13); } uart_write(NULL, "microTVM Zephyr runtime - running\n", 34); #endif // Initialize microTVM RPC server, which will receive commands from the UART and execute them. microtvm_rpc_server_t server = MicroTVMRpcServerInit(serial_write, NULL); TVMLogf("microTVM Zephyr runtime - running"); #ifdef CONFIG_LED gpio_pin_set(led0_pin, LED0_PIN, 0); #endif // The main application loop. We continuously read commands from the UART // and dispatch them to MicroTVMRpcServerLoop(). while (true) { #ifdef FVP uint8_t data[128]; uint32_t bytes_read = semihost_read(data, 128); #else uint8_t* data; unsigned int key = irq_lock(); uint32_t bytes_read = ring_buf_get_claim(&uart_rx_rbuf, &data, RING_BUF_SIZE_BYTES); #endif if (bytes_read > 0) { uint8_t* ptr = data; size_t bytes_remaining = bytes_read; while (bytes_remaining > 0) { // Pass the received bytes to the RPC server. tvm_crt_error_t err = MicroTVMRpcServerLoop(server, &ptr, &bytes_remaining); if (err != kTvmErrorNoError && err != kTvmErrorFramingShortPacket) { TVMPlatformAbort(err); } #ifdef FVP } } #else g_num_bytes_in_rx_buffer -= bytes_read; if (g_num_bytes_written != 0 || g_num_bytes_requested != 0) { if (g_num_bytes_written != g_num_bytes_requested) { TVMPlatformAbort((tvm_crt_error_t)0xbeef5); } g_num_bytes_written = 0; g_num_bytes_requested = 0; } } int err = ring_buf_get_finish(&uart_rx_rbuf, bytes_read); if (err != 0) { TVMPlatformAbort((tvm_crt_error_t)0xbeef6); } } irq_unlock(key); #endif } #ifdef CONFIG_ARCH_POSIX posix_exit(0); #endif }
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr_cmsisnn/include/crt_config.h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file include/crt_config.h * \brief CRT configuration for demo app. */ #ifndef TVM_RUNTIME_CRT_CONFIG_H_ #define TVM_RUNTIME_CRT_CONFIG_H_ /*! Log level of the CRT runtime */ #define TVM_CRT_LOG_LEVEL TVM_CRT_LOG_LEVEL_DEBUG /*! Support low-level debugging in MISRA-C runtime */ #define TVM_CRT_DEBUG 0 /*! Maximum supported dimension in NDArray */ #define TVM_CRT_MAX_NDIM 6 /*! Maximum supported arguments in generated functions */ #define TVM_CRT_MAX_ARGS 10 /*! Maximum supported string length in dltype, e.g. "int8", "int16", "float32" */ #define TVM_CRT_MAX_STRLEN_DLTYPE 10 /*! Maximum supported string length in function names */ #define TVM_CRT_MAX_STRLEN_FUNCTION_NAME 120 /*! Maximum supported string length in parameter names */ #define TVM_CRT_MAX_STRLEN_PARAM_NAME 80 /*! Maximum number of registered modules. */ #define TVM_CRT_MAX_REGISTERED_MODULES 2 /*! Size of the global function registry, in bytes. */ #define TVM_CRT_GLOBAL_FUNC_REGISTRY_SIZE_BYTES 512 /*! Maximum packet size, in bytes, including the length header. */ #define TVM_CRT_MAX_PACKET_SIZE_BYTES 512 #endif // TVM_RUNTIME_CRT_CONFIG_H_
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr_cmsisnn/model/convert_input.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import os import pathlib import sys import numpy as np def create_file(name, prefix, tensor_name, tensor_data, output_path): """ This function generates a header file containing the data from the numpy array provided. """ file_path = pathlib.Path(f"{output_path}/" + name).resolve() # Create header file with npy_data as a C array raw_path = file_path.with_suffix(".c").resolve() with open(raw_path, "w") as header_file: header_file.write( "#include <stddef.h>\n" "#include <stdint.h>\n" f"const size_t {tensor_name}_len = {tensor_data.size};\n" f"{prefix} float {tensor_name}_storage[] = " ) header_file.write("{") for i in np.ndindex(tensor_data.shape): header_file.write(f"{tensor_data[i]}, ") header_file.write("};\n\n") def create_files(input_file, output_dir): """ This function generates C files for the input and output arrays required to run inferences """ # Create out folder os.makedirs(output_dir, exist_ok=True) # Create input header file input_data = np.loadtxt(input_file) create_file("inputs", "const", "input", input_data, output_dir) # Create output header file output_data = np.zeros([12], np.float32) create_file( "outputs", "", "output", output_data, output_dir, ) if __name__ == "__main__": create_files(sys.argv[1], sys.argv[2])
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr_cmsisnn/model/convert_labels.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. import os import pathlib import sys def create_labels_header(labels_file, output_path): """ This function generates a header file containing the ImageNet labels as an array of strings """ labels_path = pathlib.Path(labels_file).resolve() file_path = pathlib.Path(f"{output_path}/labels.c").resolve() with open(labels_path) as f: labels = f.readlines() with open(file_path, "w") as header_file: header_file.write(f"char* labels[] = {{") for _, label in enumerate(labels): header_file.write(f'"{label.rstrip()}",') header_file.write("};\n") if __name__ == "__main__": create_labels_header(sys.argv[1], sys.argv[2])
https://github.com/zk-ml/tachikoma
apps/microtvm/zephyr_cmsisnn/src/main.c
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/printk.h> #include <tvm/runtime/c_runtime_api.h> #include <tvm/runtime/crt/stack_allocator.h> #include <zephyr.h> #include "tvmgen_default.h" extern char* labels[12]; extern float input_storage[490]; extern float output_storage[12]; extern const size_t output_len; static uint8_t __attribute__((aligned(TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES))) g_crt_workspace[TVMGEN_DEFAULT_WORKSPACE_SIZE]; tvm_workspace_t app_workspace; void TVMLogf(const char* msg, ...) { va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); } void __attribute__((noreturn)) TVMPlatformAbort(tvm_crt_error_t error_code) { fprintf(stderr, "TVMPlatformAbort: %d\n", error_code); exit(-1); } tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) { uintptr_t ret = StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr); return ret; } tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) { return StackMemoryManager_Free(&app_workspace, ptr); } void main(void) { StackMemoryManager_Init(&app_workspace, g_crt_workspace, TVMGEN_DEFAULT_WORKSPACE_SIZE); struct tvmgen_default_inputs inputs = {.input = input_storage}; struct tvmgen_default_outputs outputs = {.Identity = output_storage}; if (tvmgen_default_run(&inputs, &outputs) != 0) { printk("Model run failed\n"); exit(-1); } // Calculate index of max value float max_value = 0.0; size_t max_index = -1; for (unsigned int i = 0; i < output_len; ++i) { if (output_storage[i] > max_value) { max_value = output_storage[i]; max_index = i; } } printk("The word is '%s'!\n", labels[max_index]); exit(0); }
https://github.com/zk-ml/tachikoma
apps/pt_tvmdsoop/tests/test_as_torch.py
#!/usr/bin/env python # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. """Test script for tvm torch module""" import tempfile import numpy as np import torch import torch.nn import tvm from tvm.target.target import Target import tvm.testing from tvm.contrib.torch import as_torch from tvm.script import tir as T @as_torch def matmul(M: int, N: int, K: int, dtype: str): @T.prim_func def main(a: T.handle, b: T.handle, c: T.handle) -> None: A = T.match_buffer(a, [M, K], dtype=dtype) B = T.match_buffer(b, [N, K], dtype=dtype) C = T.match_buffer(c, [M, N], dtype=dtype) for i, j, k in T.grid(M, N, K): with T.block(): vi, vj, vk = T.axis.remap("SSR", [i, j, k]) with T.init(): C[vi, vj] = T.float32(0) C[vi, vj] = C[vi, vj] + A[vi, vk] * B[vj, vk] return main @as_torch @tvm.script.ir_module class ModuleGPU: @T.prim_func def main(A: T.Buffer[8, "float32"], B: T.Buffer[8, "float32"]) -> None: T.func_attr({"global_symbol": "main", "tir.noalias": True}) for i_0 in T.thread_binding(2, thread="blockIdx.x"): for i_2 in T.thread_binding(2, thread="threadIdx.x"): for i_1 in T.serial(2): with T.block("B"): vi = T.axis.spatial(8, i_0 * 4 + i_1 * 2 + i_2) T.reads(A[vi]) T.writes(B[vi]) B[vi] = A[vi] + T.float32(1) @as_torch @T.prim_func def func_with_part_access_region(a: T.handle, b: T.handle, c: T.handle) -> None: A = T.match_buffer(a, [128, 128]) B = T.match_buffer(b, [128, 128]) C = T.match_buffer(c, [128, 128]) with T.block(): for i, j in T.grid(128, 128): with T.block("s1"): vi, vj = T.axis.remap("SS", [i, j]) T.reads(A[vi, vj]) B[vi, vj] = A[vi, vj] + T.float32(1) for i, j in T.grid(128, 128): with T.block("s2"): vi, vj = T.axis.remap("SS", [i, j]) T.writes(C[vi, vj]) C[vi, vj] = B[vi, vj] + T.float32(1) @as_torch @tvm.script.ir_module class MyModule: @T.prim_func def main(a: T.handle, b: T.handle): # We exchange data between function by handles, which are similar to pointer. T.func_attr({"global_symbol": "main", "tir.noalias": True}) # Create buffer from handles. A = T.match_buffer(a, (8,), dtype="float32") B = T.match_buffer(b, (8,), dtype="float32") for i in range(8): # A block is an abstraction for computation. with T.block("B"): # Define a spatial block iterator and bind it to value i. vi = T.axis.spatial(8, i) B[vi] = A[vi] + 1.0 @as_torch @T.prim_func def loop_split(a: T.handle, b: T.handle) -> None: A = T.match_buffer(a, [128, 128], dtype="float32") B = T.match_buffer(b, [128], dtype="float32") for i, ko in T.grid(128, 4): for ki in T.thread_binding(0, 32, thread="threadIdx.x"): with T.block("B"): vi = T.axis.S(128, i) vk = T.axis.R(128, ko * 32 + ki) T.reads([B[vi], A[vi, vk]]) T.writes([B[vi]]) with T.init(): B[vi] = T.float32(0) B[vi] = B[vi] + A[vi, vk] @as_torch def elementwise_with_root(M: int, N: int, dtype: str): @T.prim_func def f(a: T.handle, b: T.handle, c: T.handle) -> None: A = T.match_buffer(a, [M, N]) B = T.match_buffer(b, [M, N]) C = T.match_buffer(c, [M, N]) with T.block(): for i, j in T.grid(M, N): with T.block("s1"): vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A[vi, vj] + T.float32(1) for i, j in T.grid(M, N): with T.block("s2"): vi, vj = T.axis.remap("SS", [i, j]) C[vi, vj] = B[vi, vj] + T.float32(1) return f class MinuesOnes(torch.nn.Module): def __init__(self): super(MinuesOnes, self).__init__() self.engine = MyModule def forward(self, *input): self.engine.forward(*input) return input[-1] - 1 def test_tvmscript_torch_matmul(): s1 = np.random.rand(128, 128).astype("float32") s2 = np.random.rand(128, 128).astype("float32") s3 = np.random.rand(128, 128).astype("float32") q1 = torch.from_numpy(s1) q2 = torch.from_numpy(s2) q3 = torch.from_numpy(s3) numpy_result = np.matmul(s1, np.transpose(s2)) nn_module = matmul(128, 128, 128, "float32") nn_module(q1, q2, q3) tvm.testing.assert_allclose(q3.numpy(), numpy_result, atol=1e-5, rtol=1e-5) def test_tvmscript_torch_decorator(): q1 = torch.arange(8).type(torch.float32) q2 = torch.zeros((8,), dtype=torch.float32) MyModule(q1, q2) tvm.testing.assert_allclose(q2.numpy(), (q1 + 1).numpy(), atol=1e-5, rtol=1e-5) def test_tvmscript_torch_gpu(): cuda0 = torch.device("cuda:0") q1 = torch.arange(8, device=cuda0).type(torch.float32) q2 = torch.zeros((8,), dtype=torch.float32, device=cuda0) with tempfile.NamedTemporaryFile(suffix=".pt") as tmp: torch.save(ModuleGPU, tmp.name) loaded_mod = torch.load(tmp.name) loaded_mod(q1, q2) tvm.testing.assert_allclose(q2.cpu().numpy(), (q1 + 1).cpu().numpy(), atol=1e-5, rtol=1e-5) def test_torch_with_tvmscript(): ref_result = np.arange(8).astype("float32") q1 = torch.arange(8).type(torch.float32) q2 = torch.zeros((8,), dtype=torch.float32) nn_module = MinuesOnes() ret = nn_module.forward(q1, q2) tvm.testing.assert_allclose(ret.numpy(), ref_result, atol=1e-5, rtol=1e-5) def test_tvmscript_torch_func_with_part_access_region(): a1 = torch.rand(128, 128) a2 = torch.zeros(128, 128) a3 = torch.zeros(128, 128) result = a1 + 2 func_with_part_access_region.tune() func_with_part_access_region(a1, a2, a3) tvm.testing.assert_allclose(a3.numpy(), result.numpy(), atol=1e-5, rtol=1e-5) def test_tvmscript_torch_loop_split(): x = torch.rand(128, 128).cuda() y = torch.zeros(128).cuda() result = torch.sum(x.cpu(), dim=1).numpy() loop_split.tune( "nvidia/geforce-rtx-3070", max_trials_global=128, strategy="replay-trace", ) loop_split(x, y) tvm.testing.assert_allclose(y.cpu().numpy(), result, atol=1e-5, rtol=1e-5) def test_tvmscript_torch_elementwise_with_root(): a1 = torch.rand(128, 128) a2 = torch.zeros(128, 128) a3 = torch.zeros(128, 128) result = a1 + 2 func = elementwise_with_root(128, 128, "float32") func.tune( max_trials_global=128, strategy="replay-trace", ) func(a1, a2, a3) tvm.testing.assert_allclose(a3.numpy(), result.numpy(), atol=1e-5, rtol=1e-5) if __name__ == "__main__": test_tvmscript_torch_matmul() test_tvmscript_torch_decorator() test_tvmscript_torch_gpu() test_torch_with_tvmscript() test_tvmscript_torch_func_with_part_access_region() test_tvmscript_torch_loop_split() test_tvmscript_torch_elementwise_with_root()
https://github.com/zk-ml/tachikoma