def testMLIRFunctionCreation(self): self.setUp() module = E.MLIRModule() t = module.make_scalar_type("f32") m = module.make_memref_type(t, [3, 4, -1, 5]) printWithCurrentFunctionName(str(t)) print(str(m)) print(str(module.make_function("copy", [m, m], []))) print(str(module.make_function("sqrtf", [t], [t])))
def testFunctionDeclaration(self): module = E.MLIRModule() boolAttr = self.module.boolAttr(True) t = module.make_memref_type(self.f32Type, [10]) t_llvm_noalias = t({"llvm.noalias": boolAttr}) t_readonly = t({"readonly": boolAttr}) f = module.declare_function("foo", [t, t_llvm_noalias, t_readonly], []) str = module.__str__() self.assertIn( "func @foo(memref<10xf32>, memref<10xf32> {llvm.noalias: true}, memref<10xf32> {readonly: true})", str)
def testMLIRScalarTypes(self): self.setUp() module = E.MLIRModule() printWithCurrentFunctionName(str(module.make_scalar_type("bf16"))) print(str(module.make_scalar_type("f16"))) print(str(module.make_scalar_type("f32"))) print(str(module.make_scalar_type("f64"))) print(str(module.make_scalar_type("i", 1))) print(str(module.make_scalar_type("i", 8))) print(str(module.make_scalar_type("i", 32))) print(str(module.make_scalar_type("i", 123))) print(str(module.make_scalar_type("index")))
def testMLIRScalarTypes(self): self.setUp() module = E.MLIRModule() printWithCurrentFunctionName(str(module.make_type("bf16"))) print(str(module.make_type("f16"))) print(str(module.make_type("f32"))) print(str(module.make_type("f64"))) print(str(module.make_type("i1"))) print(str(module.make_type("i8"))) print(str(module.make_type("i32"))) print(str(module.make_type("i123"))) print(str(module.make_type("index")))
def testMLIRFunctionCreation(self): module = E.MLIRModule() t = module.make_scalar_type("f32") self.assertIn("f32", t.__str__()) m = module.make_memref_type(t, [3, 4, -1, 5]) self.assertIn("memref<3x4x?x5xf32>", m.__str__()) f = module.make_function("copy", [m, m], []) self.assertIn( "func @copy(%arg0: memref<3x4x?x5xf32>, %arg1: memref<3x4x?x5xf32>) {", f.__str__()) f = module.make_function("sqrtf", [t], [t]) self.assertIn("func @sqrtf(%arg0: f32) -> f32", f.__str__())
def testMLIRScalarTypes(self): module = E.MLIRModule() t = module.make_scalar_type("bf16") self.assertIn("bf16", t.__str__()) t = module.make_scalar_type("f16") self.assertIn("f16", t.__str__()) t = module.make_scalar_type("f32") self.assertIn("f32", t.__str__()) t = module.make_scalar_type("f64") self.assertIn("f64", t.__str__()) t = module.make_scalar_type("i", 1) self.assertIn("i1", t.__str__()) t = module.make_scalar_type("i", 8) self.assertIn("i8", t.__str__()) t = module.make_scalar_type("i", 32) self.assertIn("i32", t.__str__()) t = module.make_scalar_type("i", 123) self.assertIn("i123", t.__str__()) t = module.make_scalar_type("index") self.assertIn("index", t.__str__())
def setUp(self): self.module = E.MLIRModule() self.boolType = self.module.make_scalar_type("i", 1) self.i32Type = self.module.make_scalar_type("i", 32) self.f32Type = self.module.make_scalar_type("f32") self.indexType = self.module.make_index_type()
def setUp(self): self.module = E.MLIRModule() self.boolType = self.module.make_type("i1") self.i32Type = self.module.make_type("i32") self.f32Type = self.module.make_type("f32") self.indexType = self.module.make_index_type()