mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
Create the memref dialect and move dialect-specific ops from std dialect to this dialect. Moved ops: AllocOp -> MemRef_AllocOp AllocaOp -> MemRef_AllocaOp AssumeAlignmentOp -> MemRef_AssumeAlignmentOp DeallocOp -> MemRef_DeallocOp DimOp -> MemRef_DimOp MemRefCastOp -> MemRef_CastOp MemRefReinterpretCastOp -> MemRef_ReinterpretCastOp GetGlobalMemRefOp -> MemRef_GetGlobalOp GlobalMemRefOp -> MemRef_GlobalOp LoadOp -> MemRef_LoadOp PrefetchOp -> MemRef_PrefetchOp ReshapeOp -> MemRef_ReshapeOp StoreOp -> MemRef_StoreOp SubViewOp -> MemRef_SubViewOp TransposeOp -> MemRef_TransposeOp TensorLoadOp -> MemRef_TensorLoadOp TensorStoreOp -> MemRef_TensorStoreOp TensorToMemRefOp -> MemRef_BufferCastOp ViewOp -> MemRef_ViewOp The roadmap to split the memref dialect from std is discussed here: https://llvm.discourse.group/t/rfc-split-the-memref-dialect-from-std/2667 Differential Revision: https://reviews.llvm.org/D98041
60 lines
1.5 KiB
MLIR
60 lines
1.5 KiB
MLIR
// RUN: mlir-opt %s -tensor-constant-bufferize -split-input-file | FileCheck %s
|
|
|
|
// CHECK-LABEL: module {
|
|
// We check the debug name too since we put some effort into making that readable.
|
|
// The name isn't load-bearing though.
|
|
// CHECK: memref.global "private" constant @__constant_3x4xf32 : memref<3x4xf32> = dense<7.000000e+00>
|
|
// CHECK: @basic
|
|
func @basic() -> tensor<3x4xf32> {
|
|
// CHECK: %[[MEMREF:.*]] = memref.get_global @__constant_3x4xf32 : memref<3x4xf32>
|
|
// CHECK: %[[TENSOR:.*]] = memref.tensor_load %[[MEMREF]]
|
|
%0 = constant dense<7.0> : tensor<3x4xf32>
|
|
// CHECK: return %[[TENSOR]]
|
|
return %0 : tensor<3x4xf32>
|
|
}
|
|
|
|
// CHECK: }
|
|
|
|
// -----
|
|
|
|
// CHECK-LABEL: module {
|
|
|
|
// Only one global is created.
|
|
// CHECK: memref.global
|
|
// CHECK-NOT: memref.global
|
|
func @duplicate_constants() -> (tensor<3x4xf32>, tensor<3x4xf32>) {
|
|
%0 = constant dense<7.0> : tensor<3x4xf32>
|
|
%1 = constant dense<7.0> : tensor<3x4xf32>
|
|
return %0, %1 : tensor<3x4xf32>, tensor<3x4xf32>
|
|
}
|
|
|
|
// CHECK: }
|
|
|
|
// -----
|
|
|
|
// CHECK-LABEL: module {
|
|
|
|
// Two globals are created.
|
|
// CHECK: memref.global
|
|
// CHECK: memref.global
|
|
// CHECK-NOT: memref.global
|
|
func @multiple_constants() -> (tensor<3x4xf32>, tensor<3x4xf32>) {
|
|
%0 = constant dense<7.0> : tensor<3x4xf32>
|
|
%1 = constant dense<8.0> : tensor<3x4xf32>
|
|
return %0, %1 : tensor<3x4xf32>, tensor<3x4xf32>
|
|
}
|
|
|
|
// CHECK: }
|
|
|
|
// -----
|
|
|
|
// CHECK-LABEL: module {
|
|
// We don't convert non-tensor globals.
|
|
// CHECK-NOT: memref.global
|
|
func @non_tensor() {
|
|
%0 = constant 7 : i32
|
|
return
|
|
}
|
|
|
|
// CHECK: }
|