Skip to content

Commit

Permalink
Merge pull request apache#137 from tqchen/master
Browse files Browse the repository at this point in the history
Enable better TShape parsing, support long, and integer
  • Loading branch information
tqchen authored Jun 22, 2016
2 parents 9faf1af + d3a049f commit 948abff
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mshadow/tensor_blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,15 @@ inline std::ostream &operator<<(std::ostream &os, const TShape &shape) {
inline std::istream &operator>>(std::istream &is, TShape &shape) {
// get (
while (true) {
char ch = is.get();
char ch = is.peek();
if (isdigit(ch)) {
index_t idx;
if (is >> idx) {
shape.CopyFrom(&idx, &idx + 1);
}
return is;
}
is.get();
if (ch == '(') break;
if (!isspace(ch)) {
is.setstate(std::ios::failbit);
Expand All @@ -401,6 +409,9 @@ inline std::istream &operator>>(std::istream &is, TShape &shape) {
do {
ch = is.get();
} while (isspace(ch));
if (ch == 'L') {
ch = is.get();
}
if (ch == ',') {
while (true) {
ch = is.peek();
Expand Down

0 comments on commit 948abff

Please sign in to comment.