2021-01-11 18:16:03 +08:00
|
|
|
/****************************************************************************
|
|
|
|
|
*
|
2021-12-29 11:08:24 +08:00
|
|
|
* Copyright (c) 2021 Vivante Corporation
|
2021-01-11 18:16:03 +08:00
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
2021-12-29 11:08:24 +08:00
|
|
|
|
|
|
|
|
#ifndef TIM_VX_OP_IMPL_H_
|
|
|
|
|
#define TIM_VX_OP_IMPL_H_
|
2021-01-11 18:16:03 +08:00
|
|
|
#include "graph_private.h"
|
2021-12-29 11:08:24 +08:00
|
|
|
#include "tim/vx/graph.h"
|
|
|
|
|
#include "tim/vx/types.h"
|
2021-01-11 18:16:03 +08:00
|
|
|
|
|
|
|
|
namespace tim {
|
|
|
|
|
namespace vx {
|
|
|
|
|
|
2021-12-29 11:08:24 +08:00
|
|
|
class OpImpl {
|
|
|
|
|
public:
|
|
|
|
|
OpImpl(Graph* graph, uint32_t kind, int input_cnt, int output_cnt,
|
2022-01-04 14:35:17 +08:00
|
|
|
DataLayout layout);
|
2022-03-09 12:10:08 +08:00
|
|
|
OpImpl(Graph* graph, DataLayout layout);
|
|
|
|
|
|
2022-01-04 14:35:17 +08:00
|
|
|
virtual ~OpImpl() = default;
|
2021-12-29 11:08:24 +08:00
|
|
|
virtual OpImpl& BindInput(const std::shared_ptr<Tensor>& tensor) = 0;
|
|
|
|
|
virtual OpImpl& BindOutput(const std::shared_ptr<Tensor>& tensor) = 0;
|
|
|
|
|
virtual std::vector<std::shared_ptr<Tensor>> InputsTensor() = 0;
|
|
|
|
|
virtual std::vector<std::shared_ptr<Tensor>> OutputsTensor() = 0;
|
|
|
|
|
virtual vsi_nn_node_t* node() = 0;
|
2022-07-06 17:03:54 +08:00
|
|
|
virtual void SetRoundingPolicy(
|
|
|
|
|
OverflowPolicy overflow_policy = OverflowPolicy::SATURATE,
|
|
|
|
|
RoundingPolicy rounding_policy = RoundingPolicy::RTNE,
|
|
|
|
|
RoundType down_scale_size_rounding = RoundType::FLOOR,
|
|
|
|
|
uint32_t accumulator_bits = 0);
|
2021-05-08 09:29:47 +08:00
|
|
|
|
2022-01-04 14:35:17 +08:00
|
|
|
GraphImpl* graph_{nullptr};
|
2021-12-29 11:08:24 +08:00
|
|
|
uint32_t kind_{0};
|
2021-01-11 18:16:03 +08:00
|
|
|
int32_t input_cnt_{0};
|
|
|
|
|
int32_t output_cnt_{0};
|
2021-05-08 09:29:47 +08:00
|
|
|
DataLayout layout_{DataLayout::ANY};
|
2021-01-11 18:16:03 +08:00
|
|
|
int32_t input_tensor_index{0};
|
|
|
|
|
int32_t output_tensor_index{0};
|
2021-05-08 09:29:47 +08:00
|
|
|
std::vector<std::shared_ptr<Tensor>> inputs_tensor_;
|
|
|
|
|
std::vector<std::shared_ptr<Tensor>> outputs_tensor_;
|
2021-01-11 18:16:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace vx
|
|
|
|
|
} // namespace tim
|
|
|
|
|
|
2021-12-29 11:08:24 +08:00
|
|
|
#endif
|