MCPcopy Create free account
hub / github.com/ml-explore/mlx / time_irregular_binary_ops_4D

Function time_irregular_binary_ops_4D

benchmarks/cpp/irregular_strides.cpp:76–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void 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
116void time_irregular_reshape() {
117 auto device = mx::default_device();

Callers 1

mainFunction · 0.85

Calls 3

uniformFunction · 0.50
transposeFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected