Dragonfly2
74 строки · 2.4 Кб
1/*
2* Copyright 2023 The Dragonfly Authors
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16
17package types
18
19import (
20"fmt"
21)
22
23const (
24// ModelFileName is model file name.
25ModelFileName = "model.graphdef"
26
27// ModelConfigFileName is model config file name.
28ModelConfigFileName = "config.pbtxt"
29
30// GNNModelNameSuffix is suffix of GNN model name.
31GNNModelNameSuffix = "gnn"
32
33// MLPModelNameSuffix is suffix of MLP model name.
34MLPModelNameSuffix = "mlp"
35
36// DefaultTritonPlatform is default triton backend configuration.
37DefaultTritonPlatform = "tensorrt_plan"
38)
39
40type ModelParams struct {
41ID uint `uri:"id" binding:"required"`
42}
43
44type UpdateModelRequest struct {
45BIO string `json:"BIO" binding:"omitempty"`
46State string `json:"state" binding:"omitempty,oneof=active inactive"`
47}
48
49type GetModelsQuery struct {
50Name string `json:"name" binding:"omitempty"`
51Type string `json:"type" binding:"omitempty"`
52Version string `json:"version" binding:"omitempty"`
53SchedulerID uint `json:"scheduler_id" binding:"omitempty"`
54Page int `form:"page" binding:"omitempty,gte=1"`
55PerPage int `form:"per_page" binding:"omitempty,gte=1,lte=10000000"`
56}
57
58type ModelEvaluation struct {
59Recall float64 `json:"recall" binding:"omitempty,gte=0,lte=1"`
60Precision float64 `json:"precision" binding:"omitempty,gte=0,lte=1"`
61F1Score float64 `json:"f1_score" binding:"omitempty,gte=0,lte=1"`
62MSE float64 `json:"mse" binding:"omitempty,gte=0"`
63MAE float64 `json:"mae" binding:"omitempty,gte=0"`
64}
65
66// MakeObjectKeyOfModelFile returns object key of model file.
67func MakeObjectKeyOfModelFile(id string, version int) string {
68return fmt.Sprintf("%s/%s/%s", id, fmt.Sprint(version), ModelFileName)
69}
70
71// MakeObjectKeyOfModelConfigFile returns object key of model config file.
72func MakeObjectKeyOfModelConfigFile(id string) string {
73return fmt.Sprintf("%s/%s", id, ModelConfigFileName)
74}
75