File size: 1,886 Bytes
134b4c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**************************************************************************************************
 *
 * Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
 *
 * This source file is the property of Axera Semiconductor Co., Ltd. and
 * may not be copied or distributed in any isomorphic form without the prior
 * written consent of Axera Semiconductor Co., Ltd.
 *
 **************************************************************************************************/

#pragma once

#include "middleware/runner.hpp"

#if defined(ENV_AXCL_RUNTIME_API_ENABLE) || defined(ENV_AXCL_NATIVE_API_ENABLE)

#include <functional>

namespace middleware {

class axcl_base : public runner {
public:
    using npu_func = std::function<bool()>;

    [[nodiscard]] static bool init(const std::string& config, const uint32_t& index, const npu_func& func);
    [[nodiscard]] static bool final(const npu_func& func);

    [[nodiscard]] bool flush_input() const override;
    [[nodiscard]] bool invalidate_output() const override;

    [[nodiscard]] bool feed(const std::string& input_folder, const std::string& stimulus_name) const override;
    [[nodiscard]] bool verify(const std::string& output_folder, const std::string& stimulus_name) const override;
    [[nodiscard]] bool save(const std::string& output_folder, const std::string& stimulus_name) const override;

private:
    [[nodiscard]] static bool feed(const std::string& folder, const std::string& stimulus_name, const std::string& tensor_name, void* address, uintmax_t size) ;
    [[nodiscard]] static bool verify(const std::string &folder, const std::string &stimulus_name, const std::string &tensor_name, void *address, uintmax_t size) ;
    [[nodiscard]] static bool save(const std::string& output_folder, const std::string& stimulus_name, const std::string& tensor_name, void* address, uintmax_t size);
};

}
#endif