MindStudio制作MindSpore TBE算子(二)算子测试
在上一节中,成功制作了Mindspore的Add算子,具体可以查看MindStudio制作MindSpore TBE算子(一)算子制作,这一节,一起看看如何对算子进行测试。
建议参考以下内容一起食用:
算子代码实现
MindSpore框架TBE算子开发全流程
制作Mindspore的TBE流程中用于测试的是test_xxx_impl.py和xxx_case_timestation.json文件。
一、算子仿真验证
算子仿真验证是进行算子单元测试(UT测试),其中UT(Unit Test)是软件工程中常见的一种测试方式,目的是对代码中的最小可测试单元(如函数、类、模块)进行验证。针对 CANN 开发来说,UT 主要用于:
- 针对算子实现的单元级别功能测试
- 在真实或模拟环境中运行,验证算子输入输出是否符合预期可能包括边界情况、异常情况测试
特点:
- 以代码单元为测试对象(如 C++ 算子实现、Python 接口等)
- 关注 API 接口行为、异常处理、性能等
- 适用于 CI/CD 流程中的自动化测试
利用MindStudio执行UT测试
- 右键算子工程文件,点击New Case,创建 TBE UT CASE
- 选择测试的算子为新创建的addCustom算子,点击OK
- 生成了对应的test_xxx_impl.py文件
- 编辑对应的py文件,清理掉对应注释,
- 右击对应的python文件,执行TBE算子测试
- 如果这里出现报错
2025-02-10 20:32:17 Get case names failed.The file does not exist. /home/science/MindstudioProjects/Add_custom/out/addcustom_case.json
2025-02-10 20:32:17 Result of getting case name:Traceback (most recent call last):File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/bin/op_ut_helper", line 20, in <module>from absl import app
ModuleNotFoundError: No module named 'absl'
遇到这个报错是因为:如果 op_ut_helper 依赖的是 Ascend 自带的 Python,而安装 absl 时使用的是系统 Python,那么 op_ut_helper 可能找不到 absl。
解决方法有两种:
1. 在系统python下安装缺的包;
2. 利用anaconda的mindspore环境重新安装CANN
这里我推荐适应方法2
./Ascend-cann-toolkit_8.0.0_linux-x86_64.run --uninstall
./Ascend-cann-toolkit_8.0.0_linux-x86_64.run --install
解决这个问题之后,便可以选择测试例子
7. 执行测试用例
这里需要注意的是,需要选择的SOC核心为Ascend910芯片,这里我选择Ascend910Pro。
9. bug调整
报错信息:
Soc Version: Ascend910ProBfailed: [addcustom_impl] addcustom_impl_pre_static_test_addcustom_impl_auto_case_name_1 (Ascend910ProB), error msg: Failed, Case File "/home/science/MindstudioProjects/Add_custom/testcases/ut/ops_test/test_addcustom_impl.py", line 16Error trace: Call op func failed, err_trace: Traceback (most recent call last):File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/ut/op_ut.py", line 873, in _call_op_funcop_func(*case_info.op_params, **addition_params)File "/home/science/anaconda3/envs/mindspore/lib/python3.9/site-packages/mindspore/ops/op_info_register.py", line 298, in wrapped_functionreturn func(*args, **kwargs)TypeError: addcustom_impl() missing 1 required positional argument: 'z'------------------------------------------------------------------------
这里需要对之前的impl代码进行修改
addcustome_impl.py
from __future__ import absolute_import
from tbe import tvm
import tbe.dsl as tbe
from tbe.common.register import register_op_compute
from tbe.common.utils import shape_refine
from tbe.common.utils import shape_util
from tbe.common.utils import para_check
from functools import reduce
from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataTypeSHAPE_SIZE_LIMIT = 2147483648@register_op_compute("addcustom")
def addcustom_compute(x, y):"""The compute function of the Addcustom implementation."""# shape转为listshape_x = shape_util.shape_to_list(x.shape)shape_y = shape_util.shape_to_list(y.shape)# shape_max取shape_x与shape_y的每个维度的大值shape_x, shape_y, shape_max = shape_util.broadcast_shapes(shape_x, shape_y,param_name_input1="input_x",param_name_input2="input_y")shape_size = reduce(lambda x, y: x * y, shape_max[:])if shape_size > SHAPE_SIZE_LIMIT:raise RuntimeError("the shape is too large to calculate")# 将input_x的shape广播为shape_maxinput_x = tbe.broadcast(x, shape_max)input_y = tbe.broadcast(y, shape_max)# 执行input_x + input_yres = tbe.vadd(input_x, input_y)return res# 算子注册信息
# Define the kernel info of Addcustom
# 算子注册名称
addcustom_op_info = (TBERegOp("Addcustom") \# 融合策略,这里选择不融合.fusion_type("OPAQUE") \.partial_flag(True) \.async_flag(False) \# 生成算子二进制名称.binfile_name("addcustom.so") \.compute_cost(10) \.kernel_name("addcustom_impl") \# 算子输入信息.input(0, "x", False, "required", "all")\.input(1, "y", False, "required", "all")\.output(0, "z", False, "required", "all")\# 数据格式名称.dtype_format(DataType.F16_Default, DataType.F16_Default, DataType.F16_Default)\.get_op_info())# 算子的入口函数,描述了算子的编译过程
# Binding kernel info with the kernel implementation.
# 装饰器与算子注册信息绑定,执行后会注册到后端
@op_info_register(addcustom_op_info)
def addcustom_impl(x, y, z, kernel_name="addcustom_impl"):"""The entry function of the Addcustom implementation."""# 获取算子输入tensor的shape与dtypeshape_x = x.get("shape")shape_y = y.get("shape")# 检验算子输入类型check_tuple = ("float16")input_data_type = x.get("dtype").lower()para_check.check_dtype(input_data_type, check_tuple, param_name="input_x")# shape_max取shape_x与shape_y的每个维度的最大值shape_x, shape_y, shape_max = shape_util.broadcast_shapes(shape_x, shape_y,param_name_input1="x",param_name_input2="y")# 如果shape的长度等于1,就直接赋值,如果shape的长度不等于1,做切片,将最后一个维度舍弃(按照内存排布,最后一个维度为1与没有最后一个维度的数据排布相同,例如2*3=2*3*1,将最后一个为1的维度舍弃,可提升后续的调度效率)if shape_x[-1] == 1 and shape_y[-1] == 1 and shape_max[-1] == 1:shape_x = shape_x if len(shape_x) == 1 else shape_x[:-1]shape_y = shape_y if len(shape_y) == 1 else shape_y[:-1]shape_max = shape_max if len(shape_max) == 1 else shape_max[:-1]# 使用TVM的placeholder接口对输入tensor进行占位,返回一个tensor对象data_x = tvm.placeholder(shape_x, name="data_1", dtype=input_data_type)data_y = tvm.placeholder(shape_y, name="data_2", dtype=input_data_type)with tvm.target.cce():# 计算过程res = addcustom_compute(data_x, data_y)# 自动调度模块sch = tbe.auto_schedule(res)# 配置编译信息config = {"print_ir": False,"name": kernel_name,"tensor_list": [data_x, data_y, res]}tbe.build(sch, config)# # 算子调用,测试算子计算正确性
# if __name__ == '__main__':
# input_output_dict = {"shape": (5, 6, 7),"format": "ND","ori_shape": (5, 6, 7),"ori_format": "ND", "dtype": "float16"}
# addcustom_impl(input_output_dict, input_output_dict, input_output_dict, kernel_name="add")
test_addcustom_impl.py
# # -*- coding:utf-8 -*-
import sys
import numpy as np
from op_test_frame.ut import BroadcastOpUT# [TODO] change op_func_name here
ut_case = BroadcastOpUT("addcustom_impl", op_func_name="addcustom_impl")# [TODO] coding expect function here
def calc_expect_func(input_x, input_y, output):res = input_x["value"] + input_y["value"] # 计算加法return [res, ]# [TODO] coding cases here
ut_case.add_precision_case("all", {"params": [{"dtype": "float16", "format": "ND", "ori_format": "ND", "ori_shape": (32,), "shape": (32,), "param_type": "input"}, # input_x{"dtype": "float16", "format": "ND", "ori_format": "ND", "ori_shape": (32,), "shape": (32,), "param_type": "input"}, # input_y{"dtype": "float16", "format": "ND", "ori_format": "ND", "ori_shape": (32,), "shape": (32,), "param_type": "output"} # 添加输出参数],"calc_expect_func": calc_expect_func
})
- 测试结果
addcustom ut_impl start running...
Run command is:
export PATH=%%PYTHON_BIN%%:/home/science/Ascend/ascend-toolkit/8.0.0/atc/ccec_compiler/bin/:%%PYTHON_BIN%%:/home/science/Ascend/ascend-toolkit/8.0.0/compiler/ccec_compiler/bin/:/home/science/Ascend/ascend-toolkit/8.0.0/atc/bin/:/home/science/Ascend/ascend-toolkit/8.0.0/compiler/bin/:${PATH} && export PYTHONPATH=/home/science/MindstudioProjects/Add_custom/mindspore:/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages:/home/science/Ascend/ascend-toolkit/8.0.0/atc/python/site-packages:/home/science/Ascend/ascend-toolkit/8.0.0/compiler/python/site-packages:${PYTHONPATH}:${PYTHONPATH} && export ADK_PATH=/home/science/Ascend/ascend-toolkit/8.0.0 && export LD_LIBRARY_PATH=/home/science/Ascend/ascend-toolkit/8.0.0/atc/lib64:/home/science/Ascend/ascend-toolkit/8.0.0/compiler/lib64:/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/tools/simulator/Ascend910ProB/lib:${LD_LIBRARY_PATH} && export CAMODEL_LOG_PATH=/home/science/MindstudioProjects/Add_custom/out/model && export ASCEND_OPP_PATH=/home/science/Ascend/ascend-toolkit/8.0.0/opp && export PROJECT_PATH=/home/science/MindstudioProjects/Add_custom && export TVM_AICPU_OS_SYSROOT=/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/toolchain/hcc/sysroot && export SIMULATOR_PATH=/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/tools/simulator && unset LD_PRELOAD && rm -rf /home/science/MindstudioProjects/Add_custom/out/coverage_report/ut_impl && rm -rf /home/science/MindstudioProjects/Add_custom/out/model && mkdir -p -m750 /home/science/MindstudioProjects/Add_custom/out/model && rm -rf /home/science/MindstudioProjects/Add_custom/out/bin && mkdir -p -m750 /home/science/MindstudioProjects/Add_custom/out/bin && cd /home/science/MindstudioProjects/Add_custom/out/bin && /home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/bin/op_ut_run --case_files=/home/science/MindstudioProjects/Add_custom/testcases/ut/ops_test --data_path=./data --simulator_data_path=/home/science/MindstudioProjects/Add_custom/out/model --simulator_lib_path=/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/tools/simulator --simulator_mode=pv --soc_version=Ascend910ProB --cov_report=html --cov_report_path=/home/science/MindstudioProjects/Add_custom/out/coverage_report/ut_impl --case_name=addcustom_impl_pre_static_test_addcustom_impl_auto_case_name_1
run /home/science/MindstudioProjects/Add_custom ut test
===============================================================================
>>>> <<<<
>>>> Model Init Suc <<<<
>>>> <<<<
===============================================================================
[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:61 drvMoveTsReport:taskReportQueue is empty
[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:61 drvMoveTsReport:taskReportQueue is empty
[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:61 drvMoveTsReport:taskReportQueue is empty
[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:61 drvMoveTsReport:taskReportQueue is empty
[DRVSTUB_LOG] driver_queue.c:75 drvMoveTsReport:memcpy one report from TS to Driver stub successfully.[DRVSTUB_LOG] driver_queue.c:61 drvMoveTsReport:taskReportQueue is empty
[INFO] model_api.cc:782 stopModel Model stopped successfully.
start run ops ut time: 2025-02-10 22:33:55.804219
[INFO] 2025-02-10 22:33:55.841581 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/ut/op_ut_runner.py", line 366] multiprocess_run_args count: 2
[INFO] 2025-02-10 22:33:55.841770 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/ut/op_ut_runner.py", line 369] process_num is 1, run cases one by one
[INFO] 2025-02-10 22:33:55.842073 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/ut/op_ut_runner.py", line 205] start run: /home/science/MindstudioProjects/Add_custom/testcases/ut/ops_test/test_addcustom_impl.py
>>>> start run test case
[Ascend910ProB] addcustom_impl test start running...
addcustom_impl_pre_static_test_addcustom_impl_auto_case_name_1 (addcustom_impl) (precision) ... [INFO] 2025-02-10 22:34:01.097596 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 105] Load RTS shared library...
[INFO] 2025-02-10 22:34:01.098069 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 219] start load ascend simulator
[INFO] 2025-02-10 22:34:01.107970 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 231] Load ascend simulator success.
[INFO] 2025-02-10 22:34:02.181230 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtSetDevice() success.
[INFO] 2025-02-10 22:34:02.182355 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtStreamCreate() success.
[INFO] 2025-02-10 22:34:02.184036 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtMalloc() success.
[INFO] 2025-02-10 22:34:02.193498 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtMemcpy() success.
[INFO] 2025-02-10 22:34:02.194372 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtMalloc() success.
[INFO] 2025-02-10 22:34:02.195212 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtMemcpy() success.
[INFO] 2025-02-10 22:34:02.195873 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtMalloc() success.
[INFO] 2025-02-10 22:34:02.196505 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtMemset() success.
[INFO] 2025-02-10 22:34:02.197192 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtDevBinaryRegister() success.
[INFO] 2025-02-10 22:34:02.197720 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtFunctionRegister() success.
[INFO] 2025-02-10 22:34:02.206531 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtKernelLaunch() success.
[INFO] 2025-02-10 22:34:02.221129 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtStreamSynchronize() success.
[INFO] 2025-02-10 22:34:02.222081 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtMallocHost() success.
[INFO] 2025-02-10 22:34:02.222630 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtMemcpy() success.
[INFO] 2025-02-10 22:34:02.223189 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtFree() success.
[INFO] 2025-02-10 22:34:02.223564 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtFree() success.
[INFO] 2025-02-10 22:34:02.223956 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtFree() success.
[INFO] 2025-02-10 22:34:02.224431 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtStreamDestroy() success.
[INFO] 2025-02-10 22:34:02.244534 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/runtime/rts_api.py", line 780] Runtime API call rtDeviceReset() success.
Error count: 0, Max atol error count: 0, Threshold count(rtol * data_size):0.032
ok----------------------------------
run 1 tests, success: 1
>>>> end run test case, op_type:addcustom_impl cost time: 2
[INFO] 2025-02-10 22:34:02.248955 [File "/home/science/Ascend/ascend-toolkit/8.0.0/toolkit/python/site-packages/op_test_frame/ut/op_ut_runner.py", line 255] end run: /home/science/MindstudioProjects/Add_custom/testcases/ut/ops_test/test_addcustom_impl.py
/home/science/MindstudioProjects/Add_custom/out/bin/report/combine_rpt_path [] ['rpt_1_test_addcustom_impl.data']
load /home/science/MindstudioProjects/Add_custom/out/bin/report/combine_rpt_path/rpt_1_test_addcustom_impl.data success, case cnt: 1
========================================================================
------------------------------------------------------------------------
- test soc: [Ascend910ProB]
- test case count: 1
- success count: 1
- failed count: 0
- error count: 0
------------------------------------------------------------------------
Soc Version: Ascend910ProBsuccess: [addcustom_impl] addcustom_impl_pre_static_test_addcustom_impl_auto_case_name_1 (Ascend910ProB) (precision)
------------------------------------------------------------------------
========================================================================end run ops ut time: 2025-02-10 22:34:02.266352TBE TestRun FinishedUt_Impl report index.html: http://localhost:63342/Add_custom/out/coverage_report/ut_impl/index.html?_ijt=laasfbagsbclwufgwngbqcposk
从报告中也可以看到,依然是有代码是UT测试中没有覆盖的内容,这也代表着我们需要进行更多更全面的测试用例编写。
相关文章:
MindStudio制作MindSpore TBE算子(二)算子测试
在上一节中,成功制作了Mindspore的Add算子,具体可以查看MindStudio制作MindSpore TBE算子(一)算子制作,这一节,一起看看如何对算子进行测试。 建议参考以下内容一起食用: 算子代码实现 MindSpor…...
深度解读城市地下网管管廊改造要点
引 言 近日国家发改委和住建部联合发布通知(后附),要求各地抓紧编制“城市地下管网和综合管廊建设改造实施方案”并于12月27日前报国家发改委和住建部相关司处,逾期未报的城市(县、区),视同自愿…...
Docker 部署 redis | 国内阿里镜像
一、简易单机版 1、镜像拉取 # docker hub 镜像 docker pull redis:7.0.4-bullseye # 阿里云镜像 docker pull alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/redis_optimized:20240221-6.2.7-2.3.0 2、运行镜像 docker run -itd --name redis \n …...
Day88:加载游戏图片
在游戏开发中,加载和显示图片是非常常见的需求,尤其是在 2D 游戏 中,角色、背景、道具、敌人等都需要用图片来表示。今天,我们将学习如何在 Python 游戏开发中使用 Pygame 加载并显示图片。 1. 加载游戏图片的基本步骤 在 Pygame 中加载图片通常需要以下几个步骤: 导入 P…...
Elasticsearch:在 Elastic 中玩转 DeepSeek R1 来实现 RAG 应用
在这个春节,如一声春雷,DeepSeek R1 横空出世。现在人人都在谈论 DeepSeek R1。这个大语言模型无疑在中国及世界的人工智能发展史上留下了重要的里程碑。那么我们改如何结合 DeepSeek R1 及 Elasticsearch 来实现 RAG 呢?在之前的文章 “使用…...
SOME/IP报文格式及发现协议详解
在之前的文章中,我们介绍了SOME/IP协议的几种服务接口。在本篇博客中,主要介绍some/ip协议传输的header报文格式以及SOME/IP-SD发现协议。 目录 流程 报文格式 Message ID Length Request ID protocal version/Interface Version Message Type…...
elementplus 使用日期时间选择器,设置可选范围为前后大于2年且只能选择历史时间不能大于当前时间点
需求:时间选择器可选的时间范围进行限制,-2年<a<2年且a<new Date().getTime()核心:这里需要注意plus版没有picker-options换成disabled-date属性了,使用了visible-change和calendar-change属性逻辑:另设一个参…...
C语言·关键字·char关键字
C语言菜鸟入门关键字char关键字_c char-CSDN博客...
Ansible简单介绍及用法
一、简介 Ansible是一个简单的自动化运维管理工具,基于Python语言实现,由Paramiko和PyYAML两个关键模块构建,可用于自动化部署应用、配置、编排task(持续交付、无宕机更新等)。主版本大概每2个月发布一次。 Ansible与Saltstack最大的区别是…...
Mac 本地搭建自己的 DeepSeek
Mac 本地搭建自己的 DeepSeek 安装 Ollama通过Ollama命令安装 DeepSeek 模型安装一个UI客户端,提升体验 注:本文章完全参考网上教程,没有丝毫原创,只是记录一下我本人在安装DeepSeek 的步骤 安装 Ollama https://ollama.com/dow…...
深度学习-交易预测
下面为你详细介绍如何使用Python结合深度学习库TensorFlow和Keras来构建一个简单的交易预测模型。在这个示例中,我们以股票价格预测为例,假设我们要根据过去一段时间的股票价格数据来预测未来的价格走势。 步骤分析 数据准备:获取股票价格数…...
Prompt逆向工程:如何“骗“大模型吐露其Prompt?
提示词的“逆向工程”,让AI大语言模型帮你反推提示词 一、前言 在日常生活中,我们不时会遇到一些令人惊艳的文本,不论是一篇精彩绝伦的小说、一篇深入浅出的科普文章,还是一篇充满热情的音乐推荐,它们都能在我们的心…...
游戏手柄Type-c方案,支持一边充电一边传输数据
乐得瑞推出LDR6023SS,专门针对USB-C接口手机手柄方案,支持手机快充,支持任天堂游戏机,PS4等设备~同时支持手机充电跟数据传输 1、概述 LDR6023SS SSOP16 是乐得瑞科技针对 USB Type-C 标准中的 Bridge 设备而开发的双 USB-C DRP …...
Vue设计模式到底多少种?
Vue设计模式到底多少种? 很多同学问,Vue到底有多少种设计模式??各个模式到底是什么意思??又各自适合什么场景?? 这里我给大家直接说下,Vue的设计模式没有一个固定的数值…...
C++ 中的 std::timed_mutex 和 std::recursive_timed_mutex
1、背景 在多线程编程中,互斥锁(Mutex)是用于保护共享资源的重要工具。C 标准库提供了多种互斥锁类型,其中 std::timed_mutex 和 std::recursive_timed_mutex 是两种支持超时功能的互斥锁。在阅读FastDDS源码时,发现了…...
HAL库外设宝典:基于CubeMX的STM32开发手册(持续更新)
目录 前言 GPIO(通用输入输出引脚) 推挽输出模式 浮空输入和上拉输入模式 GPIO其他模式以及内部电路原理 输出驱动器 输入驱动器 中断 外部中断(EXTI) 深入中断(内部机制及原理) 外部中断/事件控…...
Kotlin实战经验:将接口回调转换成suspend挂起函数
在 Kotlin 协程中, suspendCoroutine 和 suspendCancellableCoroutine 是用于将回调或基于 future 的异步操作转换成挂起函数。 suspendCoroutine 用途:将回调式异步操作转换为可挂起函数 行为: 启动一个新的协程来处理基于回调的操作挂起当前协程,直到调用回调回调负责…...
银行国际结算
银行国结项目,即国际结算项目,是银行业务中的重要组成部分,它涉及跨国界的货币收付和资金转移。 一、银行国结项目的定义 银行国结项目是指银行为国际贸易、投资等活动提供的国际结算服务,包括各种国际支付和资金清算业务。这些…...
java后端开发day13--面向对象综合练习
(以下内容全部来自上述课程) 注意:先有javabean,才能创建对象。 1.文字版格斗游戏 格斗游戏,每个游戏角色的姓名,血量,都不相同,在选定人物的时候(new对象的时候&#…...
Vue解决父子组件传值,子组件改变值后父组件的值也改变的问题
vue开发过程中,父组件通过props传值给子组件,子组件在页面展示父组件的值,在操作子组件值以后,即使不点击确定按钮,父组件中的值也发生了变化,但是需求是操作子组件数据以后,必须点击"确定…...
【通俗解释,入门级】DeepSeek - R1 - Zero:强化学习提升LLM推理能力的奥秘
DeepSeek - R1 - Zero:强化学习提升LLM推理能力的奥秘 第一节:强化学习在DeepSeek - R1 - Zero中的基本概念与公式解释【通俗解释】 强化学习在DeepSeek - R1 - Zero里就像是一位“聪明的探险家”,在各种可能的推理路径中探索,通…...
《图解设计模式》笔记(六)访问数据结构
十三、Visitor 模式:访问数据结构并处理数据 Visitor:访问者 我们会“处理”在数据结构中保存着的元素,通常把“处理”代码放在表示数据结构的类中。 但每增加一种处理,就不得不去修改表示数据结构的类。 在 Visitor模式中&am…...
windows11上,使用pipx安装Poetry,Poetry的安装路径是什么?
当使用 pipx 安装 Poetry 时,pipx 会将 Poetry 安装到一个独立的虚拟环境中,并将其可执行文件链接到一个集中的目录中。以下是 pipx 安装 Poetry 时的路径信息: 1. Poetry 的安装路径 pipx 会为每个工具(如 Poetry)创…...
使用 vcpkg 简化 C++ 项目依赖管理
使用 vcpkg 简化 C 项目依赖管理 什么是 vcpkg? vcpkg 是微软推出的跨平台 C/C 包管理工具,支持 Windows/Linux/macOS。它可以帮助开发者: ✅ 一键安装 2000 开源库 ✅ 自动解决依赖关系 ✅ 生成 Visual Studio 集成配置 ✅ 支持自定义编译…...
怎样确定网站访问速度出现问题是后台还是服务器造成的?
网站的访问速度会影响到用户的体验感,当网络过于卡顿或访问速度较慢时,会给用户带来不好的体验感,但是网站访问速度不仅会是后台造成影响的,也可能是服务器的原因,那么我们该如何分辨呢? 当网站使用了数据库…...
【Elasticsearch】管道聚合
管道聚合就是在已有聚合结果之上在进行聚合,管道聚合是针对于聚合的聚合 在 Elasticsearch 中,管道聚合(Pipeline Aggregations)是一种特殊的聚合类型,用于对其他聚合的结果进行进一步的计算和处理,而不是直…...
CNN-GRU卷积神经网络门控循环单元多变量多步预测,光伏功率预测(Matlab完整源码和数据)
代码地址:CNN-GRU卷积神经网络门控循环单元多变量多步预测,光伏功率预测(Matlab完整源码和数据) CNN-GRU卷积神经网络门控循环单元多变量多步预测,光伏功率预测 一、引言 1.1、研究背景和意义 随着全球能源危机和环境问题的日…...
后端java工程师经验之谈,工作7年,mysql使用心得
mysql 工作7年,mysql使用心得 mysql1.创建变量2.创建存储过程2.1:WHILE循环2.2:repeat循环2.3:loop循环2.4:存储过程,游标2.5:存储过程,有输入参数和输出参数 3.三种注释写法4.case …...
综合评价 | 基于随机变异系数-TOPSIS组合法的综合评价模型(Matlab)
基于随机变异系数-TOPSIS组合法的综合评价模型 代码获取私信回复:综合评价 | 基于随机变异系数-TOPSIS组合法的综合评价模型(Matlab) 一、引言 1.1、研究背景与意义 在现代社会,随着信息量的不断增加和数据复杂性的提升&#…...
Visual Studio Code中文出现黄色框子的解决办法
Visual Studio Code中文出现黄色框子的解决办法 一、vsCode中文出现黄色框子-如图二、解决办法 一、vsCode中文出现黄色框子-如图 二、解决办法 点击 “文件”点击 “首选项”点击 “设置” 搜索框直接搜索unicode选择“文本编辑器”,往下滑动,找到“Un…...
手写一个C++ Android Binder服务及源码分析
手写一个C Android Binder服务及源码分析 前言一、 基于C语言编写Android Binder跨进程通信Demo总结及改进二、C语言编写自己的Binder服务Demo1. binder服务demo功能介绍2. binder服务demo代码结构图3. binder服务demo代码实现3.1 IHelloService.h代码实现3.2 BnHelloService.c…...
【AIGC】在VSCode中集成 DeepSeek(OPEN AI同理)
在 Visual Studio Code (VSCode) 中集成 AI 编程能力,可以通过安装和配置特定插件来实现。以下是如何通过 Continue 和 Cline 插件集成 DeepSeek: 一、集成 DeepSeek 获取 DeepSeek API 密钥:访问 DeepSeek 官方网站,注册并获取 …...
使用 Three.js 实现热力渐变效果
大家好!我是 [数擎 AI],一位热爱探索新技术的前端开发者,在这里分享前端和 Web3D、AI 技术的干货与实战经验。如果你对技术有热情,欢迎关注我的文章,我们一起成长、进步! 开发领域:前端开发 | A…...
Vue事件处理 - 绑定事件
Vue 渐进式JavaScript 框架 基于Vue2的学习笔记 - Vue事件处理 - 绑定事件及事件处理 目录 事件处理 绑定方式 函数表达式 绑定函数名 输入框绑定事件 拿到输入框的值 传值加事件源 事件第三种写法 总结 事件处理 绑定方式 函数表达式 在按钮上使用函数表达式绑定事…...
DVWA靶场通关——SQL Injection篇
一,Low难度下unionget字符串select****注入 1,首先手工注入判断是否存在SQL注入漏洞,输入1 这是正常回显的结果,再键入1’ You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ver…...
DeepSeek 助力 Vue 开发:打造丝滑的步骤条
前言:哈喽,大家好,今天给大家分享一篇文章!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏关注哦 💕 目录 Deep…...
今日学习总结
1.完成了P2242公路维修问题 2.完成了P10605下头论文 1.P2242 思考:建立单向链表,使用qsort降序排序。 #include<stdio.h> #include<stdlib.h> #include<stdbool.h> #include<string.h> int n,m; int a[15005],b[15005],ans;…...
Transformer 的辉煌与大模型方向确立,点燃AGI之火把
GPT3,指明大模型发展方向,点燃大模型软件行业繁荣之火,目前大模型有100万个。 DeepSeek-V3,指明下一个阶段大模型发张方向,破壁: 资金壁垒:训练成本降低,适配丰富硬件,总…...
DeepSeek-Coder系列模型:智能编程助手的未来
文章目录 一、模型架构与核心功能1. 模型架构2. 核心功能 二、多语言支持与代码生成1. Python代码生成2. Java代码生成3. C代码生成4. JavaScript代码生成 三、仓库级代码理解1. 代码结构分析2. 上下文理解 四、FIM填充技术1. 函数自动填充2. 代码补全 五、应用场景1. 代码补全…...
微信小程序longpress以及touchend的bug,touchend不触发,touchend不执行
核心原因:bind:touchend里面不能放wx:if 举例: <view bind:longpress"longpressBtn" bind:touchend"touchendBtn"><view wx:if"{{isRecording}}" >松开发送</view><view wx:else"…...
多租户架构设计与实现:基于 PostgreSQL 和 Node.js
多租户架构设计与实现:基于 PostgreSQL 和 Node.js 引言 多租户架构(Multi-tenancy)是现代 SaaS(Software as a Service)应用的核心设计模式之一。它允许多个租户共享同一套应用实例,同时确保数据隔离和安全性。本文将详细介绍多租户架构的设计方案,并基于 PostgreSQL…...
四、OSG学习笔记-基础图元
前一章节: 三、OSG学习笔记-应用基础-CSDN博客https://blog.csdn.net/weixin_36323170/article/details/145514021 代码:CuiQingCheng/OsgStudy - Gitee.com 一、绘制盒子模型 下面一个简单的 demo #include<windows.h> #include<osg/Node&…...
windows平台本地部署DeepSeek大模型+Open WebUI网页界面(可以离线使用)
环境准备: 确定部署方案请参考:DeepSeek-R1系列(1.5b/7b/8b/32b/70b/761b)大模型部署需要什么硬件条件-CSDN博客 根据本人电脑配置:windows11 + i9-13900HX+RTX4060+DDR5 5600 32G内存 确定部署方案:DeepSeek-R1:7b + Ollama + Open WebUI 1. 安装 Ollama Ollama 是一…...
功能架构元模型
功能架构的元模型是对功能架构进行描述和建模的基础框架,它有助于统一不同团队对系统的理解,并为系统的设计和开发提供一致的标准和规范。虽然具体的元模型可能因不同的应用领域和特定需求而有所差异,但一般来说,功能架构的元模型可以涵盖以下几个方面: 组件/模块元模型:…...
云计算——AWS Solutions Architect – Associate(saa)4.安全组和NACL
安全组一充当虚拟防火墙对于关联实例,在实例级别控制入站和出站流量。 网络访问控制列表(NACL)一充当防火墙关联子网,在子网级别控制入站和出站流量。 在专有网络中,安全组和网络ACL(NACL)一起帮助构建分层网络防御。 安全组在实例级别操作…...
Fiddler Classic(HTTP流量代理+半汉化)
目录 一、关于Fiddler (一) Fiddler Classic (二) Fiddler Everywhere (三) Fiddler Everywhere Reporter (四) FiddlerCore (五) 总结 二、 软件安全性 1. 软件安装包 2. 软件汉化dll 三、安装与半汉化 1. 正常打开安装包点击下一步安装即可,安装路径自…...
【hive】记一次hiveserver内存溢出排查,线程池未正确关闭导致
一、使用 MemoryAnalyzer软件打开hprof文件 很大有30G,win内存24GB,不用担心可以打开,ma软件能够生成索引文件,逐块分析内存,如下图。 大约需要4小时。 overview中开不到具体信息。 二、使用Leak Suspects功能继续…...
MySQL的字段类型
MySQL 字段类型可以简单分为三大类 数值类型:整型(TINYINT、SMALLINT、MEDIUMINT、INT 和 BIGINT)、浮点型(FLOAT 和 DOUBLE)、定点型(DECIMAL)字符串类型:CHAR、VARCHAR、TINYTEXT…...
HTML之JavaScript运算符
HTML之JavaScript运算符 1.算术运算符 - * / %除以0,结果为Infinity取余数,如果除数为0,结果为NaN NAN:Not A Number2.复合赋值运算符 - * / %/ 除以0,结果为Infinity% 如果除数为0,结果为NaN NaN:No…...
UE5--浅析委托原理(Delegate)
委托概述 委托是一种用于事件处理的机制。通过使用委托,可以将一个或多个函数绑定到一个事件上,在事件触发时自动调用这些函数。代理也叫做委托,比如:跳,跑,开枪,伤害等响应,就是注册一个委托回调,其作用就是提供一种消息机制,都知道消息的传递需要发送方和接收方,…...