| 538 | } |
| 539 | |
| 540 | TensorLayout TensorLayout::reshape(const TensorShape& shape) const { |
| 541 | TensorLayout ret; |
| 542 | auto succ = try_reshape(ret, shape); |
| 543 | megdnn_throw_if( |
| 544 | !succ, tensor_reshape_error, |
| 545 | ssprintf( |
| 546 | "can not reshape from %s to %s", to_string().c_str(), |
| 547 | shape.to_string().c_str())); |
| 548 | return ret; |
| 549 | } |
| 550 | |
| 551 | std::string TensorLayout::to_string() const { |
| 552 | std::string rst("{"); |