Files
TheRock/compiler/amd-llvm/mlir/test/Dialect/Tosa/tosa-arith-const-to-tosa-const.mlir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

101 lines
3.6 KiB
MLIR

// RUN: mlir-opt %s --tosa-arith-const-to-tosa-const --split-input-file | FileCheck %s
// CHECK-LABEL: func.func @rewrite_f32_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf32>}> : () -> tensor<2xf32>
// CHECK: return %[[CST]]
func.func @rewrite_f32_tensor() -> tensor<2xf32> {
%c = arith.constant dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf32>
return %c : tensor<2xf32>
}
// -----
// CHECK-LABEL: func.func @rewrite_i32_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<[1, 0, -1]> : tensor<3xi32>}> : () -> tensor<3xi32>
// CHECK: return %[[CST]]
func.func @rewrite_i32_tensor() -> tensor<3xi32> {
%c = arith.constant dense<[1, 0, -1]> : tensor<3xi32>
return %c : tensor<3xi32>
}
// -----
// CHECK-LABEL: func.func @rewrite_i1_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<[true, false]> : tensor<2xi1>}> : () -> tensor<2xi1>
func.func @rewrite_i1_tensor() -> tensor<2xi1> {
%c = arith.constant dense<[true, false]> : tensor<2xi1>
return %c : tensor<2xi1>
}
// -----
// CHECK-LABEL: func.func @rewrite_rank0_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<1.234500e+00> : tensor<f32>}> : () -> tensor<f32>
func.func @rewrite_rank0_tensor() -> tensor<f32> {
%c = arith.constant dense<1.234500e+00> : tensor<f32>
return %c : tensor<f32>
}
// -----
// CHECK-LABEL: func.func @preserve_scalar_i32
// CHECK: %[[CST:.*]] = arith.constant 42 : i32
func.func @preserve_scalar_i32() -> i32 {
%c = arith.constant 42 : i32
return %c : i32
}
// -----
// CHECK-LABEL: func.func @preserve_index_tensor
// CHECK: %[[CST:.*]] = arith.constant dense<[0, 1]> : tensor<2xindex>
func.func @preserve_index_tensor() -> tensor<2xindex> {
%c = arith.constant dense<[0, 1]> : tensor<2xindex>
return %c : tensor<2xindex>
}
// -----
// CHECK-LABEL: func.func @rewrite_resource_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense_resource<blob1> : tensor<4xf32>}> : () -> tensor<4xf32>
func.func @rewrite_resource_tensor() -> tensor<4xf32> {
%c = arith.constant dense_resource<"blob1"> : tensor<4xf32>
return %c : tensor<4xf32>
}
// -----
// CHECK-LABEL: func.func @rewrite_quant_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<[10, 20]> : tensor<2xui8>}> : () -> tensor<2xui8>
func.func @rewrite_quant_tensor() -> tensor<2xui8> {
%c = arith.constant dense<[10, 20]> : tensor<2xui8>
return %c : tensor<2xui8>
}
// -----
// CHECK-LABEL: func.func @rewrite_quant_uniform_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<["10", "20"]> : tensor<2x!quant.uniform<i8:f32, 5.000000e-01>>}> : () -> tensor<2x!quant.uniform<i8:f32, 5.000000e-01>>
func.func @rewrite_quant_uniform_tensor() -> tensor<2x!quant.uniform<i8:f32, 0.5:0>> {
%c = arith.constant dense<["10", "20"]> : tensor<2x!quant.uniform<i8:f32, 0.5:0>>
return %c : tensor<2x!quant.uniform<i8:f32, 0.5:0>>
}
// -----
// CHECK-LABEL: func.func @rewrite_fp8_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<[1.000000e+00, -5.000000e-01]> : tensor<2xf8E4M3FN>}> : () -> tensor<2xf8E4M3FN>
func.func @rewrite_fp8_tensor() -> tensor<2xf8E4M3FN> {
%c = arith.constant dense<[1.0, -0.5]> : tensor<2xf8E4M3FN>
return %c : tensor<2xf8E4M3FN>
}
// -----
// CHECK-LABEL: func.func @rewrite_mxint8_tensor
// CHECK: %[[CST:.*]] = "tosa.const"() <{values = dense<["0x00", "0x7F"]> : tensor<2x!tosa.mxint8>}> : () -> tensor<2x!tosa.mxint8>
func.func @rewrite_mxint8_tensor() -> tensor<2x!tosa.mxint8> {
%c = arith.constant dense<["0x00", "0x7F"]> : tensor<2x!tosa.mxint8>
return %c : tensor<2x!tosa.mxint8>
}