// Copyright 2020 The TensorFlow Authors. All Rights Reserved.
//
// 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.

namespace tflite.acceleration;

enum Comparison : byte {
  EQUAL = 0,
  MINIMUM = 1,
}

// Mapping from available device features to compatibility decisions. Basic usage is to:
// 1) Map easily available device data (like Android version,
// Manufacturer, Device) to things like SoC vendor, SoC model.
// 2) Map complete device data to delegate-specific features and support status
// 3) Map delegate-specific features to delegate configuration.
//
// The structure describes a decision tree, with multiple matching branches.
// The branches are applied depth-first.
table DeviceDatabase {
  root:[DeviceDecisionTreeNode];
}

table DeviceDecisionTreeNode {
  // The variables are strings, as we have multiple clients that want to
  // introduce their own fields. Known variables are listed in variables.h.
  variable:string (shared);
  comparison:Comparison;
  items:[DeviceDecisionTreeEdge];
}

table DeviceDecisionTreeEdge {
  // Under which variable value does this item match.
  value:string (key, shared);
  // Which child branches should also be consulted and used to override this
  // node.
  children:[DeviceDecisionTreeNode];
  // What information can be derived about this device.
  derived_properties:[DerivedProperty];
}

// Derived variable value to combine with detected variables.
table DerivedProperty {
  variable:string (shared);
  value:string (shared);
}

root_type DeviceDatabase;
