diff --git a/dnn/scripts/cutlass_generator/BUILD b/dnn/scripts/cutlass_generator/BUILD index 27c4529e3149c769b028096872f7c896dc0500de..cb54d00c7cc0f2a57bc2e9778022562df0390779 100644 --- a/dnn/scripts/cutlass_generator/BUILD +++ b/dnn/scripts/cutlass_generator/BUILD @@ -4,12 +4,12 @@ genrule( name = "cutlass_kimpls", outs = cutlass_gen_list, cmd = """GEN=$(location //brain/megbrain/dnn/scripts/cutlass_generator:generator.py) - python3 $$GEN --operations gemm --type simt $(@D) - python3 $$GEN --operations gemv --type simt $(@D) - python3 $$GEN --operations deconv --type simt $(@D) - python3 $$GEN --operations conv2d --type simt $(@D) - python3 $$GEN --operations conv2d --type tensorop8816 $(@D) - python3 $$GEN --operations conv2d --type tensorop8832 $(@D) + CUTLASS_WITH_LONG_PATH=true python3 $$GEN --operations gemm --type simt $(@D) + CUTLASS_WITH_LONG_PATH=true python3 $$GEN --operations gemv --type simt $(@D) + CUTLASS_WITH_LONG_PATH=true python3 $$GEN --operations deconv --type simt $(@D) + CUTLASS_WITH_LONG_PATH=true python3 $$GEN --operations conv2d --type simt $(@D) + CUTLASS_WITH_LONG_PATH=true python3 $$GEN --operations conv2d --type tensorop8816 $(@D) + CUTLASS_WITH_LONG_PATH=true python3 $$GEN --operations conv2d --type tensorop8832 $(@D) """, tools = ["//brain/megbrain/dnn/scripts/cutlass_generator:generator.py"], visibility = ["//visibility:public"], diff --git a/dnn/scripts/cutlass_generator/conv2d_operation.py b/dnn/scripts/cutlass_generator/conv2d_operation.py index 7acbc708721909d01b3403efe68e8f925bcf4566..a931a8fbbba060e7eeb83d464ec42a4bb12261c2 100644 --- a/dnn/scripts/cutlass_generator/conv2d_operation.py +++ b/dnn/scripts/cutlass_generator/conv2d_operation.py @@ -531,9 +531,10 @@ void initialize_${configuration_name}(Manifest &manifest) { ################################################################################################### class EmitConvSingleKernelWrapper(): - def __init__(self, kernel_path, operation): + def __init__(self, kernel_path, operation, short_path=False): self.kernel_path = kernel_path self.operation = operation + self.short_path = short_path if self.operation.conv_kind == ConvKind.Fprop: self.instance_emitter = EmitConv2dInstance() @@ -582,7 +583,11 @@ void initialize_${operation_name}(Manifest &manifest) { # def __enter__(self): - self.kernel_path = os.path.join(self.kernel_path, "%s.cu" % self.operation.procedural_name()) + if self.short_path: + self.kernel_path = os.path.join(self.kernel_path, "%s.cu" % GlobalCnt.cnt) + GlobalCnt.cnt += 1 + else: + self.kernel_path = os.path.join(self.kernel_path, "%s.cu" % self.operation.procedural_name()) self.kernel_file = open(self.kernel_path, "w") self.kernel_file.write(self.header_template) return self diff --git a/dnn/scripts/cutlass_generator/gemm_operation.py b/dnn/scripts/cutlass_generator/gemm_operation.py index fd95f0bba2fc394517964357649131250b662074..90b1c9405b2297a5ddec48658d7d723baa68f3bf 100644 --- a/dnn/scripts/cutlass_generator/gemm_operation.py +++ b/dnn/scripts/cutlass_generator/gemm_operation.py @@ -994,7 +994,8 @@ void initialize_${configuration_name}(Manifest &manifest) { ################################################################################################### class EmitGemmSingleKernelWrapper: - def __init__(self, kernel_path, gemm_operation): + def __init__(self, kernel_path, gemm_operation, short_path=False): + self.short_path = short_path self.kernel_path = kernel_path self.operation = gemm_operation @@ -1070,10 +1071,11 @@ void initialize_${operation_name}(Manifest &manifest) { ################################################################################################### class EmitGemvSingleKernelWrapper: - def __init__(self, kernel_path, gemm_operation, wrapper_path): + def __init__(self, kernel_path, gemm_operation, wrapper_path, short_path=False): self.kernel_path = kernel_path self.wrapper_path = wrapper_path self.operation = gemm_operation + self.short_path = short_path self.wrapper_template = """ template void megdnn::cuda::cutlass_wrapper:: @@ -1107,7 +1109,11 @@ ${operation_instance} """ # def __enter__(self): - self.kernel_path = os.path.join(self.kernel_path, "%s.cu" % self.operation.procedural_name()) + if self.short_path: + self.kernel_path = os.path.join(self.kernel_path, "%s.cu" % GlobalCnt.cnt) + GlobalCnt.cnt += 1 + else: + self.kernel_path = os.path.join(self.kernel_path, "%s.cu" % self.operation.procedural_name()) self.kernel_file = open(self.kernel_path, "w") self.kernel_file.write(SubstituteTemplate(self.header_template, { 'wrapper_path': self.wrapper_path, diff --git a/dnn/scripts/cutlass_generator/generator.py b/dnn/scripts/cutlass_generator/generator.py index 73018de6cde5352dbfec8a12e62d6412821e1580..b49aec21f01af3c89d491c49e6dafb480b2eaab8 100644 --- a/dnn/scripts/cutlass_generator/generator.py +++ b/dnn/scripts/cutlass_generator/generator.py @@ -8,6 +8,7 @@ import enum import os.path import shutil import argparse +import platform from library import * from manifest import * @@ -634,7 +635,7 @@ if __name__ == "__main__": default='simt', help="kernel type of CUTLASS kernel generator") gemv_wrapper_path = "src/cuda/matrix_mul/cutlass_matrix_mul_wrapper_batched_gemv_strided.cuinl" - + short_path = (platform.system() == "Windows" or platform.system().find('NT') >= 0) and ('true'!= os.getenv("CUTLASS_WITH_LONG_PATH", default='False').lower()) args = parser.parse_args() if args.operations == "gemm": @@ -648,15 +649,15 @@ if __name__ == "__main__": if args.operations == "conv2d" or args.operations == "deconv": for operation in operations: - with EmitConvSingleKernelWrapper(args.output, operation) as emitter: + with EmitConvSingleKernelWrapper(args.output, operation, short_path) as emitter: emitter.emit() elif args.operations == "gemm": for operation in operations: - with EmitGemmSingleKernelWrapper(args.output, operation) as emitter: + with EmitGemmSingleKernelWrapper(args.output, operation, short_path) as emitter: emitter.emit() elif args.operations == "gemv": for operation in operations: - with EmitGemvSingleKernelWrapper(args.output, operation, gemv_wrapper_path) as emitter: + with EmitGemvSingleKernelWrapper(args.output, operation, gemv_wrapper_path, short_path) as emitter: emitter.emit() if args.operations != "gemv": diff --git a/dnn/scripts/cutlass_generator/library.py b/dnn/scripts/cutlass_generator/library.py index ae6ff246297f17e221cd666f63375aa509a47ecb..0559f28f745358d311c57709356e2ed0ac2502b6 100644 --- a/dnn/scripts/cutlass_generator/library.py +++ b/dnn/scripts/cutlass_generator/library.py @@ -612,3 +612,6 @@ class TensorDescription: self.complex_transform = complex_transform ################################################################################################### + +class GlobalCnt: + cnt = 0 \ No newline at end of file