MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / ConcatFile

Function ConcatFile

dnn/scripts/cutlass_generator/generator.py:1898–2096  ·  view source on GitHub ↗
(
    split_number: int,
    file_path: str,
    operations: str,
    type: str,
    head: str,
    required_cuda_ver_major: str,
    required_cuda_ver_minor: str,
    epilogue: str,
    wrapper_path=None,
)

Source from the content-addressed store, hash-verified

1896# wrapper_path - wrapper path
1897################################################################################
1898def ConcatFile(
1899 split_number: int,
1900 file_path: str,
1901 operations: str,
1902 type: str,
1903 head: str,
1904 required_cuda_ver_major: str,
1905 required_cuda_ver_minor: str,
1906 epilogue: str,
1907 wrapper_path=None,
1908):
1909 import os
1910
1911 meragefiledir = file_path
1912 filenames = os.listdir(meragefiledir)
1913 # filter file
1914 if "tensorop" in type:
1915 sub_string_1 = "tensorop"
1916 sub_string_2 = type[8:]
1917 else:
1918 sub_string_1 = sub_string_2 = "simt"
1919 if "dwconv2d_" in operations:
1920 filtered_operations = operations[:2] + operations[9:]
1921 if "rrconv2d_" in operations:
1922 filtered_operations = operations[:2] + operations[9:]
1923 elif ("conv2d" in operations) or ("deconv" in operations):
1924 filtered_operations = "cutlass"
1925 else:
1926 filtered_operations = operations
1927 # get the file list number
1928 file_list = {}
1929 file_list[operations + type] = 0
1930 for filename in filenames:
1931 if (
1932 (filtered_operations in filename)
1933 and (sub_string_1 in filename)
1934 and (sub_string_2 in filename)
1935 and ("all_" not in filename)
1936 ):
1937 file_list[operations + type] += 1
1938 # concat file for linux
1939 flag_1 = 0
1940 flag_2 = 0
1941 for filename in filenames:
1942 if (
1943 (filtered_operations in filename)
1944 and (sub_string_1 in filename)
1945 and (sub_string_2 in filename)
1946 and ("all_" not in filename)
1947 ):
1948 flag_1 += 1
1949 filepath = meragefiledir + "/" + filename
1950 if (flag_1 >= flag_2 * (file_list[operations + type] / split_number)) and (
1951 flag_1 <= (flag_2 + 1) * (file_list[operations + type] / split_number)
1952 ):
1953 file = open(
1954 file_path + "/{}_{}_{}.cu".format(operations, type, flag_2), "a"
1955 )

Callers 1

generator.pyFile · 0.85

Calls 6

SubstituteTemplateFunction · 0.85
strFunction · 0.85
formatMethod · 0.45
writeMethod · 0.45
removeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected