ubuntu 22.04 LTS 在 llvm release/17.x 分支上编译 cookbook llvm example Chapter 02

不错的资料:

LLVM+Clang+编译器+链接器--保值【进阶之路二】 - 掘金

——————————————————————————————————————

下载 llvm-cookbook example:

$ git clone https://github.com/elongbug/llvm-cookbook.git

也可以参照llvm-projec中的官方代码,一样的差不多:

https://github.com/llvm/llvm-project/tree/main/llvm/examples/Kaleidoscope

开发环境:

 从apt source 安装llvm、clang和lldb:

$ apt install llvm
$ apt install llvm-dev
$ apt install clang
$ apt install lldb
$ cd llvm-cookbook/Chapter_2
$ make
$ ./toy example1

 运行效果:

事隔十个版本,llvm的接口如故,还是让人惊讶与当时接口定义的周到;

具体代码如下:

Makefile:

CC = clang++
SOURCE = ch2_toy.cpp
TARGET = toy$(TARGET) : $(SOURCE)$(CC) $(SOURCE) -o  $(TARGET) -g -O3 `llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native`clean :rm $(TARGET)

ch2_toy.cpp:

#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include <cctype>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
using namespace llvm;enum Token_Type { EOF_TOKEN = 0, DEF_TOKEN, IDENTIFIER_TOKEN, NUMERIC_TOKEN };FILE *file;
static std::string Identifier_string;
static int Numeric_Val;static int get_token() {static int LastChar = ' ';while (isspace(LastChar))LastChar = fgetc(file);if (isalpha(LastChar)) {Identifier_string = LastChar;while (isalnum((LastChar = fgetc(file))))Identifier_string += LastChar;if (Identifier_string == "def")return DEF_TOKEN;return IDENTIFIER_TOKEN;}if (isdigit(LastChar)) {std::string NumStr;do {NumStr += LastChar;LastChar = fgetc(file);} while (isdigit(LastChar));Numeric_Val = strtod(NumStr.c_str(), 0);return NUMERIC_TOKEN;}if (LastChar == '#') {doLastChar = fgetc(file);while (LastChar != EOF && LastChar != '\n' && LastChar != '\r');if (LastChar != EOF)return get_token();}if (LastChar == EOF)return EOF_TOKEN;int ThisChar = LastChar;LastChar = fgetc(file);return ThisChar;
}namespace {class BaseAST {
public:virtual ~BaseAST() {}virtual Value *Codegen() = 0;
};class NumericAST : public BaseAST {int numeric_val;public:NumericAST(int val) : numeric_val(val) {}virtual Value *Codegen();
};class VariableAST : public BaseAST {std::string Var_Name;public:VariableAST(const std::string &name) : Var_Name(name) {}virtual Value *Codegen();
};class BinaryAST : public BaseAST {std::string Bin_Operator;BaseAST *LHS, *RHS;public:BinaryAST(std::string op, BaseAST *lhs, BaseAST *rhs): Bin_Operator(op), LHS(lhs), RHS(rhs) {}virtual Value *Codegen();
};class FunctionCallAST : public BaseAST {std::string Function_Callee;std::vector<BaseAST *> Function_Arguments;public:FunctionCallAST(const std::string &callee, std::vector<BaseAST *> &args): Function_Callee(callee), Function_Arguments(args) {}virtual Value *Codegen();
};class FunctionDeclAST {std::string Func_Name;std::vector<std::string> Arguments;public:FunctionDeclAST(const std::string &name, const std::vector<std::string> &args): Func_Name(name), Arguments(args){};Function *Codegen();
};class FunctionDefnAST {FunctionDeclAST *Func_Decl;BaseAST *Body;public:FunctionDefnAST(FunctionDeclAST *proto, BaseAST *body): Func_Decl(proto), Body(body) {}Function *Codegen();
};
} // namespacestatic int Current_token;
static int next_token() { return Current_token = get_token(); }static std::map<char, int> Operator_Precedence;static int getBinOpPrecedence() {if (!isascii(Current_token))return -1;int TokPrec = Operator_Precedence[Current_token];if (TokPrec <= 0)return -1;return TokPrec;
}static BaseAST *expression_parser();static BaseAST *identifier_parser() {std::string IdName = Identifier_string;next_token();if (Current_token != '(')return new VariableAST(IdName);next_token();std::vector<BaseAST *> Args;if (Current_token != ')') {while (1) {BaseAST *Arg = expression_parser();if (!Arg)return 0;Args.push_back(Arg);if (Current_token == ')')break;if (Current_token != ',')return 0;next_token();}}next_token();return new FunctionCallAST(IdName, Args);
}static BaseAST *numeric_parser() {BaseAST *Result = new NumericAST(Numeric_Val);next_token();return Result;
}static BaseAST *paran_parser() {next_token();BaseAST *V = expression_parser();if (!V)return 0;if (Current_token != ')')return 0;return V;
}static BaseAST *Base_Parser() {switch (Current_token) {default:return 0;case IDENTIFIER_TOKEN:return identifier_parser();case NUMERIC_TOKEN:return numeric_parser();case '(':return paran_parser();}
}static BaseAST *binary_op_parser(int Old_Prec, BaseAST *LHS) {while (1) {int Operator_Prec = getBinOpPrecedence();if (Operator_Prec < Old_Prec)return LHS;int BinOp = Current_token;next_token();BaseAST *RHS = Base_Parser();if (!RHS)return 0;int Next_Prec = getBinOpPrecedence();if (Operator_Prec < Next_Prec) {RHS = binary_op_parser(Operator_Prec + 1, RHS);if (RHS == 0)return 0;}LHS = new BinaryAST(std::to_string(BinOp), LHS, RHS);}
}static BaseAST *expression_parser() {BaseAST *LHS = Base_Parser();if (!LHS)return 0;return binary_op_parser(0, LHS);
}static FunctionDeclAST *func_decl_parser() {if (Current_token != IDENTIFIER_TOKEN)return 0;std::string FnName = Identifier_string;next_token();if (Current_token != '(')return 0;std::vector<std::string> Function_Argument_Names;while (next_token() == IDENTIFIER_TOKEN)Function_Argument_Names.push_back(Identifier_string);if (Current_token != ')')return 0;next_token();return new FunctionDeclAST(FnName, Function_Argument_Names);
}static FunctionDefnAST *func_defn_parser() {next_token();FunctionDeclAST *Decl = func_decl_parser();if (Decl == 0)return 0;if (BaseAST *Body = expression_parser())return new FunctionDefnAST(Decl, Body);return 0;
}static FunctionDefnAST *top_level_parser() {if (BaseAST *E = expression_parser()) {FunctionDeclAST *Func_Decl =new FunctionDeclAST("", std::vector<std::string>());return new FunctionDefnAST(Func_Decl, E);}return 0;
}static void init_precedence() {Operator_Precedence['-'] = 1;Operator_Precedence['+'] = 2;Operator_Precedence['/'] = 3;Operator_Precedence['*'] = 4;
}static Module *Module_Ob;
static LLVMContext MyGlobalContext;
static IRBuilder<> Builder(MyGlobalContext);
static std::map<std::string, Value *> Named_Values;Value *NumericAST::Codegen() {return ConstantInt::get(Type::getInt32Ty(MyGlobalContext), numeric_val);
}Value *VariableAST::Codegen() {Value *V = Named_Values[Var_Name];return V ? V : 0;
}Value *BinaryAST::Codegen() {Value *L = LHS->Codegen();Value *R = RHS->Codegen();if (L == 0 || R == 0)return 0;switch (atoi(Bin_Operator.c_str())) {case '+':return Builder.CreateAdd(L, R, "addtmp");case '-':return Builder.CreateSub(L, R, "subtmp");case '*':return Builder.CreateMul(L, R, "multmp");case '/':return Builder.CreateUDiv(L, R, "divtmp");default:return 0;}
}Value *FunctionCallAST::Codegen() {Function *CalleeF = Module_Ob->getFunction(Function_Callee);std::vector<Value *> ArgsV;for (unsigned i = 0, e = Function_Arguments.size(); i != e; ++i) {ArgsV.push_back(Function_Arguments[i]->Codegen());if (ArgsV.back() == 0)return 0;}return Builder.CreateCall(CalleeF, ArgsV, "calltmp");
}Function *FunctionDeclAST::Codegen() {std::vector<Type *> Integers(Arguments.size(),Type::getInt32Ty(MyGlobalContext));FunctionType *FT =FunctionType::get(Type::getInt32Ty(MyGlobalContext), Integers, false);Function *F =Function::Create(FT, Function::ExternalLinkage, Func_Name, Module_Ob);if (F->getName() != Func_Name) {F->eraseFromParent();F = Module_Ob->getFunction(Func_Name);if (!F->empty())return 0;if (F->arg_size() != Arguments.size())return 0;}unsigned Idx = 0;for (Function::arg_iterator Arg_It = F->arg_begin(); Idx != Arguments.size();++Arg_It, ++Idx) {Arg_It->setName(Arguments[Idx]);Named_Values[Arguments[Idx]] = Arg_It;}return F;
}Function *FunctionDefnAST::Codegen() {Named_Values.clear();Function *TheFunction = Func_Decl->Codegen();if (TheFunction == 0)return 0;BasicBlock *BB = BasicBlock::Create(MyGlobalContext, "entry", TheFunction);Builder.SetInsertPoint(BB);if (Value *RetVal = Body->Codegen()) {Builder.CreateRet(RetVal);verifyFunction(*TheFunction);return TheFunction;}TheFunction->eraseFromParent();return 0;
}static void HandleDefn() {if (FunctionDefnAST *F = func_defn_parser()) {if (Function *LF = F->Codegen()) {}} else {next_token();}
}static void HandleTopExpression() {if (FunctionDefnAST *F = top_level_parser()) {if (Function *LF = F->Codegen()) {}} else {next_token();}
}static void Driver() {while (1) {switch (Current_token) {case EOF_TOKEN:return;case ';':next_token();break;case DEF_TOKEN:HandleDefn();break;default:HandleTopExpression();break;}}
}extern "C" double putchard(double X) {putchar((char)X);return 0;
}int main(int argc, char *argv[]) {LLVMContext &Context = MyGlobalContext;init_precedence();file = fopen(argv[1], "r");if (file == 0) {printf("Could not open file\n");}next_token();Module_Ob = new Module("my compiler", Context);Driver();Module_Ob->print(llvm::outs(), nullptr);return 0;
}

 ————————————————————————————————————————

