Skip to content
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

[Fix bug] torch fusion rule test #85

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def generate_testcases():
if op1 in d1_required_layers or op2 in d1_required_layers:
input_shape = [config['SHAPE_1D']]
else:
input_shape = [config['HW'], config['HW'], config['CIN']]
if implement == "tensorflow":
input_shape = [config['HW'], config['HW'], config['CIN']]
else:
input_shape = [config['CIN'], config['HW'], config['HW']]
bf_cls = type(class_name, (BasicFusion,), {
'name': name,
'cases': cases,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ..utils import read_profiled_results
from nn_meter.builder.utils import merge_info
from nn_meter.builder.backend_meta.utils import Latency
logging = logging.getLogger("nn-Meter")


class BaseTestCase:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def analyze(self, profile_results):
latency = {key: str(value) for key, value in rule.latency.items()}
result[name]['latency'] = latency

result[name]['obey'] = obey
result[name]['obey'] = bool(obey)

return result
5 changes: 3 additions & 2 deletions nn_meter/builder/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def copy_to_workspace(backend_type, workspace_path, backendConfigFile = None):
os.makedirs(os.path.join(workspace_path, 'configs'), exist_ok=True)

# backend config
if backend_type == 'customized' and backendConfigFile:
copyfile(backendConfigFile, os.path.join(workspace_path, 'configs', 'backend_config.yaml'))
if backend_type == 'customized':
if backendConfigFile:
copyfile(backendConfigFile, os.path.join(workspace_path, 'configs', 'backend_config.yaml'))
else:
if backend_type == 'tflite':
config_name = __backend_tflite_cfg_filename__
Expand Down
8 changes: 4 additions & 4 deletions nn_meter/builder/nn_modules/torch_networks/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ def forward(self, x):

class FC(BaseOperator):
def get_model(self):
cin = self.input_shape[0]
cout = self.input_shape[0] if "COUT" not in self.config else self.config["COUT"]
cin = self.input_shape[-1]
cout = self.input_shape[-1] if "COUT" not in self.config else self.config["COUT"]
return nn.Linear(cin, cout)

def get_output_shape(self):
cout = self.input_shape[0] if "COUT" not in self.config else self.config["COUT"]
return [cout] + self.input_shape[1:]
cout = self.input_shape[-1] if "COUT" not in self.config else self.config["COUT"]
return self.input_shape[:-1] + [cout]

#-------------------- activation function --------------------#

Expand Down