import sys import os sys.path.append(os.environ['MLIR_LIBRARY_PATH']) import mlir # Get block from input file. mlir.registerAllDialects() ctx = mlir.Context() ctx.allowUnregisteredDialects(True) sourcemgr = mlir.SourceMgr() module = mlir.Module("./test_block.mlir", ctx, sourcemgr) region = module.getOperation().getRegion(0) block = region.front() front_region = block.front().getRegion(0) # Test Block::getParent() def test_getParent(): return block.getParent() # Test Block::getParentOp() def test_getParentOp(): return block.getParentOp() # Test Block::isEntryBlock() def test_isEntryBlock(): return front_region.back().isEntryBlock() # Test Block::args_empty() def test_args_empty(): return front_region.back().args_empty()
def test_constructor(): mlir.registerAllDialects() ctx = mlir.Context() sourcemgr = mlir.SourceMgr() module = mlir.Module("./test_input.mlir", ctx, sourcemgr) return module
import sys import os sys.path.append(os.environ['MLIR_LIBRARY_PATH']) import mlir # Get region from milr file. mlir.registerAllDialects() ctx = mlir.Context() ctx.allowUnregisteredDialects(True) sourcemgr = mlir.SourceMgr() module = mlir.Module("./test_region.mlir", ctx, sourcemgr) operation = module.getOperation() region = operation.getRegion(0) block = region.front() front_region = block.front().getRegion(0) # Test Region::getContext() def test_getContext(): return region.getContext() # Test Region::getParentRegion() def test_getParentRegion(): return front_region.getParentRegion() # Test Region::getParentOp() def test_getParentOp(): operation = region.getParentOp() return operation.getName() # Test Region::getRegionNumber() def test_getRegionNumber():
import sys import os sys.path.append(os.environ['MLIR_LIBRARY_PATH']) import mlir # Get operation from milr file. mlir.registerAllDialects() ctx = mlir.Context() ctx.allowUnregisteredDialects(True) sourcemgr = mlir.SourceMgr() module = mlir.Module("./test_operation.mlir", ctx, sourcemgr) operation = module.getOperation() region = operation.getRegion(0) block = region.front() test_operation = block.front() # Test Operation::getName() def test_getName(): return operation.getName() # Test Operation::isRegistered() def test_isRegistered(): return operation.isRegistered() # Test Operation::getBlock() def test_getBlock(): return test_operation.getBlock()
import sys import os sys.path.append(os.environ['MLIR_LIBRARY_PATH']) import mlir # Construct Module with context. ctx = mlir.Context() module = mlir.Module(ctx) # Get operation twice to test ownership. operation = module.getOperation() name = operation.getName() same_operation = module.getOperation() same_name = same_operation.getName() # Test Module constructor with MLIRContext def test_constructor(): return module # Test Module::getOperation() def test_getOperation(): return_list = [] return_list.append(name) return_list.append(same_name) return return_list