安装和使用 nn-Meter

安装和使用 nn-Meter

nn-Meter: Towards Accurate Latency Prediction of Deep-Learning Model Inference on Diverse Edge Devices
nn-Meter:精准预测深度学习模型在边缘设备上的推理延迟

Li Lyna Zhang, Shihao Han, Jianyu Wei, Ningxin Zheng, Ting Cao, Yuqing Yang, Yunxin Liu

1. nn-Meter

https://github.com/microsoft/nn-Meter

nn-Meter is a novel and efficient system to accurately predict the inference latency of DNN models on diverse edge devices. The key idea is dividing a whole model inference into kernels, i.e., the execution units of fused operators on a device, and conduct kernel-level prediction. We currently evaluate four popular platforms on a large dataset of 26k models. It achieves 99.0% (mobile CPU), 99.1% (mobile Adreno 640 GPU), 99.0% (mobile Adreno 630 GPU), and 83.4% (Intel VPU) prediction accuracy.
为了高效、准确地预测深度神经网络模型在不同边缘设备上的推理延迟,作者提出并开发了一个基于内核的模型推理延迟预测系统 nn-Meter,引入了内核检测,可找出算子融合行为。通过对最有价值的数据进行采样,nn-Meter 有效地建立了内核的延迟预测器。

The current supported hardware and inference frameworks:

DeviceFrameworkProcessor±10% AccuracyHardware name
Pixel4TFLite v2.1CortexA76 CPU99.0%cortexA76cpu_tflite21
Mi9TFLite v2.1Adreno 640 GPU99.1%adreno640gpu_tflite21
Pixel3XLTFLite v2.1Adreno 630 GPU99.0%adreno630gpu_tflite21
Intel Movidius NCS2OpenVINO2019R2Myriad VPU83.4%myriadvpu_openvino2019r2

Tags
https://github.com/microsoft/nn-Meter/tags

Releases
https://github.com/microsoft/nn-Meter/releases

https://github.com/microsoft/nn-Meter/releases/tag/v1.0-data

adreno630gpu_tflite21.zip
adreno640gpu_tflite21.zip
cortexA76cpu_tflite21.zip
datasets.zip
ir_graphs.zip
myriadvpu_openvino2019r2.zip
onnx_models.zip
pb_models.zip
Source code (zip)
Source code (tar.gz)

https://github.com/microsoft/nn-Meter/releases/tag/v2.0-data

tflite_benchmark_tools_v2.1.zip
tflite_benchmark_tools_v2.7.zip
Source code (zip)
Source code (tar.gz)

nn-Meter Builder
https://github.com/microsoft/nn-Meter/blob/main/docs/builder/overview.md

Neural Network Intelligence,NNI
https://github.com/microsoft/nni
https://www.microsoft.com/en-us/research/project/neural-network-intelligence/
https://nni.readthedocs.io/zh/stable/

NNI (Neural Network Intelligence) is a toolkit to help users run automated machine learning (AutoML) experiments.

26k latency benchmark dataset
https://github.com/microsoft/nn-Meter/releases/download/v1.0-data/datasets.zip

2. Installation

Currently nn-Meter has been tested on Linux and Windows system. Windows 10, Ubuntu 16.04 and 20.04 with python 3.6.10 are tested and supported. Please first install python3 before nn-Meter installation. Then nn-Meter could be installed by running:

pip install nn-meter
pip install nn-meter --default-timeout=1000 -i https://pypi.tuna.tsinghua.edu.cn/simple

nn-meter==2.0 has been released now.