一,从源码编译 llvm

下载源码:

$ git clone https://github.com/llvm/llvm-project.git

创建 对应 commit id分支:

$ cd llvm-project
$ git checkout  5b78868661f42a70fa30  -b  17.x.greater

源码成功编译 llvm-project commit id:

    ~/ex/llvm-project$ git log -1commit 5b78868661f42a70fa3006b1db41f78a6178d596 (HEAD -> main)

 生成构建:

cmake -G "Unix Makefiles" ../llvm    \
-DLLVM_ENABLE_PROJECTS=all           \
-DLLVM_BUILD_EXAMPLES=ON             \
-DLLVM_TARGETS_TO_BUILD="host"       \
-DCMAKE_BUILD_TYPE=Release           \
-DLLVM_ENABLE_ASSERTIONS=ON          \
-DLLVM_ENABLE_RUNTIMES=all           \
-DLLVM_BUILD_LLVM_DYLIB=ON           \  
-DCMAKE_INSTALL_PREFIX=../inst_clanglld_rtall_5b78868661

make -j8

(i9 9900k 8物理core 16logic core, 64GB mem, 64GB swap)

make install

二,编译Chapter2 example

可行的 Makefile:

CC = /home/kleenelan/ex/cookbook_llvm/inst_clanglld_rtall_5b78868661/bin/clang++
SOURCE = ch2_toy.cpp
TARGET = toy$(TARGET) : $(SOURCE)$(CC) $(SOURCE) -o  $(TARGET) -g  `/home/kleenelan/ex/cookbook_llvm/inst_clanglld_rtall_5b78868661/bin/llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native` -I/home/kleenelan/ex/cookbook_llvm/inst_clanglld_rtall_5b78868661/include/c++/v1   -I/home/kleenelan/ex/cookbook_llvm/inst_clanglld_rtall_5b78868661/include/x86_64-unknown-linux-gnu/c++/v1  -L/usr/lib/gcc/x86_64-linux-gnu/11/  -L/home/kleenelan/ex/cookbook_llvm/inst_clanglld_rtall_5b78868661/lib/x86_64-unknown-linux-gnu -lc++clean :rm $(TARGET)

