-chlo-legalize-to-stablehlo

הפיכת הפעילות למשפטית לתהליך חוקי מפעולות CHLO לבין פעולות StableHLO ו-צורה

-shape-legalize-to-stablehlo

להפוך פעולות שקשורות לצורות במסגרת StableHLO מבחינה משפטית.

כרטיס ניסיוני שמגדיר פעולות שקשורות לצורות במסגרת פעולות StableHLO.

שילוב בין חישובי צורות ונתונים באמצעות כרטיס אופציונלי מאפשרת לסביבה העסקית של StableHLO לנצל באופן פוטנציאלי צינורות עיבוד נתונים הידור (compilation) שמשתמשים בפעולות StableHLO כדי ליצור מודל של דינאמיזם.

-stablehlo-aggressive-folder

פעולות Folds StableHLO

אפשרויות

-fold-float : Allow for potentially lossy computations using float type.

-stablehlo-aggressive-simplification

יצירת פעולות קנוניות של StableHLO

-stablehlo-canonicalize-dynamism

גרסה קנונית של פעולות StableHLO דינמיות לתפעול סטטיות.

מחליפה פעולות StableHLO דינמיות כמו DynamicReshapeOp מקבילות סטטיות כמו ReshapeOp אם כל הרכיבים הדינמיים של הפעולות האלה הן למעשה קבועות.

לדוגמה, אם האופרנד Output_shape של DynamicReshapeOp הוא קבוע אז הפעולה יכולה להפוך ל-ReshapeOp.

-stablehlo-convert-to-signless

עוברים לטרנספורמציה של ה-IR למספרים שלמים ללא סימנים.

-stablehlo-legalize-composite-to-call

מחליפה פעולות מורכבות בקריאה לפירוק שלהן

מחליפה פעולות מורכבות בקריאה לפירוקן, למשל אלה:

stablehlo.composite "my_namespace.my_op" %arg0, %arg1 {
  decomposition = @bar,
  version = 1,
  composite_attributes = {
    "my_attribute": "my_value"
  }
}

יהפוך ל:

func.call @bar(%arg0, %arg1)

ניתן להחריג קבוצת משנה של רכיבים מרוכבים מהטרנספורמציה הזו באמצעות "חוץ" דגל, למשל:

stablehlo-opt --stablehlo-legalize-composite-to-call=except='foo.baz,foo.qux'

אפשרויות

-except : Names of composites that should not be replaced with calls.

-stablehlo-legalize-deprecated-ops

הפיכת פעולות שהוצאו משימוש לחוקיות עבור פעולות עם תמיכה טובה.

