38
38
* @return The corresponding aclDataType. If the input type is not recognized,
39
39
* ACL_DT_UNDEFINED is returned.
40
40
*/
41
- aclDataType type_mapping (ggml_type type );
41
+ aclDataType ggml_cann_type_mapping (ggml_type type );
42
42
43
43
/**
44
44
* @brief Creates an ACL tensor from a ggml_tensor with optional shape.
@@ -59,7 +59,7 @@ aclDataType type_mapping(ggml_type type);
59
59
* @param offset Offset in bytes for the ACL tensor data. Defaults to 0.
60
60
* @return Pointer to the created ACL tensor.
61
61
*/
62
- aclTensor * create_acl_tensor (const ggml_tensor * tensor , int64_t * ne = nullptr ,
62
+ aclTensor * ggml_cann_create_tensor (const ggml_tensor * tensor , int64_t * ne = nullptr ,
63
63
size_t * nb = nullptr , int64_t dims = 0 ,
64
64
aclFormat format = ACL_FORMAT_ND ,
65
65
size_t offset = 0 );
@@ -83,7 +83,7 @@ aclTensor* create_acl_tensor(const ggml_tensor* tensor, int64_t* ne = nullptr,
83
83
* @param offset Offset in bytes for the ACL tensor data. Defaults to 0.
84
84
* @return Pointer to the created ACL tensor.
85
85
*/
86
- aclTensor * create_acl_tensor (void * data_ptr , aclDataType dtype ,
86
+ aclTensor * ggml_cann_create_tensor (void * data_ptr , aclDataType dtype ,
87
87
size_t type_size , int64_t * ne , size_t * nb ,
88
88
int64_t dims , aclFormat format = ACL_FORMAT_ND ,
89
89
size_t offset = 0 );
@@ -104,7 +104,7 @@ aclTensor* create_acl_tensor(void* data_ptr, aclDataType dtype,
104
104
* to 1. If such a dimension is found, broadcasting is required to align t1
105
105
* with t0 for element-wise operations.
106
106
*/
107
- bool need_bcast (const ggml_tensor * t0 , const ggml_tensor * t1 );
107
+ bool ggml_cann_need_bcast (const ggml_tensor * t0 , const ggml_tensor * t1 );
108
108
109
109
/**
110
110
* @brief Computes broadcast shapes and strides for two ggml_tensors.
@@ -159,19 +159,19 @@ bool need_bcast(const ggml_tensor* t0, const ggml_tensor* t1);
159
159
* dim1 in a inserted dim, should add nb for dim1,
160
160
* and all other nb moves to next in order.
161
161
*/
162
- int64_t get_bcast_shape (const ggml_tensor * src0 , const ggml_tensor * src1 ,
162
+ int64_t ggml_cann_get_bcast_shape (const ggml_tensor * src0 , const ggml_tensor * src1 ,
163
163
int64_t * bcast_ne_src0 , int64_t * bcast_ne_src1 ,
164
164
size_t * bcast_nb_src0 , size_t * bcast_nb_src1 );
165
165
166
166
// Bcast macro to avoid duplicate code.
167
- #define BCAST_SHAPE (src0 , src1 ) \
168
- int64_t bcast_##src0##_ne[GGML_MAX_DIMS * 2]; \
169
- int64_t bcast_##src1##_ne[GGML_MAX_DIMS * 2]; \
170
- size_t bcast_##src0##_nb[GGML_MAX_DIMS * 2]; \
171
- size_t bcast_##src1##_nb[GGML_MAX_DIMS * 2]; \
172
- int64_t bcast_dims = \
173
- get_bcast_shape( src0, src1, bcast_##src0##_ne, bcast_##src1##_ne, \
174
- bcast_##src0##_nb, bcast_##src1##_nb);
167
+ #define BCAST_SHAPE (src0 , src1 ) \
168
+ int64_t bcast_##src0##_ne[GGML_MAX_DIMS * 2]; \
169
+ int64_t bcast_##src1##_ne[GGML_MAX_DIMS * 2]; \
170
+ size_t bcast_##src0##_nb[GGML_MAX_DIMS * 2]; \
171
+ size_t bcast_##src1##_nb[GGML_MAX_DIMS * 2]; \
172
+ int64_t bcast_dims = ggml_cann_get_bcast_shape( \
173
+ src0, src1, bcast_##src0##_ne, bcast_##src1##_ne, bcast_##src0##_nb , \
174
+ bcast_##src1##_nb);
175
175
176
176
#define BCAST_PARAM (tensor ) bcast_##tensor##_ne, bcast_##tensor##_nb, bcast_dims
177
177
@@ -201,17 +201,15 @@ int64_t get_bcast_shape(const ggml_tensor* src0, const ggml_tensor* src1,
201
201
* shapes needed for matrix multiplication. It ensures that dimensions where
202
202
* weight tensor requires expansion are appropriately handled to conform with
203
203
* broadcasting rules.
204
- * @note compare with get_bcast_shape ,mul_mat broadcast need add this new dim before
205
- * cast dim.
206
- * @sa get_bcast_shape
204
+ * @note compare with ggml_cann_get_bcast_shape ,mul_mat broadcast need add this new dim
205
+ * before cast dim.
206
+ * @sa ggml_cann_get_bcast_shape
207
207
*/
208
- int64_t get_mul_mat_bcast_shape (const int64_t * input_ne ,
209
- const int64_t * weight_ne , const int64_t * dst_ne ,
210
- const size_t * input_nb , const size_t * weight_nb ,
211
- const size_t * dst_nb , int64_t * bcast_input_ne ,
212
- int64_t * bcast_weight_ne , int64_t * bcast_dst_ne ,
213
- size_t * bcast_input_nb , size_t * bcast_weight_nb ,
214
- size_t * bcast_dst_nb );
208
+ int64_t ggml_cann_get_mulmat_bcast_shape (
209
+ const int64_t * input_ne , const int64_t * weight_ne , const int64_t * dst_ne ,
210
+ const size_t * input_nb , const size_t * weight_nb , const size_t * dst_nb ,
211
+ int64_t * bcast_input_ne , int64_t * bcast_weight_ne , int64_t * bcast_dst_ne ,
212
+ size_t * bcast_input_nb , size_t * bcast_weight_nb , size_t * bcast_dst_nb );
215
213
216
214
// Bcast macro to avoid duplicate code.
217
215
#define BCAST_MUL_MAT_SHAPE (input , weight , dst ) \
@@ -221,7 +219,7 @@ int64_t get_mul_mat_bcast_shape(const int64_t* input_ne,
221
219
size_t bcast_##input##_nb[GGML_MAX_DIMS * 2]; \
222
220
size_t bcast_##weight##_nb[GGML_MAX_DIMS * 2]; \
223
221
size_t bcast_##dst##_nb[GGML_MAX_DIMS * 2]; \
224
- int64_t bcast_dims = get_mul_mat_bcast_shape( \
222
+ int64_t bcast_dims = ggml_cann_get_mulmat_bcast_shape( \
225
223
input->ne, weight->ne, dst->ne, input->nb, weight->nb, dst->nb, \
226
224
bcast_##input##_ne, bcast_##weight##_ne, bcast_##dst##_ne, \
227
225
bcast_##input##_nb, bcast_##weight##_nb, bcast_##dst##_nb);
0 commit comments