]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - tidl/tidl-api.git/blob - tidl_api/src/device_arginfo.h
Quantization history configuration parameters
[tidl/tidl-api.git] / tidl_api / src / device_arginfo.h
1 /******************************************************************************
2  * Copyright (c) 2017-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 device_arginfo.h
31 #pragma once
33 #include "executor.h"
34 #include <memory>
36 namespace tidl
37 {
39 /*! @class DeviceArgInfo
40  *  @brief Describe input and output buffers required by ExecutionObjects
41  */
42 class DeviceArgInfo: public ArgInfo
43 {
44     public:
45         //! Enumerates the types of arguments represented by DeviceArgInfo
46         enum class Kind { BUFFER=0, LOCAL, SCALAR };
48         //! Construct an DeviceArgInfo object
49         DeviceArgInfo(const ArgInfo& ai, Kind kind) :
50             ArgInfo(ai), kind_m(kind)
51         {}
53         DeviceArgInfo(void *p, size_t size, Kind kind) :
54             ArgInfo(p, size), kind_m(kind)
55         {}
57         Kind   kind() const { return kind_m; }
58         bool   isLocal() const { return (ptr_m == nullptr) && (size_m > 0); }
60     private:
61         Kind         kind_m;
62 };
64 /*! @class PipeInfo
65  *  @brief Describe input and output required by piping output and input
66  *         between Execution Objects
67  */
68 class PipeInfo
69 {
70     public:
71         uint32_t dataQ_m[OCL_TIDL_MAX_IN_BUFS];
72         uint32_t bufAddr_m[OCL_TIDL_MAX_IN_BUFS];
73 };
75 /*! @class IODeviceArgInfo
76  *  @brief Describe input and output buffers by an Execution Object (EO)
77  *         Also used to chain execution objects - the output buffer of a
78  *         producer EO is the same as the input buffer of a consumer EO.
79  *         The PipeInfo must be shared across the producer and consumer EO,
80  *         hence the shared pointer.
81  */
82 class IODeviceArgInfo
83 {
84     public:
85         explicit IODeviceArgInfo(const ArgInfo& arg):
86                         arg_m(arg, DeviceArgInfo::Kind::BUFFER)
87         {
88             pipe_m = std::make_shared<PipeInfo>();
89         }
91         IODeviceArgInfo(): arg_m(nullptr, 0, DeviceArgInfo::Kind::BUFFER)
92         {
93             pipe_m = nullptr;
94         }
96         PipeInfo&            GetPipe()      { return *pipe_m; }
97         const DeviceArgInfo& GetArg() const { return arg_m; }
99         //IODeviceArgInfo(const IODeviceArgInfo&)            = delete;
100         //IODeviceArgInfo& operator=(const IODeviceArgInfo&) = delete;
102     private:
103         DeviceArgInfo             arg_m;
104         std::shared_ptr<PipeInfo> pipe_m;
105 };
109 } //namespace