| 1985 | // ggml_add_cast |
| 1986 | |
| 1987 | static struct ggml_tensor * ggml_add_cast_impl( |
| 1988 | struct ggml_context * ctx, |
| 1989 | struct ggml_tensor * a, |
| 1990 | struct ggml_tensor * b, |
| 1991 | enum ggml_type type) { |
| 1992 | // TODO: support less-strict constraint |
| 1993 | // GGML_ASSERT(ggml_can_repeat(b, a)); |
| 1994 | GGML_ASSERT(ggml_can_repeat_rows(b, a)); |
| 1995 | |
| 1996 | // currently only supported for quantized input and f16 |
| 1997 | GGML_ASSERT(ggml_is_quantized(a->type) || |
| 1998 | a->type == GGML_TYPE_F16 || |
| 1999 | a->type == GGML_TYPE_BF16); |
| 2000 | |
| 2001 | struct ggml_tensor * result = ggml_new_tensor(ctx, type, GGML_MAX_DIMS, a->ne); |
| 2002 | |
| 2003 | result->op = GGML_OP_ADD; |
| 2004 | result->src[0] = a; |
| 2005 | result->src[1] = b; |
| 2006 | |
| 2007 | return result; |
| 2008 | } |
| 2009 | |
| 2010 | struct ggml_tensor * ggml_add_cast( |
| 2011 | struct ggml_context * ctx, |
no test coverage detected