Перейти к содержимому

Что такое mace cl compiled program bin

  • автор:

How to build¶

and then run the container with the following command.

# Create container # Set 'host' network to use ADB docker run -it --rm --privileged -v /dev/bus/usb:/dev/bus/usb --net=host \ -v /local/path:/container/path xiaomimace/mace-dev /bin/bash 

Usage¶

1. Pull MACE source code¶

git clone https://github.com/XiaoMi/mace.git git fetch —all —tags —prune # Checkout the latest tag (i.e. release version) tag_name=`git describe —abbrev=0 —tags` git checkout tags/$

It’s highly recommanded to use a release version instead of master branch.

2. Model Preprocessing¶

  • TensorFlow

TensorFlow provides Graph Transform Tool to improve inference efficiency by making various optimizations like Ops folding, redundant node removal etc. It’s strongly recommended to make these optimizations before graph conversion step.

The following commands show the suggested graph transformations and optimizations for different runtimes,

# CPU/GPU: ./transform_graph \ --in_graph=tf_model.pb \ --out_graph=tf_model_opt.pb \ --inputs='input' \ --outputs='output' \ --transforms='strip_unused_nodes(type=float, shape="1,64,64,3") strip_unused_nodes(type=float, shape="1,64,64,3") remove_nodes(op=Identity, op=CheckNumerics) fold_constants(ignore_errors=true) flatten_atrous_conv fold_batch_norms fold_old_batch_norms strip_unused_nodes sort_by_execution_order' 
# DSP: ./transform_graph \ --in_graph=tf_model.pb \ --out_graph=tf_model_opt.pb \ --inputs='input' \ --outputs='output' \ --transforms='strip_unused_nodes(type=float, shape="1,64,64,3") strip_unused_nodes(type=float, shape="1,64,64,3") remove_nodes(op=Identity, op=CheckNumerics) fold_constants(ignore_errors=true) fold_batch_norms fold_old_batch_norms backport_concatv2 quantize_weights(minimum_size=2) quantize_nodes strip_unused_nodes sort_by_execution_order' 

MACE converter only supports Caffe 1.0+, you need to upgrade your models with Caffe built-in tool when necessary,

# Upgrade prototxt $CAFFE_ROOT/build/tools/upgrade_net_proto_text MODEL.prototxt MODEL.new.prototxt # Upgrade caffemodel $CAFFE_ROOT/build/tools/upgrade_net_proto_binary MODEL.caffemodel MODEL.new.caffemodel

3. Build static/shared library¶

3.1 Overview¶

MACE can build either static or shared library (which is specified by linkshared in YAML model deployment file). The followings are two use cases.

    Build well tuned library for specific SoCs

When target_socs is specified in YAML model deployment file, the build tool will enable automatic tuning for GPU kernels. This usually takes some time to finish depending on the complexity of your model.

Note You should plug in device(s) with the correspoding SoC(s).
When target_socs is not specified, the generated library is compatible with general devices.

Note There will be around of 1 ~ 10% performance drop for GPU runtime compared to the well tuned library.

MACE provide command line tool ( tools/converter.py ) for model conversion, compiling, test run, benchmark and correctness validation.

  1. tools/converter.py should be run at the root directory of this project.
  2. When linkshared is set to 1 , build_type should be proto . And currently only android devices supported.
3.2 tools/converter.py usage¶

Commands

build library and test tools.

# Build library python tools/converter.py build --config=models/config.yaml 

run the model(s).

# Test model run time python tools/converter.py run --config=models/config.yaml --round=100 # Validate the correctness by comparing the results against the # original model and framework, measured with cosine distance for similarity. python tools/converter.py run --config=models/config.yaml --validate # Check the memory usage of the model(**Just keep only one model in configuration file**) python tools/converter.py run --config=models/config.yaml --round=10000 & sleep 5 adb shell dumpsys meminfo | grep mace_run kill %1 

run rely on build command, you should run after build .

benchmark and profiling model.

# Benchmark model, get detailed statistics of each Op. python tools/converter.py benchmark --config=models/config.yaml 

benchmark rely on build command, you should benchmark after build .

Common arguments

option type default commands explanation
—omp_num_threads int -1 run / benchmark number of threads
—cpu_affinity_policy int 1 run / benchmark 0:AFFINITY_NONE/1:AFFINITY_BIG_ONLY/2:AFFINITY_LITTLE_ONLY
—gpu_perf_hint int 3 run / benchmark 0:DEFAULT/1:LOW/2:NORMAL/3:HIGH
—gpu_perf_hint int 3 run / benchmark 0:DEFAULT/1:LOW/2:NORMAL/3:HIGH
—gpu_priority_hint int 3 run / benchmark 0:DEFAULT/1:LOW/2:NORMAL/3:HIGH

Using -h to get detailed help.

python tools/converter.py -h python tools/converter.py build -h python tools/converter.py run -h python tools/converter.py benchmark -h 

4. Deployment¶

build command will generate the static/shared library, model files and header files and packaged as build/$/libmace_$.tar.gz .

  • The generated static libraries are organized as follows,
