]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - tidl/tidl-api.git/blob - tidl_api/inc/execution_object_internal.h
Build Python bindings library by default
[tidl/tidl-api.git] / tidl_api / inc / execution_object_internal.h
1 /******************************************************************************
2  * Copyright (c) 2018 Texas Instruments Incorporated - http://www.ti.com/
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *      * Redistributions of source code must retain the above copyright
8  *        notice, this list of conditions and the following disclaimer.
9  *      * Redistributions in binary form must reproduce the above copyright
10  *        notice, this list of conditions and the following disclaimer in the
11  *        documentation and/or other materials provided with the distribution.
12  *      * Neither the name of Texas Instruments Incorporated nor the
13  *        names of its contributors may be used to endorse or promote products
14  *        derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  *  THE POSSIBILITY OF SUCH DAMAGE.
27  *****************************************************************************/
29 /*! @file execution_object_internal.h */
31 #pragma once
33 namespace tidl {
35 class LayerOutput;
37 typedef std::vector<std::unique_ptr<const LayerOutput>> LayerOutputs;
39 /*! @cond HIDDEN_SYMBOLS
40     @class ExecutionObjectInternalInterface
41     @brief Internal interface for running the TIDL network on OpenCL devices
42            Do not use this internal class directly.
43            Please use ExecutionObject or ExecutionObejctPipeline instead.
44 */
45 class ExecutionObjectInternalInterface
46 {
47     public:
48         virtual ~ExecutionObjectInternalInterface() {};
50         //! Specify the input and output buffers used by the EO
51         //! @param in buffer used for input.
52         //! @param out buffer used for output.
53         virtual void SetInputOutputBuffer(const ArgInfo& in,
54                                           const ArgInfo& out) =0;
56         //! Returns a pointer to the input buffer set via SetInputOutputBuffer
57         virtual char* GetInputBufferPtr() const =0;
59         //! Returns size of the input buffer
60         virtual size_t GetInputBufferSizeInBytes() const =0;
62         //! Returns a pointer to the output buffer
63         virtual char* GetOutputBufferPtr() const =0;
65         //! Returns size of the output buffer
66         virtual size_t GetOutputBufferSizeInBytes() const =0;
68         //! @brief Set the frame index of the frame currently processed by the
69         //! ExecutionObject. Used for trace/debug messages
70         //! @param idx index of the frame
71         virtual void  SetFrameIndex(int idx) =0;
73         //! Returns the index of a frame being processed (set by SetFrameIndex)
74         virtual int   GetFrameIndex() const =0;
76         //! @brief Start processing a frame. The call is asynchronous and returns
77         //! immediately. Use ExecutionObject::ProcessFrameWait to wait
78         virtual bool ProcessFrameStartAsync() =0;
80         //! Wait for the execution object to complete processing a frame
81         //! @return false if ExecutionObject::ProcessFrameWait was called
82         //! without a corresponding call to
83         //! ExecutionObject::ProcessFrameStartAsync.
84         virtual bool ProcessFrameWait() =0;
86         //! Returns the device name that the ExecutionObject runs on
87         virtual const std::string& GetDeviceName() const =0;
89         //! Write the output buffer for each layer to a file
90         //! \<filename_prefix>_<ID>_HxW.bin
91         virtual void WriteLayerOutputsToFile(const std::string& filename_prefix=
92                                              "trace_dump_") const =0;
94         //! Returns a LayerOutput object corresponding to a layer.
95         //! Caller is responsible for deleting the LayerOutput object.
96         //! @see LayerOutput
97         //! @param layer_index The layer index of the layer
98         //! @param output_index The output index of the buffer for a given
99         //!                     layer. Defaults to 0.
100         virtual const LayerOutput* GetOutputFromLayer(uint32_t layer_index,
101                                              uint32_t output_index=0) const =0;
103         //! Get output buffers from all layers
104         virtual const LayerOutputs* GetOutputsFromAllLayers() const =0;
105 };
106 /*!  @endcond
107 */
109 } // namespace tidl