File: substitution.proto

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (109 lines) | stat: -rw-r--r-- 2,817 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
syntax = "proto3";

option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.optimization_guide.proto";
option java_outer_classname = "ModelExecutionProto";

package optimization_guide.proto;

import "components/optimization_guide/proto/descriptors.proto";

enum ControlToken {
  CONTROL_TOKEN_UNKNOWN = 0;
  CONTROL_TOKEN_SYSTEM = 1;
  CONTROL_TOKEN_MODEL = 2;
  CONTROL_TOKEN_USER = 3;
  CONTROL_TOKEN_END = 4;
}

message SubstitutedString {
  reserved 2, 3;

  // String template with %s as the delimiter for substitutions.
  string string_template = 1;

  // The strings to be substituted in `string_template`.
  repeated StringSubstitution substitutions = 6;

  // The conditions for which to apply this substituted string.
  ConditionList conditions = 4;

  // Whether the input context should be ignored if this substituted string is
  // applied.
  bool should_ignore_input_context = 5;
}

message StringSubstitution {
  // The candidates to use for this string substitution.
  //
  // The first candidate that passes all conditions will be the one that is used
  // for the substitution.
  repeated StringArg candidates = 1;
}

message RangeExpr {
  // Reference to the a repeated field to range over.
  ProtoField proto_field = 1;

  // The expression to evaluate for each field entry.
  SubstitutedString expr = 2;
}

message IndexExpr {
  // If true, use 1-based indexes instead of 0-based.
  bool one_based = 1;
}

message MediaField {
  // Field containing the media.
  ProtoField proto_field = 1;
}

message StringArg {
  oneof arg {
    string raw_string = 1;
    ProtoField proto_field = 2;
    RangeExpr range_expr = 4;
    IndexExpr index_expr = 5;
    ControlToken control_token = 6;
    MediaField media_field = 7;
  }

  // TODO(b/302402959): Add support for max number of characters to apply.

  // The conditions for which to apply this substituted string.
  ConditionList conditions = 3;
}

// Operators available for comparing the value of fields.
enum OperatorType {
  OPERATOR_TYPE_UNSPECIFIED = 0;
  // Equal.
  OPERATOR_TYPE_EQUAL_TO = 1;
  // Not Equal.
  OPERATOR_TYPE_NOT_EQUAL_TO = 2;
}

enum ConditionEvaluationType {
  CONDITION_EVALUATION_TYPE_UNSPECIFIED = 0;
  CONDITION_EVALUATION_TYPE_AND = 1;
  CONDITION_EVALUATION_TYPE_OR = 2;
}

message ConditionList {
  // How to evaluate the below conditions.
  ConditionEvaluationType condition_evaluation_type = 1;

  // The set of conditions to evaluate.
  repeated Condition conditions = 2;
}

// Evaluated as "value at proto_field" "operator_type" "value".
message Condition {
  ProtoField proto_field = 1;
  OperatorType operator_type = 2;
  Value value = 3;
}