Skip to content

Commit 583e1d0

Browse files
committed
[Target] Added WithoutHost method
1 parent 8c9573b commit 583e1d0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/tvm/target/target.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ class Target : public ObjectRef {
218218
*/
219219
static Target WithHost(const Target& target, const Target& host);
220220

221+
/*! \return The target with the host stripped out */
222+
Target WithoutHost() const;
223+
221224
/*!
222225
* \brief Returns true if \p this target represents an external codegen. If so,
223226
* \p this->kind->name can be used as the "Compiler" attribute on partitioned functions,

src/target/target.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,16 @@ Map<String, ObjectRef> TargetNode::Export() const {
662662

663663
Optional<Target> TargetNode::GetHost() const { return this->host.as<Target>(); }
664664

665+
Target Target::WithoutHost() const {
666+
if ((*this)->GetHost()) {
667+
auto output = make_object<TargetNode>(*get());
668+
output->host = NullOpt;
669+
return Target(output);
670+
} else {
671+
return *this;
672+
}
673+
}
674+
665675
int TargetNode::GetTargetDeviceType() const {
666676
if (Optional<Integer> device_type = GetAttr<Integer>("target_device_type")) {
667677
return Downcast<Integer>(device_type)->value;

0 commit comments

Comments
 (0)