| 655 | } |
| 656 | |
| 657 | int64 parameters() const { |
| 658 | if (!shape().empty()) { |
| 659 | int64 params = 1; |
| 660 | bool complete_shape = true; |
| 661 | for (int64 d : shape()) { |
| 662 | // Sometimes parameters could be <0 when a dim is unknown. |
| 663 | if (d < 0) { |
| 664 | complete_shape = false; |
| 665 | break; |
| 666 | } |
| 667 | params *= d; |
| 668 | } |
| 669 | if (complete_shape) { |
| 670 | return params; |
| 671 | } else { |
| 672 | fprintf(stderr, "Incomplete shape.\n"); |
| 673 | } |
| 674 | } |
| 675 | return 0; |
| 676 | } |
| 677 | |
| 678 | int64 float_ops(int64 step) const { |
| 679 | // If not run, return static analysis. |