ch2_toy.cpp

#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include <cctype>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
using namespace llvm;enum Token_Type { EOF_TOKEN = 0, DEF_TOKEN, IDENTIFIER_TOKEN, NUMERIC_TOKEN };FILE *file;
static std::string Identifier_string;
static int Numeric_Val;static int get_token() {static int LastChar = ' ';while (isspace(LastChar))LastChar = fgetc(file);if (isalpha(LastChar)) {Identifier_string = LastChar;while (isalnum((LastChar = fgetc(file))))Identifier_string += LastChar;if (Identifier_string == "def")return DEF_TOKEN;return IDENTIFIER_TOKEN;}if (isdigit(LastChar)) {std::string NumStr;do {NumStr += LastChar;LastChar = fgetc(file);} while (isdigit(LastChar));Numeric_Val = strtod(NumStr.c_str(), 0);return NUMERIC_TOKEN;}if (LastChar == '#') {doLastChar = fgetc(file);while (LastChar != EOF && LastChar != '\n' && LastChar != '\r');if (LastChar != EOF)return get_token();}if (LastChar == EOF)return EOF_TOKEN;int ThisChar = LastChar;LastChar = fgetc(file);return ThisChar;
}namespace {class BaseAST {
public:virtual ~BaseAST() {}virtual Value *Codegen() = 0;
};class NumericAST : public BaseAST {int numeric_val;public:NumericAST(int val) : numeric_val(val) {}virtual Value *Codegen();
};class VariableAST : public BaseAST {std::string Var_Name;public:VariableAST(const std::string &name) : Var_Name(name) {}virtual Value *Codegen();
};class BinaryAST : public BaseAST {std::string Bin_Operator;BaseAST *LHS, *RHS;public:BinaryAST(std::string op, BaseAST *lhs, BaseAST *rhs): Bin_Operator(op), LHS(lhs), RHS(rhs) {}virtual Value *Codegen();
};class FunctionCallAST : public BaseAST {std::string Function_Callee;std::vector<BaseAST *> Function_Arguments;public:FunctionCallAST(const std::string &callee, std::vector<BaseAST *> &args): Function_Callee(callee), Function_Arguments(args) {}virtual Value *Codegen();
};class FunctionDeclAST {std::string Func_Name;std::vector<std::string> Arguments;public:FunctionDeclAST(const std::string &name, const std::vector<std::string> &args): Func_Name(name), Arguments(args){};Function *Codegen();
};class FunctionDefnAST {FunctionDeclAST *Func_Decl;BaseAST *Body;public:FunctionDefnAST(FunctionDeclAST *proto, BaseAST *body): Func_Decl(proto), Body(body) {}Function *Codegen();
};
} // namespacestatic int Current_token;
static int next_token() { return Current_token = get_token(); }static std::map<char, int> Operator_Precedence;static int getBinOpPrecedence() {if (!isascii(Current_token))return -1;int TokPrec = Operator_Precedence[Current_token];if (TokPrec <= 0)return -1;return TokPrec;
}static BaseAST *expression_parser();static BaseAST *identifier_parser() {std::string IdName = Identifier_string;next_token();if (Current_token != '(')return new VariableAST(IdName);next_token();std::vector<BaseAST *> Args;if (Current_token != ')') {while (1) {BaseAST *Arg = expression_parser();if (!Arg)return 0;Args.push_back(Arg);if (Current_token == ')')break;if (Current_token != ',')return 0;next_token();}}next_token();return new FunctionCallAST(IdName, Args);
}static BaseAST *numeric_parser() {BaseAST *Result = new NumericAST(Numeric_Val);next_token();return Result;
}static BaseAST *paran_parser() {next_token();BaseAST *V = expression_parser();if (!V)return 0;if (Current_token != ')')return 0;return V;
}static BaseAST *Base_Parser() {switch (Current_token) {default:return 0;case IDENTIFIER_TOKEN:return identifier_parser();case NUMERIC_TOKEN:return numeric_parser();case '(':return paran_parser();}
}static BaseAST *binary_op_parser(int Old_Prec, BaseAST *LHS) {while (1) {int Operator_Prec = getBinOpPrecedence();if (Operator_Prec < Old_Prec)return LHS;int BinOp = Current_token;next_token();BaseAST *RHS = Base_Parser();if (!RHS)return 0;int Next_Prec = getBinOpPrecedence();if (Operator_Prec < Next_Prec) {RHS = binary_op_parser(Operator_Prec + 1, RHS);if (RHS == 0)return 0;}LHS = new BinaryAST(std::to_string(BinOp), LHS, RHS);}
}static BaseAST *expression_parser() {BaseAST *LHS = Base_Parser();if (!LHS)return 0;return binary_op_parser(0, LHS);
}static FunctionDeclAST *func_decl_parser() {if (Current_token != IDENTIFIER_TOKEN)return 0;std::string FnName = Identifier_string;next_token();if (Current_token != '(')return 0;std::vector<std::string> Function_Argument_Names;while (next_token() == IDENTIFIER_TOKEN)Function_Argument_Names.push_back(Identifier_string);if (Current_token != ')')return 0;next_token();return new FunctionDeclAST(FnName, Function_Argument_Names);
}static FunctionDefnAST *func_defn_parser() {next_token();FunctionDeclAST *Decl = func_decl_parser();if (Decl == 0)return 0;if (BaseAST *Body = expression_parser())return new FunctionDefnAST(Decl, Body);return 0;
}static FunctionDefnAST *top_level_parser() {if (BaseAST *E = expression_parser()) {FunctionDeclAST *Func_Decl =new FunctionDeclAST("", std::vector<std::string>());return new FunctionDefnAST(Func_Decl, E);}return 0;
}static void init_precedence() {Operator_Precedence['-'] = 1;Operator_Precedence['+'] = 2;Operator_Precedence['/'] = 3;Operator_Precedence['*'] = 4;
}static Module *Module_Ob;
static LLVMContext MyGlobalContext;
static IRBuilder<> Builder(MyGlobalContext);
static std::map<std::string, Value *> Named_Values;Value *NumericAST::Codegen() {return ConstantInt::get(Type::getInt32Ty(MyGlobalContext), numeric_val);
}Value *VariableAST::Codegen() {Value *V = Named_Values[Var_Name];return V ? V : 0;
}Value *BinaryAST::Codegen() {Value *L = LHS->Codegen();Value *R = RHS->Codegen();if (L == 0 || R == 0)return 0;switch (atoi(Bin_Operator.c_str())) {case '+':return Builder.CreateAdd(L, R, "addtmp");case '-':return Builder.CreateSub(L, R, "subtmp");case '*':return Builder.CreateMul(L, R, "multmp");case '/':return Builder.CreateUDiv(L, R, "divtmp");default:return 0;}
}Value *FunctionCallAST::Codegen() {Function *CalleeF = Module_Ob->getFunction(Function_Callee);std::vector<Value *> ArgsV;for (unsigned i = 0, e = Function_Arguments.size(); i != e; ++i) {ArgsV.push_back(Function_Arguments[i]->Codegen());if (ArgsV.back() == 0)return 0;}return Builder.CreateCall(CalleeF, ArgsV, "calltmp");
}Function *FunctionDeclAST::Codegen() {std::vector<Type *> Integers(Arguments.size(),Type::getInt32Ty(MyGlobalContext));FunctionType *FT =FunctionType::get(Type::getInt32Ty(MyGlobalContext), Integers, false);Function *F =Function::Create(FT, Function::ExternalLinkage, Func_Name, Module_Ob);if (F->getName() != Func_Name) {F->eraseFromParent();F = Module_Ob->getFunction(Func_Name);if (!F->empty())return 0;if (F->arg_size() != Arguments.size())return 0;}unsigned Idx = 0;for (Function::arg_iterator Arg_It = F->arg_begin(); Idx != Arguments.size();++Arg_It, ++Idx) {Arg_It->setName(Arguments[Idx]);Named_Values[Arguments[Idx]] = Arg_It;}return F;
}Function *FunctionDefnAST::Codegen() {Named_Values.clear();Function *TheFunction = Func_Decl->Codegen();if (TheFunction == 0)return 0;BasicBlock *BB = BasicBlock::Create(MyGlobalContext, "entry", TheFunction);Builder.SetInsertPoint(BB);if (Value *RetVal = Body->Codegen()) {Builder.CreateRet(RetVal);verifyFunction(*TheFunction);return TheFunction;}TheFunction->eraseFromParent();return 0;
}static void HandleDefn() {if (FunctionDefnAST *F = func_defn_parser()) {if (Function *LF = F->Codegen()) {}} else {next_token();}
}static void HandleTopExpression() {if (FunctionDefnAST *F = top_level_parser()) {if (Function *LF = F->Codegen()) {}} else {next_token();}
}static void Driver() {while (1) {switch (Current_token) {case EOF_TOKEN:return;case ';':next_token();break;case DEF_TOKEN:HandleDefn();break;default:HandleTopExpression();break;}}
}extern "C" double putchard(double X) {putchar((char)X);return 0;
}int main(int argc, char *argv[]) {LLVMContext &Context = MyGlobalContext;init_precedence();file = fopen(argv[1], "r");if (file == 0) {printf("Could not open file\n");}next_token();Module_Ob = new Module("my compiler", Context);Driver();Module_Ob->print(llvm::outs(), nullptr);return 0;
}

