You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

MDToDApi.cc 18 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. /**
  2. * Copyright 2020 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. #include "MDToDApi.h" // NOLINT
  17. #include <string>
  18. #include <fstream>
  19. #include <iostream>
  20. #include <memory>
  21. #include <unordered_map>
  22. #include <utility>
  23. #include <vector>
  24. #include <set>
  25. #include "album_op_android.h" // NOLINT
  26. #include "minddata/dataset/include/dataset/execute.h"
  27. #include "minddata/dataset/include/dataset/type_id.h"
  28. #include "minddata/dataset/util/path.h"
  29. #include "minddata/dataset/include/dataset/vision.h"
  30. #include "minddata/dataset/include/dataset/data_helper.h"
  31. #include "minddata/dataset/core/de_tensor.h"
  32. #include "include/api/types.h"
  33. #if defined(__ANDROID__) || defined(ANDROID)
  34. #include <android/log.h>
  35. #include <android/asset_manager.h>
  36. #endif
  37. using mindspore::dataset::Path;
  38. using mindspore::dataset::Tensor;
  39. using TensorOperation = mindspore::dataset::TensorOperation;
  40. using RotateOperation = mindspore::dataset::vision::RotateOperation;
  41. using mindspore::LogStream;
  42. using mindspore::MsLogLevel::DEBUG;
  43. using mindspore::MsLogLevel::ERROR;
  44. using mindspore::MsLogLevel::INFO;
  45. using mindspore::Status;
  46. using mindspore::dataset::BorderType;
  47. using mindspore::dataset::InterpolationMode;
  48. namespace mindspore {
  49. class MDToDApi {
  50. public:
  51. std::shared_ptr<mindspore::dataset::AlbumOp> _iter;
  52. std::vector<std::shared_ptr<TensorOperation>> _augs;
  53. std::string _storage_folder;
  54. std::string _folder_path;
  55. bool _hasBatch;
  56. int64_t _file_id;
  57. public:
  58. MDToDApi() : _iter(nullptr), _augs({}), _storage_folder(""), _file_id(-1), _hasBatch(false) {
  59. MS_LOG(INFO) << "MDToDAPI Call constructor";
  60. }
  61. ~MDToDApi() {
  62. MS_LOG(INFO) << "MDToDAPI Call destractor";
  63. // dereference dataset and iterator
  64. _augs.clear();
  65. }
  66. };
  67. std::vector<std::string> MDToDBuffToVector(MDToDBuff_t StrBuff) {
  68. std::vector<std::string> strVector;
  69. if (StrBuff.DataSize > 0) {
  70. const char *p = static_cast<char *>(StrBuff.Buff);
  71. do {
  72. strVector.push_back(std::string(p));
  73. p += strVector.back().size() + 1;
  74. } while (p < static_cast<char *>(StrBuff.Buff) + StrBuff.DataSize);
  75. }
  76. return strVector;
  77. }
  78. extern "C"
  79. int MDToDApi_pathTest(const char* path) {
  80. Path f(path);
  81. MS_LOG(INFO) << f.Exists() << f.IsDirectory() << f.ParentPath();
  82. // Print out the first few items in the directory
  83. auto dir_it = Path::DirIterator::OpenDirectory(&f);
  84. MS_LOG(INFO) << dir_it.get();
  85. int i = 0;
  86. const int path_len_limit = 5;
  87. while (dir_it->hasNext()) {
  88. Path v = dir_it->next();
  89. MS_LOG(INFO) << v.toString() << "\n";
  90. i++;
  91. if (i > path_len_limit) break;
  92. }
  93. return 0;
  94. }
  95. extern "C" MDToDApi *MDToDApi_createPipeLine(MDToDConf_t MDConf) {
  96. MS_LOG(INFO) << "Start createPipeLine";
  97. std::string folder_path(MDConf.pFolderPath);
  98. std::string schema_file(MDConf.pSchemFile);
  99. std::vector<std::string> column_names = MDToDBuffToVector(MDConf.columnsToReadBuff);
  100. if (std::find(column_names.begin(), column_names.end(), "id") == column_names.end()) {
  101. MS_LOG(INFO) << "Column id not foud adding it ";
  102. column_names.push_back("id");
  103. }
  104. std::vector<std::shared_ptr<TensorOperation>> mapOperations;
  105. if (std::find(column_names.begin(), column_names.end(), "image") != column_names.end()) {
  106. MS_LOG(INFO) << "Found column image create map with:";
  107. MS_LOG(INFO) << "resize: { " << MDConf.ResizeSizeWH[0] << ", " << MDConf.ResizeSizeWH[1] << " }";
  108. MS_LOG(INFO) << "crop: { " << MDConf.CropSizeWH[0] << ", " << MDConf.CropSizeWH[1] << " }";
  109. MS_LOG(INFO) << "MEAN: { " << MDConf.MEAN[0] << ", " << MDConf.MEAN[1] << ", " << MDConf.MEAN[2] << " }";
  110. MS_LOG(INFO) << "STD: { " << MDConf.STD[0] << ", " << MDConf.STD[1] << ", " << MDConf.STD[2] << " }";
  111. if ((MDConf.ResizeSizeWH[0] != 0) && (MDConf.ResizeSizeWH[1] != 0)) {
  112. std::shared_ptr<TensorOperation> resize_op =
  113. mindspore::dataset::vision::Resize({MDConf.ResizeSizeWH[0], MDConf.ResizeSizeWH[1]});
  114. MS_LOG(INFO) << "Push back resize";
  115. mapOperations.push_back(resize_op);
  116. }
  117. if (MDConf.fixOrientation == 1) {
  118. std::shared_ptr<TensorOperation> rotate_op = mindspore::dataset::vision::Rotate();
  119. MS_LOG(INFO) << "Push back rotate";
  120. mapOperations.push_back(rotate_op);
  121. // hasBatch = true; Batch not currently supported inMInddata-Lite
  122. }
  123. if ((MDConf.CropSizeWH[0] != 0) && (MDConf.CropSizeWH[1] != 0)) {
  124. std::vector<int> Crop(MDConf.CropSizeWH, MDConf.CropSizeWH + 2);
  125. std::shared_ptr<TensorOperation> center_crop_op = mindspore::dataset::vision::CenterCrop(Crop);
  126. MS_LOG(INFO) << "Push back crop";
  127. mapOperations.push_back(center_crop_op);
  128. // hasBatch = true; Batch not currently supported inMInddata-Lite
  129. }
  130. }
  131. MS_LOG(INFO) << "Read id=" << MDConf.fileid << " (-1) for all";
  132. std::shared_ptr<mindspore::dataset::AlbumOp> iter = nullptr;
  133. const std::set<std::string> exts = {};
  134. if (MDConf.fileid > -1) {
  135. // read specific image using SequentialSampler witn
  136. iter =
  137. std::make_shared<mindspore::dataset::AlbumOp>(folder_path, true, schema_file, column_names, exts, MDConf.fileid);
  138. } else {
  139. iter = std::make_shared<mindspore::dataset::AlbumOp>(folder_path, true, schema_file, column_names, exts);
  140. }
  141. // Create objects for the tensor ops
  142. MS_LOG(INFO) << " Create pipline parameters";
  143. MS_LOG(INFO) << "floder path: " << folder_path << " , schema json: " << schema_file;
  144. MS_LOG(INFO) << "Reading columns:";
  145. for (auto str : column_names) {
  146. MS_LOG(INFO) << str << " ";
  147. }
  148. bool hasBatch = false;
  149. MDToDApi *pMDToDApi = new MDToDApi;
  150. pMDToDApi->_iter = iter;
  151. pMDToDApi->_augs = mapOperations;
  152. pMDToDApi->_storage_folder = std::string(MDConf.pStoragePath);
  153. pMDToDApi->_folder_path = folder_path;
  154. pMDToDApi->_hasBatch = hasBatch;
  155. return pMDToDApi;
  156. }
  157. template <typename T>
  158. void MDBuffToVector(const MDToDBuff_t &MDBuff, std::vector<T> *vec) {
  159. vec->clear();
  160. if (MDBuff.DataSize > 0) {
  161. int nofElements = MDBuff.DataSize / sizeof(T);
  162. vec->assign(reinterpret_cast<T *>(MDBuff.Buff), reinterpret_cast<T *>(MDBuff.Buff) + nofElements);
  163. }
  164. }
  165. template <typename T>
  166. void GetValue(std::unordered_map<std::string, std::shared_ptr<Tensor>> row, std::string columnName, T *o) {
  167. auto column = row[columnName];
  168. if (column != NULL) {
  169. MS_LOG(INFO) << "Tensor " << columnName << " shape: " << column->shape() << " type: " << column->type()
  170. << " bytes: " << column->SizeInBytes();
  171. column->GetItemAt<T>(o, {});
  172. MS_LOG(INFO) << columnName << ": " << +*o;
  173. } else {
  174. MS_LOG(INFO) << "Tensor " << columnName << " Not found"
  175. << ".";
  176. *o = 0;
  177. }
  178. }
  179. void GetTensorToBuff(std::unordered_map<std::string, std::shared_ptr<Tensor>> row, std::string columnName,
  180. bool hasBatch, MDToDBuff_t *resBuff) {
  181. auto column = row[columnName];
  182. resBuff->TensorSize[0] = resBuff->TensorSize[1] = resBuff->TensorSize[2] = resBuff->TensorSize[3] =
  183. 0; // Mark all dims do not exist in tensor
  184. int firstDim = (hasBatch) ? 1 : 0;
  185. if (column != NULL) {
  186. MS_LOG(INFO) << "Tensor " << columnName << " shape: " << column->shape() << " type: " << column->type()
  187. << " bytes: " << column->SizeInBytes() << "nof elements: " << column->shape()[firstDim];
  188. auto tesoreShape = column->shape().AsVector();
  189. for (int ix = 0; ix < tesoreShape.size(); ix++) {
  190. MS_LOG(INFO) << "Tensor " << columnName << " shape[" << ix << "] = " << tesoreShape[ix];
  191. resBuff->TensorSize[ix] = tesoreShape[ix];
  192. }
  193. if (!hasBatch) {
  194. for (int ix = 3; ix > 0; ix--) {
  195. resBuff->TensorSize[ix] = resBuff->TensorSize[ix - 1];
  196. }
  197. resBuff->TensorSize[0] = 1;
  198. }
  199. if (column->shape()[firstDim] > 0) {
  200. if (mindspore::dataset::DataType::DE_STRING == column->type()) {
  201. std::string str;
  202. for (int ix = 0; ix < column->shape()[firstDim]; ix++) {
  203. std::string_view strView;
  204. if (hasBatch) {
  205. column->GetItemAt(&strView, {0, ix});
  206. } else {
  207. column->GetItemAt(&strView, {ix});
  208. }
  209. MS_LOG(INFO) << "string " << columnName << "[" << ix << "]:" << strView << " (size: " << strView.size()
  210. << ")";
  211. str.append(strView);
  212. str.push_back('\0');
  213. }
  214. resBuff->DataSize = str.size();
  215. errno_t ret = memcpy_s(resBuff->Buff, resBuff->MaxBuffSize, str.data(), resBuff->DataSize);
  216. if (ret != 0) {
  217. resBuff->DataSize = 0; // memcpy fail amount of data copied is 0
  218. MS_LOG(ERROR) << "memcpy_s return: " << ret;
  219. }
  220. } else {
  221. mindspore::dataset::DataHelper dh;
  222. resBuff->DataSize =
  223. dh.DumpData(column->GetBuffer(), column->SizeInBytes(), resBuff->Buff, resBuff->MaxBuffSize);
  224. }
  225. MS_LOG(INFO) << columnName << " " << resBuff->DataSize
  226. << " bytesCopyed to buff (MaxBuffSize: " << resBuff->MaxBuffSize << ") ";
  227. if (resBuff->DataSize == 0) {
  228. MS_LOG(ERROR) << "COPY FAIL!!!! " << columnName << " Too large"
  229. << "."; // memcpy failed
  230. }
  231. } else {
  232. MS_LOG(INFO) << "Tensor " << columnName << " is empty (has size 0)";
  233. }
  234. } else {
  235. MS_LOG(INFO) << "Tensor " << columnName << " was not read.";
  236. }
  237. }
  238. extern "C" int MDToDApi_GetNext(MDToDApi *pMDToDApi, MDToDResult_t *results) {
  239. MS_LOG(INFO) << "Start GetNext";
  240. if (pMDToDApi == nullptr || pMDToDApi->_iter == nullptr) {
  241. MS_LOG(ERROR) << "GetNext called with null ptr. abort";
  242. return -1;
  243. }
  244. // Set default
  245. results->fileid = -1;
  246. results->embeddingBuff.DataSize = 0;
  247. results->imageBuff.DataSize = 0;
  248. MS_LOG(INFO) << "Start GetNext [1]" << pMDToDApi;
  249. // get next row for dataset
  250. std::unordered_map<std::string, std::shared_ptr<Tensor>> row;
  251. // create Execute functions, this replaces Map in Pipeline
  252. bool ret = pMDToDApi->_iter->GetNextRow(&row);
  253. uint32_t orientation = 0;
  254. if (row.size() != 0 && ret) {
  255. GetValue<uint32_t>(row, "orientation", &orientation);
  256. MS_LOG(INFO) << "get orientation from row = " << orientation;
  257. if ((pMDToDApi->_augs).size() > 0) {
  258. // String and Tensors
  259. // for each operation, run eager mode, single threaded operation, will have to memcpy
  260. // regardless
  261. for (int i = 0; i < (pMDToDApi->_augs).size(); i++) {
  262. // each Execute call will invoke a memcpy, this cannot really be optimized further
  263. // for this use case, std move is added for fail save.
  264. if (pMDToDApi->_augs[i]->Name() == "Rotate") {
  265. if (orientation > 1) {
  266. RotateOperation *p = static_cast<RotateOperation *>(pMDToDApi->_augs[i].get());
  267. p->setAngle(orientation);
  268. orientation = 0; // clear oriation filed if already performed
  269. } else {
  270. continue;
  271. }
  272. }
  273. mindspore::MSTensor image(std::make_shared<mindspore::dataset::DETensor>(row["image"]));
  274. (void)mindspore::dataset::Execute((pMDToDApi->_augs)[i])(image, &image);
  275. mindspore::dataset::Tensor::CreateFromMemory(
  276. mindspore::dataset::TensorShape(image.Shape()),
  277. mindspore::dataset::MSTypeToDEType(static_cast<mindspore::TypeId>(image.DataType())),
  278. (const uint8_t *)(image.Data().get()), &(row["image"]));
  279. if (row["image"] == nullptr) {
  280. // nullptr means that the eager mode image processing failed, we fail in this case
  281. return -1;
  282. }
  283. }
  284. }
  285. // FILE ID
  286. GetValue<int64_t>(row, "id", &results->fileid);
  287. pMDToDApi->_file_id = results->fileid; // hold current file id to enable embeddings update (no itr->getCurrent)
  288. // IS FOR TRAIN
  289. GetValue<int32_t>(row, "_isForTrain", &results->isForTrain);
  290. GetValue<int32_t>(row, "_noOfFaces", &results->noOfFaces);
  291. results->orientation = (int32_t)orientation;
  292. // String and Tensors
  293. GetTensorToBuff(row, "image_filename", pMDToDApi->_hasBatch, &results->fileNameBuff);
  294. GetTensorToBuff(row, "image", pMDToDApi->_hasBatch, &results->imageBuff);
  295. GetTensorToBuff(row, "_embedding", pMDToDApi->_hasBatch, &results->embeddingBuff);
  296. GetTensorToBuff(row, "label", pMDToDApi->_hasBatch, &results->labelBuff);
  297. GetTensorToBuff(row, "_boundingBoxes", pMDToDApi->_hasBatch, &results->boundingBoxesBuff);
  298. GetTensorToBuff(row, "_confidences", pMDToDApi->_hasBatch, &results->confidencesBuff);
  299. GetTensorToBuff(row, "_landmarks", pMDToDApi->_hasBatch, &results->landmarksBuff);
  300. GetTensorToBuff(row, "_faceFileNames", pMDToDApi->_hasBatch, &results->faceFileNamesBuff);
  301. GetTensorToBuff(row, "_imageQualities", pMDToDApi->_hasBatch, &results->imageQualitiesBuff);
  302. GetTensorToBuff(row, "_faceEmbeddings", pMDToDApi->_hasBatch, &results->faceEmbeddingsBuff);
  303. return 0;
  304. }
  305. return -1;
  306. }
  307. extern "C" int MDToDApi_Stop(MDToDApi *pMDToDApi) {
  308. // Manually terminate the pipeline
  309. MS_LOG(INFO) << "pipline stopped";
  310. return 0;
  311. }
  312. extern "C" int MDToDApi_Destroy(MDToDApi *pMDToDApi) {
  313. MS_LOG(INFO) << "pipline deleted start";
  314. delete pMDToDApi;
  315. MS_LOG(INFO) << "pipline deleted end";
  316. return 0;
  317. }
  318. int GetJsonFullFileName(const MDToDApi *pMDToDApi, std::string *filePath) {
  319. int64_t file_id = pMDToDApi->_file_id;
  320. if (file_id < 0) {
  321. MS_LOG(ERROR) << "Illegal file ID to update: " << file_id << ".";
  322. return -1;
  323. }
  324. std::string converted = std::to_string(pMDToDApi->_file_id);
  325. *filePath = pMDToDApi->_folder_path + "/" + converted + ".json";
  326. return 0;
  327. }
  328. extern "C" int MDToDApi_UpdateEmbeding(MDToDApi *pMDToDApi, const char *column, float *emmbeddings,
  329. size_t emmbeddingsSize) {
  330. auto columnName = std::string(column);
  331. MS_LOG(INFO) << "Start Update " << columnName;
  332. std::string converted = std::to_string(pMDToDApi->_file_id);
  333. std::string embedding_file_path = pMDToDApi->_storage_folder + "/" + converted + columnName + ".bin";
  334. mindspore::dataset::DataHelper dh;
  335. MS_LOG(INFO) << "Try to Save file " << embedding_file_path;
  336. std::vector<float> bin_content(emmbeddings, emmbeddings + emmbeddingsSize);
  337. Status rc = dh.template WriteBinFile<float>(embedding_file_path, bin_content);
  338. if (rc.IsError()) {
  339. MS_LOG(ERROR) << "Fail to write embedding file: " << embedding_file_path << ".";
  340. return -1;
  341. }
  342. MS_LOG(INFO) << "Saved file " << embedding_file_path;
  343. std::string file_path;
  344. if (GetJsonFullFileName(pMDToDApi, &file_path) != 0) {
  345. MS_LOG(ERROR) << "Failed to update " << columnName;
  346. return -1;
  347. }
  348. MS_LOG(INFO) << "Updating json file: " << file_path;
  349. rc = dh.UpdateValue(file_path, std::string(column), embedding_file_path);
  350. if (rc.IsError()) {
  351. MS_LOG(ERROR) << "Fail to update json: " << file_path << ".";
  352. return -1;
  353. }
  354. return 0;
  355. }
  356. extern "C" int MDToDApi_UpdateStringArray(MDToDApi *pMDToDApi, const char *column, MDToDBuff_t MDbuff) {
  357. auto columnName = std::string(column);
  358. std::string file_path;
  359. if (GetJsonFullFileName(pMDToDApi, &file_path) != 0) {
  360. MS_LOG(ERROR) << "Failed to update " << columnName;
  361. return -1;
  362. }
  363. MS_LOG(INFO) << "Start Update string Array column: " << columnName << " in file " << file_path;
  364. mindspore::dataset::DataHelper dh;
  365. std::vector<std::string> strVec;
  366. if (MDbuff.DataSize > 0) {
  367. const char *p = reinterpret_cast<char *>(MDbuff.Buff);
  368. do {
  369. strVec.push_back(std::string(p));
  370. p += strVec.back().size() + 1;
  371. } while (p < reinterpret_cast<char *>(MDbuff.Buff) + MDbuff.DataSize);
  372. }
  373. Status rc = dh.UpdateArray(file_path, columnName, strVec);
  374. if (rc.IsError()) {
  375. MS_LOG(ERROR) << "Fail to update json: " << file_path << ".";
  376. return -1;
  377. }
  378. return 0;
  379. }
  380. extern "C" int MDToDApi_UpdateFloatArray(MDToDApi *pMDToDApi, const char *column, MDToDBuff_t MDBuff) {
  381. auto columnName = std::string(column);
  382. std::string file_path;
  383. if (GetJsonFullFileName(pMDToDApi, &file_path) != 0) {
  384. MS_LOG(ERROR) << "Failed to updaet " << columnName;
  385. return -1;
  386. }
  387. MS_LOG(INFO) << "Start Update float Array column: " << columnName << " in file " << file_path;
  388. mindspore::dataset::DataHelper dh;
  389. std::vector<float> vec;
  390. MDBuffToVector<float>(MDBuff, &vec);
  391. Status rc = dh.UpdateArray<float>(file_path, columnName, vec);
  392. if (rc.IsError()) {
  393. MS_LOG(ERROR) << "Fail to update json: " << file_path << ".";
  394. return -1;
  395. }
  396. return 0;
  397. }
  398. extern "C" int MDToDApi_UpdateIsForTrain(MDToDApi *pMDToDApi, int32_t isForTrain) {
  399. int64_t file_id = pMDToDApi->_file_id;
  400. MS_LOG(INFO) << "Start Update isForTRain for id: " << file_id << " To " << isForTrain;
  401. if (file_id < 0) return -1;
  402. std::string converted = std::to_string(pMDToDApi->_file_id);
  403. std::string file_path = pMDToDApi->_folder_path + "/" + converted + ".json";
  404. mindspore::dataset::DataHelper dh;
  405. MS_LOG(INFO) << "Updating file: " << file_path;
  406. Status rc = dh.UpdateValue<int32_t>(file_path, "_isForTrain", isForTrain, "");
  407. if (rc.IsError()) {
  408. MS_LOG(ERROR) << "Fail to update json: " << file_path << ".";
  409. return -1;
  410. }
  411. return 0;
  412. }
  413. extern "C" int MDToDApi_UpdateNoOfFaces(MDToDApi *pMDToDApi, int32_t noOfFaces) {
  414. int64_t file_id = pMDToDApi->_file_id;
  415. MS_LOG(INFO) << "Start Update noOfFaces for id: " << file_id << " To " << noOfFaces;
  416. if (file_id < 0) return -1;
  417. std::string converted = std::to_string(pMDToDApi->_file_id);
  418. std::string file_path = pMDToDApi->_folder_path + "/" + converted + ".json";
  419. mindspore::dataset::DataHelper dh;
  420. MS_LOG(INFO) << "Updating file: " << file_path;
  421. Status rc = dh.UpdateValue<int32_t>(file_path, "_noOfFaces", noOfFaces, "");
  422. if (rc.IsError()) {
  423. MS_LOG(ERROR) << "Fail to update json: " << file_path << ".";
  424. return -1;
  425. }
  426. return 0;
  427. }
  428. } // namespace mindspore