Skip to content

Commit bc1ab11

Browse files
add the op_attrs in tracer and move profiling's function from model.cpp to profiling.hpp (#266)
* add op_attr in tracer and move profiling's function from model.cpp to profiling.hpp * add the op_attrs in tracer and move profiling's function from model.cpp to profiling.hpp * fix the multiprocess error in profiling * amend the code format * fix an error * fix an error * fix an error * refine attrs in json, fix bug in csv, pack csv and json into one dir * add include in profling to fix cpplint Co-authored-by: Eason9393 <[email protected]>
1 parent 5885bd0 commit bc1ab11

File tree

6 files changed

+517
-472
lines changed

6 files changed

+517
-472
lines changed

nlp_toolkit/backends/neural_engine/executor/include/dispatcher.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ class Dispatcher {
273273
kernel_handler_[execute_kernel_]->set_reshape_time(reshape_time_); }
274274
inline const vector<float>& get_reshape_time() {
275275
return kernel_handler_[execute_kernel_]->get_reshape_time(); }
276+
inline void set_attrs(const std::map<string, string>input_attrs) {
277+
kernel_handler_[execute_kernel_]->set_attrs(input_attrs);}
278+
inline const std::map<string, string>& get_attrs() { return kernel_handler_[execute_kernel_]->get_attrs();}
276279

277280
protected:
278281
// get input_hash

nlp_toolkit/backends/neural_engine/executor/include/model.hpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "operator_registry.hpp"
3434
#include "tensor.hpp"
3535
#include "thread_pool.hpp"
36-
#include "profiling_trace.hpp"
36+
#include "profiling.hpp"
3737

3838
namespace executor {
3939

@@ -101,14 +101,6 @@ class Model {
101101
return output_tensors_;
102102
}
103103

104-
void Profiling(char* space_name = "InstCount", char* count_name = "inst_count",
105-
char* mtx_name = "inst_mtx", int warm_up = 1);
106-
void ProfilingSparse(FILE* fp);
107-
void ProfilingOperator(FILE* fp, const shared_ptr<Dispatcher>& op);
108-
void ProfilingTensors(FILE* fp, const vector<Tensor*>& tensors);
109-
void ProfilingWeights(FILE* fp, const shared_ptr<Dispatcher>& op);
110-
void ProfilingSparseEstimate(FILE* fp, const shared_ptr<Dispatcher>& op,
111-
const float average_latency = 0.);
112104

113105

114106

nlp_toolkit/backends/neural_engine/executor/include/operator.hpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
#ifndef ENGINE_EXECUTOR_INCLUDE_OPERATOR_HPP_
1616
#define ENGINE_EXECUTOR_INCLUDE_OPERATOR_HPP_
1717

18-
#include <algorithm>
19-
#include <string>
20-
#include <vector>
18+
#include <algorithm> //NOLINT
19+
#include <string> //NOLINT
20+
#include <vector> //NOLINT
21+
#include <map> //NOLINT
2122
#include <mutex> //NOLINT
2223

2324
#include "common.hpp"
@@ -103,13 +104,15 @@ class Operator {
103104
inline const string& table_id() const { return table_id_; }
104105
inline void set_perf_ratio_id(const string& perf_ratio_id) { perf_ratio_id_ = perf_ratio_id; }
105106
inline const string& perf_ratio_id() const { return perf_ratio_id_; }
106-
inline void set_it_shape(const vector<int64_t> input_shape) { input_tensor_shape.emplace_back(input_shape); }
107-
inline void set_ot_shape(const vector<int64_t> output_shape) { output_tensor_shape.emplace_back(output_shape); }
108-
inline const vector<vector<int64_t>>& get_it_shape() const { return input_tensor_shape; }
109-
inline const vector<vector<int64_t>>& get_ot_shape() const { return output_tensor_shape; }
107+
inline void set_it_shape(const vector<int64_t> input_shape) { input_tensor_shape_.emplace_back(input_shape); }
108+
inline void set_ot_shape(const vector<int64_t> output_shape) { output_tensor_shape_.emplace_back(output_shape); }
109+
inline const vector<vector<int64_t>>& get_it_shape() const { return input_tensor_shape_; }
110+
inline const vector<vector<int64_t>>& get_ot_shape() const { return output_tensor_shape_; }
110111
// get executor kernel time add reshape time
111-
inline void set_reshape_time(const float reshape_time_) { reshape_time.emplace_back(reshape_time_); }
112-
inline const vector<float>& get_reshape_time() const { return reshape_time; }
112+
inline void set_reshape_time(const float reshape_time) { reshape_time_.emplace_back(reshape_time); }
113+
inline const vector<float>& get_reshape_time() const { return reshape_time_; }
114+
inline void set_attrs(const std::map<string, string>& input_attrs) {attrs_ = input_attrs;}
115+
inline const std::map<string, string>& get_attrs() const { return attrs_;}
113116

114117
protected:
115118
/** The conf that stores the operator configurations */
@@ -129,9 +132,10 @@ class Operator {
129132
vector<int64_t> weight_shape_;
130133
string table_id_;
131134
string perf_ratio_id_;
132-
vector<vector<int64_t>> input_tensor_shape;
133-
vector<vector<int64_t>> output_tensor_shape;
134-
vector<float> reshape_time;
135+
vector<vector<int64_t>> input_tensor_shape_;
136+
vector<vector<int64_t>> output_tensor_shape_;
137+
vector<float> reshape_time_;
138+
std::map<string, string> attrs_;
135139
}; // class Operator
136140

137141
} // namespace executor

0 commit comments

Comments
 (0)