huajsj commented on a change in pull request #10234:
URL: https://github.com/apache/tvm/pull/10234#discussion_r813343920
##########
File path: src/runtime/pipeline/pipeline_struct.h
##########
@@ -42,6 +53,99 @@ using GlobalOutputPair = std::pair<int, int>;
* The first 'int' is the module index, and the second 'int' is the module
output index.
*/
using ModuleOutputPair = std::pair<int, int>;
+/*!
+ *\brief The pair includes the runtime module index and the module input index.
+ * The first 'int' is the module index, and the second 'int' is the module
input index.
+ */
+using ModuleInputPair = std::pair<int, int>;
+/*!\brief The runtime module interface type.*/
+enum InterfaceType {
+ INPUT = 0,
+ OUTPUT,
+};
+/*!
+ *\brief The structure includes the module index and the module output index.
+ */
+struct ModuleInterfaceID {
+ ModuleInterfaceID() : runtime_idx(0), runtime_interface_idx(0),
interface_type(OUTPUT) { ; }
+ ModuleInterfaceID(int runtime_index, int runtime_interface_index,
InterfaceType type = OUTPUT) {
+ runtime_idx = runtime_index;
+ runtime_interface_idx = runtime_interface_index;
+ interface_type = type;
+ }
+ int runtime_idx;
+ union {
+ /*!\brief The output interface index.*/
+ int runtime_output_idx;
+ /*!\brief The input interface index.*/
+ int runtime_input_idx;
+ /*!\brief The interface index.*/
+ int runtime_interface_idx;
+ };
+ /*!\brief The interface type*/
+ InterfaceType interface_type;
+};
+/*!\brief The data notification structure.*/
+class DataNotify {
+ private:
+ /*!\brief The 'contitional variable' is used to wait for notification.*/
+ std::condition_variable notify_cv;
+ /*!\brief The mutex is used to protect the 'conditional variable'.*/
+ std::mutex mutex_;
+ /*!\brief Whether a data is ready or not.*/
+ bool data_ready_ = false;
+ /*!\brief Whether the thread should exit or not.*/
+ std::atomic<bool> exit_state_{false};
+ /*!
+ * \brief The 'ModuleInterfaceID' in which the data was ready and triggered
this
+ * notification.
+ */
+ ModuleInterfaceID notification_source_;
+
+ public:
+ /*!
+ * \brief Constructing the DataNotify class.
+ * \param parent_output_id The id of a runtime interface which is sending
out the data
+ * notification.
+ */
+ explicit DataNotify(ModuleInterfaceID parent_output_id) {
+ notification_source_ = parent_output_id;
+ }
+ /*!
+ * \brief Getting the notification source.
+ * \return The first 'int' is the runtime index, and the second 'int' is the
output index.
+ */
+ ModuleInterfaceID GetNotifySource(void) { return notification_source_; }
+ /*!
+ *\brief Waiting for the notification.
+ *\return Returning the value 'false' when the notification is in a 'exit'
state, else
+ * return true.
+ */
+ bool Wait(void) {
+ std::unique_lock<std::mutex> lock(mutex_);
+ notify_cv.wait(lock, [&] { return this->data_ready_; });
+ data_ready_ = false;
+ return !exit_state_;
Review comment:
fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]