24#ifndef TVM_TOPI_NN_INSTANCE_NORM_H_
25#define TVM_TOPI_NN_INSTANCE_NORM_H_
54 int channel_axis,
const ffi::Array<int64_t>& axis,
double epsilon,
55 std::string name =
"T_instance_norm", std::string tag =
kInjective) {
60 <<
"instance_norm: data, gamma and beta must have the same type";
62 <<
"instance_norm: only support float32 and float16 for now";
65 auto ndim = data->shape.size();
75 f32_ty](
const ffi::Array<PrimVar>& indices) {
80 for (
size_t i = 0;
i < ndim; ++
i) {
117 for (
int i = 0,
n =
static_cast<int>(indices.size());
i <
n; ++
i) {
125 channel = indices[channel_axis];
133 if (beta.defined()) {
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
Definition base_expr.h:137
static PrimType Float(int bits, int lanes=1)
Construct a floating-point type with fixed lanes.
ExpectedType ty() const
Definition base_expr.h:380
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Managed reference to CastNode.
Definition expr.h:95
Tensor structure representing a possible input, or intermediate computation result.
Definition tensor.h:98
Checked scalar view over a VarNode.
Definition var.h:46
Tensor expression language DSL.
Definition extracted_task.h:33
PrimVar var(std::string name_hint, PrimType t=PrimType::Int(32))
Construct a new Var expression.
Tensor compute(ffi::Array< PrimExpr > shape, FCompute fcompute, std::string name="tensor", std::string tag="", ffi::Map< ffi::String, ffi::Any > attrs={})
Construct a new tensor by computing over shape, using the computation rule: result_tensor[axis] = fco...
@ kCommReduce
Communicative reduction. Cannot be directly parallelized.
Definition var.h:104
PrimExpr MakeConst(PrimType dtype, ValueType value, Span span=Span())
Make a const value with certain data type.
Definition op.h:1002
Tensor instance_norm(const Tensor &data, const Tensor &gamma, const Tensor &beta, int channel_axis, const ffi::Array< int64_t > &axis, double epsilon, std::string name="T_instance_norm", std::string tag=kInjective)
Instance normalization.
Definition instance_norm.h:53
ffi::Array< PrimExpr > MakeReduceTargetShape(const std::vector< int > &real_axis, const Tensor &data, bool keepdims, bool atleast1d)
Calculate the target shape for a reduce op.
Definition reduction.h:99
ffi::Array< IterVar > MakeReduceAxes(const std::vector< int > &real_axis, const Tensor &data)
Enumerate the axes for a reduce op.
Definition reduction.h:89
FCommReduce MakeTupleSumReducer()
Create communitive reducer summing over tuples.
Definition reduction.h:601
std::vector< int > GetRealAxis(int ndim, const ffi::Optional< ffi::Array< int64_t > > &axis)
Convert a reduction axis which could be empty or have negative elements into a real axis with valid d...
Definition reduction.h:65
constexpr auto kInjective
Definition tags.h:33
tvm::PrimExpr multiply(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition broadcast.h:227
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
PrimExpr rsqrt(PrimExpr x, Span span=Span())
Definition op.h:759
Operation node can generate one or multiple Tensors.