• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_MINDSPORE_CCSRC_DEBUG_DATA_DUMP_TENSOR_STAT_DUMP_H_
18 #define MINDSPORE_MINDSPORE_CCSRC_DEBUG_DATA_DUMP_TENSOR_STAT_DUMP_H_
19 
20 #include <memory>
21 #include <string>
22 #include <fstream>
23 #include <mutex>
24 #include "utils/ms_utils.h"
25 #include "include/backend/visible.h"
26 #include "ir/dtype.h"
27 
28 namespace mindspore {
29 class Debugger;
30 class TensorData;
31 
32 class BACKEND_EXPORT TensorStatDump {
33  public:
34   static bool OpenStatisticsFile(const std::string &dump_path);
35 
36   TensorStatDump(const std::string &op_type, const std::string &op_name, uint32_t task_id, uint32_t stream_id,
37                  uint64_t timestamp, bool input, size_t slot, size_t tensor_loader_slot_);
38   TensorStatDump(const std::string &op_type, const std::string &op_name, const std::string &task_id,
39                  const std::string &stream_id, const std::string &timestamp, const std::string &io, size_t slot,
40                  size_t tensor_loader_slot, const mindspore::TypeId data_type);
41   bool DumpTensorStatsToFile(const std::string &dump_path, const std::shared_ptr<TensorData> data);
42   bool DumpTensorStatsToFile(const std::string &original_kernel_name, const std::string &dump_path,
43                              const Debugger *debugger);
44 
45  private:
46   const std::string op_type_;
47   const std::string op_name_;
48   const std::string task_id_;
49   const std::string stream_id_;
50   const std::string timestamp_;
51   std::string io_;
52   size_t slot_;
53   size_t tensor_loader_slot_;
54   mindspore::TypeId data_type_{mindspore::TypeId::kTypeUnknown};
55 };
56 }  // namespace mindspore
57 #endif  // MINDSPORE_MINDSPORE_CCSRC_DEBUG_DATA_DUMP_TENSOR_STAT_DUMP_H_
58