(base) yongqiang@yongqiang:~/yongqiang_work$ pip install nn-meter --default-timeout=1000 -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: nn-meter in /home/yongqiang/miniconda3/lib/python3.11/site-packages (2.0)
Requirement already satisfied: numpy in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (1.25.2)
Requirement already satisfied: pandas in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (1.5.3)
Requirement already satisfied: tqdm in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (4.65.0)
Requirement already satisfied: networkx in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (3.2.1)
Requirement already satisfied: requests in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (2.31.0)
Requirement already satisfied: protobuf in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (4.25.0)
Requirement already satisfied: PyYAML in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (6.0.1)
Requirement already satisfied: scikit-learn in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (1.3.2)
Requirement already satisfied: packaging in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (23.0)
Requirement already satisfied: jsonlines in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from nn-meter) (4.0.0)
Requirement already satisfied: attrs>=19.2.0 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from jsonlines->nn-meter) (23.1.0)
Requirement already satisfied: python-dateutil>=2.8.1 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from pandas->nn-meter) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from pandas->nn-meter) (2022.7)
Requirement already satisfied: charset-normalizer<4,>=2 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from requests->nn-meter) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from requests->nn-meter) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from requests->nn-meter) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from requests->nn-meter) (2023.7.22)
Requirement already satisfied: scipy>=1.5.0 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from scikit-learn->nn-meter) (1.11.3)
Requirement already satisfied: joblib>=1.1.1 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from scikit-learn->nn-meter) (1.3.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from scikit-learn->nn-meter) (3.2.0)
Requirement already satisfied: six>=1.5 in /home/yongqiang/miniconda3/lib/python3.11/site-packages (from python-dateutil>=2.8.1->pandas->nn-meter) (1.16.0)
(base) yongqiang@yongqiang:~/yongqiang_work$

If you want to try latest code, please install nn-Meter from source code. First git clone nn-Meter package to local:

git clone git@github.com:microsoft/nn-Meter.git
cd nn-Meter

Then simply run the following pip install in an environment that has python >= 3.6. The command will complete the automatic installation of all necessary dependencies and nn-Meter.

pip install .