$ make

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

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

相关文章

Vue实现动态遍历生成el-input

实现效果: el-input的label是measureName, el-input绑定的值是formDatat.measureCode 接口返回的数据格式如下 处理过的formData的格式如下

SpringBoot+微信小程序奶茶在线点单小程序系统 附带详细运行指导视频

文章目录 一、项目演示二、项目介绍三、运行截图四、主要代码 一、项目演示 项目演示地址&#xff1a; 视频地址 二、项目介绍 项目描述&#xff1a;这是一个基于SpringBoot微信小程序框架开发的奶茶在线点单小程序系统。首先&#xff0c;这是一个前后端分离的项目&#xff…

机器学习深度学习——NLP实战(情感分析模型——textCNN实现)

&#x1f468;‍&#x1f393;作者简介&#xff1a;一位即将上大四&#xff0c;正专攻机器学习的保研er &#x1f30c;上期文章&#xff1a;机器学习&&深度学习——NLP实战&#xff08;情感分析模型——RNN实现&#xff09; &#x1f4da;订阅专栏&#xff1a;机器学习…

SpringBoot复习:(56)使用@Transactional注解标记的方法的执行流程

首先&#xff0c;如果在某个类或某个方法被标记为Transactional时&#xff0c;Spring boot底层会在创建这个bean时生成代理对象&#xff08;默认使用cglib) 示例&#xff1a; 当调用studentService的addStudent方法时&#xff0c;会直接跳到CglibAopProxy类去执行intercept方…

