tvm
repr_printer.h
Go to the documentation of this file.
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  */
23 #ifndef TVM_NODE_REPR_PRINTER_H_
24 #define TVM_NODE_REPR_PRINTER_H_
25 
26 #include <tvm/node/functor.h>
27 
28 #include <iostream>
29 
30 namespace tvm {
32 class ReprPrinter {
33  public:
35  std::ostream& stream;
37  int indent{0};
38 
39  explicit ReprPrinter(std::ostream& stream) // NOLINT(*)
40  : stream(stream) {}
41 
43  TVM_DLL void Print(const ObjectRef& node);
45  TVM_DLL void PrintIndent();
46  // Allow registration to be printer.
48  TVM_DLL static FType& vtable();
49 };
50 
55 TVM_DLL void Dump(const runtime::ObjectRef& node);
56 
61 TVM_DLL void Dump(const runtime::Object* node);
62 
63 } // namespace tvm
64 
65 namespace tvm {
66 namespace runtime {
67 // default print function for all objects
68 // provide in the runtime namespace as this is where objectref originally comes from.
69 inline std::ostream& operator<<(std::ostream& os, const ObjectRef& n) { // NOLINT(*)
70  ReprPrinter(os).Print(n);
71  return os;
72 }
73 } // namespace runtime
74 } // namespace tvm
75 #endif // TVM_NODE_REPR_PRINTER_H_
A dynamically dispatched functor on the type of the first argument.
Definition: functor.h:64
int indent
The indentation level.
Definition: repr_printer.h:37
std::ostream & stream
The output stream.
Definition: repr_printer.h:35
ReprPrinter(std::ostream &stream)
Definition: repr_printer.h:39
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
void Print(const ObjectRef &node)
The node to be printed.
base class of all object containers.
Definition: object.h:167
A printer class to print the AST/IR nodes.
Definition: repr_printer.h:32
PrimExpr operator<<(PrimExpr a, PrimExpr b)
left shift operator
Defines the Functor data structures.
void Dump(const runtime::ObjectRef &node)
Dump the node to stderr, used for debug purposes.
Base class of all object reference.
Definition: object.h:511
void PrintIndent()
Print indent to the stream.
static FType & vtable()