Skip to content

Commit ac068d7

Browse files
committed
[FFI][REFACTOR] Cleanup namespace
This PR cleansup the namespace to ensure all ffi classes are accessed through ffi:: namespace. It will helps to cleanup the ffi package before isolation.
1 parent 170302b commit ac068d7

File tree

877 files changed

+15206
-14367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

877 files changed

+15206
-14367
lines changed

apps/hexagon_launcher/launcher_core.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ tvm::runtime::Module load_module(const std::string& file_name) {
163163
return tvm::runtime::Module();
164164
}
165165

166-
std::ostream& operator<<(std::ostream& os, const tvm::Array<tvm::String>& strings) {
166+
std::ostream& operator<<(std::ostream& os, const tvm::ffi::Array<tvm::ffi::String>& strings) {
167167
os << '[';
168168
for (int i = 0, e = strings.size(); i != e; ++i) {
169169
if (i != 0) os << ',';
@@ -191,7 +191,7 @@ tvm::runtime::Module create_graph_executor(const std::string& graph_json,
191191

192192
tvm::runtime::Module create_aot_executor(tvm::runtime::Module factory_module, tvm::Device device) {
193193
tvm::ffi::Function list_modules = get_module_func(factory_module, "list_module_names");
194-
tvm::Array<tvm::String> module_names = list_modules();
194+
tvm::ffi::Array<tvm::ffi::String> module_names = list_modules();
195195
if (module_names.size() != 1) {
196196
LOG(WARNING) << __func__ << ": expecting single module, got: " << module_names << ", using "
197197
<< module_names[0];

apps/ios_rpc/tvmrpc/TVMRuntime.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void Init(const std::string& name) {
116116
namespace refl = tvm::ffi::reflection;
117117
refl::GlobalDef().def_packed("ffi.Module.load_from_file.dylib_custom",
118118
[](ffi::PackedArgs args, ffi::Any* rv) {
119-
auto n = make_object<UnsignedDSOLoader>();
119+
auto n = ffi::make_object<UnsignedDSOLoader>();
120120
n->Init(args[0]);
121121
*rv = tvm::ffi::CreateLibraryModule(n);
122122
});

docs/arch/pass_infra.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ needs to be executed when running under a user-provided optimization level. The
9393
.. code:: c++
9494

9595
class PassInfoNode : public Object {
96-
String name;
96+
ffi::String name;
9797
int opt_level;
98-
Array<String> required;
98+
ffi::Array<ffi::String> required;
9999
};
100100

101101
PassContext
@@ -125,11 +125,11 @@ Python APIs to create a compilation pipeline using pass context.
125125
class PassContextNode : public Object {
126126
public:
127127
int opt_level{2};
128-
tvm::Array<tvm::Expr> required_pass;
129-
tvm::Array<tvm::Expr> disabled_pass;
130-
mutable Optional<DiagnosticContext> diag_ctx;
131-
Map<String, Any> config;
132-
Array<instrument::PassInstrument> instruments;
128+
tvm::ffi::Array<tvm::Expr> required_pass;
129+
tvm::ffi::Array<tvm::Expr> disabled_pass;
130+
mutable ffi::Optional<DiagnosticContext> diag_ctx;
131+
ffi::Map<ffi::String, Any> config;
132+
ffi::Array<instrument::PassInstrument> instruments;
133133
};
134134

135135
class PassContext : public NodeRef {
@@ -262,7 +262,7 @@ of passes for execution.
262262
class SequentialPassNode : PassNode {
263263
PassInfo pass_info;
264264
// Passes need to be executed.
265-
Array<Pass> passes;
265+
ffi::Array<Pass> passes;
266266
bool PassEnabled(const PassInfo& info) const;
267267
Module operator()(const Module& mod, const PassContext& pass_ctx) const final;
268268
};
@@ -321,22 +321,22 @@ favorably use Python APIs to create a specific pass object.
321321
Pass CreateFunctionPass(
322322
std::function<Function(Function, IRModule, PassContext)> pass_func,
323323
int opt_level,
324-
String name,
325-
Array<String> required);
324+
ffi::String name,
325+
ffi::Array<ffi::String> required);
326326

327327
Pass CreatePrimFuncPass(
328328
std::function<PrimFunc(PrimFunc, IRModule, PassContext)> pass_func,
329329
int opt_level,
330-
String name,
331-
Array<String> required);
330+
ffi::String name,
331+
ffi::Array<ffi::String> required);
332332

333333
Pass CreateModulePass(
334334
std::function<IRModule(IRModule, PassContext)> pass_func,
335335
int opt_level,
336-
String name,
337-
Array<String> required);
336+
ffi::String name,
337+
ffi::Array<ffi::String> required);
338338

339-
Pass Sequential(tvm::Array<Pass> passes, PassInfo pass_info);
339+
Pass Sequential(tvm::ffi::Array<Pass> passes, PassInfo pass_info);
340340

341341
Pass Registration
342342
^^^^^^^^^^^^^^^^^
@@ -440,7 +440,7 @@ Multiple ``PassInstrument`` instances can be registed into a single
440440

441441
class PassInstrumentNode : public Object {
442442
public:
443-
String name;
443+
ffi::String name;
444444
virtual void EnterPassContext() const = 0;
445445
virtual void ExitPassContext() const = 0;
446446
virtual bool ShouldRun(const IRModule& mod, const transform::PassInfo& info) const = 0;

ffi/include/tvm/ffi/cast.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,5 @@ inline ObjectPtr<BaseType> GetObjectPtr(ObjectType* ptr) {
7373
return details::ObjectUnsafe::ObjectPtrFromUnowned<BaseType>(ptr);
7474
}
7575
} // namespace ffi
76-
77-
using ffi::GetObjectPtr;
78-
using ffi::GetRef;
7976
} // namespace tvm
8077
#endif // TVM_FFI_CAST_H_

ffi/include/tvm/ffi/container/array.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,5 @@ inline constexpr bool type_contains_v<Array<T>, Array<U>> = type_contains_v<T, U
11401140
} // namespace details
11411141

11421142
} // namespace ffi
1143-
1144-
using ffi::Array;
11451143
} // namespace tvm
11461144
#endif // TVM_FFI_CONTAINER_ARRAY_H_

ffi/include/tvm/ffi/container/map.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,5 @@ inline constexpr bool type_contains_v<Map<K, V>, Map<KU, VU>> =
17551755
} // namespace details
17561756

