xref: /aosp_15_r20/external/federated-compute/fcp/client/fl_runner.proto (revision 14675a029014e728ec732f129a32e299b2da0601)
1*14675a02SAndroid Build Coastguard Worker/*
2*14675a02SAndroid Build Coastguard Worker * Copyright 2020 Google LLC
3*14675a02SAndroid Build Coastguard Worker *
4*14675a02SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*14675a02SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*14675a02SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*14675a02SAndroid Build Coastguard Worker *
8*14675a02SAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*14675a02SAndroid Build Coastguard Worker *
10*14675a02SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*14675a02SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*14675a02SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*14675a02SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*14675a02SAndroid Build Coastguard Worker * limitations under the License.
15*14675a02SAndroid Build Coastguard Worker */
16*14675a02SAndroid Build Coastguard Workersyntax = "proto3";
17*14675a02SAndroid Build Coastguard Worker
18*14675a02SAndroid Build Coastguard Workerpackage fcp.client;
19*14675a02SAndroid Build Coastguard Worker
20*14675a02SAndroid Build Coastguard Workerimport "google/protobuf/duration.proto";
21*14675a02SAndroid Build Coastguard Workerimport "fcp/client/engine/engine.proto";
22*14675a02SAndroid Build Coastguard Workerimport "tensorflow/core/framework/tensor.proto";
23*14675a02SAndroid Build Coastguard Worker
24*14675a02SAndroid Build Coastguard Workeroption java_package = "com.google.intelligence.fcp.client";
25*14675a02SAndroid Build Coastguard Workeroption java_multiple_files = true;
26*14675a02SAndroid Build Coastguard Worker
27*14675a02SAndroid Build Coastguard Worker/**
28*14675a02SAndroid Build Coastguard Worker * This protocol buffer is used to report results and statistics of a Federated
29*14675a02SAndroid Build Coastguard Worker * Computation - including checking in with the server, running a plan, and
30*14675a02SAndroid Build Coastguard Worker * reporting back results - to the caller. It is a protocol buffer to support
31*14675a02SAndroid Build Coastguard Worker * sending it across language boundaries.
32*14675a02SAndroid Build Coastguard Worker */
33*14675a02SAndroid Build Coastguard Workermessage FLRunnerResult {
34*14675a02SAndroid Build Coastguard Worker  reserved 1;
35*14675a02SAndroid Build Coastguard Worker  // A RetryInfo returned to the caller for consideration in scheduling future
36*14675a02SAndroid Build Coastguard Worker  // runs of this task.
37*14675a02SAndroid Build Coastguard Worker  RetryInfo retry_info = 4;
38*14675a02SAndroid Build Coastguard Worker  // An enum that summarizes whether the client has contributed to an FL/FA
39*14675a02SAndroid Build Coastguard Worker  // round.
40*14675a02SAndroid Build Coastguard Worker  enum ContributionResult {
41*14675a02SAndroid Build Coastguard Worker    UNSPECIFIED = 0;
42*14675a02SAndroid Build Coastguard Worker    SUCCESS = 1;
43*14675a02SAndroid Build Coastguard Worker    // Any outcome that is not a success.
44*14675a02SAndroid Build Coastguard Worker    FAIL = 2;
45*14675a02SAndroid Build Coastguard Worker  }
46*14675a02SAndroid Build Coastguard Worker
47*14675a02SAndroid Build Coastguard Worker  ContributionResult contribution_result = 5;
48*14675a02SAndroid Build Coastguard Worker  reserved 2, 3;
49*14675a02SAndroid Build Coastguard Worker
50*14675a02SAndroid Build Coastguard Worker
51*14675a02SAndroid Build Coastguard Worker  // All fields below are added by OnDevicePersonalization module for logging and
52*14675a02SAndroid Build Coastguard Worker  // debugging purpose.
53*14675a02SAndroid Build Coastguard Worker  // Debug message will be present if ContributionResult is FAIL.
54*14675a02SAndroid Build Coastguard Worker  string error_message = 200;
55*14675a02SAndroid Build Coastguard Worker
56*14675a02SAndroid Build Coastguard Worker  enum ErrorStatus {
57*14675a02SAndroid Build Coastguard Worker    ERROR_STATUS_UNSPECIFIED = 0;
58*14675a02SAndroid Build Coastguard Worker    // A TensorFlow error occurred.
59*14675a02SAndroid Build Coastguard Worker    TENSORFLOW_ERROR = 1;
60*14675a02SAndroid Build Coastguard Worker    // The input parameters are invalid.
61*14675a02SAndroid Build Coastguard Worker    INVALID_ARGUMENT = 2;
62*14675a02SAndroid Build Coastguard Worker    // An example iterator error occurred.
63*14675a02SAndroid Build Coastguard Worker    EXAMPLE_ITERATOR_ERROR = 3;
64*14675a02SAndroid Build Coastguard Worker    // Not eligible to execute task.
65*14675a02SAndroid Build Coastguard Worker    NOT_ELIGIBLE = 4;
66*14675a02SAndroid Build Coastguard Worker  }
67*14675a02SAndroid Build Coastguard Worker
68*14675a02SAndroid Build Coastguard Worker  // Used to populate error happens in c++ to java code. Mainly for debug and
69*14675a02SAndroid Build Coastguard Worker  // logging purpose.
70*14675a02SAndroid Build Coastguard Worker  ErrorStatus error_status = 201;
71*14675a02SAndroid Build Coastguard Worker
72*14675a02SAndroid Build Coastguard Worker  message ExampleStats {
73*14675a02SAndroid Build Coastguard Worker    // For TensorlowSpec-based plans, this refers to the overall number of
74*14675a02SAndroid Build Coastguard Worker    // elements returned by all ExampleIterator::Next() calls. For
75*14675a02SAndroid Build Coastguard Worker    // ExampleQuerySpec-based plans, this refers to the total number of row counts
76*14675a02SAndroid Build Coastguard Worker    // calculated at example store layer and passed via ExampleQueryResults.
77*14675a02SAndroid Build Coastguard Worker    int32 example_count = 1;
78*14675a02SAndroid Build Coastguard Worker    int64 example_size_bytes = 2;
79*14675a02SAndroid Build Coastguard Worker  }
80*14675a02SAndroid Build Coastguard Worker
81*14675a02SAndroid Build Coastguard Worker  // Used to record the stats of examples used in computation. Mainly used for
82*14675a02SAndroid Build Coastguard Worker  // debug and logging purpose.
83*14675a02SAndroid Build Coastguard Worker  ExampleStats example_stats = 202;
84*14675a02SAndroid Build Coastguard Worker}
85*14675a02SAndroid Build Coastguard Worker
86*14675a02SAndroid Build Coastguard Worker// A suggestion to the client when to retry the connection to the service next
87*14675a02SAndroid Build Coastguard Worker// time
88*14675a02SAndroid Build Coastguard Workermessage RetryInfo {
89*14675a02SAndroid Build Coastguard Worker  // Optional. If set, should be provided back to the next
90*14675a02SAndroid Build Coastguard Worker  // RunFederatedComputation invocation.
91*14675a02SAndroid Build Coastguard Worker  string retry_token = 1;
92*14675a02SAndroid Build Coastguard Worker
93*14675a02SAndroid Build Coastguard Worker  // The suggested delay duration after which the client should
94*14675a02SAndroid Build Coastguard Worker  // retry. Clients should ideally not retry any earlier than this.
95*14675a02SAndroid Build Coastguard Worker  google.protobuf.Duration minimum_delay = 2;
96*14675a02SAndroid Build Coastguard Worker}
97*14675a02SAndroid Build Coastguard Worker
98*14675a02SAndroid Build Coastguard Worker/**
99*14675a02SAndroid Build Coastguard Worker * This protocol buffer is used to pass TensorflowSpec-based plan outputs across
100*14675a02SAndroid Build Coastguard Worker * the JNI boundary so they can be accessed in compatibility tests.
101*14675a02SAndroid Build Coastguard Worker */
102*14675a02SAndroid Build Coastguard Workermessage FLRunnerTensorflowSpecResult {
103*14675a02SAndroid Build Coastguard Worker  // The outcome of running the plan.
104*14675a02SAndroid Build Coastguard Worker  engine.PhaseOutcome outcome = 1;
105*14675a02SAndroid Build Coastguard Worker  // The location of the output checkpoint file, if one was created.
106*14675a02SAndroid Build Coastguard Worker  string checkpoint_output_filename = 2;
107*14675a02SAndroid Build Coastguard Worker  // A map of output tensor names and values, if any.
108*14675a02SAndroid Build Coastguard Worker  map<string, tensorflow.TensorProto> output_tensors = 3;
109*14675a02SAndroid Build Coastguard Worker}
110