LCOV - code coverage report
Current view: top level - src/include/kompute/operations - OpBase.hpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 1 100.0 %
Date: 2024-01-20 13:42:20 Functions: 1 2 50.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: Apache-2.0
       2             : #pragma once
       3             : 
       4             : #include "kompute/Algorithm.hpp"
       5             : #include "kompute/Core.hpp"
       6             : #include "kompute/Tensor.hpp"
       7             : 
       8             : namespace kp {
       9             : 
      10             : /**
      11             :  *  Base Operation which provides the high level interface that Kompute
      12             :  *  operations implement in order to perform a set of actions in the GPU.
      13             :  *
      14             :  *  Operations can perform actions on tensors, and optionally can also own an
      15             :  *  Algorithm with respective parameters. kp::Operations with kp::Algorithms
      16             :  *  would inherit from kp::OpBaseAlgo.
      17             :  */
      18             : class OpBase
      19             : {
      20             :   public:
      21             :     /**
      22             :      * Default destructor for OpBase class. This OpBase destructor class should
      23             :      * always be called to destroy and free owned resources unless it is
      24             :      * intended to destroy the resources in the parent class.
      25             :      */
      26         390 :     virtual ~OpBase() { KP_LOG_DEBUG("Kompute OpBase destructor started"); }
      27             : 
      28             :     /**
      29             :      * The record function is intended to only send a record command or run
      30             :      * commands that are expected to record operations that are to be submitted
      31             :      * as a batch into the GPU.
      32             :      *
      33             :      * @param commandBuffer The command buffer to record the command into.
      34             :      */
      35             :     virtual void record(const vk::CommandBuffer& commandBuffer) = 0;
      36             : 
      37             :     /**
      38             :      * Pre eval is called before the Sequence has called eval and submitted the
      39             :      * commands to the GPU for processing, and can be used to perform any
      40             :      * per-eval setup steps required as the computation iteration begins. It's
      41             :      * worth noting that there are situations where eval can be called multiple
      42             :      * times, so the resources that are created should be idempotent in case
      43             :      * it's called multiple times in a row.
      44             :      *
      45             :      * @param commandBuffer The command buffer to record the command into.
      46             :      */
      47             :     virtual void preEval(const vk::CommandBuffer& commandBuffer) = 0;
      48             : 
      49             :     /**
      50             :      * Post eval is called after the Sequence has called eval and submitted the
      51             :      * commands to the GPU for processing, and can be used to perform any
      52             :      * tear-down steps required as the computation iteration finishes. It's
      53             :      * worth noting that there are situations where eval can be called multiple
      54             :      * times, so the resources that are destroyed should not require a re-init
      55             :      * unless explicitly provided by the user.
      56             :      *
      57             :      * @param commandBuffer The command buffer to record the command into.
      58             :      */
      59             :     virtual void postEval(const vk::CommandBuffer& commandBuffer) = 0;
      60             : };
      61             : 
      62             : } // End namespace kp

Generated by: LCOV version 1.14