// Copyright 2021 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.

syntax = "proto2";

package xai;
option cc_enable_arenas = true;


// Event Protocol buffer, Top define
message Event {
  // Timestamp
  required double wall_time = 1;

  // The step of train.
  optional int64 step = 2;

  oneof what {
    // An event file was started, with the specified version.
    // Now version is "Mindspore.Event:1"
    string version = 3;

    // Must begins with 6
    Explain explain = 6;
  }
}


message Explain {
    message Inference{
        repeated float ground_truth_prob = 1;
        repeated int32 predicted_label = 2;
        repeated float predicted_prob = 3;
        repeated float ground_truth_prob_sd = 4;
        repeated float ground_truth_prob_itl95_low = 5;
        repeated float ground_truth_prob_itl95_hi = 6;
        repeated float predicted_prob_sd = 7;
        repeated float predicted_prob_itl95_low = 8;
        repeated float predicted_prob_itl95_hi = 9;
    }

    message Explanation{
        optional string explain_method = 1;
        optional int32 label = 2;
        optional string heatmap_path = 3;
    }

    message Benchmark{
        optional string benchmark_method = 1;
        optional string explain_method = 2;
        optional float total_score = 3;
        repeated float label_score = 4;
    }

    message Metadata{
        repeated string label = 1;
        repeated string explain_method = 2;
        repeated string benchmark_method = 3;
    }

    message HocLayer {
        optional float prob = 1;
        repeated int32 box = 2; // List of repeated x, y, w, h
    }

    message Hoc {
        optional int32 label = 1;
        optional string mask = 2;
        repeated HocLayer layer = 3;
    }

    optional int32 sample_id = 1;  // The Metadata and sample id must have one fill in
    optional string image_path = 2;
    repeated int32 ground_truth_label = 3;

    optional Inference inference = 4;
    repeated Explanation explanation = 5;
    repeated Benchmark benchmark = 6;

    optional Metadata metadata = 7;
    optional string status = 8;  // enum value: run, end

    repeated Hoc hoc = 9; // hierarchical occlusion counterfactual
}
