-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example tensors #616
Example tensors #616
Conversation
Signed-off-by: Naren Dasan <naren@narendasan.com> Signed-off-by: Naren Dasan <narens@nvidia.com>
Signed-off-by: Naren Dasan <naren@narendasan.com> Signed-off-by: Naren Dasan <narens@nvidia.com>
Signed-off-by: Naren Dasan <naren@narendasan.com> Signed-off-by: Naren Dasan <narens@nvidia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to C++ style guidelines:
diff --git a/workspace/cpp/src/compile_spec.cpp b/tmp/changes.txt
index 9521166..bd2de94 100644
--- a/workspace/cpp/src/compile_spec.cpp
+++ b/tmp/changes.txt
@@ -294,7 +294,9 @@ CompileSpec::Input::Input(at::Tensor tensor) {
this->shape = tensor.sizes().vec();
this->dtype = tensor.scalar_type();
this->explicit_set_dtype = true;
- TRTORCH_ASSERT(tensor.is_contiguous(at::MemoryFormat::ChannelsLast) || tensor.is_contiguous(at::MemoryFormat::Contiguous), "Tensor does not have a supported contiguous memory format, supported formats are contiguous or channel_last");
+ TRTORCH_ASSERT(
+ tensor.is_contiguous(at::MemoryFormat::ChannelsLast) || tensor.is_contiguous(at::MemoryFormat::Contiguous),
+ "Tensor does not have a supported contiguous memory format, supported formats are contiguous or channel_last");
at::MemoryFormat frmt;
if (tensor.is_contiguous(at::MemoryFormat::Contiguous)) {
frmt = at::MemoryFormat::Contiguous;
diff --git a/workspace/tests/cpp/test_example_tensors.cpp b/tmp/changes.txt
index 2d82ed3..f0f509f 100644
--- a/workspace/tests/cpp/test_example_tensors.cpp
+++ b/tmp/changes.txt
@@ -21,4 +21,3 @@ INSTANTIATE_TEST_SUITE_P(
CompiledModuleForwardIsCloseSuite,
CppAPITests,
testing::Values(PathAndInSize({"tests/modules/resnet18_traced.jit.pt", {{1, 3, 224, 224}}, 2e-5})));
-
ERROR: Some files do not conform to style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
Reformatting /workspace/tests/modules/hub.py
Reformatting /workspace/tests/py/test_ptq_to_backend.py
Reformatting /workspace/tests/py/test_to_backend_api.py
Reformatting /workspace/tests/py/test_trt_intercompatability.py
--- /workspace/tests/py/test_api.py (original)
+++ /workspace/tests/py/test_api.py (reformatted)
@@ -88,15 +88,12 @@
self.assertTrue(same < 2e-2)
def test_device(self):
- compile_spec = {
- "inputs": [self.input],
- "device": trtorch.Device("gpu:0"),
- "enabled_precisions": {torch.float}
- }
-
- trt_mod = trtorch.compile(self.scripted_model, compile_spec)
- same = (trt_mod(self.input) - self.scripted_model(self.input)).abs().max()
- self.assertTrue(same < 2e-2)
+ compile_spec = {"inputs": [self.input], "device": trtorch.Device("gpu:0"), "enabled_precisions": {torch.float}}
+
+ trt_mod = trtorch.compile(self.scripted_model, compile_spec)
+ same = (trt_mod(self.input) - self.scripted_model(self.input)).abs().max()
+ self.assertTrue(same < 2e-2)
+
class TestCompileHalf(ModelTestCase):
Reformatting /workspace/tests/py/test_qat_trt_accuracy.py
Reformatting /workspace/tests/py/test_ptq_trt_calibrator.py
Reformatting /workspace/tests/py/model_test_case.py
Reformatting /workspace/tests/py/test_ptq_dataloader_calibrator.py
Reformatting /workspace/tests/py/test_api_dla.py
Reformatting /workspace/tests/py/test_multi_gpu.py
Reformatting /workspace/tests/py/test_api.py
ERROR: Some files do not conform to style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to C++ style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to Python style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Tests pass
Description
Adds a new convience constructor to both Python and C++ APIs to allow users to provide example tensors to implicitly set shape, dtype and layout. Does not allow for dynamic shape, there the existing Input constructors should be used
Fixes #514
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: