// Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
// --------- Warning: This is a build system generated file. ----------
//

//! @file
//!
//! @brief This file was generated by <i>omni.bind</i>.

#include <omni/core/Interface.h>
#include <omni/core/OmniAttr.h>
#include <omni/core/ResultError.h>

#include <functional>
#include <type_traits>
#include <utility>

#ifndef OMNI_BIND_INCLUDE_INTERFACE_IMPL


//! Base class for graph partitioning passes.
//!
//! Partition passes are typically run just after population passes and only on newly modified
//! @ref omni::graph::exec::unstable::INodeGraphDef objects. The job of a partition pass is to recognize patterns in the
//! newly populated graph and replace them with a new definition or augment existing one.
//!
//! Partition passes can only mutate the graph from the @ref omni::graph::exec::unstable::IPartitionPass::commit method
//! using provided @ref omni::graph::exec::unstable::IGraphBuilder. This will guarantee that the rest of the pipeline
//! is aware of changes made to the graph and avoid potential threading issues.
//!
//! See @ref  groupOmniGraphExecPasses for more pass related functionality.
template <>
class omni::core::Generated<omni::graph::exec::unstable::IPartitionPass_abi>
    : public omni::graph::exec::unstable::IPartitionPass_abi
{
public:
    OMNI_PLUGIN_INTERFACE("omni::graph::exec::unstable::IPartitionPass")

    //! Call from pass pipeline to initialize the pass for @p topology.
    //!
    //! This interface method implementation can't mutate given @p topology. Multiple passes can run concurrently on it.
    //!
    //! Returns True if initialization was successful and pipeline should issue calls to run and commit.
    //! Otherwise this pass will be destroyed and won't participate in partitioning @p topology.
    bool initialize(omni::core::ObjectParam<omni::graph::exec::unstable::ITopology> topology);

    //! Call from pass pipeline to discover nodes requiring partitioning.
    //!
    //! No topology changes are permitted at this point. Multiple passes will get a chance to receive this
    //! notification.
    //!
    //! Call to this method comes from graph traversal that may run multiple passes concurrently.
    void run(omni::core::ObjectParam<omni::graph::exec::unstable::INode> node);

    //! Call to verify generated partitions and commit new definition/s replacing discovered partitions.
    //!
    //! Commit of partitions is done serially and in the priority order of the pass. Passes with higher order will get
    //! the chance first. This is the only partition pass method that can mutate the graph.
    void commit(omni::core::ObjectParam<omni::graph::exec::unstable::IGraphBuilder> builder);
};

#endif

#ifndef OMNI_BIND_INCLUDE_INTERFACE_DECL

inline bool omni::core::Generated<omni::graph::exec::unstable::IPartitionPass_abi>::initialize(
    omni::core::ObjectParam<omni::graph::exec::unstable::ITopology> topology)
{
    OMNI_THROW_IF_ARG_NULL(topology);
    auto return_ = initialize_abi(topology.get());
    return return_;
}

inline void omni::core::Generated<omni::graph::exec::unstable::IPartitionPass_abi>::run(
    omni::core::ObjectParam<omni::graph::exec::unstable::INode> node)
{
    OMNI_THROW_IF_ARG_NULL(node);
    run_abi(node.get());
}

inline void omni::core::Generated<omni::graph::exec::unstable::IPartitionPass_abi>::commit(
    omni::core::ObjectParam<omni::graph::exec::unstable::IGraphBuilder> builder)
{
    OMNI_THROW_IF_ARG_NULL(builder);
    commit_abi(builder.get());
}

#endif

#undef OMNI_BIND_INCLUDE_INTERFACE_DECL
#undef OMNI_BIND_INCLUDE_INTERFACE_IMPL
