Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyi9801 committed Nov 21, 2024
1 parent 50b3152 commit 2abf96e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/webnn/builders/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ inline std::string GetTensorName(const ConstPointerContainer<std::vector<NodeArg
return (input_defs.size() > index) ? std::string(input_defs[index]->Name()) : "";
}

inline std::vector<uint32_t> GetVecUint32FromVecInt64(const std::vector<int64_t>& int64_vec) {
inline std::vector<uint32_t> GetVecUint32FromVecInt64(gsl::span<const int64_t> int64_vec) {
std::vector<uint32_t> uint32_vec;
uint32_vec.reserve(int64_vec.size());
std::transform(int64_vec.begin(), int64_vec.end(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ Status SliceOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, const
std::string input_name;
// This is an optional input, return empty vector.
if (!is_required) {
if (input_defs.size() <= input_idx) return Status::OK();
if (input_defs.size() <= input_idx)
return Status::OK();
input_name = input_defs[input_idx]->Name();
if (input_name.empty()) return Status::OK();
if (input_name.empty())
return Status::OK();
}
input_name = input_defs[input_idx]->Name();
const auto& initializers(model_builder.GetInitializerTensors());
Expand Down Expand Up @@ -112,15 +114,11 @@ Status SliceOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, const

emscripten::val output = reverse_output;
if (is_slice_required) {
std::vector<uint32_t> starts(rank);
std::vector<uint32_t> starts = GetVecUint32FromVecInt64(compute_metadata.starts_);
std::vector<uint32_t> steps = GetVecUint32FromVecInt64(compute_metadata.steps_);;
std::vector<uint32_t> sizes(rank);
std::vector<uint32_t> steps(rank);
std::transform(compute_metadata.starts_.cbegin(), compute_metadata.starts_.cend(), starts.begin(),
[](int64_t i) { return SafeInt<uint32_t>(i); });
std::transform(compute_metadata.ends_.cbegin(), compute_metadata.ends_.cend(), compute_metadata.starts_.cbegin(),

Check warning on line 120 in onnxruntime/core/providers/webnn/builders/impl/slice_op_builder.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Add #include <algorithm> for transform [build/include_what_you_use] [4] Raw Output: onnxruntime/core/providers/webnn/builders/impl/slice_op_builder.cc:120: Add #include <algorithm> for transform [build/include_what_you_use] [4]
sizes.begin(), [](int64_t i, int64_t j) { return SafeInt<uint32_t>(i - j); });
std::transform(compute_metadata.steps_.cbegin(), compute_metadata.steps_.cend(), steps.begin(),
[](int64_t i) { return SafeInt<uint32_t>(i); });

emscripten::val options = emscripten::val::object();
options.set("strides", emscripten::val::array(steps));
Expand Down

0 comments on commit 2abf96e

Please sign in to comment.