24#ifndef TVM_TOPI_DETAIL_RAVEL_UNRAVEL_H_
25#define TVM_TOPI_DETAIL_RAVEL_UNRAVEL_H_
45inline PrimExpr RavelIndex(ffi::Array<PrimExpr> indices, ffi::Array<PrimExpr>
shape) {
47 if (indices.size() == 0U) {
51 for (
size_t i = 0;
i < indices.size(); ++
i) {
69inline ffi::Array<PrimExpr> UnravelIndex(
PrimExpr idx, ffi::Array<PrimExpr>
shape) {
70 std::vector<PrimExpr> indices;
72 for (
int i =
static_cast<int>(
shape.size()) - 1;
i >= 0; --
i) {
76 std::reverse(indices.begin(), indices.end());
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Tensor expression language DSL.
Definition extracted_task.h:33
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
PrimExpr indexdiv(PrimExpr a, PrimExpr b, Span span=Span())
compute floor(a / b) where a and b are non-negative.
PrimExpr indexmod(PrimExpr a, PrimExpr b, Span span=Span())
compute the remainder floor(a / b) where a and b are non-negative.
Operation node can generate one or multiple Tensors.