summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/App.cs132
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/Program.cs37
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/SingleTest.cs57
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/TensorsInfoTest.cs144
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/Tizen.MachineLearning.Inference.Test.csproj29
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/Tizen.MachineLearning.Inference.Test.sln25
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/res/models/mobilenet_v1_1.0_224_quant.tflitebin0 -> 4276000 bytes
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/shared/res/Tizen.MachineLearning.Inference.Test.pngbin0 -> 10097 bytes
-rwxr-xr-xtest/Tizen.MachineLearning.Inference.Test/tizen-manifest.xml12
9 files changed, 436 insertions, 0 deletions
diff --git a/test/Tizen.MachineLearning.Inference.Test/App.cs b/test/Tizen.MachineLearning.Inference.Test/App.cs
new file mode 100755
index 000000000..3f4e51817
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/App.cs
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using System;
+using Log = Tizen.Log;
+using Xamarin.Forms;
+using Tizen.MachineLearning.Inference.Test;
+
+namespace XamarinForTizen.Tizen
+{
+ public class App : Application
+ {
+ Button btnPipeline;
+ Button btnSingle;
+ Button btnTensorsInfo;
+ Label lblResult;
+
+
+ public App()
+ {
+ btnPipeline = new Button
+ {
+ Text = "Pipeline Test",
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.StartAndExpand,
+ };
+ btnPipeline.Clicked += OnBtnPilelineClicked;
+
+ btnSingle = new Button
+ {
+ Text = "Single Test",
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.StartAndExpand,
+ };
+ btnSingle.Clicked += OnBtnSingleClicked;
+
+ btnTensorsInfo = new Button
+ {
+ Text = "TensorsInfo Test",
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.StartAndExpand,
+ };
+ btnTensorsInfo.Clicked += OnBtnTensorsInfoClicked;
+
+ lblResult = new Label
+ {
+ Text = "",
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ };
+ // The root page of your application
+ MainPage = new ContentPage
+ {
+ Content = new StackLayout
+ {
+ VerticalOptions = LayoutOptions.Start,
+ Children = {
+ btnPipeline,
+ btnSingle,
+ btnTensorsInfo,
+ lblResult,
+ }
+ }
+ };
+ }
+
+ protected override void OnStart()
+ {
+ // Handle when your app starts
+ }
+
+ protected override void OnSleep()
+ {
+ // Handle when your app sleeps
+ }
+
+ protected override void OnResume()
+ {
+ // Handle when your app resumes
+ }
+
+ private void OnBtnPilelineClicked(object s, EventArgs e)
+ {
+ string retMsg = "";
+ retMsg += "Pipeline Test Started\n\n";
+
+ retMsg += "\nPipeline Test Done";
+
+ lblResult.Text = retMsg;
+ }
+
+ private void OnBtnSingleClicked(object s, EventArgs e)
+ {
+ string msg = "Single Test Started\n";
+
+ msg += " * BasicSingleTest_Success00: ";
+ msg += SingleShotTest.BasicSingleTest_Success00() ? "OK\n" : "Failed\n";
+
+ msg += "Single Test is Done\n";
+
+ lblResult.Text = msg;
+ }
+
+ private void OnBtnTensorsInfoClicked(object s, EventArgs e)
+ {
+ string msg = "TensorsInfo Test Started\n";
+
+ msg += " * BasicTensorTest_Success00: ";
+ msg += TensorsInfoTest.BasicTensorTest_Success00() ? "OK\n" : "Failed\n";
+
+ msg += " * BasicTensorTest_Success01: ";
+ msg += TensorsInfoTest.BasicTensorTest_Success01() ? "OK\n" : "Failed\n";
+
+ msg += " * BasicTensorTest_Success02: ";
+ msg += TensorsInfoTest.BasicTensorTest_Success02() ? "OK\n" : "Failed\n";
+
+ lblResult.Text = msg;
+ }
+ }
+}
diff --git a/test/Tizen.MachineLearning.Inference.Test/Program.cs b/test/Tizen.MachineLearning.Inference.Test/Program.cs
new file mode 100755
index 000000000..f8d0fb7e7
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/Program.cs
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using System;
+
+namespace XamarinForTizen.Tizen
+{
+ class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
+ {
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+
+ LoadApplication(new App());
+ }
+
+ static void Main(string[] args)
+ {
+ var app = new Program();
+ global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
+ app.Run(args);
+ }
+ }
+}
diff --git a/test/Tizen.MachineLearning.Inference.Test/SingleTest.cs b/test/Tizen.MachineLearning.Inference.Test/SingleTest.cs
new file mode 100755
index 000000000..78c6b8b13
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/SingleTest.cs
@@ -0,0 +1,57 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Threading.Tasks;
+using Tizen.MachineLearning.Inference;
+
+namespace Tizen.MachineLearning.Inference.Test
+{
+ class SingleShotTest
+ {
+ const string TAG = "ML.Inference.Test";
+ private static string ResourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+
+ public static bool BasicSingleTest_Success00()
+ {
+ byte[] in_buffer = new byte[3 * 224 * 224 * 1];
+ byte[] out_buffer;
+ string model_path = ResourcePath + "models/mobilenet_v1_1.0_224_quant.tflite";
+
+ TensorsInfo in_info;
+ TensorsInfo out_info;
+ TensorsData in_data;
+ TensorsData out_data;
+
+ /* Set input & output TensorsInfo */
+ in_info = new TensorsInfo();
+ in_info.AddTensorInfo(TensorType.UInt8, new int[4] { 3, 224, 224, 1 });
+
+ out_info = new TensorsInfo();
+ out_info.AddTensorInfo(TensorType.UInt8, new int[4] { 1001, 1, 1, 1 });
+
+ /* Create single inference engine */
+ SingleShot single = new SingleShot(model_path, in_info, out_info);
+
+ /* Set input data */
+ in_data = in_info.GetTensorsData();
+ in_data.SetTensorData(0, in_buffer);
+
+ /* Single shot invoke */
+ out_data = single.Invoke(in_data);
+
+ /* Get output data from TensorsData */
+ out_buffer = out_data.GetTensorData(0);
+
+ /* Release Single inference instance */
+ single.Dispose();
+
+ /* clean up */
+ in_data.Dispose();
+ out_data.Dispose();
+ in_info.Dispose();
+ out_info.Dispose();
+
+ return true;
+ }
+ }
+}
diff --git a/test/Tizen.MachineLearning.Inference.Test/TensorsInfoTest.cs b/test/Tizen.MachineLearning.Inference.Test/TensorsInfoTest.cs
new file mode 100755
index 000000000..460e65855
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/TensorsInfoTest.cs
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+using Tizen.MachineLearning.Inference;
+
+namespace Tizen.MachineLearning.Inference.Test
+{
+ public static class TensorsInfoTest
+ {
+ const string TAG = "Nnstreamer";
+
+ public static bool BasicTensorTest_Success00()
+ {
+ int[] in_dim = new int[4] { 3, 224, 224, 1 };
+
+ TensorsInfo tensorsInfo = new TensorsInfo();
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ /* Check */
+ if (tensorsInfo.GetTensorType(0) != TensorType.UInt8)
+ return false;
+
+ int[] in_res = tensorsInfo.GetDimension(0);
+ for (int i = 0; i < 4; ++i)
+ {
+ if (in_dim[i] != in_res[i])
+ return false;
+ }
+ return true;
+ }
+ public static bool BasicTensorTest_Success01()
+ {
+ TensorsInfo tensorsInfo;
+ TensorsData tensorsData;
+ int[] in_dim = new int[4] { 10, 1, 1, 1 };
+ byte[] buffer_in = new byte[] { 17, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ byte[] buffer_out;
+
+ tensorsInfo = new TensorsInfo();
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+ Log.Info(TAG, "Current Count: " + tensorsInfo.Count);
+
+ tensorsData = tensorsInfo.GetTensorsData();
+ tensorsData.SetTensorData(0, buffer_in);
+
+ buffer_out = tensorsData.GetTensorData(0);
+
+ if (buffer_in.Length != buffer_out.Length)
+ {
+ Log.Error(TAG, "The size of buffers is different");
+ return false;
+ }
+
+ for (int i = 0; i < buffer_in.Length; ++i)
+ {
+ if (buffer_in[i] != buffer_out[i])
+ {
+ Log.Error(TAG, "The value of " + i.ToString() + " th element is different");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static bool BasicTensorTest_Success02()
+ {
+ TensorsInfo tensorsInfo;
+ TensorsData tensorsData;
+ int[] in_dim = new int[4] { 10, 1, 1, 1 };
+ byte[] buffer_in = new byte[] { 17, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ byte[] buffer_out;
+
+ tensorsInfo = new TensorsInfo();
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim);
+
+ tensorsData = tensorsInfo.GetTensorsData();
+ tensorsData.SetTensorData(0, buffer_in);
+ buffer_out = tensorsData.GetTensorData(0);
+
+ if (buffer_in.Length != buffer_out.Length)
+ {
+ Log.Error(TAG, "The size of buffers is different");
+ return false;
+ }
+
+ for (int i = 0; i < buffer_in.Length; ++i)
+ {
+ if (buffer_in[i] != buffer_out[i])
+ {
+ Log.Error(TAG, "The value of " + i.ToString() + " th element is different");
+ return false;
+ }
+ }
+ tensorsData.Dispose();
+
+ /* Add new tensor */
+ int[] in2_dim = new int[4] { 5, 1, 1, 1 };
+ byte[] buffer_in2 = new byte[] { 10, 20, 30, 40, 50 };
+ byte[] buffer_out2;
+
+
+ tensorsInfo.AddTensorInfo(TensorType.UInt8, in2_dim);
+
+ tensorsData = tensorsInfo.GetTensorsData();
+ tensorsData.SetTensorData(0, buffer_in);
+ buffer_out = tensorsData.GetTensorData(0);
+ tensorsData.SetTensorData(1, buffer_in2);
+ buffer_out2 = tensorsData.GetTensorData(1);
+
+ if (buffer_in2.Length != buffer_out2.Length)
+ {
+ Log.Error(TAG, "The size of buffers is different");
+ return false;
+ }
+
+ for (int i = 0; i < buffer_in2.Length; ++i)
+ {
+ if (buffer_in2[i] != buffer_out2[i])
+ {
+ Log.Error(TAG, "The value of " + i.ToString() + " th element is different");
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/test/Tizen.MachineLearning.Inference.Test/Tizen.MachineLearning.Inference.Test.csproj b/test/Tizen.MachineLearning.Inference.Test/Tizen.MachineLearning.Inference.Test.csproj
new file mode 100755
index 000000000..85e0af006
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/Tizen.MachineLearning.Inference.Test.csproj
@@ -0,0 +1,29 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <!-- Property Group for Tizen50 Project -->
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>tizen60</TargetFramework>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>portable</DebugType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>None</DebugType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Folder Include="lib\" />
+ <Folder Include="res\" />
+ </ItemGroup>
+
+
+ <!-- Include Nuget Package for Tizen Project building -->
+ <ItemGroup>
+ <PackageReference Include="Tizen.NET" Version="6.0.0.14863" />
+ <PackageReference Include="Tizen.NET.Sdk" Version="1.0.3" />
+ <PackageReference Include="Xamarin.Forms" Version="4.0.0.482894" />
+ </ItemGroup>
+
+</Project>
diff --git a/test/Tizen.MachineLearning.Inference.Test/Tizen.MachineLearning.Inference.Test.sln b/test/Tizen.MachineLearning.Inference.Test/Tizen.MachineLearning.Inference.Test.sln
new file mode 100755
index 000000000..3df090cc1
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/Tizen.MachineLearning.Inference.Test.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.645
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.MachineLearning.Inference.Test", "Tizen.MachineLearning.Inference.Test.csproj", "{55443533-832E-49A8-B8E4-1A4C07A97F87}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {55443533-832E-49A8-B8E4-1A4C07A97F87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {55443533-832E-49A8-B8E4-1A4C07A97F87}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {55443533-832E-49A8-B8E4-1A4C07A97F87}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {55443533-832E-49A8-B8E4-1A4C07A97F87}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {2EFA7F43-50B6-4153-8FE6-290DD0A33E80}
+ EndGlobalSection
+EndGlobal
diff --git a/test/Tizen.MachineLearning.Inference.Test/res/models/mobilenet_v1_1.0_224_quant.tflite b/test/Tizen.MachineLearning.Inference.Test/res/models/mobilenet_v1_1.0_224_quant.tflite
new file mode 100755
index 000000000..9a81d7c81
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/res/models/mobilenet_v1_1.0_224_quant.tflite
Binary files differ
diff --git a/test/Tizen.MachineLearning.Inference.Test/shared/res/Tizen.MachineLearning.Inference.Test.png b/test/Tizen.MachineLearning.Inference.Test/shared/res/Tizen.MachineLearning.Inference.Test.png
new file mode 100755
index 000000000..9f3cb9860
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/shared/res/Tizen.MachineLearning.Inference.Test.png
Binary files differ
diff --git a/test/Tizen.MachineLearning.Inference.Test/tizen-manifest.xml b/test/Tizen.MachineLearning.Inference.Test/tizen-manifest.xml
new file mode 100755
index 000000000..468c117ff
--- /dev/null
+++ b/test/Tizen.MachineLearning.Inference.Test/tizen-manifest.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="org.tizen.machine.inference.Test" version="1.0.0" api-version="5" xmlns="http://tizen.org/ns/packages">
+ <profile name="mobile" />
+ <ui-application appid="org.tizen.machine.Inference.Test" exec="Tizen.MachineLearning.Inference.Test.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
+ <label>Tizen.MachineLearning.Inference.Test.dll</label>
+ <icon>Tizen.MachineLearning.Inference.Test.png</icon>
+ <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+ <splash-screens />
+ </ui-application>
+ <shortcut-list />
+ <provides-appdefined-privileges />
+</manifest>