Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Build applications tests and benchmarks on Windows [Include #2924 changes] #2952

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "third_party/iniparser"]
path = third_party/iniparser
[submodule "subprojects/iniparser"]
path = subprojects/iniparser
url = https://github.com/ndevilla/iniparser.git

[submodule "third_party/ruy"]
path = third_party/ruy
url = https://github.com/google/ruy

15 changes: 11 additions & 4 deletions Applications/AlexNet/jni/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
build_root = meson.build_root()
res_path = meson.current_source_dir() / '..' / 'res'
fs = import('fs')
app_res_dir = fs.parent(meson.current_source_dir()) / 'res'
build_app_res_dir = nntr_app_resdir / 'AlexNet'

nntr_alex_resdir = nntr_app_resdir / 'AlexNet'
run_command('cp', '-lr', res_path, nntr_alex_resdir)
if host_machine.system() == 'windows'
app_res_dir_win = app_res_dir.replace('/', '\\')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need that, it can be done in native file.
Please see https://mesonbuild.com/Machine-files.html#binaries
and also my POC

[binaries]
#mkdir = ['mkdir']
mkdir = ['wine', 'cmd.exe', '/c','mkdir']
nproc = ['wine', 'cmd', '/c', '@echo', '%NUMBER_OF_PROCESSORS%']
touch = ['@DIRNAME@'/'touch.bat']

It'll require find_program('cp')

build_app_res_dir_win = build_app_res_dir.replace('/', '\\')
run_command('cmd.exe', '/C', 'mkdir', build_app_res_dir_win)
run_command('cmd.exe', '/C', 'xcopy',app_res_dir_win, build_app_res_dir_win)
else
run_command('cp', '-lr', app_res_dir, build_app_res_dir)
endif

