Custom pseudo-operations for generic rewriting

オープン
#2,162 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
28/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

まず、添付された cusops2ons.py.txt と test_generic_as_wrap.py.txt を読み、次に Opset、script、Op、op_schema 周辺の onnxscript rewriter の使用方法を調査してください。カスタム擬似演算が汎用リライトに参加できるかどうかを判断し、意図したリライト動作を示すテストを含む、動作するカスタムノードの例を文書化してください。

索引モデルが issue の本文から書いたものです。

説明

This text organized as

  1. Problem
  2. Solution
  3. This issue subject

Problem to solve

I want element-wise operations move above their commutatives (friends). See picture:

Image

I don't want to encode every possible interchange pair, so must be generic element-wise and generic friend. Can I have it with current onnxscript (0.2.2) rewriter?

  1. Solution

Use meta-abc node pairs like this:

Image

In the attachment, there is prototype implementation.
It moves elementwise operations (ReLU and Tanh) above Identity and Flatten

cusops2ons.py.txt

test_generic_as_wrap.py.txt

For now, we encode elementwise wrappers as [Split(axis=20), Sub]
and wrappers of their friend as [Split(axis=30), Sub]

What do you think about this approach to generics?

  1. The issue

Well, it works! But using Split and Sub as replacement to ABC_pre and ABC_post is obviously bad.
I actually tried to create custom pseudo-operation, but failed.

As I create op like this:

my_opset = Opset("com.mydomain", 15)

@script(my_opset)
def joy_of_relu( x:FLOAT ) -> FLOAT:
    y =    op.Relu(x)
    return op.Relu(y)


opsch = joy_of_relu.op_schema

shiny_new_op = Op(
    opset=my_opset, name="relurelu", op_schema=opsch
)

it not work with rewriter, also I tried onnxruntime_extensions.onnx_op

So, if it is possible, it would be great to have example of using rewriter with custom nodes.

主要言語
Python
スター
457
フォーク
149
平均マージ
3日 20時間
マージ済み PR(30日)
22

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/onnxscript のほかの issue

microsoft/onnxscript の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。