梳理tensorflow serving的项目主要模块及其功能
梳理tensorflow serving的请求调用链路和生命周期
其他重要目录:
架构特点:
Predict:通用预测接口
Classify:分类任务接口
Regress:回归任务接口
GetModelStatus:获取模型状态
HandleReloadConfigRequest:处理模型重载请求
A. 模型相关(model.proto)
B. 输入输出(input.proto)
C. 预测相关:
predict.proto:
classification.proto:
regression.proto:
D. 模型元数据(get_model_metadata.proto)
E. 状态监控(get_model_status.proto)
F. 日志相关(logging.proto, prediction_log.proto)
典型调用流程示例:
Client -> PredictionService.Predict
Request:
- model_spec: {name: "model_name", version: 1}
- inputs: {key: tensor_data}
Response:
- outputs: {key: prediction_result}
Client -> ModelService.GetModelStatus
Request:
- model_spec: {name: "model_name", version: 1}
Response:
- model_version_status: [
{version: 1, state: AVAILABLE}
]
Client -> PredictionService.Classify
Request:
- model_spec: {name: "classifier"}
- input: {examples: [...]}
Response:
- result: {classifications: [...]}
客户端请求
│
▼
┌───────────────────────────────┐
│ [接入层] │
│ ├──► REST API请求 ──► HTTPServer(http_server.cc) │
│ │ │ │
│ │ ▼ │
│ │ HTTPRestAPIHandler │
│ │ │ │
│ │ ▼ │
│ └──► gRPC请求 ──► PredictionServiceImpl │
└───────────────────────────────┘
│
▼
┌───────────────────────────────┐
│ [核心处理层] │
│ ServerCore(server_core.cc) │
│ ├──► 1. 请求验证和预处理 │
│ │ │
│ ├──► 2. 模型管理器(AspiredVersionsManager) │
│ │ │ │
│ │ ├──► 模型版本控制 │
│ │ └──► 模型生命周期管理 │
│ │ │
│ ├──► 3. 模型加载器(Loader) │
│ │ │ │
│ │ └──► 加载指定版本模型 │
│ │ │
│ ├──► 4. 批处理系统(Batching) │
│ │ │ │
│ │ └──► 请求批处理优化 │
│ │ │
│ └──► 5. 模型推理执行 │
│ │ │
│ └──► TensorFlow计算图执行 │
└───────────────────────────────┘
│
▼
┌───────────────────────────────┐
│ [响应层] │
│ 处理推理结果 │
└───────────────────────────────┘
│
▼
返回客户端响应
本文由博客一文多发平台 OpenWrite 发布!
参与评论
手机查看
返回顶部