ggerganov / ggml

Tensor library for machine learning
MIT License
10.89k stars 1k forks source link

User defined operation #836

Open Francis235 opened 4 months ago

Francis235 commented 4 months ago

How should I add a new operator?

balisujohn commented 4 months ago

You might want to first ask by creating an issue or discussion question to make sure there isn't a way to do what you want with existing operators. If there isn't, I'd recommend copying the code of an operator with the same number of arguments and creating a new OP with a different name with the exact same behavior to start. Then you can change the behavior to match what you want. Here is an example of a recent PR that adds a new OP https://github.com/ggerganov/ggml/pull/806, you can look at the diff to see what kind of changes you need to make,

Francis235 commented 3 months ago

Thanks for your suggestion.

You might want to first ask by creating an issue or discussion question to make sure there isn't a way to do what you want with existing operators. If there isn't, I'd recommend copying the code of an operator with the same number of arguments and creating a new OP with a different name with the exact same behavior to start. Then you can change the behavior to match what you want. Here is an example of a recent PR that adds a new OP #806, you can look at the diff to see what kind of changes you need to make,