@@ -1 +1,33 @@
|
||||
#################################################################################################
|
||||
#
|
||||
# Copyright (c) 2017 - 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#################################################################################################
|
||||
|
||||
CUPY_CACHE_DIR=./ python test_frontend.py
|
||||
|
||||
@@ -29,13 +29,15 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#################################################################################################
|
||||
## Test case for Pytorch
|
||||
|
||||
"""
|
||||
Test cases for frontends
|
||||
"""
|
||||
|
||||
import pycutlass
|
||||
import unittest
|
||||
from pycutlass import *
|
||||
from pycutlass.utils.device import device_cc
|
||||
import torch
|
||||
import cupy as cp
|
||||
|
||||
|
||||
class Test_Frontend(unittest.TestCase):
|
||||
@@ -49,9 +51,7 @@ class Test_Frontend(unittest.TestCase):
|
||||
cutlass.OpClass.Simt, MathOperation.multiply_add
|
||||
)
|
||||
|
||||
# Stages > 2 is supported only for compute capability 80 and beyond
|
||||
stages = 4 if cc >= 80 else 2
|
||||
|
||||
stages = 2
|
||||
tile_description = TileDescription(
|
||||
[128, 128, 8], stages, [2, 4, 1],
|
||||
math_inst
|
||||
@@ -84,6 +84,11 @@ class Test_Frontend(unittest.TestCase):
|
||||
|
||||
|
||||
def test_torch_frontend(self):
|
||||
try:
|
||||
import torch
|
||||
except:
|
||||
self.assertTrue(False, "Unable to import torch")
|
||||
|
||||
problem_size = cutlass.gemm.GemmCoord(512, 256, 128)
|
||||
|
||||
tensor_A = torch.ceil(torch.empty(size=(problem_size.m(), problem_size.k()), dtype=torch.float32, device="cuda").uniform_(-8.5, 7.5))
|
||||
@@ -111,6 +116,11 @@ class Test_Frontend(unittest.TestCase):
|
||||
self.assertTrue(torch.equal(tensor_D, tensor_D_ref))
|
||||
|
||||
def test_cupy_frontend(self):
|
||||
try:
|
||||
import cupy as cp
|
||||
except:
|
||||
self.assertTrue(False, "Unable to import cupy")
|
||||
|
||||
cp.cuda.set_allocator(rmm.rmm_cupy_allocator)
|
||||
|
||||
problem_size = cutlass.gemm.GemmCoord(512, 256, 128)
|
||||
@@ -139,7 +149,6 @@ class Test_Frontend(unittest.TestCase):
|
||||
self.assertTrue(cp.array_equal(tensor_D, tensor_D_ref))
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pycutlass.get_memory_pool(2**32, 2**32)
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user