mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-10-27 08:21:30 +00:00
ggml : add ggml_op_is_empty (#16122)
* ggml : add ggml_op_is_empty * ggml : move to ggml-impl.h
This commit is contained in:
@@ -73,7 +73,7 @@ static inline int ggml_up(int n, int m) {
|
|||||||
return (n + m - 1) & ~(m - 1);
|
return (n + m - 1) & ~(m - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to ggml.h?
|
// TODO: move to ggml.h? (won't be able to inline)
|
||||||
static bool ggml_are_same_layout(const struct ggml_tensor * a, const struct ggml_tensor * b) {
|
static bool ggml_are_same_layout(const struct ggml_tensor * a, const struct ggml_tensor * b) {
|
||||||
if (a->type != b->type) {
|
if (a->type != b->type) {
|
||||||
return false;
|
return false;
|
||||||
@@ -89,6 +89,19 @@ static bool ggml_are_same_layout(const struct ggml_tensor * a, const struct ggml
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ggml_op_is_empty(enum ggml_op op) {
|
||||||
|
switch (op) {
|
||||||
|
case GGML_OP_NONE:
|
||||||
|
case GGML_OP_RESHAPE:
|
||||||
|
case GGML_OP_TRANSPOSE:
|
||||||
|
case GGML_OP_VIEW:
|
||||||
|
case GGML_OP_PERMUTE:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// logging
|
// logging
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -184,20 +184,6 @@ bool ggml_mem_ranges_check(ggml_mem_ranges_t mrs, const ggml_tensor * tensor) {
|
|||||||
return ggml_mem_ranges_check_dst(mrs, tensor);
|
return ggml_mem_ranges_check_dst(mrs, tensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to ggml.h?
|
|
||||||
static bool is_empty(ggml_op op) {
|
|
||||||
switch (op) {
|
|
||||||
case GGML_OP_NONE:
|
|
||||||
case GGML_OP_RESHAPE:
|
|
||||||
case GGML_OP_TRANSPOSE:
|
|
||||||
case GGML_OP_VIEW:
|
|
||||||
case GGML_OP_PERMUTE:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct node_info {
|
struct node_info {
|
||||||
ggml_tensor * node;
|
ggml_tensor * node;
|
||||||
|
|
||||||
@@ -212,7 +198,7 @@ struct node_info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool is_empty() const {
|
bool is_empty() const {
|
||||||
return ::is_empty(node->op);
|
return ggml_op_is_empty(node->op);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_fused(ggml_tensor * t) {
|
void add_fused(ggml_tensor * t) {
|
||||||
@@ -289,7 +275,7 @@ static std::vector<int> ggml_metal_graph_optimize_reorder(const std::vector<node
|
|||||||
case GGML_OP_GET_ROWS:
|
case GGML_OP_GET_ROWS:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return is_empty(op);
|
return ggml_op_is_empty(op);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user