Skip to content

Commit a71ae3b

Browse files
authored
ggml : add ggml_op_is_empty (#16122)
* ggml : add ggml_op_is_empty * ggml : move to ggml-impl.h
1 parent 05a2458 commit a71ae3b

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

ggml/src/ggml-impl.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static inline int ggml_up(int n, int m) {
7373
return (n + m - 1) & ~(m - 1);
7474
}
7575

76-
// TODO: move to ggml.h?
76+
// TODO: move to ggml.h? (won't be able to inline)
7777
static bool ggml_are_same_layout(const struct ggml_tensor * a, const struct ggml_tensor * b) {
7878
if (a->type != b->type) {
7979
return false;
@@ -89,6 +89,19 @@ static bool ggml_are_same_layout(const struct ggml_tensor * a, const struct ggml
8989
return true;
9090
}
9191

92+
static bool ggml_op_is_empty(enum ggml_op op) {
93+
switch (op) {
94+
case GGML_OP_NONE:
95+
case GGML_OP_RESHAPE:
96+
case GGML_OP_TRANSPOSE:
97+
case GGML_OP_VIEW:
98+
case GGML_OP_PERMUTE:
99+
return true;
100+
default:
101+
return false;
102+
}
103+
}
104+
92105
//
93106
// logging
94107
//

ggml/src/ggml-metal/ggml-metal-common.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,6 @@ bool ggml_mem_ranges_check(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
184184
return ggml_mem_ranges_check_dst(mrs, tensor);
185185
}
186186

187-
// TODO: move to ggml.h?
188-
static bool is_empty(ggml_op op) {
189-
switch (op) {
190-
case GGML_OP_NONE:
191-
case GGML_OP_RESHAPE:
192-
case GGML_OP_TRANSPOSE:
193-
case GGML_OP_VIEW:
194-
case GGML_OP_PERMUTE:
195-
return true;
196-
default:
197-
return false;
198-
}
199-
}
200-
201187
struct node_info {
202188
ggml_tensor * node;
203189

@@ -212,7 +198,7 @@ struct node_info {
212198
}
213199

214200
bool is_empty() const {
215-
return ::is_empty(node->op);
201+
return ggml_op_is_empty(node->op);
216202
}
217203

218204
void add_fused(ggml_tensor * t) {
@@ -289,7 +275,7 @@ static std::vector<int> ggml_metal_graph_optimize_reorder(const std::vector<node
289275
case GGML_OP_GET_ROWS:
290276
return true;
291277
default:
292-
return is_empty(op);
278+
return ggml_op_is_empty(op);
293279
}
294280
};
295281

0 commit comments

Comments
 (0)