浏览代码

unity_graph -> unity_audio_encoder_graph

Guillaume Wenzek 1 年之前
父节点
当前提交
6f32f3c06f
共有 3 个文件被更改,包括 9 次插入9 次删除
  1. 3 3
      ggml/examples/unity/unity.cpp
  2. 4 4
      ggml/ggml.py
  3. 2 2
      ggml/test_unity_cpp.py

+ 3 - 3
ggml/examples/unity/unity.cpp

@@ -469,7 +469,7 @@ extern "C" bool unity_model_load(const char* fname, unity_model& model, gpt_voca
 }
 }
 
 
 // build the computation graph
 // build the computation graph
-extern "C" ggml_cgraph* unity_graph(
+extern "C" ggml_cgraph* unity_audio_encoder_graph(
     const unity_model & model,
     const unity_model & model,
     ggml_tensor* input
     ggml_tensor* input
 ) {
 ) {
@@ -603,7 +603,7 @@ extern "C" struct ggml_cgraph* unity_eval(
     // reset the allocator to free all the memory allocated during the previous inference
     // reset the allocator to free all the memory allocated during the previous inference
     ggml_allocr_reset(allocr);
     ggml_allocr_reset(allocr);
 
 
-    struct ggml_cgraph * gf = unity_graph(model, input);
+    struct ggml_cgraph * gf = unity_audio_encoder_graph(model, input);
 
 
     // allocate tensors
     // allocate tensors
     ggml_allocr_alloc_graph(allocr, gf);
     ggml_allocr_alloc_graph(allocr, gf);
@@ -678,7 +678,7 @@ int main(int argc, char ** argv) {
     // allocate the compute buffer
     // allocate the compute buffer
     {
     {
         allocr = ggml_allocr_new_measure(GGML_MEM_ALIGN);
         allocr = ggml_allocr_new_measure(GGML_MEM_ALIGN);
-        struct ggml_cgraph * gf = unity_graph(model, input);
+        struct ggml_cgraph * gf = unity_audio_encoder_graph(model, input);
 
 
         // compute the required memory
         // compute the required memory
         size_t mem_size = ggml_allocr_alloc_graph(allocr, gf) + GGML_MEM_ALIGN;
         size_t mem_size = ggml_allocr_alloc_graph(allocr, gf) + GGML_MEM_ALIGN;

+ 4 - 4
ggml/ggml.py

@@ -191,12 +191,12 @@ def unity_model_load(model_file: Path) -> Tuple[NativeObj, NativeObj]:
     return model, vocab
     return model, vocab
 
 
 
 
-lib.unity_graph.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
-lib.unity_graph.restype = ctypes.POINTER(ggml_cgraph)
+lib.unity_audio_encoder_graph.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
+lib.unity_audio_encoder_graph.restype = ctypes.POINTER(ggml_cgraph)
 
 
 
 
-def unity_graph(model: NativeObj, tensor: ggml_tensor_p) -> ggml_cgraph_p:
-    return lib.unity_graph(model.ptr, tensor)  # type: ignore
+def unity_audio_encoder_graph(model: NativeObj, tensor: ggml_tensor_p) -> ggml_cgraph_p:
+    return lib.unity_audio_encoder_graph(model.ptr, tensor)  # type: ignore
 
 
 
 
 lib.unity_eval.argtypes = [
 lib.unity_eval.argtypes = [

+ 2 - 2
ggml/test_unity_cpp.py

@@ -131,12 +131,12 @@ def test_unity_model_load(ctx: Ctx) -> None:
     example = ggml.from_file(ctx, UNITY_MODELS / "unity-large/seqs_before_conformer_block.bin", (1024, 137))
     example = ggml.from_file(ctx, UNITY_MODELS / "unity-large/seqs_before_conformer_block.bin", (1024, 137))
 
 
     with ggml.MeasureArena() as arena:
     with ggml.MeasureArena() as arena:
-        graph = ggml.unity_graph(model, example)
+        graph = ggml.unity_audio_encoder_graph(model, example)
         # TODO: why the extra memory ?
         # TODO: why the extra memory ?
         mem_size = ggml.ggml_allocr_alloc_graph(arena.ptr, graph) + ggml.GGML_MEM_ALIGN
         mem_size = ggml.ggml_allocr_alloc_graph(arena.ptr, graph) + ggml.GGML_MEM_ALIGN
 
 
     with ggml.FixedSizeArena(mem_size) as allocr:
     with ggml.FixedSizeArena(mem_size) as allocr:
-        print(f"unity_graph: compute buffer size: {mem_size/1024/1024} MB")
+        print(f"unity_audio_encoder_graph: compute buffer size: {mem_size/1024/1024} MB")
 
 
         eval_res_ptr = ggml.unity_eval(allocr, model, example, 1)
         eval_res_ptr = ggml.unity_eval(allocr, model, example, 1)
         eval_res = eval_res_ptr.contents
         eval_res = eval_res_ptr.contents