24#ifndef TVM_TOPI_NN_DENSE_H_
25#define TVM_TOPI_NN_DENSE_H_
49 const ffi::Optional<tvm::te::Tensor>& bias,
51 TVM_FFI_ICHECK_EQ(data->shape.size(), 2) <<
"dense requires 2-D data";
52 TVM_FFI_ICHECK_EQ(weight->shape.size(), 2) <<
"dense requires 2-D weight";
53 if (bias.has_value()) {
54 TVM_FFI_ICHECK_EQ(bias.value()->shape.size(), 1) <<
"dense requires 1-D bias";
57 auto batch = data->shape[0];
58 auto in_dim = data->shape[1];
59 auto out_dim = weight->shape[0];
70 if (bias.has_value()) {
Definition base_expr.h:161
Checked scalar view over a VarNode.
Definition expr.h:742
Range container
Definition expr.h:1025
Tensor structure representing a possible input, or intermediate computation result.
Definition tensor.h:111
PrimExpr sum(PrimExpr source, ffi::Array< s_tir::IterVar > axis, ffi::Array< PrimExpr > init={}, Location loc=UnknownLoc())
sum of source expression over axis
TVM_TIRX_DLL PrimExpr cast(PrimType t, PrimExpr value, Location loc=UnknownLoc())
cast value to type.
Tensor expression language DSL.
Definition extracted_task.h:33
IterVar reduce_axis(Range dom, std::string name="rv")
Create a new IterVar for reduction operations.
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...
tvm::te::Tensor dense(const tvm::te::Tensor &data, const tvm::te::Tensor &weight, const ffi::Optional< tvm::te::Tensor > &bias, const PrimType &out_dtype)
Creates an operation that calculates data * weight^T + bias.
Definition dense.h:48
constexpr auto kBroadcast
Definition tags.h:36
tvm::te::Tensor matmul(const tvm::te::Tensor &A, const tvm::te::Tensor &B, bool trans_a=false, bool trans_b=false, std::string name="T_matmul", std::string tag=kMatMul)
Creates an operation that calculates a matrix multiplication (row-major notation): A(i,...
Definition transform.h:1638
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
Operation node can generate one or multiple Tensors.