| 74 | } |
| 75 | |
| 76 | void time_irregular_binary_ops_4D() { |
| 77 | auto device = mx::default_device(); |
| 78 | mx::Shape shape = {8, 8, 512, 512}; |
| 79 | auto a = mx::random::uniform(shape); |
| 80 | auto b = mx::random::uniform(shape); |
| 81 | |
| 82 | TIMEM("4D regular", mx::add, a, b, device); |
| 83 | |
| 84 | b = mx::transpose(b, {0, 1, 3, 2}); |
| 85 | TIMEM("4D mx::transpose", mx::add, a, b, device); |
| 86 | |
| 87 | std::string om = "4D broadcast dims "; |
| 88 | for (int i = 0; i < shape.size(); ++i) { |
| 89 | shape[i] = 1; |
| 90 | b = mx::random::uniform(shape); |
| 91 | std::ostringstream msg; |
| 92 | msg << om << i; |
| 93 | TIMEM(msg.str(), mx::add, a, b, device); |
| 94 | |
| 95 | for (int j = i + 1; j < shape.size(); ++j) { |
| 96 | shape[j] = 1; |
| 97 | std::ostringstream msg; |
| 98 | msg << om << i << ", " << j; |
| 99 | b = mx::random::uniform(shape); |
| 100 | TIMEM(msg.str(), mx::add, a, b, device); |
| 101 | shape[j] = a.shape(j); |
| 102 | |
| 103 | for (int k = j + 1; k < shape.size(); ++k) { |
| 104 | shape[k] = 1; |
| 105 | std::ostringstream msg; |
| 106 | msg << om << i << ", " << j << ", " << k; |
| 107 | b = mx::random::uniform(shape); |
| 108 | TIMEM(msg.str(), mx::add, a, b, device); |
| 109 | shape[k] = a.shape(k); |
| 110 | } |
| 111 | } |
| 112 | shape[i] = a.shape(i); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | void time_irregular_reshape() { |
| 117 | auto device = mx::default_device(); |