add-new-op

Guide adding new operators to the MNN framework with TDD steps.

15.8k|2.4k|Updated Apr 15, 2019
One-click install
npx skills add https://github.com/alibaba/MNN --skill add-new-op
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-new-op
Source: https://github.com/alibaba/MNN/tree/main/skills/add-new-op
Command: npx skills add https://github.com/alibaba/MNN --skill add-new-op

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a structured, step-by-step process for adding new operator (op) support to the MNN deep learning framework, ensuring correctness and maintainability through Test-Driven Development (TDD).

Core Features & Use Cases

  • Schema Definition: Defines new operator types and their parameters using FlatBuffers Schema.
  • Shape Inference: Implements logic to calculate output tensor shapes based on input shapes and parameters.
  • Compute Implementation: Provides methods for both geometric decomposition (reusing existing ops) and direct CPU backend implementation.
  • Unit Testing: Guides the creation of comprehensive unit tests to verify operator correctness across various scenarios.
  • Backend Extension: Outlines the process for extending support to hardware accelerators like Metal, OpenCL, Vulkan, and CUDA.
  • Use Case: A developer needs to add a novel activation function or a custom layer to MNN. This Skill guides them through defining the op, implementing its logic, testing it thoroughly, and potentially optimizing it for different hardware.

Quick Start

Follow the step-by-step instructions in the skills/add-new-op directory to add a new operator to the MNN framework.

Frequently Asked Questions about add-new-op

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new operator to the MNN framework?

To add a new operator to the MNN framework, you must follow a structured process covering schema definition, shape computation, backend implementation, and unit testing. This ensures correctness and maintainability.

What is the best way to ensure correctness when adding custom layers to MNN?

The best way to ensure correctness for custom MNN layers is using a Test-Driven Development (TDD) approach. You create comprehensive unit tests to verify operator logic across various scenarios before finalizing implementation.

Does adding a new MNN operator require defining a FlatBuffers schema?

Yes, adding a new MNN operator requires defining a FlatBuffers schema. This schema definition step specifies the new operator types and their parameters for the deep learning framework.

Can I implement GPU acceleration for custom MNN operators?

Yes, you can implement GPU acceleration for custom MNN operators. The process outlines extending backend support to hardware accelerators like Metal, OpenCL, Vulkan, and CUDA.

What does shape inference involve during MNN operator development?

Shape inference during MNN operator development involves implementing logic to calculate output tensor shapes based on input shapes and parameters. This is a required step before compute implementation.

How do I reuse existing ops when implementing a new MNN operator?

To reuse existing operations when implementing a new MNN operator, you use the geometric decomposition method. This compute implementation approach breaks down new logic to utilize pre-existing framework operators.