Repository navigation
Train Support #35
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
Train Support #35
Changes from all commits
5dfdb6f
afdaaa7
83dbb6b
b58aeae
c853f52
16996a7
4f38405
463e06f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,11 @@ def __init__(self, validation, arg_attributes): | |
| self.validation = validation | ||
| self.n_arg = len(arg_attributes) | ||
| self.arg_attributes = arg_attributes | ||
| self.arg_use_count = 1 | ||
|
|
||
| def get_argv_idx(self): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 spike를 실행시킬때 validation_wrapper.c 파일에 선언하는 array의 size와 parameter value들이 저장된 path를 command line argument로 넣어주고 있습니다. LLVM kernel caller code를 만들때 현재 몇번째 argument를 사용해야하는지에 대한 counter 함수입니다. |
||
| self.arg_use_count += 1 | ||
| return self.arg_use_count-1 | ||
|
|
||
| def write_header(self): | ||
| self.writeline('#include <stdio.h>') | ||
|
|
@@ -42,29 +47,17 @@ def is_out_arg(self, arg_name): | |
| return LLVMKernelArgs.is_llvm_arg_out(value) | ||
|
|
||
| def load_arg(self): | ||
| self.writeline(f'char file_name[256]{self.ending}') | ||
| self.writeline(f'char path[512]{self.ending}') | ||
| self.writeline(f'sprintf(file_name, "%d.raw", n_call){self.ending}') | ||
| for i, arg_name in enumerate(self.arg_attributes.keys()): | ||
| if self.is_in_arg(arg_name): | ||
| path = os.path.join(self.dump_path, f'arg{i}_1/') | ||
| self.writeline(f'strcpy(path, "{path}"){self.ending}') | ||
| self.writeline(f'strcat(path, file_name){self.ending}') | ||
| self.writeline(f'if(load_arg({arg_name}, sizeof({arg_name}), path) == -1){self.open_bracket}') | ||
| self.writeline(f'if(load_arg({arg_name}, sizeof({arg_name}), argv[{self.get_argv_idx()}]) == -1){self.open_bracket}') | ||
| with self.code.indent(): | ||
| self.writeline(f'return -1{self.ending}') | ||
| self.writeline(self.closed_bracket) | ||
|
|
||
| def dump_arg(self): | ||
| self.writeline(f'sprintf(file_name, "%d.raw", n_call){self.ending}') | ||
| for i, arg_name in enumerate(self.arg_attributes.keys()): | ||
| if self.is_out_arg(arg_name): | ||
| path = os.path.join(self.dump_path, f'{arg_name}/') | ||
| if not os.path.exists(path): | ||
| os.makedirs(path, exist_ok=True) | ||
| self.writeline(f'strcpy(path, "{path}"){self.ending}') | ||
| self.writeline(f'strcat(path, file_name){self.ending}') | ||
| self.writeline(f'if(dump_arg({arg_name}, sizeof({arg_name}), path) == -1){self.open_bracket}') | ||
| self.writeline(f'if(dump_arg({arg_name}, sizeof({arg_name}), argv[{self.get_argv_idx()}]) == -1){self.open_bracket}') | ||
| with self.code.indent(): | ||
| self.writeline(f'return -1{self.ending}') | ||
| self.writeline(self.closed_bracket) | ||
|
|
@@ -79,7 +72,8 @@ def generate_kernel_declare(self): | |
|
|
||
| def generate_args_define(self): | ||
| for arg_name, (_, arg_type, arg_shape) in self.arg_attributes.items(): | ||
| self.writeline(f'{cpp.DTYPE_TO_CPP[arg_type]} {arg_name}[{arg_shape}] __attribute__ ((aligned (4096))){self.ending}') | ||
| self.writeline(f'{cpp.DTYPE_TO_CPP[arg_type]} {arg_name}[atoi(argv[{self.get_argv_idx()}])] __attribute__ ((aligned (4096))){self.ending}') | ||
| self.writeline(self.newline) | ||
|
|
||
| def generate_load_dump_fn(self): | ||
| self.writeline(f'{self.newline}int load_arg(void *arg, int size, const char *path) {self.open_bracket}') | ||
|
|
@@ -116,10 +110,9 @@ def generate_load_dump_fn(self): | |
|
|
||
| def generate_main(self): | ||
| self.writeline(f'{self.newline}int main(int argc, char *argv[]) {self.open_bracket}{self.newline}') | ||
|
|
||
| with self.code.indent(): | ||
| self.generate_args_define() | ||
| if self.validation: | ||
| self.writeline(f'int n_call = atoi(argv[1]){self.ending}{self.newline}') | ||
| self.load_arg() | ||
| self.writeline(self.newline) | ||
|
|
||
|
|
@@ -139,7 +132,6 @@ def generate_wrapper_file(self, path, name): | |
|
|
||
| self.write_header() | ||
| self.generate_kernel_declare() | ||
| self.generate_args_define() | ||
|
|
||
| if self.validation: | ||
| self.generate_load_dump_fn() | ||
|
|
||
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.
zero_inplace_batching_rule는 무엇인가요?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.
이 부분은 커밋에서 지워야 할 것 같습니다.