17571757
} // namespace ffi
1758-
1759-
using ffi::Map;
17601758
} // namespace tvm
17611759
#endif // TVM_FFI_CONTAINER_MAP_H_

ffi/include/tvm/ffi/container/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,5 @@ template <typename... V, typename T>
298298
inline constexpr bool type_contains_v<Variant<V...>, T> = (type_contains_v<V, T> || ...);
299299
} // namespace details
300300
} // namespace ffi
301-
302-
using ffi::Variant;
303301
} // namespace tvm
304302
#endif // TVM_FFI_CONTAINER_VARIANT_H_

ffi/include/tvm/ffi/dtype.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ namespace ffi {
3838
* \brief Extension code beyond the DLDataType.
3939
*
4040
* This class is always consistent with the DLPack.
41-
*
42-
* TODO(tvm-team): update to latest DLPack types.
4341
*/
4442
enum DLExtDataTypeCode { kDLExtCustomBegin = 129 };
4543

ffi/include/tvm/ffi/memory.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,5 @@ inline ObjectPtr<ArrayType> make_inplace_array_object(size_t num_elems, Args&&..
225225
}
226226

227227
} // namespace ffi
228-
229-
using ffi::make_object;
230228
} // namespace tvm
231229
#endif // TVM_FFI_MEMORY_H_

ffi/include/tvm/ffi/optional.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,5 @@ class Optional<T, std::enable_if_t<use_ptr_based_optional_v<T>>> : public Object
410410
}
411411
};
412412
} // namespace ffi
413-
414-
using ffi::Optional;
415413
} // namespace tvm
416414
#endif // TVM_FFI_OPTIONAL_H_

0 commit comments

Comments
 (0)