Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions beginner_source/torchtext_custom_dataset_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
* 문장에 변환 적용하기
* 버킷 배치 처리

다음 영어에서 독일어 번역을 수행할 수 있는 모델을 훈련하기 위해 데이터셋을 준비해야 한다고 가정해 보겠습니다.

영어에서 독일어 번역을 수행할 수 있는 모델을 훈련하기 위해 데이터셋을 준비해야 한다고 가정해 보겠습니다.
`Tatoeba Project <https://tatoeba.org/en>`_가 제공하는 탭으로 구분된 독일어-영어 문장 쌍을 사용하겠습니다.
이 데이터는 `다운로드 링크 <https://www.manythings.org/anki/deu-eng.zip>`__ 에서 받을 수 있습니다.

Expand Down Expand Up @@ -83,7 +84,7 @@
# 위의 코드 블록에서는 다음과 같은 작업을 수행하고 있습니다
#
# 1. 2번째 줄에서 파일 이름의 반복가능한 객체를 생성하고 있습니다
# 2. 3번째 줄에서 해당 반복가능한 객체 `FileOpener`에 전달하고,
# 2. 3번째 줄에서 해당 반복가능한 객체를 `FileOpener`에 전달하고,
# 파일을 읽기 모드로 열게 됩니다.
# 3. 4번째 줄에서 해당 파일을 파싱하는 함수를 호출합니다.
# 해당 함수는 탭으로 구분된 파일의 각각 줄(row)이 있는 반복 가능한 튜플 객체를 리턴합니다.
Expand Down Expand Up @@ -330,7 +331,7 @@ def separateSourceTarget(sequence_pairs):
# %%
# 이제 원하는 데이터를 얻었습니다
#
# 페딩
# 패딩
# -------
# 앞서 설명한 것처럼 어휘를 구축할 때, 배치에서 모든 시퀀스를 동일한 길이로 만들기 위해
# 짧은 문장은 패딩하게 됩니다. 패딩은 다음과 같이 수행할 수 있습니다.
Expand Down
52 changes: 28 additions & 24 deletions recipes_source/torch_logs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
(beta) Using TORCH_LOGS python API with torch.compile
(beta) torch.compile과 함께 TORCH_LOGS 파이썬 API 사용하기
==========================================================================================
**Author:** `Michael Lazos <https://github.com/mlazos>`_
**저자:** `Michael Lazos <https://github.com/mlazos>`_
**번역:** `장효영 <https://github.com/hyoyoung>`_
"""

import logging
Expand All @@ -10,29 +11,33 @@
#
# This tutorial introduces the ``TORCH_LOGS`` environment variable, as well as the Python API, and
# demonstrates how to apply it to observe the phases of ``torch.compile``.
# 이 튜토리얼에서는 ``TORCH_LOGS`` 환경 변수와 함께 Python API를 소개하고,
# 이를 적용하여 ``torch.compile``의 단계를 관찰하는 방법을 보여줍니다.
#
# .. note::
#
# This tutorial requires PyTorch 2.2.0 or later.
# 이 튜토리얼에는 PyTorch 2.2.0 이상 버전이 필요합니다.
#
#


######################################################################
# Setup
# 설정
# ~~~~~~~~~~~~~~~~~~~~~
# In this example, we'll set up a simple Python function which performs an elementwise
# add and observe the compilation process with ``TORCH_LOGS`` Python API.
# 이 예제에서는 요소별 덧셈을 수행하는 간단한 파이썬 함수를 설정하고
# ``TORCH_LOGS`` 파이썬 API를 사용하여 컴파일 프로세스를 관찰해 보겠습니다.
#
# .. note::
#
# There is also an environment variable ``TORCH_LOGS``, which can be used to
# change logging settings at the command line. The equivalent environment
# variable setting is shown for each example.
# 명령줄에서 로깅 설정을 변경하는 데 사용할 수 있는
# 환경 변수 ``TORCH_LOGS``도 있습니다. 각 예제에 해당하는
# 환경 변수 설정이 표시되어 있습니다.

import torch

# exit cleanly if we are on a device that doesn't support torch.compile
# torch.compile을 지원하지 않는 기기인 경우 완전히 종료합니다.
if torch.cuda.get_device_capability() < (7, 0):
print("Skipping because torch.compile is not supported on this device.")
else:
Expand All @@ -45,52 +50,51 @@ def fn(x, y):
inputs = (torch.ones(2, 2, device="cuda"), torch.zeros(2, 2, device="cuda"))


# print separator and reset dynamo
# between each example
# 각 예제 사이의 구분 기호를 출력하고 dynamo를 reset합니다
def separator(name):
print(f"==================={name}=========================")
torch._dynamo.reset()


separator("Dynamo Tracing")
# View dynamo tracing
# dynamo tracing 보기
# TORCH_LOGS="+dynamo"
torch._logging.set_logs(dynamo=logging.DEBUG)
fn(*inputs)

separator("Traced Graph")
# View traced graph
# traced 그래프 보기
# TORCH_LOGS="graph"
torch._logging.set_logs(graph=True)
fn(*inputs)

separator("Fusion Decisions")
# View fusion decisions
# fusion decision 보기
# TORCH_LOGS="fusion"
torch._logging.set_logs(fusion=True)
fn(*inputs)

separator("Output Code")
# View output code generated by inductor
# inductor가 생성한 결과 코드 보기
# TORCH_LOGS="output_code"
torch._logging.set_logs(output_code=True)
fn(*inputs)

separator("")

######################################################################
# Conclusion
# 결론
# ~~~~~~~~~~
#
# In this tutorial we introduced the TORCH_LOGS environment variable and python API
# by experimenting with a small number of the available logging options.
# To view descriptions of all available options, run any python script
# which imports torch and set TORCH_LOGS to "help".
# 이 튜토리얼에서는 사용 가능한 몇 가지 로깅 옵션을 실험하여
# TORCH_LOGS 환경 변수와 Python API를 소개했습니다.
# 사용 가능한 모든 옵션에 대한 설명을 보려면
# 파이썬 스크립트에서 import torch를 실행하고 TORCH_LOGS를 "help"로 설정하세요.
#
# Alternatively, you can view the `torch._logging documentation`_ to see
# descriptions of all available logging options.
# 다른 방법으로는, `torch._logging 문서`_ 를 보면,
# 사용 가능한 모든 로깅 옵션에 대한 설명을 확인할 수 있습니다.
#
# For more information on torch.compile, see the `torch.compile tutorial`_.
# torch.compile에 관한 더 많은 정보는, `torch.compile 튜토리얼`_를 보세요.
#
# .. _torch._logging documentation: https://pytorch.org/docs/main/logging.html
# .. _torch.compile tutorial: https://tutorials.pytorch.kr/intermediate/torch_compile_tutorial.html
# .. _torch._logging 문서: https://pytorch.org/docs/main/logging.html
# .. _torch.compile 튜토리얼: https://tutorials.pytorch.kr/intermediate/torch_compile_tutorial.html