24#ifndef TVM_TOPI_DETAIL_EXTERN_H_
25#define TVM_TOPI_DETAIL_EXTERN_H_
46using FExtern = std::function<
PrimExpr(ffi::Array<BufferVar>, ffi::Array<BufferVar>)>;
65inline ffi::Array<Tensor> make_extern(
const ffi::Array<ffi::Array<PrimExpr>>&
out_shapes,
67 const ffi::Array<Tensor>& inputs, FExtern
fextern,
68 std::string name, std::string tag,
69 ::tvm::ffi::Map<ffi::String, ffi::Any> attrs) {
71 <<
"make_extern: out_shapes and out_types must have equal size";
73 ffi::Array<BufferVar> input_placeholders;
74 for (
auto t : inputs) {
77 ffi::Array<BufferVar> output_placeholders;
82 auto body =
fextern(input_placeholders, output_placeholders);
85 auto op =
ExternOp(name, tag, attrs, inputs, input_placeholders, output_placeholders,
body_stmt);
87 ffi::Array<Tensor> outputs;
88 for (
size_t i = 0;
i < output_placeholders.size(); ++
i) {
89 outputs.push_back(op.output(
i));
107 if (
buf->strides.size() > 0) {
131inline PrimExpr call_packed(ffi::Array<Expr> args) {
Managed reference to CallNode.
Definition expr.h:474
Managed reference to ExprNode.
Definition base_expr.h:335
static IntImm Int32(int64_t value, Span span=Span())
Construct a scalar int32 constant.
Definition expr.h:528
static PointerType VoidPointerTy(ffi::String storage_scope="")
Construct an opaque pointer with void element type.
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
Definition base_expr.h:137
static PrimType Int(int bits, int lanes=1)
Construct a signed integer type with fixed lanes.
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Managed reference to ExternOpNode.
Definition operation.h:388
Checked zero-state view over an ordinary VarNode with BufferType.
Definition buffer.h:179
Managed reference to EvaluateNode.
Definition stmt.h:356
Tensor expression language DSL.
Definition extracted_task.h:33
const Op & tvm_stack_make_shape()
Allocate a shape tuple on stack, return the handle.
const Op & tvm_call_packed()
See pesudo code.
const Op & tvm_stack_make_array()
Allocate a Tensor(DLTensor) on stack, return the handle.
BufferVar decl_buffer(ffi::Array< PrimExpr > shape, PrimType dtype=PrimType::Float(32), ffi::String name="buffer", ffi::String storage_scope="", Span span=Span())
Construct a new buffer given shape, and dtype.
PrimExpr MakeConst(PrimType dtype, ValueType value, Span span=Span())
Make a const value with certain data type.
Definition op.h:1002
Tensor shape(const Tensor &src, PrimType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition transform.h:2009
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
Operation node can generate one or multiple Tensors.