-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Abhiram Iyer <[email protected]> Signed-off-by: Abhiram Iyer <[email protected]>
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "torch/torch.h" | ||
#include "core/util/prelude.h" | ||
#include "core/conversion/converters/converters.h" | ||
|
||
namespace trtorch { | ||
namespace core { | ||
namespace conversion { | ||
namespace converters { | ||
namespace impl { | ||
namespace { | ||
|
||
auto interpolate_registrations = RegisterNodeConversionPatterns() | ||
.pattern({ | ||
"aten::upsample_nearest2d(Tensor self, int[2] output_size, float? scales_h=None, float? scales_w=None) -> (Tensor)", | ||
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool { | ||
auto in = args[0].ITensor(); | ||
|
||
auto shape = util::toVec(in->getDimensions()); | ||
|
||
LOG_DEBUG("Shape of input is" << in); | ||
|
||
std::cout << "TEST!" << std::endl; | ||
|
||
return true; | ||
} | ||
}); | ||
|
||
|
||
} // namespace | ||
} // namespace impl | ||
} // namespace converters | ||
} // namespace conversion | ||
} // namespace core | ||
} // namespace 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,70 @@ | ||
# import torch.nn as nn | ||
# import torch | ||
|
||
# class FeatureExtractor(nn.Module): | ||
# def __init__(self): | ||
# super(FeatureExtractor, self).__init__() | ||
# self.conv1 = nn.Conv2d(1, 6, 3) | ||
# self.conv2 = nn.Conv2d(6, 16, 3) | ||
|
||
# def forward(self, x): | ||
# x = torch.max_pool2d(torch.relu(self.conv1(x)), (2, 2)) | ||
# x = torch.max_pool2d(torch.relu(self.conv2(x)), 2) | ||
|
||
# return x | ||
|
||
# class Classifier(nn.Module): | ||
# def __init__(self): | ||
# super(Classifier, self).__init__() | ||
|
||
# self.fc1 = nn.Linear(16*6*6, 120) | ||
# self.fc2 = nn.Linear(120, 84) | ||
# self.fc3 = nn.Linear(84, 10) | ||
|
||
# def forward(self, x): | ||
# x = torch.flatten(x, 1) | ||
# x = torch.relu(self.fc1(x)) | ||
# x = torch.relu(self.fc2(x)) | ||
# x = self.fc3(x) | ||
|
||
# return x | ||
|
||
# class LeNet(nn.Module): | ||
# def __init__(self): | ||
# super(LeNet, self).__init__() | ||
# self.feat = FeatureExtractor() | ||
# self.classifier = Classifier() | ||
|
||
# def forward(self, x): | ||
# x = self.feat(x) | ||
# x = self.classifier(x) | ||
|
||
# return x | ||
|
||
# model = LeNet() | ||
# model.eval() | ||
# traced_model = torch.jit.trace(model, torch.empty([1, 1, 32, 32])) | ||
# torch.jit.save(traced_model, 'traced_model.ts') | ||
# torch.jit.save(torch.jit.script(model), 'script_model.ts') | ||
|
||
|
||
import torch.nn as nn | ||
import torch | ||
import torch.nn.functional as F | ||
#import trtorch | ||
|
||
class Interp(nn.Module): | ||
def __init__(self): | ||
super(Interp, self).__init__() | ||
|
||
def forward(self, x): | ||
return F.interpolate(x, scale_factor=(5,5), mode='nearest') | ||
|
||
model = Interp() | ||
model.eval() | ||
trace = torch.jit.trace(model, torch.empty([1, 1, 2, 2])) | ||
torch.jit.save(trace, 'trace.ts') | ||
|
||
#trtorch.check_method_op_support(trace, "forward") | ||
|
||
|