@@ -74,28 +74,28 @@ TFModel::TFModel(ModelMeta model_meta, int num_threads)
7474void TFModel::feed_tensor (Tensor* tensor, const InputData& input) {
7575 std::int64_t num_elements = tensor->NumElements ();
7676 switch (input.dtype ()) {
77- case DataType::DELTA_FLOAT32:{
78- std::cout << " input: " << num_elements << " " << tensor->TotalBytes () << std::endl;
77+ case DataType::DELTA_FLOAT32: {
78+ std::cout << " input: " << num_elements << " " << tensor->TotalBytes ()
79+ << std::endl;
7980 auto ptr = tensor->flat <float >().data ();
8081 std::fill_n (ptr, num_elements, 0.0 );
81- std::copy_n (static_cast <float *>(input.ptr ()), num_elements,
82- ptr);
82+ std::copy_n (static_cast <float *>(input.ptr ()), num_elements, ptr);
8383 break ;
8484 }
85- case DataType::DELTA_INT32:{
85+ case DataType::DELTA_INT32: {
8686 std::copy_n (static_cast <int *>(input.ptr ()), num_elements,
8787 tensor->flat <int >().data ());
8888 break ;
89- }
89+ }
9090 case DataType::DELTA_CHAR: {
9191 char * cstr = static_cast <char *>(input.ptr ());
9292 std::string str = std::string (cstr);
9393 tensor->scalar <tensorflow::tstring>()() = str;
9494 break ;
9595 }
96- default :{
96+ default : {
9797 LOG_FATAL << " Not support dtype:" << delta_dtype_str (input.dtype ());
98- }
98+ }
9999 }
100100}
101101
@@ -107,7 +107,7 @@ void TFModel::fetch_tensor(const Tensor& tensor, OutputData* output) {
107107 // copy data
108108 std::size_t num_elements = tensor.NumElements ();
109109 std::size_t total_bytes = tensor.TotalBytes ();
110- std::cout << " output: " << num_elements << " " << total_bytes << " \n " ;
110+ std::cout << " output: " << num_elements << " " << total_bytes << " \n " ;
111111 DELTA_CHECK (num_elements == output->nelms ())
112112 << " expect " << num_elements << " elems, but given " << output->nelms ();
113113
@@ -186,33 +186,32 @@ int TFModel::run(const std::vector<InputData>& inputs,
186186 set_feeds (&feeds, inputs);
187187 set_fetches (&fetches, *output);
188188
189- // std::cout << "input xxxxxxxxxxxxxxxxx"<< "\n";
190- // auto ti = feeds[0].second;
191- // for (auto i = 0; i < ti.NumElements(); i++){
189+ // std::cout << "input xxxxxxxxxxxxxxxxx"<< "\n";
190+ // auto ti = feeds[0].second;
191+ // for (auto i = 0; i < ti.NumElements(); i++){
192192 // std::cout << std::showpoint << ti.flat<float>()(i) << " ";
193193 // if (i % 40 == 1){std::cout << "\n";}
194194 // }
195- // std::cout << "\n";
196- // std::cout << "input -------------------"<< "\n";
197-
195+ // std::cout << "\n";
196+ // std::cout << "input -------------------"<< "\n";
198197
199198 // Session run
200199 RunOptions run_options;
201200 RunMetadata run_meta;
202- tensorflow::Status s = _bundle.GetSession ()->Run (run_options, feeds, fetches, {},
203- &output_tensors, &run_meta);
201+ tensorflow::Status s = _bundle.GetSession ()->Run (
202+ run_options, feeds, fetches, {}, &output_tensors, &run_meta);
204203 if (!s.ok ()) {
205204 LOG_FATAL << " Error, TF Model run failed: " << s;
206205 exit (-1 );
207206 }
208207
209- // std::cout << "output xxxxxxxxxxxxxxxxx"<< "\n";
210- // auto t = output_tensors[0];
211- // for (auto i = 0; i < t.NumElements(); i++){
208+ // std::cout << "output xxxxxxxxxxxxxxxxx"<< "\n";
209+ // auto t = output_tensors[0];
210+ // for (auto i = 0; i < t.NumElements(); i++){
212211 // std::cout << std::showpoint << t.flat<float>()(i) << " ";
213212 // }
214- // std::cout << "\n";
215- // std::cout << "output -------------------"<< "\n";
213+ // std::cout << "\n";
214+ // std::cout << "output -------------------"<< "\n";
216215
217216 get_featches (output_tensors, output);
218217
@@ -287,13 +286,14 @@ DeltaStatus TFModel::load_from_saved_model() {
287286 LOG_INFO << " load saved model from path: " << path;
288287 if (!MaybeSavedModelDirectory (path)) {
289288 LOG_FATAL << " SaveModel not in :" << path;
290- return DeltaStatus::STATUS_ERROR;
289+ return DeltaStatus::STATUS_ERROR;
291290 }
292291
293- tensorflow::Status s = LoadSavedModel (options, run_options, path,
294- {tensorflow::kSavedModelTagServe }, &_bundle);
292+ tensorflow::Status s = LoadSavedModel (
293+ options, run_options, path, {tensorflow::kSavedModelTagServe }, &_bundle);
295294 if (!s.ok ()) {
296- LOG_FATAL << " Failed Load model from saved_model.pb : " << s.error_message ();
295+ LOG_FATAL << " Failed Load model from saved_model.pb : "
296+ << s.error_message ();
297297 }
298298
299299 return DeltaStatus::STATUS_OK;
0 commit comments