jenkins 安装nodejs 14

参考&#xff1a; jenkins容器安装nodejs-前端问答-PHP中文网

VR漫游:720度实景参观,打造魅力生态小区

随着城市的不断发展&#xff0c;小区的建设越发具有生态化、绿色化的特点&#xff0c;人们也会偏向选择更加适合居住的小区。为了让更多的用户体验小区的舒适性&#xff0c;不少地产开发商准备引入VR漫游技术。 VR漫游不仅能够真实地展示现场环境&#xff0c;还可以改变传统网络…

【大虾送书第六期】搞懂大模型的智能基因,RLHF系统设计关键问答

目录 ✨1、RLHF是什么&#xff1f; ✨2、RLHF适用于哪些任务&#xff1f; ✨3、RLHF和其他构建奖励模型的方法相比有何优劣&#xff1f; ✨4、什么样的人类反馈才是好的反馈 ✨5、RLHF算法有哪些类别&#xff0c;各有什么优缺点&#xff1f; ✨6、RLHF采用人类反馈会带来哪些局…

Android13新特性之通知权限提升

Android13新特性之通知权限提升 随着移动通信的高速发展&#xff0c;保障通信的安全性变得尤为重要。在Android 13的最新版本中&#xff0c;通知权限的管理得到了进一步加强。为了实现安全的通信和确保用户的隐私&#xff0c;必须正确申请通知权限。本文将详细探讨如何在Andro…

