/**
 * Copyright 2019 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// ms_manager.proto
syntax = "proto3";

package mindspore.serving.proto;
import "mindspore_serving/proto/ms_service.proto";

message TensorInfo {
  TensorShape shape = 1; // tensor shape info
  DataType dtype = 2; // tensor content data type
  int64 size = 3;
}

message AgentSpec {
  int64 rank_id = 1;
  int64 batch_size = 2;
  repeated TensorInfo inputs = 3;
  repeated TensorInfo outputs = 4;
}

message CommonServableMeta {
  string servable_name = 1;
  bool with_batch_dim = 2;
  repeated int64 without_batch_dim_inputs = 3;
  int64 inputs_count = 4;
  int64 outputs_count = 5;
}

message DistributedServableMeta {
  int64 rank_size = 1;
  int64 stage_size = 2;
}

message AgentRegisterRequest {
  repeated AgentSpec agent_spec = 1;
  string address = 2;
}

message AgentRegisterReply {
  ErrorMsg error_msg = 1;
}

message AgentExitRequest {
  oneof address_choice {
    string address = 1; // by agent process
    string agent_ip = 2; // by agent start up process
  }
}

message AgentExitReply {
  ErrorMsg error_msg = 1;
}

message AgentFailedRequest {
}

message AgentFailedReply {
  ErrorMsg error_msg = 1;
}

message AgentConfigAcquireRequest {
}

message AgentConfigAcquireReply {
  message OneRankConfig {
    string ip = 1;
    int64 device_id = 2;
  }
  string rank_table_content = 1;
  repeated OneRankConfig rank_list = 2;
  CommonServableMeta common_meta = 3;
  DistributedServableMeta distributed_meta = 4;
}