1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20/*!
21 *
22 * \file tvm/relay/op/make_op.h
23 * \brief Header of internal operator functions
24 * to assist in creating ops in C++
25 */
26#ifndef TVM_RELAY_OP_MAKE_OP_H_
27#define TVM_RELAY_OP_MAKE_OP_H_
28
29#include <tvm/relay/expr.h>
30#include <tvm/relay/op.h>
31#include <tvm/tir/index_map.h>
32
33// Include Templated Make Functions
34#include "nn/convolution_make.h"
35#include "nn/pooling.h"
36
37namespace tvm {
38namespace relay {
39
40Expr MakeBroadCastTo(Expr data, Array<Integer> shape);
41
42Expr MakeCast(Expr data, DataType dtype);
43
44Expr MakeClip(Expr a, double a_min, double a_max);
45
46Expr MakeConcatenate(Expr data, int axis);
47
48Expr MakeMatmul(Expr tensor_a, Expr tensor_b, IndexExpr units, DataType out_dtype, bool transpose_a,
49 bool transpose_b);
50
51Expr MakeDense(Expr data, Expr weight, IndexExpr units, DataType out_dtype);
52
53Expr MakeBatchMatmul(Expr lhs, Expr rhs, DataType out_dtype, bool transpose_a, bool transpose_b);
54
55Expr MakeExpandDims(Expr data, int axis, int num_newaxis);
56
57Expr MakeFixedPointMultiplyPerAxis(Expr x, Expr m, Expr lshift, Expr rshift,
58 bool is_lshift_required, bool is_rshift_required,
59 Array<Integer> axis);
60
61Expr MakeFull(Expr fill_value, Array<Integer> shape, DataType dtype);
62
63Expr MakeLayoutTransform(Expr data, String src_layout, String dst_layout);
64
65Expr MakeMetaScheduleLayoutTransform(Expr data, tir::IndexMap index_map);
66
67Expr MakeAutoSchedulerLayoutTransform(Expr data, String src_layout, String dst_layout);
68
69Expr MakeOnes(Array<Integer> shape, DataType dtype);
70
71Expr MakePad(Expr data, Array<Array<Integer>> pad_width, Expr pad_value, String pad_mode);
72
73Expr MakeReduce(Expr data, Array<Integer> axis, bool keepdims, bool exclude, String op_name);
74
75Expr MakeRepeat(Expr data, int repeats, int axis);
76
77Expr MakeReshape(Expr data, Array<Integer> newshape, bool allowzero = false);
78
79Expr MakeReshapeLike(Expr lhs, Expr rhs, int lhs_begin, Integer lhs_end, int rhs_begin,
80 Integer rhs_end);
81
82Expr MakeSplit(Expr data, ObjectRef indices_or_sections, int axis);
83
84Expr MakeSqueeze(Expr data, Array<Integer> axis);
85
86Expr MakeStack(Expr data, int axis);
87
88Expr MakeTranspose(Expr data, Array<Integer> axes);
89
90Expr MakeStridedSlice(Expr data, Array<Integer> begin, Array<Integer> end, Array<Integer> strides,
91 String slice_mode,
92 Optional<Array<Integer>> axes = NullValue<Array<Integer>>());
93
94Expr MakeTile(Expr data, Array<Integer> reps);
95
96Expr MakeTopK(Expr data, int k, int axis, String ret_type, bool is_ascend, DataType dtype);
97
98Expr MakeUpSampling(Expr data, double scale_h, double scale_w, String layout, String method,
99 bool align_corners);
100
101Expr MakeUpSampling3D(Expr data, double scale_d, double scale_h, double scale_w, String layout,
102 String method, String coordinate_transformation_mode);
103
104Expr MakeVariance(Expr data, Expr mean, Array<Integer> axis, bool keepdims, bool exclude,
105 bool unbiased);
106
107Expr MakeZeros(Array<Integer> shape, DataType dtype);
108
109Expr MakeOneHot(Expr indices, Expr on_value, Expr off_value, int depth, int axis, DataType dtype);
110
111Expr MakeResize2D(Expr data, Array<IndexExpr> size, Array<FloatImm> roi, String layout,
112 String method, String coordinate_transformation_mode, String rounding_method,
113 double cubic_alpha, int cubic_exclude, double extrapolation_value,
114 DataType out_dtype);
115
116Expr MakeSparseToDense(Expr indices, Array<Integer> output_shape, Expr values, Expr default_value);
117
118Expr MakeArange(Expr start, Expr stop, Expr step, DataType dtype);
119
120Expr MakeShapeOf(Expr data, DataType dtype);
121
122Expr MakeTake(Expr data, Expr indices, Integer batch_dims, Integer axis, String mode);
123
124Expr MakeBiasAdd(Expr data, Expr bias, int axis);
125
126} // namespace relay
127} // namespace tvm
128#endif // TVM_RELAY_OP_MAKE_OP_H_
129