Skip to content

Commit

Permalink
add documentation, use supports_op if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesGaessler committed Sep 3, 2024
1 parent 1296c71 commit d419343
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 46 deletions.
4 changes: 4 additions & 0 deletions src/ggml-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,10 @@ GGML_CALL static bool ggml_backend_cpu_supports_op(ggml_backend_t backend, const
op->type != GGML_TYPE_IQ1_M; // missing type_traits.from_float
case GGML_OP_MUL_MAT:
return op->src[1]->type == GGML_TYPE_F32 || op->src[1]->type == ggml_internal_get_type_traits(op->src[0]->type).vec_dot_type;
case GGML_OP_ROPE_BACK:
return op->src[2] == NULL && (op->op_params[2] & 4) == 0;
case GGML_OP_IM2COL_BACK:
return op->src[0]->type == GGML_TYPE_F32 && op->src[1]->type == GGML_TYPE_F32;
default:
return true;
}
Expand Down
7 changes: 3 additions & 4 deletions src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -6637,14 +6637,12 @@ struct ggml_tensor * ggml_rope_back(
GGML_ASSERT(ggml_is_vector(b));
GGML_ASSERT(b->type == GGML_TYPE_I32);
GGML_ASSERT(a->ne[2] == b->ne[0]);
GGML_ASSERT(c == NULL && "freq factors not implemented yet");

GGML_ASSERT((mode & 4) == 0 && "ggml_rope_back() for ChatGLM not implemented yet");

bool is_node = false;

if (a->grad) {
is_node = false; // TODO: implement backward
GGML_ASSERT(false && "backwards pass not implemented");
is_node = false;
}

struct ggml_tensor * result = ggml_dup_tensor(ctx, a);
Expand All @@ -6662,6 +6660,7 @@ struct ggml_tensor * ggml_rope_back(
result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
result->src[0] = a;
result->src[1] = b;
result->src[2] = c;

return result;
}
Expand Down
Loading

0 comments on commit d419343

Please sign in to comment.