人类反馈强化学习RLHF;微软应用商店推出AI摘要功能

&#x1f989; AI新闻 &#x1f680; 微软应用商店推出AI摘要功能&#xff0c;快速总结用户对App的评价 摘要&#xff1a;微软应用商店正式推出了AI摘要功能&#xff0c;该功能能够将数千条在线评论总结成一段精练的文字&#xff0c;为用户选择和下载新应用和游戏提供参考。该…

excel常见的数学函数篇2

一、数学函数 1、ABS(number)&#xff1a;返回数字的绝对值 语法&#xff1a;ABS(数字)&#xff1b;返回数字的绝对值&#xff1b;若引用单元格&#xff0c;把数字换为单元格地址即可 2、INT(number)&#xff1a;向小取整 语法&#xff1a;INT(数字)&#xff1b;若引用单元格…

神经网络基础-神经网络补充概念-14-逻辑回归中损失函数的解释

概念 逻辑回归损失函数是用来衡量逻辑回归模型预测与实际观测之间差异的函数。它的目标是找到一组模型参数&#xff0c;使得预测结果尽可能接近实际观测。 理解 在逻辑回归中&#xff0c;常用的损失函数是对数似然损失&#xff08;Log-Likelihood Loss&#xff09;&#xff…

ES:一次分片设计问题导致的故障