nn-Meter is a latency predictor of models with type of Tensorflow, PyTorch, Onnx, nn-meter IR graph and NNI IR graph (https://github.com/microsoft/nni). To use nn-Meter for specific model type, you also need to install corresponding required packages. The well tested versions are listed below:

Testing Model TypeRequirements
Tensorflowtensorflow==2.6.0
Torchtorch==1.9.0, torchvision==0.10.0, (alternative) [onnx>=1.9.0, onnx-simplifier==0.3.6] or [nni>=2.4]
Onnxonnx==1.9.0
nn-Meter IR graph
NNI IR graphnni>=2.4

Please also check the versions of numpy and scikit_learn. The different versions may change the prediction accuracy of kernel predictors.

The stable version of wheel binary package will be released soon.

3. Usage

To apply for hardware latency prediction, nn-Meter provides two types of interfaces:

  • command line nn-meter after nn-meter installation.
  • Python binding provided by the module nn_meter

Here is a summary of supported inputs of the two methods.

Testing Model TypeCommand SupportPython Binding
TensorflowCheckpoint file dumped by tf.saved_model() and end with .pbCheckpoint file dumped by tf.saved_model and end with .pb
TorchModels in torchvision.modelsObject of torch.nn.Module
OnnxCheckpoint file dumped by torch.onnx.export() or onnx.save() and end with .onnxCheckpoint file dumped by onnx.save() or model loaded by onnx.load()
nn-Meter IR graphJson file in the format of nn-Meter IR Graphdict object following the format of nn-Meter IR Graph
NNI IR graph-NNI IR graph object

In both methods, users could appoint predictor name and version to target a specific hardware platform (device). Currently, nn-Meter supports prediction on the following four configs:

Predictor (device_inference_framework)Processor CategoryVersion
cortexA76cpu_tflite21CPU1.0
adreno640gpu_tflite21GPU1.0
adreno630gpu_tflite21GPU1.0
myriadvpu_openvino2019r2VPU1.0

Users can get all predefined predictors and versions by running

# all predefined predictors
nn-meter --list-predictors
(base) yongqiang@yongqiang:~/yongqiang_work$ nn-meter --list-predictors
(nn-Meter) Supported latency predictors:
(nn-Meter) [Predictor] cortexA76cpu_tflite21: version=1.0
(nn-Meter) [Predictor] adreno640gpu_tflite21: version=1.0
(nn-Meter) [Predictor] adreno630gpu_tflite21: version=1.0
(nn-Meter) [Predictor] myriadvpu_openvino2019r2: version=1.0
(base) yongqiang@yongqiang:~/yongqiang_work$
(base) yongqiang@yongqiang:~/yongqiang_work$ nn-meter -h
usage: nn-meter [-h] [-v] [--list-predictors] [--list-backends] [--list-kernels] [--list-operators] [--list-testcases]{predict,lat_pred,get_ir,create,connect,register,unregister} ...please run "nn-meter {positional argument} --help" to see nn-meter guidancepositional arguments:{predict,lat_pred,get_ir,create,connect,register,unregister}predict (lat_pred)  apply latency predictor for testing modelget_ir              specify a model type to convert to nn-meter ir graphcreate              create a workspace folder for nn-Meter builderconnect             connect to backendregister            register customized module to nn-Meter, supporting type: predictor, backend, operator, testcase, operatorunregister          unregister customized module from nn-Meter, supporting type: predictor, backend, operator, testcase, operatoroptions:-h, --help            show this help message and exit-v, --verbose         increase output verbosity--list-predictors     list all supported predictors--list-backends       list all supported backends--list-kernels        list all supported kernels when building kernel predictors--list-operators      list all supported operators when building fusion rule test cases--list-testcases      list all supported special test cases when building fusion rule test cases
(base) yongqiang@yongqiang:~/yongqiang_work$

3.1. Predict latency of saved CNN model

After installation, a command named nn-meter is enabled. To predict the latency for a CNN model with a predefined predictor in command line, users can run the following commands (sample models can be downloaded here)

# for Tensorflow (*.pb) file
nn-meter predict --predictor <hardware> [--predictor-version <version>] --tensorflow <pb-file_or_folder> 
# Example Usage
nn-meter predict --predictor cortexA76cpu_tflite21 --predictor-version 1.0 --tensorflow mobilenetv3small_0.pb # for ONNX (*.onnx) file
nn-meter predict --predictor <hardware> [--predictor-version <version>] --onnx <onnx-file_or_folder>
# Example Usage
nn-meter predict --predictor cortexA76cpu_tflite21 --predictor-version 1.0 --onnx mobilenetv3small_0.onnx # for torch model from torchvision model zoo
nn-meter predict --predictor <hardware> [--predictor-version <version>] --torchvision <model-name> <model-name>... 
# Example Usage
nn-meter predict --predictor cortexA76cpu_tflite21 --predictor-version 1.0 --torchvision mobilenet_v2# for nn-Meter IR (*.json) file
nn-meter predict --predictor <hardware> [--predictor-version <version>] --nn-meter-ir <json-file_or_folder> 
# Example Usage
nn-meter predict --predictor cortexA76cpu_tflite21 --predictor-version 1.0 --nn-meter-ir mobilenetv3small_0.json 

--predictor-version <version> arguments is optional. When the predictor version is not specified by users, nn-meter will use the latest version of the predictor.

(base) yongqiang@yongqiang:~/yongqiang_work/nn-Meter/material/testmodels$ pwd
/home/yongqiang/yongqiang_work/nn-Meter/material/testmodels
(base) yongqiang@yongqiang:~/yongqiang_work/nn-Meter/material/testmodels$ ls -l
total 18080
-rw-r--r-- 1 yongqiang yongqiang   239602 Nov 12 10:13 mobilenetv3small_0.json
-rw-r--r-- 1 yongqiang yongqiang 10169165 Nov 12 10:13 mobilenetv3small_0.onnx
-rw-r--r-- 1 yongqiang yongqiang  8098911 Nov 12 10:13 mobilenetv3small_0.pb
(base) yongqiang@yongqiang:~/yongqiang_work/nn-Meter/material/testmodels$
nn-meter predict --predictor cortexA76cpu_tflite21 --predictor-version 1.0 --tensorflow /home/yongqiang/yongqiang_work/nn-Meter/material/testmodels/mobilenetv3small_0.pb

nn-Meter can support batch mode prediction. To predict latency for multiple models in the same model type once, user should collect all models in one folder and state the folder after --[model-type] liked argument.

It should also be noted that for PyTorch model, nn-meter can only support existing models in torchvision model zoo. The string followed by --torchvision should be exactly one or more string indicating name(s) of some existing torchvision models. To apply latency prediction for torchvision model in command line, onnx and onnx-simplifier packages are required.

3.2. Convert to nn-Meter IR Graph

Furthermore, users may be interested to convert tensorflow pb-file or onnx file to nn-Meter IR graph. Users could convert nn-Meter IR graph and save to .json file be running

# for Tensorflow (*.pb) file
nn-meter get_ir --tensorflow <pb-file> [--output <output-name>]# for ONNX (*.onnx) file
nn-meter get_ir --onnx <onnx-file> [--output <output-name>]

Output name is default to be /path/to/input/file/<input_file_name>_<model-type>_ir.json if not specified by users.

3.3. Use nn-Meter in your Python code

After installation, users can import nn-Meter in python code

from nn_meter import load_latency_predictorpredictor = load_latency_predictor(hardware_name, hardware_predictor_version) # case insensitive in backend# build your model (e.g., model instance of torch.nn.Module)
model = ... lat = predictor.predict(model, model_type) # the resulting latency is in unit of ms

By calling load_latency_predictor, user selects the target hardware and loads the corresponding predictor. nn-Meter will try to find the right predictor file in ~/.nn_meter/data. If the predictor file doesn’t exist, it will download from the Github release.

In predictor.predict(), the allowed items of the parameter model_type include ["pb", "torch", "onnx", "nnmeter-ir", "nni-ir"], representing model types of tensorflow, torch, onnx, nn-meter IR graph and NNI IR graph, respectively.

For Torch models, the shape of feature maps is unknown merely based on the given network structure, which is, however, significant parameters in latency prediction. Therefore, torch model requires a shape of input tensor for inference as a input of predictor.predict(). Based on the given input shape, a random tensor according to the shape will be generated and used. Another thing for Torch model prediction is that users can install the onnx and onnx-simplifier packages for latency prediction (referred to as Onnx-based latency prediction for torch model), or alternatively install the nni package (referred to as NNI-based latency prediction for torch model). Note that the nni option does not support command line calls. In addition, if users use nni for latency prediction, the PyTorch modules should be defined by the nn interface from NNI import nni.retiarii.nn.pytorch as nn (view NNI Documentation (https://nni.readthedocs.io/en/stable/) for more information), and the parameter apply_nni should be set as True in the function predictor.predict(). Here is an example of NNI-based latency prediction for Torch model:

import nni.retiarii.nn.pytorch as nn
from nn_meter import load_latency_predictorpredictor = load_latency_predictor(...)# build your model using nni.retiarii.nn.pytorch as nn
model = nn.Module ...input_shape = (1, 3, 224, 224)
lat = predictor.predict(model, model_type='torch', input_shape=input_shape, apply_nni=True) 

The Onnx-based latency prediction for torch model is stable but slower, while the NNI-based latency prediction for torch model is unstable as it could fail in some case but much faster compared to the Onnx-based model. The Onnx-based model is set as the default one for Torch model latency prediction in nn-Meter. Users could choose which one they preferred to use according to their needs.

Users could view the information all built-in predictors by list_latency_predictors or view the config file in nn_meter/configs/predictors.yaml.

Users could get a nn-Meter IR graph by applying model_file_to_graph and model_to_graph by calling the model name or model object and specify the model type. The supporting model types of model_file_to_graph include “onnx”, “pb”, “torch”, “nnmeter-ir” and “nni-ir”, while the supporting model types of model_to_graph include “onnx”, “torch” and “nni-ir”.

3.4. nn-Meter Builder

nn-Meter builder is an open source tool for users to build latency predictor on their own devices. There are three main parts in nn-Meter builder:

backend: the module of connecting backends;

backend_meta: the meta tools related to backend. Here we provide the fusion rule tester to detect fusion rules for users’ backend;

kernel_predictor_builder: the tool to build different kernel latency predictors.

Users could get access to nn-Meter builder by calling nn_meter.builder. For more details to use nn-Meter builder, please check the document of nn-Meter builder.

3.5. Hardware-aware NAS by nn-Meter and NNI

To empower affordable DNN on the edge and mobile devices, hardware-aware NAS searches both high accuracy and low latency models. In particular, the search algorithm only considers the models within the target latency constraints during the search process.

empower [ɪmˈpaʊə(r)]:v. 授权,给 (某人) ... 的权力,增加 (某人的) 自主权,使控制局势
affordable [əˈfɔː(r)dəb(ə)l]:adj. 负担得起的

Currently we provide two examples of hardware-aware NAS, including end-to-end multi-trial NAS (https://nni.readthedocs.io/en/stable/) which is a random search algorithm (https://arxiv.org/abs/1902.07638) on SPOS NAS (Single Path One-Shot Neural Architecture Search with Uniform Sampling) search space, and the popular ProxylessNAS (https://nni.readthedocs.io/en/stable/), which is a one-shot NAS algorithm with hardware-efficient loss function. More examples of other widely-used hardware-aware NAS and model compression algorithms are coming soon.

3.5.1. Multi-trial SPOS Demo

To run multi-trail SPOS demo, NNI should be installed through source code by following NNI Documentation (https://nni.readthedocs.io/en/stable/)

python setup.py develop

Then run multi-trail SPOS demo:

python ${NNI_ROOT}/examples/nas/oneshot/spos/multi_trial.py
  • How the demo works

Refer to NNI Documentation (https://nni.readthedocs.io/en/stable/) for how to perform NAS by NNI.

To support hardware-aware NAS, you first need a Strategy that supports filtering the models by latency. We provide such a filter named LatencyFilter in NNI and initialize a Random strategy with the filter:

simple_strategy = strategy.Random(model_filter=LatencyFilter(threshold=100, predictor=base_predictor))

LatencyFilter will predict the models’ latency by using nn-Meter and filter out the models whose latency with the given predictor are larger than the threshold (i.e., 100 in this example).
You can also build your own strategies and filters to support more flexible NAS such as sorting the models according to latency.

Then, pass this strategy to RetiariiExperiment:

exp = RetiariiExperiment(base_model, trainer, strategy=simple_strategy)exp_config = RetiariiExeConfig('local')
...
exp_config.dummy_input = [1, 3, 32, 32]exp.run(exp_config, port)

In exp_config, dummy_input is required for tracing shape info.

3.5.2. ProxylessNAS Demo

To run the one-shot ProxylessNAS demo, users can run the NNI ProxylessNAS training demo:

python ${NNI_ROOT}/examples/nas/oneshot/proxylessnas/main.py --applied_hardware <hardware> --reference_latency <reference latency (ms)>
  • How the demo works

Refer to NNI Documentation (https://nni.readthedocs.io/en/stable/) for how to perform NAS by NNI.

ProxylessNAS currently builds a lookup table, that stores the measured latency of each candidate building block in the search space. The latency sum of all building blocks in a candidate model will be treated as the model inference latency. With leveraging nn-Meter in NNI, users can apply ProxylessNAS to search efficient DNN models on more types of edge devices. In NNI implementation, a HardwareLatencyEstimator predicts expected latency for the mixed operation based on the path weight of ProxylessLayerChoice. To call nn-Meter in NNI ProxylessNAS, users can add the arguments of “--applied_hardware <hardware> --reference_latency <reference latency (ms)>” in the example (https://github.com/microsoft/nni/blob/master/examples/nas/legacy/oneshot/proxylessnas/main.py).

3.6. Benchmark Dataset

To evaluate the effectiveness of a prediction model on an arbitrary DNN model, we need a representative dataset that covers a large prediction scope. nn-Meter collects and generates 26k CNN models. (Please refer the paper for the dataset generation method.)

We release the dataset, and provide an interface of nn_meter.dataset for users to get access to the dataset. Users can also download the data from the Download Link (https://github.com/microsoft/nn-Meter/releases/download/v1.0-data/datasets.zip) on their own.

4. Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct (https://opensource.microsoft.com/codeofconduct/).
For more information see the Code of Conduct FAQ (https://opensource.microsoft.com/codeofconduct/faq/) or
contact opencode@microsoft.com with any additional questions or comments.

5. License

The entire codebase is under MIT license (https://github.com/microsoft/nn-Meter/blob/main/LICENSE)

The dataset is under Open Use of Data Agreement (https://github.com/Community-Data-License-Agreements/Releases/blob/main/O-UDA-1.0.md)

6. Citation

If you find that nn-Meter helps your research, please consider citing it:

@inproceedings{nnmeter,author = {Zhang, Li Lyna and Han, Shihao and Wei, Jianyu and Zheng, Ningxin and Cao, Ting and Yang, Yuqing and Liu, Yunxin},title = {nn-Meter: Towards Accurate Latency Prediction of Deep-Learning Model Inference on Diverse Edge Devices},year = {2021},publisher = {ACM},address = {New York, NY, USA},url = {https://doi.org/10.1145/3458864.3467882},doi = {10.1145/3458864.3467882},booktitle = {Proceedings of the 19th Annual International Conference on Mobile Systems, Applications, and Services},pages = {81–93},
}@misc{nnmetercode,author = {Microsoft Research nn-Meter Team},title = {nn-Meter: Towards Accurate Latency Prediction of Deep-Learning Model Inference on Diverse Edge Devices},year = {2021},url = {https://github.com/microsoft/nn-Meter},
}

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/
[2] microsoft / nn-Meter, https://github.com/microsoft/nn-Meter
[3] nn-meter 2.0, https://pypi.org/project/nn-meter/
[4] nn-Meter: Towards Accurate Latency Prediction of Deep-Learning Model Inference on Diverse Edge Devices, https://air.tsinghua.edu.cn/pdf/nn-Meter-Towards-Accurate-Latency-Prediction-of-Deep-Learning-Model-Inference-on-Diverse-Edge-Devices.pdf

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/139694.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

k8s上对Pod的管理部分详解

目录 一.Pod结构介绍 1.user container 2.pause 二.Pod工作形式介绍 1.自主式pod 2.控制器管理下的pod 三.对Pod的操作介绍 1.run/apply -f/create -f运行pod 2.get查看pod信息 3.exec操作运行中的pod &#xff08;1&#xff09;进入运行中的pod &#xff08;2&…

React的refs和表单组件总结

React的refs和表单组件 react中refs的使用字符串形式的ref react核心就在于虚拟DOM&#xff0c;也就是React中不总是直接操页面的真实DOM元素&#xff0c;并且结合Diffing算法&#xff0c;可以做到最小化页面重绘&#xff0c;但有些时候不可避免我们需要一种方法可以操作我们定…

深入OpenCV Android应用开发

前言 OpenCV是Open Source Computer Vision library(开源的计算机视觉库)的缩写。它是使用最广泛的计算机视觉库。Opencv是计算机视觉领域常用的操作函数的集合&#xff0c;其自身由C/C编写而成&#xff0c;同时也提供了对Python、Java以及任意JVM语言的封装。考虑到大部分And…

【Springboot】基于注解式开发Springboot-Vue3整合Mybatis-plus实现分页查询(二)——前端el-pagination实现

系列文章 【Springboot】基于注解式开发Springboot-Vue3整合Mybatis-plus实现分页查询—后端实现 文章目录 系列文章系统版本实现功能实现思路后端传入的数据格式前端el-table封装axois接口引入Element-plus的el-pagination分页组件Axois 获取后台数据 系统版本 后端&#xf…

内存映射:PS和PL DDR3的一些区别

之前写的一些资料&#xff1a; PS与PL互联与SCU以及PG082-CSDN博客 参考别人的资料&#xff1a; PL读写PS端DDR的设计_pl读写ps端ddr数据-CSDN博客 xilinx sdk、vitis查看地址_vitis如何查看microblazed地址_yang_wei_bk的博客-CSDN博客 可见&#xff0c;PS端的DDR3需要从…

【友提】2023年“思维100”编程比赛开始报名,名额有限报名抓紧

根据官方昨天发布的通知&#xff0c;2023年上海市“科学小公民”实践展示活动之“思维100”STEM应用能力编程活动&#xff08;秋季&#xff09;开始报名了&#xff0c;为便于大家了解&#xff0c;六分成长为大家整理关键信息如下。为便于叙述&#xff0c;该活动简称为思维100编…

shell之route命令介绍

shell之route命令介绍 route命令用于显示和操作IP路由表&#xff0c;它可以查看、添加、删除和修改路由表中的路由项。 以下是route命令的常见选项和用法&#xff1a; 显示路由表&#xff1a;route -n 该命令将显示当前的路由表&#xff0c;包括目标网络、网关、接口等信息。 …

[autojs]逍遥模拟器和vscode对接

第一步&#xff1a;启动autojs服务 第二步&#xff1a;去cmd查看ip地址&#xff0c;输入ipconfig 第三步&#xff1a;打开逍遥模拟器中的sutojs-左上角- 连接电脑&#xff0c;然后输入WLAN或者其他ip也行&#xff0c;根据自己电脑实际情况确认 此时vscode显示连接成功。我们写…

Linux文件缓冲区

文章目录 1. 缓冲区现象2. 用户级和系统级缓冲区3. 缓冲区刷新4. 为什么要有缓冲区5. 文件打印的全缓冲6. 模拟实现C语言文件标准库 本章gitee代码仓库&#xff1a;重定向、模拟C语言文件标准库 1. 缓冲区现象 我们这里分别调用了4个差不多的函数&#xff0c;但是结果是有一定差…

深度解析找不到msvcp120.dll相关问题以及解决方法

​在计算机使用过程中&#xff0c;我们经常会遇到一些错误提示&#xff0c;其中之一就是“msvcp120.dll丢失”。这个错误通常会导致某些应用程序无法正常运行&#xff0c;给用户带来很大的困扰。那么&#xff0c;如何解决msvcp120.dll丢失的问题呢&#xff1f;本文将为大家介绍…

leetcode刷题日记:111. Minimum Depth of Binary Tree(二叉树的最小深度)

给我们一个二叉树&#xff0c;我们应该如何来求二叉树的最小深度呢&#xff1f; 二叉树的最小深度指的是叶子结点到所处的位置最小的&#xff0c;这就是二叉树的最小深度&#xff0c;也就是说我们要找的是离根结点最近的叶子结点。如果我们从根结点向下出发寻找叶子节点&#x…

overflow: auto滚动条跳到指定位置

点击对应模块跳转页面&#xff0c;滚动到对应模块&#xff0c;露出到可视范围 代码&#xff1a; scrollToCurrentCard() {// treeWrapper是包裹多个el-tree组件的父级元素&#xff0c;也是设置overflow:auto的元素let treeWrapper document.getElementsByClassName(treeWrapp…

STM32笔记—定时器

目录 一、TIM简介 二、基本定时器&#xff08;TIM6和TIM7&#xff09; 1. TIM6和TIM7简介 2. TIM6和TIM7的主要特性 3. TIM6和TIM7的功能 3.1 时基单元 3.2 计数模式 3.3 时钟源 三、通用定时器 1. TIMx(2、3、4、5)简介 2. TIMx主要功能 3. 时钟选择 4. 影子寄存…

【算法练习Day46】判断子序列不同的子序列

​&#x1f4dd;个人主页&#xff1a;Sherry的成长之路 &#x1f3e0;学习社区&#xff1a;Sherry的成长之路&#xff08;个人社区&#xff09; &#x1f4d6;专栏链接&#xff1a;练题 &#x1f3af;长路漫漫浩浩&#xff0c;万事皆有期待 文章目录 判断子序列不同的子序列总结…

Flutter笔记:状态提升、控制器模式、GetX控制器和服务

Flutter笔记 状态提升、控制器模式、GetX控制器和服务 作者&#xff1a;李俊才 &#xff08;jcLee95&#xff09;&#xff1a;https://blog.csdn.net/qq_28550263 邮箱 &#xff1a;291148484163.com 本文地址&#xff1a;https://blog.csdn.net/qq_28550263/article/details/1…

450. 删除二叉搜索树中的节点

题目描述 给定一个二叉搜索树的根节点 root 和一个值 key&#xff0c;删除二叉搜索树中的 key 对应的节点&#xff0c;并保证二叉搜索树的性质不变。返回二叉搜索树&#xff08;有可能被更新&#xff09;的根节点的引用。 一般来说&#xff0c;删除节点可分为两个步骤&#x…

ubuntu cp210x(USB转串口)驱动安装教程

ubuntu cp210x&#xff08;USB转串口&#xff09;驱动安装 前言1. 驱动下载2. 驱动编译和安装3. 可能遇到的问题及解决办法3.1 第一种解决方案&#xff1a;检查当前是否已有CP210x.ko驱动3.2 第二种解决方案&#xff1a;修改驱动文件&#xff0c;编译 前言 CP2108 是一款高度集…

【Phoenix】目录结构

当我们通过 mix phx.new 命令生成一个新的Phoenix应用时&#xff0c;它会创建以下目录结构&#xff1a; ├── _build ├── assets ├── config ├── deps ├── lib │├── hello │├── hello.ex │├── hello_web │└── hello_web.ex ├── priv └── …

uniapp中picker 获取时间组件如何把年月日改成年月日默认时分秒为00:00:00

如图所示&#xff0c;uniapp中picker组件的日期格式为&#xff1a; 但后端要 2023-11-08 00:00:00格式 如何从2023-11-08转化为 2023-11-08 00:00:00&#xff1a;&#x1f447; const date new Date(e.detail.value);//"2023-11-17" date.setHours(0, 0, 0); // 2…

C语言从入门到精通之【数据类型和关键字】

数据类型在程序使用之前已经预先设定好了&#xff0c;在整个程序的运行过程中没有变化&#xff0c;这些称为常量&#xff08;constant&#xff09;。其他数据类型在程序运行期间可能会改变或被赋值&#xff0c;这些称为变量&#xff08;variable&#xff09;。 变量类型有几种…