Skip to content

Commit

Permalink
Cleanup type cast related warnings (onnx#3801)
Browse files Browse the repository at this point in the history
Signed-off-by: Gong Su <[email protected]>

Co-authored-by: Ashwini Khade <[email protected]>
  • Loading branch information
gongsu832 and askhade authored Dec 8, 2021
1 parent f98b19a commit c9f53d0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions onnx/common/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ struct Tensor final {
template <> \
inline type* Tensor::data<type>() { \
if (is_raw_data_) { \
return (type*)&raw_data_.data()[0]; \
return (type*)const_cast<char*>(&raw_data_.data()[0]); \
} else { \
return field.data(); \
} \
Expand All @@ -276,7 +276,7 @@ struct Tensor final {
template <> \
inline const type* Tensor::data<type>() const { \
if (is_raw_data_) { \
return (type*)(raw_data_.data()); \
return (const type*)(raw_data_.data()); \
} else { \
return field.data(); \
} \
Expand Down
8 changes: 4 additions & 4 deletions onnx/defs/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct FunctionBodyBuildContextImpl : public FunctionBodyBuildContext {
}
}

const AttributeProto* getAttribute(const std::string& name) const {
const AttributeProto* getAttribute(const std::string& name) const override {
auto iter = attributesByName_.find(name);
if (iter == attributesByName_.end()) {
return nullptr;
Expand All @@ -58,19 +58,19 @@ struct FunctionBodyBuildContextImpl : public FunctionBodyBuildContext {
}
}

bool hasInput(int inputIndex) const {
bool hasInput(int inputIndex) const override {
if (inputIndex >= node_proto_.input_size())
return false;
return node_proto_.input(inputIndex) != "";
}

bool hasOutput(int inputIndex) const {
bool hasOutput(int inputIndex) const override {
if (inputIndex >= node_proto_.output_size())
return false;
return node_proto_.output(inputIndex) != "";
}

const TypeProto* getInputType(int inputIndex) const {
const TypeProto* getInputType(int inputIndex) const override {
if (inputIndex < 0) return nullptr;
size_t j = static_cast<size_t>(inputIndex);
if (j >= input_types_.size())
Expand Down
4 changes: 2 additions & 2 deletions onnx/onnxifi_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ onnxGetExtensionFunctionAddress(
if (strcmp(name, extension_function_list[i]) == 0) {
switch (i) {
case 0:
*function = &onnxGetExtensionFunctionAddress;
*function = (void *)&onnxGetExtensionFunctionAddress;
break;
case 1:
*function = &onnxSetIOAndRunGraph;
*function = (void *)&onnxSetIOAndRunGraph;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion onnx/version_converter/adapters/axes_input_to_attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AxesInputToAttribute : public Adapter {
ONNX_ASSERTM(
raw_data.size() != 0 && raw_data.size() % 8 == 0,
"Raw Data must be non-empty and size must be a multiple of 8");
int64_t* raw = (int64_t*)raw_data.c_str();
int64_t* raw = (int64_t*)const_cast<char*>(raw_data.c_str());
node->is_(
kaxes,
std::vector<int64_t>(
Expand Down
2 changes: 1 addition & 1 deletion onnx/version_converter/adapters/reshape_5_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Reshape_5_4 final : public Adapter {
std::string raw_data = node_ptr->t(kvalue).raw();
ONNX_ASSERTM(raw_data.size() != 0 && raw_data.size() % 8 == 0,
"Raw Data must be non-empty and size must be a multiple of 8");
int64_t* raw = (int64_t*) raw_data.c_str();
int64_t* raw = (int64_t*)const_cast<char*>(raw_data.c_str());
node->is_(
kshape,
std::vector<int64_t>(
Expand Down
2 changes: 1 addition & 1 deletion onnx/version_converter/adapters/split_13_12.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Split_13_12 : public Adapter {
ONNX_ASSERTM(
raw_data.size() != 0 && raw_data.size() % 8 == 0,
"Raw Data must be non-empty and size must be a multiple of 8");
int64_t* raw = (int64_t*)raw_data.c_str();
int64_t* raw = (int64_t*)const_cast<char*>(raw_data.c_str());
node->is_(
ksplit,
std::vector<int64_t>(
Expand Down

0 comments on commit c9f53d0

Please sign in to comment.