Skip to content

Instantly share code, notes, and snippets.

View cako's full-sized avatar
🐢

Carlos da Costa cako

🐢
View GitHub Profile
# Decorator to monitor memory of CUDA kernels
# Good read:
# https://github.com/numba/nvidia-cuda-tutorial/#session-5-memory-management
import gc
import numpy as np
from numba import cuda
from typing import Tuple
import numpy as np
from numpy.core.multiarray import normalize_axis_index
from numpy.typing import NDArray
def sobel(arr: NDArray, axes: Tuple[int, int] = (-2, -1)) -> NDArray:
"""Compute the Sobel filter of an image
import numpy as np
import pytest
# Test multiple dtypes at once
@pytest.mark.parametrize(
"dtype", ["int8", "int16", "float16", "float32", "float64", "float128"]
)
def test_zero(dtype):
# Set random seed
# In-Place Memory Pinning in PyTorch
# See # https://github.com/pytorch/pytorch/issues/32167#issuecomment-753551842
#
# Copyright 2023 Carlos Alberto da Costa Filho <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the “Software”), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is