| 1858 | } // namespace |
| 1859 | |
| 1860 | Expect<ErrNo> load(WasiNNEnvironment &Env, Span<const Span<uint8_t>> Builders, |
| 1861 | [[maybe_unused]] Device Device, uint32_t &GraphId) noexcept { |
| 1862 | if (Builders.empty()) { |
| 1863 | RET_ERROR(ErrNo::InvalidArgument, |
| 1864 | "Invalid builders size, builders size must be > 0."); |
| 1865 | } |
| 1866 | |
| 1867 | // Add a graph |
| 1868 | const uint32_t GId = Env.newGraph(Backend::BitNet); |
| 1869 | auto &GraphRef = Env.NNGraph[GId].get<Graph>(); |
| 1870 | |
| 1871 | // Initialize the plugin parameters. |
| 1872 | GraphRef.EnableLog = false; |
| 1873 | GraphRef.EnableDebugLog = false; |
| 1874 | const common_params CommonParamsDefault; |
| 1875 | GraphRef.Params = CommonParamsDefault; |
| 1876 | GraphRef.Params.n_keep = 0; |
| 1877 | GraphRef.Params.n_chunks = -1; |
| 1878 | GraphRef.Params.n_parallel = 1; |
| 1879 | GraphRef.Params.grp_attn_n = 1; |
| 1880 | GraphRef.Params.grp_attn_w = 512; |
| 1881 | GraphRef.Params.n_print = -1; |
| 1882 | GraphRef.Params.split_mode = llama_split_mode::LLAMA_SPLIT_MODE_LAYER; |
| 1883 | // Initialize the model parameters. |
| 1884 | llama_model_params ModelParamsDefault = llama_model_default_params(); |
| 1885 | GraphRef.Params.n_gpu_layers = ModelParamsDefault.n_gpu_layers; |
| 1886 | GraphRef.Params.mmproj = ""sv; |
| 1887 | GraphRef.Params.warmup = false; |
| 1888 | // Initialize the context parameters. |
| 1889 | llama_context_params ContextParamsDefault = llama_context_default_params(); |
| 1890 | GraphRef.Params.n_ctx = ContextParamsDefault.n_ctx; |
| 1891 | GraphRef.Params.n_batch = ContextParamsDefault.n_batch; |
| 1892 | GraphRef.Params.n_ubatch = ContextParamsDefault.n_ubatch; |
| 1893 | GraphRef.Params.cpuparams.n_threads = ContextParamsDefault.n_threads_batch; |
| 1894 | GraphRef.Params.cpuparams_batch.n_threads = |
| 1895 | ContextParamsDefault.n_threads_batch; |
| 1896 | GraphRef.Params.rope_scaling_type = ContextParamsDefault.rope_scaling_type; |
| 1897 | GraphRef.Params.pooling_type = ContextParamsDefault.pooling_type; |
| 1898 | GraphRef.Params.attention_type = ContextParamsDefault.attention_type; |
| 1899 | GraphRef.Params.rope_freq_base = ContextParamsDefault.rope_freq_base; |
| 1900 | GraphRef.Params.rope_freq_scale = ContextParamsDefault.rope_freq_scale; |
| 1901 | GraphRef.Params.yarn_ext_factor = ContextParamsDefault.yarn_ext_factor; |
| 1902 | GraphRef.Params.yarn_attn_factor = ContextParamsDefault.yarn_attn_factor; |
| 1903 | GraphRef.Params.yarn_beta_fast = ContextParamsDefault.yarn_beta_fast; |
| 1904 | GraphRef.Params.yarn_beta_slow = ContextParamsDefault.yarn_beta_slow; |
| 1905 | GraphRef.Params.yarn_orig_ctx = ContextParamsDefault.yarn_orig_ctx; |
| 1906 | GraphRef.Params.defrag_thold = ContextParamsDefault.defrag_thold; |
| 1907 | GraphRef.Params.cb_eval = ContextParamsDefault.cb_eval; |
| 1908 | GraphRef.Params.cb_eval_user_data = ContextParamsDefault.cb_eval_user_data; |
| 1909 | GraphRef.Params.embedding = ContextParamsDefault.embeddings; |
| 1910 | GraphRef.Params.no_kv_offload = !ContextParamsDefault.offload_kqv; |
| 1911 | GraphRef.Params.flash_attn = ContextParamsDefault.flash_attn; |
| 1912 | GraphRef.Params.no_perf = ContextParamsDefault.no_perf; |
| 1913 | |
| 1914 | // Initialize the sampling parameters. |
| 1915 | const common_sampler_params SamplerParamsDefault; |
| 1916 | GraphRef.Params.sparams = SamplerParamsDefault; |
| 1917 |
nothing calls this directly
no test coverage detected