alex_sources = [
'main.cpp',
Expand Down
17 changes: 13 additions & 4 deletions Applications/Custom/LayerClient/jni/meson.build
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
res_path = meson.current_source_dir() / '..' / 'res'
fs = import('fs')
app_res_dir = fs.parent(meson.current_source_dir()) / 'res'
build_app_res_dir = nntr_app_resdir / 'LayerClient'

if host_machine.system() == 'windows'
app_res_dir_win = app_res_dir.replace('/', '\\')
build_app_res_dir_win = build_app_res_dir.replace('/', '\\')
run_command('cmd.exe', '/C', 'mkdir', build_app_res_dir_win)
run_command('cmd.exe', '/C', 'xcopy',app_res_dir_win, build_app_res_dir_win)
else
run_command('cp', '-lr', app_res_dir, build_app_res_dir)
endif

layer_client_sources = [
'main.cpp',
layer_example_pow_src,
layer_example_mae_src
]

run_command('cp', '-lr', res_path, nntr_app_resdir / 'LayerClient')

exe = executable('layer_client',
layer_client_sources,
include_directories: layer_example_inc,
Expand All @@ -17,4 +26,4 @@ exe = executable('layer_client',
)

test('app_layer_client_api', exe, args: 'model')
test('app_layer_client_ini', exe, args: res_path / 'custom_layer_client.ini')
test('app_layer_client_ini', exe, args: build_app_res_dir / 'custom_layer_client.ini')
15 changes: 11 additions & 4 deletions Applications/Layers/jni/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
build_root = meson.build_root()
res_path = meson.current_source_dir() / '..' / 'res'
fs = import('fs')
app_res_dir = fs.parent(meson.current_source_dir()) / 'res'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move closer to begin of file, it'll be useful
It's include/import as in other language.

build_app_res_dir = nntr_app_resdir / 'Layers'

nntr_Layers_resdir = nntr_app_resdir / 'Layers'
run_command('cp', '-lr', res_path, nntr_Layers_resdir)
if host_machine.system() == 'windows'
app_res_dir_win = app_res_dir.replace('/', '\\')
build_app_res_dir_win = build_app_res_dir.replace('/', '\\')
run_command('cmd.exe', '/C', 'mkdir', build_app_res_dir_win)
run_command('cmd.exe', '/C', 'xcopy',app_res_dir_win, build_app_res_dir_win)
else
run_command('cp', '-lr', app_res_dir, build_app_res_dir)
endif

Layers_sources = [
'main.cpp',
Expand Down
1 change: 1 addition & 0 deletions Applications/LogisticRegression/jni/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <iostream>
#include <layer.h>
#include <model.h>
#include <numeric>
#include <optimizer.h>
#include <random>
#include <sstream>
Expand Down
18 changes: 14 additions & 4 deletions Applications/LogisticRegression/jni/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
res_path = meson.current_source_dir() / '..' / 'res'
run_command('cp', '-lr', res_path, nntr_app_resdir / 'LogisticRegression')
fs = import('fs')
app_res_dir = fs.parent(meson.current_source_dir()) / 'res'
build_app_res_dir = nntr_app_resdir / 'LogisticRegression'

if host_machine.system() == 'windows'
app_res_dir_win = app_res_dir.replace('/', '\\')
build_app_res_dir_win = build_app_res_dir.replace('/', '\\')
run_command('cmd.exe', '/C', 'mkdir', build_app_res_dir_win)
run_command('cmd.exe', '/C', 'xcopy',app_res_dir_win, build_app_res_dir_win)
else
run_command('cp', '-lr', app_res_dir, build_app_res_dir)
endif

e = executable('nntrainer_logistic',
'main.cpp',
Expand All @@ -9,6 +19,6 @@ e = executable('nntrainer_logistic',
)

test('app_logistic', e, args: ['train',
nntr_app_resdir / 'LogisticRegression' / 'LogisticRegression.ini',
nntr_app_resdir / 'LogisticRegression' / 'dataset1.txt']
build_app_res_dir / 'LogisticRegression.ini',
build_app_res_dir / 'dataset1.txt']
)
1 change: 1 addition & 0 deletions Applications/MNIST/jni/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <iomanip>
#include <iostream>
#include <memory>
#include <numeric>
#include <random>
#include <sstream>
#include <vector>
Expand Down
18 changes: 13 additions & 5 deletions Applications/MNIST/jni/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
res_path = meson.current_source_dir() / '..' / 'res'
nntr_mnist_resdir = nntr_app_resdir / 'MNIST'
fs = import('fs')
app_res_dir = fs.parent(meson.current_source_dir()) / 'res'
build_app_res_dir = nntr_app_resdir / 'MNIST'

run_command('cp', '-lr', res_path, nntr_mnist_resdir)
if host_machine.system() == 'windows'
app_res_dir_win = app_res_dir.replace('/', '\\')
build_app_res_dir_win = build_app_res_dir.replace('/', '\\')
run_command('cmd.exe', '/C', 'mkdir', build_app_res_dir_win)
run_command('cmd.exe', '/C', 'xcopy',app_res_dir_win, build_app_res_dir_win)
else
run_command('cp', '-lr', app_res_dir, build_app_res_dir)
endif

mnist_sources = [
'main.cpp'
Expand All @@ -23,8 +31,8 @@ test(
'app_mnist',
e,
args: [
nntr_mnist_resdir / 'mnist.ini',
nntr_mnist_resdir / 'mnist_trainingSet.dat'
build_app_res_dir / 'mnist.ini',
build_app_res_dir / 'mnist_trainingSet.dat'
],
timeout: 60
)
Expand Down
1 change: 1 addition & 0 deletions Applications/Multi_input/jni/multi_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cstring>
#include <iostream>
#include <nntrainer_error.h>
#include <numeric>
#include <random>

namespace nntrainer::util {
Expand Down
1 change: 1 addition & 0 deletions Applications/ProductRatings/jni/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <cmath>
#include <fstream>
#include <iostream>
#include <numeric>
#include <random>
#include <sstream>

Expand Down
18 changes: 14 additions & 4 deletions Applications/ProductRatings/jni/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
res_path = meson.current_source_dir() / '..' / 'res'
run_command('cp', '-lr', res_path, nntr_app_resdir / 'ProductRatings')
fs = import('fs')
app_res_dir = fs.parent(meson.current_source_dir()) / 'res'
build_app_res_dir = nntr_app_resdir / 'ProductRatings'

if host_machine.system() == 'windows'
app_res_dir_win = app_res_dir.replace('/', '\\')
build_app_res_dir_win = build_app_res_dir.replace('/', '\\')
run_command('cmd.exe', '/C', 'mkdir', build_app_res_dir_win)
run_command('cmd.exe', '/C', 'xcopy',app_res_dir_win, build_app_res_dir_win)
else
run_command('cp', '-lr', app_res_dir, build_app_res_dir)
endif

e = executable('nntrainer_product_ratings',
'main.cpp',
Expand All @@ -10,6 +20,6 @@ e = executable('nntrainer_product_ratings',

# test split example
test('app_product_ratings', e, args: ['train',
nntr_app_resdir / 'ProductRatings' / 'product_ratings_model.ini',
nntr_app_resdir / 'ProductRatings' / 'sample_product_ratings.txt']
build_app_res_dir / 'product_ratings_model.ini',
build_app_res_dir / 'sample_product_ratings.txt']
)
3 changes: 3 additions & 0 deletions Applications/ReinforcementLearning/DeepQ/jni/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ run_command('cp', '-lr', res_path, nntr_deepq_resdir)

env_dir='../../Environment'

jsoncpp_dep = dependency('jsoncpp')
libcurl_dep = dependency('libcurl')

deepq_sources = [
'main.cpp',
env_dir / 'CartPole/cartpole.cpp'
Expand Down
6 changes: 3 additions & 3 deletions Applications/SimpleFC/jni/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <array>
#include <chrono>
#include <ctime>
#include <filesystem>
#include <iostream>
#include <memory>
#include <sstream>
Expand All @@ -20,7 +21,6 @@
#include <layer.h>
#include <model.h>
#include <optimizer.h>
#include <unistd.h>

#ifdef PROFILE
#include <profiler.h>
Expand Down Expand Up @@ -145,8 +145,8 @@ void createAndRun(unsigned int epochs, unsigned int batch_size,
<< std::endl;

// to test asynch fsu, we do need save the model weight data in file
std::string filePath = "./simplefc_weight_fp16_fp16_100.bin";
if (access(filePath.c_str(), F_OK) == 0) {
std::string filePath = "simplefc_weight_fp16_fp16_100.bin";
if (std::filesystem::exists(filePath)) {
model->load(filePath);
} else {
model->save(filePath, ml::train::ModelFormat::MODEL_FORMAT_BIN);
Expand Down
1 change: 1 addition & 0 deletions Applications/YOLOv2/jni/det_dataloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <filesystem>
#include <fstream>
#include <nntrainer_error.h>
#include <numeric>
#include <random>

namespace nntrainer::util {
Expand Down
1 change: 1 addition & 0 deletions Applications/YOLOv3/jni/det_dataloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <filesystem>
#include <fstream>
#include <nntrainer_error.h>
#include <numeric>
#include <random>

namespace nntrainer::util {
Expand Down
29 changes: 20 additions & 9 deletions Applications/meson.build
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
nntr_app_resdir = nntrainer_resdir / 'app'
run_command('mkdir', '-p', nntr_app_resdir)

if host_machine.system() == 'windows'
nntr_app_resdir_win = nntr_app_resdir.replace('/', '\\')
run_command('cmd.exe', '/C', 'mkdir', nntr_app_resdir_win)
else
run_command('mkdir', '-p', nntr_app_resdir)
endif

subdir('utils')
subdir('KNN/jni')
subdir('LogisticRegression/jni')
if enable_ccapi
subdir('MNIST/jni')
Expand All @@ -12,22 +17,28 @@ if enable_ccapi
endif
subdir('VGG/jni')
subdir('Resnet/jni')
subdir('YOLOv2/jni')
subdir('YOLOv3/jni')
subdir('LLaMA/jni')
subdir('Multi_input/jni')
subdir('ReinforcementLearning/DeepQ/jni')
subdir('TransferLearning/CIFAR_Classification/jni')

# if enable_capi
# subdir('TransferLearning/Draw_Classification/jni')
# endif
subdir('Custom')

subdir('ProductRatings/jni')
subdir('AlexNet/jni')
subdir('Layers/jni')
if get_option('enable-tflite-backbone')
subdir('SimpleShot')
endif
subdir('PicoGPT/jni')

subdir('SimpleFC/jni')

if host_machine.system() != 'windows'
subdir('KNN/jni')
subdir('YOLOv2/jni')
subdir('YOLOv3/jni')
subdir('LLaMA/jni')
subdir('ReinforcementLearning/DeepQ/jni')
subdir('TransferLearning/CIFAR_Classification/jni')
subdir('Custom')
subdir('PicoGPT/jni')
endif
1 change: 1 addition & 0 deletions Applications/utils/datagen/cifar/cifar_dataloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cstring>
#include <iostream>
#include <nntrainer_error.h>
#include <numeric>
#include <random>

namespace nntrainer::util {
Expand Down
2 changes: 0 additions & 2 deletions Applications/utils/jni/bitmap_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ limitations under the License.
#include <fstream>
#include <iostream>

#include <unistd.h> // NOLINT(build/include_order)

#include "bitmap_helpers.h"

#define LOG(x) std::cerr
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/benchmark_application/benchmark_resnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using ModelHandle = std::unique_ptr<ml::train::Model>;
using UserDataType = std::unique_ptr<nntrainer::util::DataLoader>;

uint64_t get_cpu_freq() {
#if not defined(_WIN32)
unsigned int freq = 0;
char cur_cpu_name[512];
int cpu = sched_getcpu();
Expand All @@ -41,6 +42,7 @@ uint64_t get_cpu_freq() {
}
fclose(f);
}
#endif
return 0;
}

Expand Down
9 changes: 8 additions & 1 deletion benchmarks/benchmark_application/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ resnet_dependencies = [nntrainer_dep,
nntrainer_ccapi_dep,
benchmark_dep, ]

benchmark_ling_args = ''

if host_machine.system() == 'windows'
benchmark_ling_args = '-lshlwapi'
endif

executable('Benchmark_ResNet',
sources,
include_directories : [include_directories('.'), fake_datagen_include_dir],
dependencies : resnet_dependencies)
dependencies : resnet_dependencies,
link_args: benchmark_ling_args)
1 change: 1 addition & 0 deletions benchmarks/fake_data_gen/fake_data_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cstring>
#include <iostream>
#include <nntrainer_error.h>
#include <numeric>
#include <random>

namespace nntrainer::util {
Expand Down
Loading
Loading