@@ -26,7 +26,9 @@ class Model : public ModelGraph {
2626
2727    Model &operator =(const  Model &other) = default ;
2828
29-     Model compress () const ;
29+     Model compress (bool  merge_nodes = false ) const ;
30+ 
31+     using  ContextManager = ModelGraph::ContextManager;
3032
3133    int  unique_tag ();
3234
@@ -87,23 +89,29 @@ class Model : public ModelGraph {
8789    //  result in `output`.
8890    //  Currently, only reduction along the last dimension is supported.
8991    Tensor reduce_sum (Tensor input, int  axis, bool  keepdims = true ,
90-                       Tensor output = NullTensor, const  std::string &name = " "  );
92+                       Tensor output = NullTensor,
93+                       const  std::string &config = " "  ,
94+                       const  std::string &name = " "  );
9195    Tensor reduce_mean (Tensor input, int  axis, bool  keepdims = true ,
9296                       Tensor output = NullTensor,
97+                        const  std::string &config = " "  ,
9398                       const  std::string &name = " "  );
9499    Tensor reduce_max (Tensor input, int  axis, bool  keepdims = true ,
95-                       Tensor output = NullTensor, const  std::string &name = " "  );
100+                       Tensor output = NullTensor,
101+                       const  std::string &config = " "  ,
102+                       const  std::string &name = " "  );
96103
97104    //  Transposes the `input` tensor according to the given `permutation`.
98105    //  For example, transpose(input, {0, 1 ,3, 2}) will swap the last two
99106    //  dimensions of the input tensor. Currently, only 4D tensors are supported.
100107    Tensor transpose (Tensor input, const  std::vector<int64_t > &permutation,
101-                      Tensor output = NullTensor, const  std::string &name = " "  );
108+                      Tensor output = NullTensor, const  std::string &config = " "  ,
109+                      const  std::string &name = " "  );
102110    //  Performs matrix multiplication between the `input` tensor and another
103111    //  `other` tensor, storing the result in `output`.
104112    Tensor matmul (Tensor input, Tensor other, Tensor output = NullTensor,
105113                  bool  trans_input = false , bool  trans_other = false ,
106-                   const  std::string &name = " "  );
114+                   const  std::string &config =  " " ,  const  std::string & name = " "  );
107115    //  Implements the 'im2col' method for 2D convolution layers, which takes an
108116    //  `input` tensor and reshapes it to a 2D matrix by extracting image patches
109117    //  from the input tensor based on the provided parameters.
@@ -120,72 +128,76 @@ class Model : public ModelGraph {
120128                    Tensor output = NullTensor, const  std::string &name = " "  );
121129    //  Calculates the exponential of the `input` tensor, element-wise.
122130    Tensor exp (Tensor input, Tensor output = NullTensor,
123-                const  std::string &name = " "  );
131+                const  std::string &config =  " " ,  const  std::string & name = " "  );
124132    //  Calculates the square root of the `input` tensor, element-wise.
125133    Tensor sqrt (Tensor input, Tensor output = NullTensor,
126-                 const  std::string &name = " "  );
134+                 const  std::string &config =  " " ,  const  std::string & name = " "  );
127135    //  Calculates the reverse square root of the `input` tensor, element-wise.
128136    Tensor rsqrt (Tensor input, Tensor output = NullTensor,
129-                  const  std::string &name = " "  );
137+                  const  std::string &config =  " " ,  const  std::string & name = " "  );
130138    //  ReLU activation
131139    Tensor relu (Tensor input, Tensor output = NullTensor,
132-                 const  std::string &name = " "  );
140+                 const  std::string &config =  " " ,  const  std::string & name = " "  );
133141    //  Copy the `input` tensor to `output` tensor
134142    Tensor copy (Tensor input, Tensor output = NullTensor,
135-                 const  std::string &name = " "  );
143+                 const  std::string &config =  " " ,  const  std::string & name = " "  );
136144    Tensor copy (float  val, Tensor output = NullTensor,
137-                 const  std::string &name = " "  );
145+                 const  std::string &config =  " " ,  const  std::string & name = " "  );
138146    //  Applies the Gaussian Error Linear Unit (GELU) activation function to the
139147    //  `input` tensor, element-wise. GELU is a smooth approximation of the
140148    //  rectifier function and is widely used in deep learning models.
141149    Tensor gelu (Tensor input, Tensor output = NullTensor,
142-                 const  std::string &name = " "  );
150+                 const  std::string &config =  " " ,  const  std::string & name = " "  );
143151    //  Sigmoid activation
144152    Tensor sigmoid (Tensor input, Tensor output = NullTensor,
153+                    const  std::string &config = " "  ,
145154                   const  std::string &name = " "  );
146155    //  Performs rotary position embedding (RoPE) on the `input` tensor
147156    Tensor rope (Tensor input, Tensor other, Tensor output = NullTensor,
148-                 const  std::string &name = " "  );
157+                 const  std::string &config =  " " ,  const  std::string & name = " "  );
149158
150159    //  Performs an element-wise addition operator between the `input` tensor
151160    //  and the `other` tensor
152161    Tensor add (Tensor input, Tensor other, Tensor output = NullTensor,
153-                const  std::string &name = " "  );
162+                const  std::string &config =  " " ,  const  std::string & name = " "  );
154163    Tensor add (Tensor input, float  value, Tensor output = NullTensor,
155-                const  std::string &name = " "  );
164+                const  std::string &config =  " " ,  const  std::string & name = " "  );
156165    //  Performs an element-wise subtraction operator between the `input` tensor
157166    //  and the `other` tensor
158167    Tensor sub (Tensor input, Tensor other, Tensor output = NullTensor,
159-                const  std::string &name = " "  );
168+                const  std::string &config =  " " ,  const  std::string & name = " "  );
160169    Tensor sub (Tensor input, float  value, Tensor output = NullTensor,
161-                const  std::string &name = " "  );
170+                const  std::string &config =  " " ,  const  std::string & name = " "  );
162171    //  Performs an element-wise multiplication operator between the `input`
163172    //  tensor and the `other` tensor,
164173    Tensor mul (Tensor input, Tensor other, Tensor output = NullTensor,
165-                const  std::string &name = " "  );
174+                const  std::string &config =  " " ,  const  std::string & name = " "  );
166175    Tensor mul (Tensor input, float  value, Tensor output = NullTensor,
167-                const  std::string &name = " "  );
176+                const  std::string &config =  " " ,  const  std::string & name = " "  );
168177    //  Performs an element-wise division operator between the `input`
169178    //  tensor and the `other` tensor,
170179    Tensor div (Tensor input, Tensor other, Tensor output = NullTensor,
171-                const  std::string &name = " "  );
180+                const  std::string &config =  " " ,  const  std::string & name = " "  );
172181    Tensor div (Tensor input, float  value, Tensor output = NullTensor,
173-                const  std::string &name = " "  );
182+                const  std::string &config =  " " ,  const  std::string & name = " "  );
174183
175184    Tensor send (Tensor input, int  remote_rank, int  tag,
176-                 Tensor output = NullTensor, const  std::string &name = " "  );
185+                 Tensor output = NullTensor, const  std::string &config = " "  ,
186+                 const  std::string &name = " "  );
177187    //  Blocks the execution until the corresponding 'send' operator with the
178188    //  specified `id` is completed.
179-     Tensor send_done (Tensor input, const  std::string &name = " "  );
189+     Tensor send_done (Tensor input, const  std::string &config = " "  ,
190+                      const  std::string &name = " "  );
180191    //  Receives a tensor from a source rank (@p src_rank), identified by the
181192    //  `id` parameter. Blocks the execution until the corresponding 'recv'
182193    //  operator is completed.
183194    Tensor recv (Tensor output, int  remote_rank, int  tag,
184-                 const  std::string &name = " "  );
195+                 const  std::string &config =  " " ,  const  std::string & name = " "  );
185196    // 
186197    Tensor put_packet (Tensor input, Tensor local_tmp_buf, Tensor recv_buf,
187198                      int  id, int  rank, int  dst_rank, size_t  dst_offset,
188-                       int  flag, const  std::string &name = " "  );
199+                       int  flag, const  std::string &config = " "  ,
200+                       const  std::string &name = " "  );
189201    //  Performs an all-reduce operator across all ranks, aggregating the input
190202    //  tensors. Takes the `input` tensor, the current GPU's rank, and the
191203    //  total number of ranks `rank_num`.
@@ -200,10 +212,12 @@ class Model : public ModelGraph {
200212                                   const  std::string &name = " "  );
201213    // / Embedding layer.
202214    Tensor embedding (Tensor input, Tensor weight, Tensor output = NullTensor,
215+                      const  std::string &config = " "  ,
203216                     const  std::string &name = " "  );
204217    // / Tensor type casting.
205218    Tensor cast (Tensor input, const  DataType &data_type,
206-                 Tensor output = NullTensor, const  std::string &name = " "  );
219+                 Tensor output = NullTensor, const  std::string &config = " "  ,
220+                 const  std::string &name = " "  );
207221
208222    //  sync across multi devices
209223    Tensor device_sync (Tensor input, int  npeers, const  std::string &name = " "  );
0 commit comments