### 现象&#xff1a; 1. 单节点CPU持续高 2.写入骤降 3.线程池队列积压&#xff0c;但没有reject 4.使用方没有记录日志 ### 排查 1.ES监控 只能看到相应的结果指标&#xff0c;无法反应出原因。 2.ES日志&#xff1a;大量日志打印相关异常&#xff08;routate等调用栈&a…

RabbitMq:Topic exchange(主题交换机)的理解和使用

RabbitMq:Topic exchange(主题交换机)的理解和使用 在RabbitMq中&#xff0c;生产者的消息都是通过交换机来接收&#xff0c;然后再从交换机分发到不同的队列中去&#xff0c;在分发的过程中交换机类型会影响分发的逻辑&#xff0c;下面主要讲解一下主题交换机。 ​ 主题交换…

渗透测试之逻辑漏洞

文章目录 一、支付漏洞1.修改附属值2.多重替换支付3.重复支付4.最小额支付5.最大值支付6.越权支付7.无限制试用8.多线程并发9.支付漏洞思路 二、密码找回漏洞1.本地验证绕过2.利用session重新绑定客户3.去掉验证参数绕过4.总结 三、短信验证码绕过1.短信验证码生命期限内可暴力…

【Java基础教程】(二十二)Java新特性篇 · 第二讲:foreach循环——概念及优缺点、使用方式及应用场景~

Java基础教程之新特性 foreach循环 1️⃣ 概念2️⃣ 优势和缺点3️⃣ 使用及应用场景&#x1f33e; 总结 1️⃣ 概念 Java的 foreach 特性最初出现在JDK 1.5中&#xff0c;也被称为“增强的for循环”。它的设计目的是提供一种简洁、易读的语法&#xff0c;用于遍历集合或数组…

一个WPF开发的、界面简洁漂亮的音频播放器

项目简介 这是一个基于C# WPF开发的&#xff0c;界面外观简洁大方&#xff0c;操作体验良好的音频播放器。 支持各种音频格式&#xff0c;包括&#xff1a;MP4、WMA、OGG、FLAC、M4A、AAC、WAV、APE 和 OPUS&#xff1b;支持标记、实时显示歌词等功能&#xff1b;支持换肤、…

深入解析:如何打造高效的直播视频美颜SDK

在当今数字化时代&#xff0c;视频直播已经成为人们交流、娱乐和信息传递的重要方式。然而&#xff0c;许多人在直播时都希望能够呈现出最佳的外观&#xff0c;这就需要高效的直播视频美颜技术。本文将深入解析如何打造高效的直播视频美颜SDK&#xff0c;以实现令人满意的视觉效…

【0815作业】搭建select的TCP客户端、poll客户端、tftp文件上传

IO多路复用&#xff08;重点&#xff01;&#xff01;&#xff01;&#xff09; 进程中如果同时需要处理多路输入输出流&#xff0c;在使用单进程单线程的情况下&#xff0c;同时处理多个输入输出请求。在无法用多进程多线程&#xff0c;可以选择用IO多路复用&#xff1b;由于不…

6个主流的工业3D管道设计软件

3D 管道设计软件是大多数行业工程工作的主要部分&#xff0c;例如&#xff1a; 电力、石油和天然气、石化、炼油厂、纸浆和造纸、化学品和加工业。 全球各工程公司使用了近 50 种工厂或管道设计软件。 每个软件都有优点和缺点&#xff0c;包括价格点。 EPC 和业主部门当前的趋势…

会声会影和Pr哪个好?

会声会影是加拿大Corel公司制作的一款功能强大的视频编辑软件&#xff0c;正版英文名&#xff1a;Corel VideoStudio&#xff0c;具有图像抓取和编修功能&#xff0c;可以抓取&#xff0c;转换MV、DV、V8、TV和实时记录抓取画面文件&#xff0c;并提供有超过100 多种的编制功能…