build/ └── mobilenet-v2-gpu ├── include │ └── mace │ └── public │ ├── mace.h │ └── mace_runtime.h ├── libmace_mobilenet-v2-gpu.tar.gz ├── lib │ ├── arm64-v8a │ │ └── libmace_mobilenet-v2-gpu.MI6.msm8998.a │ └── armeabi-v7a │ └── libmace_mobilenet-v2-gpu.MI6.msm8998.a ├── model │ ├── mobilenet_v2.data │ └── mobilenet_v2.pb └── opencl ├── arm64-v8a │ └── mobilenet-v2-gpu_compiled_opencl_kernel.MI6.msm8998.bin └── armeabi-v7a └── mobilenet-v2-gpu_compiled_opencl_kernel.MI6.msm8998.bin
  • The generated shared libraries are organized as follows,
build └── mobilenet-v2-gpu ├── include │ └── mace │ └── public │ ├── mace.h │ └── mace_runtime.h ├── lib │ ├── arm64-v8a │ │ ├── libgnustl_shared.so │ │ └── libmace.so │ └── armeabi-v7a │ ├── libgnustl_shared.so │ └── libmace.so ├── model │ ├── mobilenet_v2.data │ └── mobilenet_v2.pb └── opencl ├── arm64-v8a │ └── mobilenet-v2-gpu_compiled_opencl_kernel.MI6.msm8998.bin └── armeabi-v7a └── mobilenet-v2-gpu_compiled_opencl_kernel.MI6.msm8998.bin
  1. DSP runtime depends on libhexagon_controller.so .
  2. $.pb file will be generated only when build_type is proto .
  3. $_compiled_opencl_kernel.$.$.bin will be generated only when target_socs and gpu runtime are specified.
  4. Generated shared library depends on libgnustl_shared.so .

$_compiled_opencl_kernel.$.$.bin depends on the OpenCL version of the device, you should maintan the compatibility or configure compiling cache store with ConfigKVStorageFactory .

5. How to use the library in your project¶

Please refer to mace/examples/example.cc for full usage. The following list the key steps.

// Include the headers #include "mace/public/mace.h" #include "mace/public/mace_runtime.h" // If the build_type is code #include "mace/public/mace_engine_factory.h" // 0. Set pre-compiled OpenCL binary program file paths when available if (device_type == DeviceType::GPU) < mace::SetOpenCLBinaryPaths(opencl_binary_paths); >// 1. Set compiled OpenCL kernel cache, this is used to reduce the // initialization time since the compiling is too slow. It's suggested // to set this even when pre-compiled OpenCL program file is provided // because the OpenCL version upgrade may also leads to kernel // recompilations. const std::string file_path ="path/to/opencl_cache_file"; std::shared_ptr storage_factory( new FileStorageFactory(file_path)); ConfigKVStorageFactory(storage_factory); // 2. Declare the device type (must be same with ``runtime`` in configuration file) DeviceType device_type = DeviceType::GPU; // 3. Define the input and output tensor names. std::vector input_names = ; std::vector output_names = ; // 4. Create MaceEngine instance std::shared_ptr engine; MaceStatus create_engine_status; // Create Engine from compiled code create_engine_status = CreateMaceEngineFromCode(model_name.c_str(), nullptr, input_names, output_names, device_type, &engine); // Create Engine from model file create_engine_status = CreateMaceEngineFromProto(model_pb_data, model_data_file.c_str(), input_names, output_names, device_type, &engine); if (create_engine_status != MaceStatus::MACE_SUCCESS) < // Report error >// 5. Create Input and Output tensor buffers std::map inputs; std::map outputs; for (size_t i = 0; i < input_count; ++i) < // Allocate input and output int64_t input_size = std::accumulate(input_shapes[i].begin(), input_shapes[i].end(), 1, std::multiplies()); auto buffer_in = std::shared_ptr(new float[input_size], std::default_delete()); // Load input here // . inputs[input_names[i]] = mace::MaceTensor(input_shapes[i], buffer_in); > for (size_t i = 0; i < output_count; ++i) < int64_t output_size = std::accumulate(output_shapes[i].begin(), output_shapes[i].end(), 1, std::multiplies()); auto buffer_out = std::shared_ptr(new float[output_size], std::default_delete()); outputs[output_names[i]] = mace::MaceTensor(output_shapes[i], buffer_out); > // 6. Run the model MaceStatus status = engine.Run(inputs, &outputs);

© Copyright 2018, Mobile AI Compute Engine (MACE) Developers. Revision 7ac05858 .

MIUI 12 выведет безопасность пользовательских данных на новый уровень

Xiaomi разработала программную платформу под названием MACE (Mobile AI Compute Engine), которая выведет безопасность пользовательских данных на новый уровень. Дебютирует MACE в прошивке MIUI 12, которую должны представить уже очень скоро – 27 апреля.

MIUI 12 выведет безопасность пользовательских данных на новый уровень

