24 #ifndef TVM_TOPI_DETAIL_RAVEL_UNRAVEL_H_
25 #define TVM_TOPI_DETAIL_RAVEL_UNRAVEL_H_
45 inline PrimExpr RavelIndex(Array<PrimExpr> indices, Array<PrimExpr>
shape) {
46 ICHECK_EQ(indices.size(),
shape.size()) <<
"indices and shape must have equal size";
47 if (indices.size() == 0U) {
51 for (
size_t i = 0; i < indices.size(); ++i) {
55 idx = idx *
shape[i] + indices[i];
69 inline Array<PrimExpr> UnravelIndex(PrimExpr idx, 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());
Tensor expression language DSL.
Definition: extracted_task.h:33
Tensor shape(const Tensor &src, DataType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:1913
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
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.