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 | * \file nn.cc |
22 | * \brief Property def of nn operators. |
23 | */ |
24 | |
25 | #include <tvm/relay/attrs/debug.h> |
26 | #include <tvm/relay/op.h> |
27 | #include <tvm/tir/data_layout.h> |
28 | #include <tvm/topi/elemwise.h> |
29 | |
30 | #include <vector> |
31 | |
32 | #include "./op_common.h" |
33 | #include "./type_relations.h" |
34 | |
35 | namespace tvm { |
36 | namespace relay { |
37 | |
38 | TVM_REGISTER_NODE_TYPE(DebugAttrs); |
39 | |
40 | Array<te::Tensor> DebugCompute(const Attrs& attrs, const Array<te::Tensor>& inputs, |
41 | const Type& out_type) { |
42 | return Array<te::Tensor>{topi::identity(inputs[0])}; |
43 | } |
44 | |
45 | RELAY_REGISTER_OP("debug" ) |
46 | .describe(R"code(Enter the interpreter's debugger. |
47 | |
48 | )code" TVM_ADD_FILELINE) |
49 | .set_num_inputs(1) |
50 | .add_argument("program" , "Tuple" , "The program to execute before debugging." ) |
51 | .set_support_level(1) |
52 | .set_attrs_type<DebugAttrs>() |
53 | .add_type_rel("Debug" , IdentityRel) |
54 | .set_attr<TOpPattern>("TOpPattern" , kOpaque) |
55 | .set_attr<FTVMCompute>("FTVMCompute" , DebugCompute); |
56 | |
57 | Expr MakeDebug(Expr expr, String name) { |
58 | auto dattrs = make_object<DebugAttrs>(); |
59 | if (name.size() > 0) { |
60 | dattrs->debug_func = EnvFunc::Get(name); |
61 | } else { |
62 | dattrs->debug_func = EnvFunc(); |
63 | } |
64 | static const Op& op = Op::Get("debug" ); |
65 | return Call(op, {expr}, Attrs(dattrs), {}); |
66 | } |
67 | |
68 | TVM_REGISTER_GLOBAL("relay.op._make.debug" ).set_body_typed(MakeDebug); |
69 | |
70 | } // namespace relay |
71 | } // namespace tvm |
72 | |