Skip to content

[local-apps] add MNN to local-apps. #1629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions packages/tasks/src/local-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ function isMlxModel(model: ModelData) {
return model.tags.includes("mlx");
}

function isMNNModel(model: ModelData) {
return model.tags.includes("mnn");
}

function getQuantTag(filepath?: string): string {
const defaultTag = ":{{QUANT_TAG}}";

Expand Down Expand Up @@ -301,6 +305,22 @@ const snippetDockerModelRunner = (model: ModelData, filepath?: string): string =
return `docker model run hf.co/${model.id}${getQuantTag(filepath)}`;
};

const snippetMNN = (model: ModelData, filepath?: string): LocalAppSnippet[] => {
return [
{
title: "Build from source code",
setup: [
"git clone https://github.com/alibaba/MNN.git",
"cd MNN",
"cmake -B build",
"cmake --build build -j -DMNN_LOW_MEMORY=ON -DMNN_CPU_WEIGHT_DEQUANT_GEMM=ON -DMNN_BUILD_LLM=ON -DMNN_SUPPORT_TRANSFORMER_FUSE=ON",
].join("\n"),
content: `./build/llm_demo ${model.id}`,
},
];
};


/**
* Add your new local app here.
*
Expand Down Expand Up @@ -478,6 +498,13 @@ export const LOCAL_APPS = {
displayOnModelPage: isLlamaCppGgufModel,
snippet: snippetDockerModelRunner,
},
"MNN": {
prettyLabel: "MNN",
docsUrl: "https://github.com/alibaba/MNN",
mainTask: "text-generation",
displayOnModelPage: isMNNModel,
snippet: snippetMNN,
},
} satisfies Record<string, LocalApp>;

export type LocalAppKey = keyof typeof LOCAL_APPS;