Само главное достоинство MACE – автономность. Она выполняет все процессы прямо на мобильном устройстве, а не использует для обработки мощности серверов облачных сервисов. Ну а коль скоро данные никуда не отправляются, то и перехватить их невозможно. Но это еще не все – в MIUI 12 появится механизм защиты информации под названием «отличительная конфиденциальность». Его смысл состоит в добавлении к передаваемым посредством беспроводной связи пользовательским данным небольшой части фальшивого кода – безвредного, но в то же время мешающего декодированию информации в случае перехвата.

Алгоритм «отличительной конфиденциальности» в сочетании с MACE должны сделать смартфоны с MIUI 12 более защищенными. Для всех нынешних пользователей смартфонов Xiaomi прелесть состоит в том, что эти системы защиты реализованы программно, так что пользователи моделей, которым обещано обновление до MIUI 12, получат новые системы защиты автоматически с новой прошивкой.

Что такое mace cl compiled program bin

Jgb49 no está en línea

Jgb49

Miembro del foro
Fecha de registro: feb 2018
Mensajes: 325
Modelo de smartphone: Xiaomi redmi note 9 pro
Tu operador: Simyo
Que es mace_cl_compiled_program.bin

Pues eso, que no deja de aparecer este archivo en mi note 9 pro y no se que es. Aparece en almacenamiento interno y tambi�n dentro de la carpeta Dcim, lo elimino y al poco vuelve a aparecer.

22/12/23, 09:40:28

rpla no está en línea

rpla

Usuario poco activo
Fecha de registro: abr 2012
Mensajes: 2
Tu operador: Movistar

Mace (Mobile AI Compute Engine) es el proyecto de desarrollo de Inteligencia Artificial m�s grande creado por Xiaomi para sus smartphones. Gracias al uso de nuevas programaciones y algoritmos Xiaomi asegura que la privacidad del usuario en MIUI 12 queda apartada de los servidores, siendo relegada a quedarse en el dispositivo del usuario.

El c�digo est� en Gitub

Xiaomi Mace (Mobile AI Compute Engine) – An Open Source Project Released at GitHub

Xiaomi Mace (Mobile AI Compute Engine) - An Open Source Project Released at GitHub

Xiaomi MACE, an Open Source AI Project, announced yesterday at GitHub. The company now inviting developers to participate. This platform was actually released on December 15, 2017, by Xioami but now it’s opened for the testing process. It is designed for mobile chip optimization through AI and supports heterogeneous computing platform (CPU/GPU/DSP), TensorFlow/Caffe model, and multiple SoCs including Qualcomm, MediaTek, and other chips. Now it’s in the development process and will work for some internal firmware features like AI Portrait mode, scene recognition etc.

Xiaomi Mace (Mobile AI Compute Engine) - An Open Source Project Released at GitHub

Xioami MACE is based on a deep machine learning inference framework that is highly optimized for the mobile heterogeneous computing platform. You can check out the demo here.

You May Also Like:

The Xiaomi MACE design is focused on below-mentioned things:

  • Performance
    The runtime is highly optimized with NEON, OpenCL, Hexagon, and Winograd algorithm is introduced to speed up the convolution operations. Besides the fast inference speed, the initialization part is also intensively optimized to be faster.
  • Power consumption
    Chip dependent power options like big.LITTLE scheduling, Adreno GPU hints are included as advanced APIs.
  • Responsiveness
    UI responsiveness guarantee is sometimes obligatory when running a model. The mechanism like automatically breaking OpenCL kernel into small units is introduced to allow better preemption for the UI rendering task.
  • Memory usage and library footprint
    Graph level memory allocation optimization and buffer reuse are supported. The core library tries to keep minimum external dependencies to keep the library footprint small.
  • Model protection
    Model protection is the highest priority feature from the beginning of the design. Various techniques are introduced like converting models to C++ code and literal obfuscations.
  • Platform coverage
    A good coverage of recent Qualcomm, MediaTek, Pinecone and other ARM-based chips. CPU runtime is also compatible with most POSIX systems and architectures with limited performance.

Xiaomi Mace (Mobile AI Compute Engine) - An Open Source Project Released at GitHub

Xioami MACE Performance

Xioami MACE Model Zoo contains several common neural networks and processes which will be built for daily mobile tasks. The benchmark results can be found through the CI result. Xioami MACE depends on several open source projects like Qualcomm Hexagon NN Offload Framework, TensorFlow/Caffe model, SNPE, ARM ComputeLibrary, ncnn etc.

GitHub gives a special thanks to the Qualcomm, Pinecone and MediaTek engineering teams for their extended support in the Xiaomi MACE development. However, GitHub welcoming all the contributors to join this platform and test this to find out bugs, feature requests, or any other issue.

According to the Vice President of Xioami, Cui Baoqiu, Artifical Intelligence, and the Cloud Platform will enhance the open source project as an important part of Xioami’s Engineering platform. Thanks to the Qualcomm, Pinecone, MTK, GitHub, and TensorFlow to make a better development. The Cloud Computing Machine Learning Platform will gather and store a huge amount of data without any issue. Xiaomi hoping that this Machine Learning Mobile AI Compute Engine (Xiaomi MACE) will empower the Chinese Artificial Intelligence Industry towards the Science and Technology field.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *