11 void StoreMatrixInMatrixMarketFormat(
15 const std::string& matrix_name) {
18 is_integral<T>::value,
19 "StoreMatrixInMatrixMarket only works with integer types");
21 static set<string> dumped_matrix_names;
23 string name(matrix_name);
24 string::size_type pos = name.rfind(
'/');
25 if (pos != string::npos) {
26 name = name.substr(pos + 1);
28 if (dumped_matrix_names.find(name) == dumped_matrix_names.end()) {
29 dumped_matrix_names.insert(name);
31 FILE* fp = fopen((name +
".mtx").c_str(),
"w");
36 fprintf(fp,
"%%%%MatrixMarket matrix array integer general\n");
37 fprintf(fp,
"%d %d\n", m, n);
39 for (
int j = 0; j < n; ++j) {
40 for (
int i = 0; i < m; ++i) {
41 fprintf(fp,
"%d\n", a[j * m + i]);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...