Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "aicpu_res_package_helper.h"
12 : #include "binary_stream.h"
13 : #include "log.h"
14 : namespace Hccl {
15 :
16 57 : BinaryStream& operator<<(BinaryStream& binaryStream, const ModuleData& m)
17 : {
18 57 : binaryStream << m.name;
19 57 : binaryStream << m.data;
20 :
21 171 : HCCL_INFO("BinaryStream: packed Data name %s", m.name);
22 :
23 57 : return binaryStream;
24 : }
25 :
26 12 : BinaryStream& operator>>(BinaryStream& binaryStream, ModuleData& m)
27 : {
28 12 : binaryStream >> m.name;
29 12 : binaryStream >> m.data;
30 :
31 36 : HCCL_INFO("BinaryStream: unpacked Data name %s", m.name);
32 :
33 12 : return binaryStream;
34 : }
35 :
36 7 : std::vector<char> AicpuResPackageHelper::GetPackedData(std::vector<ModuleData>& dataVec) const
37 : {
38 7 : std::vector<char> result;
39 7 : BinaryStream binaryStream;
40 7 : binaryStream << dataVec;
41 7 : binaryStream.Dump(result);
42 :
43 7 : return result;
44 7 : }
45 :
46 2 : std::vector<ModuleData> AicpuResPackageHelper::ParsePackedData(std::vector<char>& data) const
47 : {
48 2 : std::vector<ModuleData> result;
49 2 : BinaryStream binaryStream(data);
50 2 : binaryStream >> result;
51 :
52 2 : return result;
53 2 : }
54 :
55 : } // namespace Hccl
|