-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(//core/conversion/evaluators): Allow ITensors to be wrapped in
IValues Signed-off-by: Naren Dasan <naren@narendasan.com> Signed-off-by: Naren Dasan <narens@nvidia.com>
- Loading branch information
1 parent
8c26a1b
commit 619e345
Showing
12 changed files
with
159 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
config_setting( | ||
name = "use_pre_cxx11_abi", | ||
values = { | ||
"define": "abi=pre_cxx11_abi", | ||
} | ||
) | ||
|
||
cc_library( | ||
name = "tensorcontainer", | ||
hdrs = [ | ||
"TensorContainer.h", | ||
], | ||
srcs = [ | ||
"TensorContainer.cpp", | ||
], | ||
deps = [ | ||
"@tensorrt//:nvinfer", | ||
"//core/util:prelude", | ||
] + select({ | ||
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"], | ||
"//conditions:default": ["@libtorch//:libtorch"], | ||
}), | ||
alwayslink = True, | ||
) | ||
|
||
load("@rules_pkg//:pkg.bzl", "pkg_tar") | ||
|
||
pkg_tar( | ||
name = "include", | ||
package_dir = "core/conversion/tensorcontainer/", | ||
srcs = [ | ||
"TensorContainer.h", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "core/conversion/tensorcontainer/TensorContainer.h" | ||
|
||
namespace trtorch { | ||
namespace core { | ||
namespace conversion { | ||
namespace { | ||
|
||
static auto tensor_container = | ||
torch::class_<TensorContainer>("_eval_ivalue_types", "TensorContainer") | ||
.def(torch::init<int64_t>()) | ||
.def("clone", &TensorContainer::clone); | ||
|
||
} // namespace | ||
} // conversion | ||
} // core | ||
} // trtorch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "NvInfer.h" | ||
#include "torch/custom_class.h" | ||
|
||
namespace trtorch { | ||
namespace core { | ||
namespace conversion { | ||
|
||
struct TensorContainer : torch::CustomClassHolder { | ||
int64_t tensor_; | ||
TensorContainer(int64_t init) : tensor_(init) {} | ||
|
||
c10::intrusive_ptr<TensorContainer> clone() const { | ||
return c10::make_intrusive<TensorContainer>(tensor_); | ||
} | ||
|
||
nvinfer1::ITensor* tensor() { | ||
return reinterpret_cast<nvinfer1::ITensor*>(tensor_); | ||
} | ||
}; | ||
|
||
} // conversion | ||
} // core | ||
} // trtorch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters