Skip to content

Commit

Permalink
Merge branch 'master' into squeeze_v15_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
barnasm1 authored Oct 31, 2024
2 parents bcfd4d2 + 44b86a8 commit f4ca4fb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
10 changes: 6 additions & 4 deletions samples/cpp/common/utils/src/args_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
void readInputFilesArguments(std::vector<std::string>& files, const std::string& arg) {
struct stat sb;
if (stat(arg.c_str(), &sb) != 0) {
slog::warn << "File " << arg << " cannot be opened!" << slog::endl;
return;
throw std::invalid_argument(arg + " file or directory not found.");
}
if (S_ISDIR(sb.st_mode)) {
struct CloseDir {
Expand All @@ -43,17 +42,20 @@ void readInputFilesArguments(std::vector<std::string>& files, const std::string&
using Dir = std::unique_ptr<DIR, CloseDir>;
Dir dp(opendir(arg.c_str()));
if (dp == nullptr) {
slog::warn << "Directory " << arg << " cannot be opened!" << slog::endl;
return;
throw std::invalid_argument(arg + " directory cannot be opened!");
}

struct dirent* ep;
size_t files_size = files.size();
while (nullptr != (ep = readdir(dp.get()))) {
std::string fileName = ep->d_name;
if (fileName == "." || fileName == "..")
continue;
files.push_back(arg + "/" + ep->d_name);
}
if (files.size() == files_size) {
throw std::invalid_argument("No files were found in directory " + arg);
}
} else {
files.push_back(arg);
}
Expand Down
8 changes: 4 additions & 4 deletions src/bindings/python/src/openvino/runtime/opset13/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from openvino.runtime.op import Constant, Result
from openvino.runtime.opset1 import convert_like
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.decorators import binary_op, nameable_op, unary_op
from openvino.runtime.utils.decorators import binary_op, nameable_op, unary_op, overloading
from openvino.runtime.utils.types import (
NumericData,
NodeInput,
Expand Down Expand Up @@ -271,7 +271,7 @@ def scaled_dot_product_attention(
return _get_node_factory_opset13().create("ScaledDotProductAttention", inputs, attributes)


@singledispatch
@overloading(Union[NumericData, np.number, bool, np.bool_, list], Union[NumericType, Type], Optional[str], bool) # type: ignore
@nameable_op
def constant(
value: Union[NumericData, np.number, bool, np.bool_, list],
Expand Down Expand Up @@ -339,9 +339,9 @@ def display_shared_memory_warning(warning_message: str) -> None:
return Constant(_value, shared_memory=_shared_memory)


@constant.register
@overloading(Tensor, bool, Optional[str]) # type: ignore
@nameable_op
def _(
def constant( # noqa: F811
tensor: Tensor,
shared_memory: bool = False,
name: Optional[str] = None,
Expand Down
6 changes: 3 additions & 3 deletions src/bindings/python/tests/test_graph/test_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_init_with_array(src_dtype, dst_dtype, shared_flag, data_getter):
data = np.ascontiguousarray(data)

# Create constant from based on numpy dtype or openvino type
ov_const = ops.constant(data, dtype=dst_dtype, shared_memory=shared_flag)
ov_const = ops.constant(data, dst_dtype, shared_memory=shared_flag)

# Check shape and element type of Constant class
assert isinstance(ov_const, Constant)
Expand Down Expand Up @@ -842,7 +842,7 @@ def test_get_data_casting_bf16(src_dtype, dst_dtype, copy_flag):
)
def test_get_data_casting_packed(src_dtype, ov_type, dst_dtype, copy_flag):
data = np.array([[0, 0, 0, 0, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1]], dtype=src_dtype)
ov_const = ops.constant(data, dtype=ov_type)
ov_const = ops.constant(value=data, dtype=ov_type)
arr = ov_const.get_data(dtype=dst_dtype, copy=copy_flag)

if dst_dtype is None:
Expand All @@ -867,7 +867,7 @@ def test_const_from_tensor(shared_flag):
shape = [1, 3, 32, 32]
arr = np.ones(shape).astype(np.float32)
ov_tensor = Tensor(arr, shape, Type.f32)
ov_const = ops.constant(ov_tensor, shared_memory=shared_flag)
ov_const = ops.constant(tensor=ov_tensor, shared_memory=shared_flag)

assert isinstance(ov_const, Constant)
assert np.all(list(ov_const.shape) == shape)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void ov::npuw::JustInferRequest::bind_global_parameters(std::size_t idx) {
LOG_BLOCK();
if (!is_spatial_param(sub_in_idx)) {
// Input parameter is non-spatial, do normal handling
if (do_copy || m_input_allocated.count(g_tnsr->data()) == 0) {
if (m_input_allocated.count(g_tnsr->data()) == 0 && do_copy) {
LOG_DEBUG("Will be copied");
copy_list.emplace_back(g_tnsr, s_port);
} else {
Expand Down

0 comments on commit f4ca4fb

Please sign in to comment.