// Copyright (C) 2023-2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
include "memoryManagement.fbs";

namespace MVCNN;

// Structure of Original Network.
// This construct is to be used when mapping information from
// granular VPU tasks, back to a user-representation of a network.
table SourceStructure{
  // All of the nodes in this Structure.
  // Note: The schema allows orphan nodes and all sorts of wacky
  // combinations. Prior validation suggested.
  nodes: [GraphNode];
  // IDs of the entry nodes in the network. (Multiple Inputs possible)
  first_ID: [uint];
}

// A Node in the Source Graph.
table GraphNode{
  // The unique id of this node.
  thisID: uint;
  // A name for a more user-readable representation.
  name: string;
  // IDs of other GraphNodes that produce this node
  sourceID: [uint];
  // IDs of other GraphNodes that consume this node.
  sinkID: [uint];
}

table Barrier{
  /// Overview:
  /// This object represents closely a Barrier in the device.
  /// Details of exact consumers and producers are delegated to those same
  /// producers and consumers.
  ///
  /// @field barrier_id - This is an optional field to force a barrier to use
  /// a specific barrier (note: a value given here only guarantees that any other
  /// barrier with that ID will run on the same unit, it does not guarantee a particular
  /// unit)
  barrier_id: short; // Use this to override default barrier management
  consumer_count: short;
  producer_count: short;
}

table BarrierReference{
  /// Overview:
  /// A BarrierReference is a tasks' accessor into it's barrier
  /// dependency and influence.
  ///
  /// @field wait_barriers - Ids of barriers that will free this
  /// task to run. Generally, You should always only need to wait on one barrier
  /// as they support multiple references.
  /// An empty list indicates that this task has no blocking barriers and can
  /// start immediately (for example at the start of a network)
  ///
  /// @field update_barriers - Ids of barriers that will be at least partially
  /// unlocked when this task is complete.
  /// An empty list indicates that no barriers are reliant on this task.
  ///

  wait_barriers: [uint];
  update_barriers: [uint];
  // A reference to the wait/update barriers virtual ID task
  virtual_wait_barriers: [uint];
  virtual_update_barriers: [uint];

}
