未验证 提交 c9f53d00 编写于 作者: G gongsu832 提交者: GitHub

Cleanup type cast related warnings (#3801)

Signed-off-by: NGong Su <gong_su@hotmail.com>
Co-authored-by: NAshwini Khade <askhade@microsoft.com>
上级 f98b19a9
......@@ -267,7 +267,7 @@ private:
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(); \
} \
......@@ -276,7 +276,7 @@ private:
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(); \
} \
......
......@@ -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;
......@@ -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())
......
......@@ -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;
}
}
......
......@@ -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>(
......
......@@ -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>(
......
......@@ -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>(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册