help: create an AllocOp with OpBuilder

99 views
Skip to first unread message

Ruiqin Tian

unread,
Apr 8, 2020, 6:35:22 PM4/8/20
to ml...@tensorflow.org
Hi,

I am writing this email to ask for help!  Thank you in advance.

I want to create an AllocOp with OpBuilder and insert it in the input code. Is anyone give me any help or suggestions on this? The AllocOp I want to create is as follows:
  %1 = alloc() : memref <10x20xf64>

 I am trying to use builder.create<AllocOp>(Location location, MemRefType memrefType, ArrayRef<Value> operands). Can any one give me help about how to set the correct second and the third parameter to this create<AllocOp> function call


Thank you very much!

Best,
Ruiqin Tian
PhD student, College of William and Mary

Mehdi AMINI

unread,
Apr 8, 2020, 8:46:38 PM4/8/20
to Ruiqin Tian, MLIR
Hi,

If you have general questions on MLIR that aren't directly related to TensorFlow, then the "community" channels indicated on https://mlir.llvm.org are probably better.

To answer your question, the snippet of code you showed has an alloc that does not take any operand, so you won't call this builder but the one without operands:

 builder.create<AllocOp>(Location location, MemRefType memrefType)

The only thing you need to do is create a MemRefType for <10x20xf64> first, so something like this (I haven't tried to compile this):
 
  FloatType f64Type = FloatType::getF64(ctx);
  MemRefType memrefType = MemRefType::get({10 20}, f64Type);
  AllocOp alloc = builder.create<AllocOp>(loc, memrefType);

Best,

-- 
Mehdi



--
You received this message because you are subscribed to the Google Groups "MLIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/CAPA0TLoYhzkT4nKZZoTUyty%3D%3D%3DqkfY_ZfwXsqsYjT3_qiU%3DaTQ%40mail.gmail.com.

Ruiqin Tian

unread,
Apr 10, 2020, 7:42:24 PM4/10/20
to Mehdi AMINI, MLIR
Hi Mehdi,

Thank you so much for your help! The code you provided to me is so useful! 

And also thank you for the recommendation of the mlir community!

Best,
Ruiqin
Reply all
Reply to author
Forward
0 new messages