/* * Copyright (C) Cvitek Co., Ltd. 2019-2020. All rights reserved. */ #ifndef LEAKY_RELU_OP_H_ #define LEAKY_RELU_OP_H_ #include "tpuc/CustomOp.h" #include namespace cvi { class LeakyReluOp : public CustomOp { public: LeakyReluOp(OpParam ¶m) : CustomOp(param) {} void interpretFp32(std::vector>> &operand_tensors, std::vector> &operand_shapes, std::shared_ptr> &result_tensor, std::vector &result_shape); void interpretInt8(std::vector>> &operand_tensors, std::vector> &operand_shapes, std::shared_ptr> &result_tensor, std::vector &result_shape); void quantizeInt8(); void codeGenInt8(void *ctx, std::vector> &operand_shapes, std::vector &operand_gaddrs, std::vector &result_shape, uint64_t result_gaddr, int layer_id); private: void tdma_load(cvk_context_t *ctx, cvk_tl_t *tlp, uint64_t ga_src); void tdma_store(cvk_context_t *ctx, cvk_tl_t *tlp, uint64_t ga_dst); void leakyrelu_kernel(cvk_context_t *ctx, int layer_id, cvk_tl_t &bottom, cvk_tl_t &relu, cvk_tl_t &neg, int GT_right_shift_width, int LE_right_shift_width, int GT_scale, int LE_scale); void leakyrelu_codegen(cvk_context_t *ctx, uint32_t layer_id, uint64_t input_gaddr, uint64_t output_gaddr, int input_n, int input_c, int input_h, int input_w, int GT_right_shift_width, int LE_right_shift_width, int GT_scale, int LE_scale); }; } // namespace cvi #endif