Skip to content

Instantly share code, notes, and snippets.

@cathyzhyi
Created March 18, 2024 16:42
Show Gist options
  • Save cathyzhyi/729d42df82df4afe63b8dbecd57025a5 to your computer and use it in GitHub Desktop.
Save cathyzhyi/729d42df82df4afe63b8dbecd57025a5 to your computer and use it in GitHub Desktop.
func.func @tensor_pad_2d_f32(%arg0: tensor<?x?xf32>) -> tensor<?x?xf32> {
%0 = arith.constant dense<0.0> : tensor<f32>
%1 = "stablehlo.pad"(%arg0, %0) {
edge_padding_high = array<i64: 2, 3>,
edge_padding_low = array<i64: 4, 5>,
interior_padding = array<i64: 2, 3>
} : (tensor<?x?xf32>, tensor<f32>) -> tensor<?x?xf32>
return %1 : tensor<?x?xf32>
}
func.func @tensor_pad_3d_i32(%arg0: tensor<?x?x?xi32>) -> tensor<?x?x?xi32> {
%0 = arith.constant dense<0> : tensor<i32>
%1 = "stablehlo.pad"(%arg0, %0) {
edge_padding_high = array<i64: 2, 3, 4>,
edge_padding_low = array<i64: 4, 5, 4>,
interior_padding = array<i64: 2, 3, 1>
} : (tensor<?x?x?xi32>, tensor<i32>) -> tensor<?x?x?xi32>
return %1 : tensor<?x?x?xi32>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment