Skip to content

Commit

Permalink
Add SearchParameters class (#76)
Browse files Browse the repository at this point in the history
* Initial code done. Some unit testing in place

* All unit tests passing + pre-commit changes

* Fixing codeQL issue

* Fixing pytest issue

* Adding TypeAlias

* Removing python 3.8

* Changes based on pre-review w/ Elias

* Fixing codeQL issue

* Removing type ignore

* Fixing comment
  • Loading branch information
nv-braf committed Nov 18, 2024
1 parent 30ccf32 commit 390907d
Show file tree
Hide file tree
Showing 5 changed files with 994 additions and 0 deletions.
49 changes: 49 additions & 0 deletions genai-perf/genai_perf/config/generate/search_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dataclasses import dataclass
from enum import Enum, auto
from typing import Any, List, Optional, TypeAlias, Union

ParameterList: TypeAlias = List[Union[int, str]]


class ParameterUsage(Enum):
MODEL = auto()
RUNTIME = auto()
BUILD = auto()


class ParameterCategory(Enum):
INTEGER = auto()
EXPONENTIAL = auto()
STR_LIST = auto()
INT_LIST = auto()


@dataclass
class SearchParameter:
"""
A dataclass that holds information about a configuration's search parameter
"""

usage: ParameterUsage
category: ParameterCategory

# This is only applicable to the LIST categories
enumerated_list: Optional[List[Any]] = None

# These are only applicable to INTEGER and EXPONENTIAL categories
min_range: Optional[int] = None
max_range: Optional[int] = None
Loading

0 comments on commit 390907d

Please sign in to comment.