-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LANG] Enable json load/save and pickle (#10)
- Loading branch information
Showing
15 changed files
with
521 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*! | ||
* Copyright (c) 2016 by Contributors | ||
* \file common.h | ||
* \brief Common utilities | ||
*/ | ||
#ifndef TVM_BASE_COMMON_H_ | ||
#define TVM_BASE_COMMON_H_ | ||
|
||
#include <tvm/base.h> | ||
#include <string> | ||
|
||
namespace tvm { | ||
|
||
inline std::string Type2String(const Type& t) { | ||
std::ostringstream os; | ||
os << t; | ||
return os.str(); | ||
} | ||
|
||
inline Type String2Type(std::string s) { | ||
std::istringstream is(s); | ||
halide_type_code_t code = Type::Int; | ||
if (s.substr(0, 3) == "int") { | ||
code = Type::Int; s = s.substr(3); | ||
} else if (s.substr(0, 4) == "uint") { | ||
code = Type::UInt; s = s.substr(4); | ||
} else if (s.substr(0, 5) == "float") { | ||
code = Type::Float; s = s.substr(5); | ||
} else if (s.substr(0, 5) == "float") { | ||
code = Type::Float; s = s.substr(5); | ||
} else { | ||
LOG(FATAL) << "unknown type " << s; | ||
} | ||
int bits = 32, lanes = 1; | ||
if (sscanf(s.c_str(), "%dx%d", &bits, &lanes) == 0) { | ||
LOG(FATAL) << "unknown type " << s; | ||
} | ||
return Type(code, bits, lanes); | ||
} | ||
|
||
} // namespace tvm | ||
#endif // TVM_BASE_COMMON_H_ |
Oops, something went wrong.