יש הצעה להסיר את ההוצאה משימוש של StableHLO v1.0 Opset RFC (#2283) מספר פעולות מיותרות. הכרטיס הזה עוזר להעריך את ההשפעה של הפעולות האלה הסרה בצינורות עיבוד נתונים שונים של הידור מקבילים שנתמכים לטווח ארוך.

אפשרויות

-fail-on-unused : Fail on (mostly) unused ops that are deprecated without any fallback.

-stablehlo-legalize-qdq-to-quantized-op

תבנית פיוז (הסרת קונטיינרים, פעולה בנקודה צפה (floating-point) וכמות מכמת) לפעולה בכמות גדולה ב-StableHLO

תבנית של נתיכים (ביטול קוונטיזציה, פעולה בנקודה צפה וכמות) לפעולה בכמות גדולה ב-StableHLO הערה: הכרטיס לא מוחק פעולות קיימות. לדוגמה, התוכנית הבאה

func.func @add(%arg0: tensor<16x16x!quant.uniform<ui8:f32, 34.0:16>>) -> tensor<16x16x!quant.uniform<ui8:f32, 34.0:16>> {
  %0 = stablehlo.uniform_dequantize %arg0 : (tensor<16x16x!quant.uniform<ui8:f32, 34.0:16>>) -> tensor<16x16xf32>
  %1 = stablehlo.abs %0 : tensor<16x16xf32>
  %2 = stablehlo.uniform_quantize %1 : (tensor<16x16xf32>) -> tensor<16x16x!quant.uniform<ui8:f32, 34.0:16>>
  func.return %2 : tensor<16x16x!quant.uniform<ui8:f32, 34.0:16>>
}

יהפוך ל:

func.func @add(%arg0: tensor<16x16x!quant.uniform<u8:f32, 3.400000e+01:16>>) -> tensor<16x16x!quant.uniform<u8:f32, 3.400000e+01:16>> {
  %0 = stablehlo.uniform_dequantize %arg0 : (tensor<16x16x!quant.uniform<u8:f32, 3.400000e+01:16>>) -> tensor<16x16xf32>
  %1 = stablehlo.abs %0 : tensor<16x16xf32>
  %2 = stablehlo.abs %arg0 : tensor<16x16x!quant.uniform<u8:f32, 3.400000e+01:16>>
  %3 = stablehlo.uniform_quantize %1 : (tensor<16x16xf32>) -> tensor<16x16x!quant.uniform<u8:f32, 3.400000e+01:16>>
  return %2 : tensor<16x16x!quant.uniform<u8:f32, 3.400000e+01:16>>
}

-stablehlo-legalize-quant-to-math

המרה מפעולות כמותיות של StableHLO לפעולות מתמטיות פרימיטיביות של StableHLO.

המרת תוכניות StableHLO באמצעות סוגים אחידים (UniformQuantized) לסמנטית פעולות מתמטיות מקבילות למספרים שלמים.

func.func @add(%arg0: tensor<!quant.uniform<i8:f32,1.0:0>>, %arg1: tensor<!quant.uniform<i8:f32,2.0:1>>) ->  tensor<!quant.uniform<i8:f32,3.0:2>> {
  %0 = "stablehlo.add"(%arg0, %arg1) : (tensor<!quant.uniform<i8:f32,1.0:0>>, tensor<!quant.uniform<i8:f32,2.0:1>>) -> tensor<!quant.uniform<i8:f32,3.0:2>>
  func.return %0 : tensor<!quant.uniform<i8:f32,3.0:2>>
}

יהפוך ל:

func.func @add(%arg0: tensor<i8>, %arg1: tensor<i8>) -> tensor<i8> {
  %0 = stablehlo.convert %arg0 : (tensor<i8>) -> tensor<f32>
  %cst = stablehlo.constant dense<0.333333343> : tensor<f32>
  %1 = chlo.broadcast_multiply %0, %cst : (tensor<f32>, tensor<f32>) -> tensor<f32>
  %cst_0 = stablehlo.constant dense<2.000000e+00> : tensor<f32>
  %2 = chlo.broadcast_add %1, %cst_0 : (tensor<f32>, tensor<f32>) -> tensor<f32>
  %3 = stablehlo.round_nearest_even %2 : tensor<f32>
  %4 = stablehlo.convert %3 : (tensor<f32>) -> tensor<i32>
  %5 = stablehlo.convert %arg1 : (tensor<i8>) -> tensor<f32>
  %cst_1 = stablehlo.constant dense<0.666666686> : tensor<f32>
  %6 = chlo.broadcast_multiply %5, %cst_1 : (tensor<f32>, tensor<f32>) -> tensor<f32>
  %cst_2 = stablehlo.constant dense<1.33333337> : tensor<f32>
  %7 = chlo.broadcast_add %6, %cst_2 : (tensor<f32>, tensor<f32>) -> tensor<f32>
  %8 = stablehlo.round_nearest_even %7 : tensor<f32>
  %9 = stablehlo.convert %8 : (tensor<f32>) -> tensor<i32>
  %c = stablehlo.constant dense<2> : tensor<i32>
  %10 = chlo.broadcast_add %4, %9 : (tensor<i32>, tensor<i32>) -> tensor<i32>
  %11 = chlo.broadcast_subtract %10, %c : (tensor<i32>, tensor<i32>) -> tensor<i32>
  %c_3 = stablehlo.constant dense<-128> : tensor<i32>
  %c_4 = stablehlo.constant dense<127> : tensor<i32>
  %12 = stablehlo.clamp %c_3, %11, %c_4 : tensor<i32>
  %13 = stablehlo.convert %12 : (tensor<i32>) -> tensor<i8>
  return %13 : tensor<i8>
}

-stablehlo-legalize-quantized-op-to-qdq

פרקו את פעולת StableHLO הכמותית של תבנית (ביטול קונטיינרים, פעולה נקודה צפה (floating-point) וכמות גדולה).

פירוק תוכנות כמותיות של StableHLO באמצעות כימות/פענוח אחידות ב-AI. לדוגמה, התוכנית הבאה

func.func @add(%arg0: tensor<!quant.uniform<i8:f32,1.0:0>>, %arg1: tensor<!quant.uniform<i8:f32,2.0:1>>) ->  tensor<!quant.uniform<i8:f32,3.0:2>> {
  %0 = "stablehlo.add"(%arg0, %arg1) : (tensor<!quant.uniform<i8:f32,1.0:0>>, tensor<!quant.uniform<i8:f32,2.0:1>>) -> tensor<!quant.uniform<i8:f32,3.0:2>>
  func.return %0 : tensor<!quant.uniform<i8:f32,3.0:2>>
}

יהפוך ל:

func.func @add(%arg0: tensor<!quant.uniform<i8:f32, 1.000000e+00>>, %arg1: tensor<!quant.uniform<i8:f32, 2.000000e+00:1>>) -> tensor<!quant.uniform<i8:f32, 3.000000e+00:2>> {
  %0 = stablehlo.uniform_dequantize %arg0 : (tensor<!quant.uniform<i8:f32, 1.000000e+00>>) -> tensor<f32>
  %1 = stablehlo.uniform_dequantize %arg1 : (tensor<!quant.uniform<i8:f32, 2.000000e+00:1>>) -> tensor<f32>
  %2 = stablehlo.add %0, %1 : tensor<f32>
  %3 = stablehlo.uniform_quantize %2 : (tensor<f32>) -> tensor<!quant.uniform<i8:f32, 3.000000e+00:2>>
  return %3 : tensor<!quant.uniform<i8:f32, 3.000000e+00:2>>
}

-stablehlo-legalize-to-vhlo

הופכים את StableHLO ל-VHLO מבחינה משפטית.

-stablehlo-refine-arguments

צמצום צורות הארגומנטים של הפונקציה הראשית.

שינוי הארגומנטים של הפונקציה הראשית באמצעות החתימה של סוג הקלט. אופנת ארגומנטים ב-custom_call @stablehlo.shape_refinement_operand_wrapper כדי שערך ה-IR יהיה תקין לפני הפעלת החידוד של הצורה.

אפשר להשתמש בrefinedTypesOption כדי לציין רשימה של סוגים משופרים. אפשר לציין זאת ב-MLIR באמצעות --types='tensor<...>,tensor<...>', או מועברות לשיטה ליצירת כרטיס. רשימת סוגי החידוד חייבת לציין את כל ארגומנט ל-method main שצומצמה.

אפשרויות

-types : The new types to be used for the main function's arguments, specified as an MLIR TypeRange 'tensor<1x2xf32>, ...'

-stablehlo-refine-shapes

צמצום הצורות בתוכנית StableHLO.

הולך בתוכנית StableHLO ומחדד את הצורות בתוך תפעול.

תרחיש הדגל של הכרטיס הזה הוא שימוש בעיצוב דינמי לצורות סטטיות. אם לתוכנית StableHLO בעלת צורה דינמית יש את של המבנה הנכון, ואז מעדכנים את סוגי הארגומנטים שלו מצורות דינמיות צורות סטטיות והרצת הכרטיס הזה תפיץ צורות סטטיות את התוכנית.

-vhlo-legalize-to-stablehlo

הופכים את VHLO ל-VHLO ל-StableHLO.

-vhlo-to-version

המרת גרסאות של VHLO.

אפשרויות

-target : The target version. Must be a version of the form #.#.# or 'current'.