-chlo-legalize-to-stablehlo

ทำให้ถูกต้องตามกฎหมายตั้งแต่โฟลว์การดำเนินการ CHLO ไปจนถึง StableHLO และ Shape Ops

-shape-legalize-to-stablehlo

ทำให้การดำเนินการที่เกี่ยวข้องกับรูปร่างถูกต้องตามกฎหมายใน StableHLO

บัตรผ่านเวอร์ชันทดลองที่ทำให้การดำเนินการที่เกี่ยวข้องกับรูปร่างถูกต้องตามกฎหมายของปฏิบัติการ StableHLO

การรวมการคำนวณรูปร่างและข้อมูลเข้าด้วยกันผ่านบัตรผ่านที่ไม่บังคับจะ สำหรับระบบนิเวศ StableHLO จะสามารถใช้ประโยชน์จาก ไปป์ไลน์คอมไพล์ที่ใช้การดำเนินการ StableHLO เพื่อสร้างแบบจำลองพลวัต

-stablehlo-aggressive-folder

การดำเนินการพับ StableHLO

ตัวเลือก

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

-stablehlo-aggressive-simplification

การกำหนดรูปแบบการดำเนินการ StableHLO เป็น Canonical

-stablehlo-canonicalize-dynamism

Canonical นำการดำเนินการ StableHLO แบบไดนามิกเป็นการดำเนินการแบบคงที่

แทนที่ StableHLO แบบไดนามิกอย่าง DynamicReshapeOp ด้วยค่า คู่เหมือนแบบคงที่อย่าง ReshapeOp หากองค์ประกอบไดนามิกทั้งหมดของการดำเนินการเหล่านี้ มีความคงที่จริงๆ

ตัวอย่างเช่น หากตัวถูกดำเนินการของ Export_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 Deprecation RFC (#2283) เสนอให้ลบ ซ้ำซ้อนหลายขั้นตอน บัตรผ่านนี้จะช่วยในการประเมินผลกระทบของกระบวนการดังกล่าว ในไปป์ไลน์การรวบรวมเนื้อหาที่หลากหลายโดยทำให้เนื้อหาถูกต้องตามกฎหมาย คู่กรณีที่ได้รับการสนับสนุน ในระยะยาว

ตัวเลือก

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

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

รูปแบบฟิวส์ (ลบควอนไลซ์ การดำเนินการจุดลอยตัว และการหาจำนวน) ในรูปแบบการดำเนินการที่ปรับขนาดได้ 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 ที่แปลงปริมาณแล้วเป็นรูปแบบ (ลดปริมาณ การดำเนินการจุดลอยตัว และปรับปริมาณ)

แยกโปรแกรมที่แปลงค่า StableHLO โดยใช้หน่วยวัดปริมาณ/แยกปริมาณด้วยเครื่องแบบ การดำเนินงาน ตัวอย่างเช่น โปรแกรมต่อไปนี้

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<...>' หรือ ไปยังเมธอดการสร้างบัตร รายการประเภทการปรับเกณฑ์การค้นหาต้องระบุฟิลด์ ประเภทของอาร์กิวเมนต์ทั้งหมดกับเมธอด 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 ถูกต้องตามกฎหมายเป็น StableHLO

-vhlo-to-version

แปลง VHLO เป็นเวอร์ชันต่างๆ

ตัวเลือก

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