parent
14f9a6e31c
commit
4508134ceb
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "ir/meta_tensor.h"
|
||||
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "pipeline/static_analysis/abstract_value.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace tensor {
|
||||
abstract::AbstractBasePtr MetaTensor::ToAbstract() {
|
||||
auto tens = shared_from_base<MetaTensor>();
|
||||
auto dtype = tens->Dtype();
|
||||
if (!IsSubType(dtype, kNumber)) {
|
||||
MS_LOG(EXCEPTION) << "Expect MetaTensor type kNumber but got: " << dtype->ToString() << ".";
|
||||
}
|
||||
auto tensor_shape = tens->shape();
|
||||
auto abs_tensor = std::make_shared<abstract::AbstractTensor>(dtype, tensor_shape);
|
||||
abs_tensor->set_value(shared_from_base<MetaTensor>());
|
||||
return abs_tensor;
|
||||
}
|
||||
} // namespace tensor
|
||||
} // namespace mindspore
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "minnie/tensor_minnie.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace tensor {
|
||||
TensorMinnie &TensorMinnie::operator=(const TensorMinnie &tensor) {
|
||||
if (&tensor == this) {
|
||||
return *this;
|
||||
}
|
||||
this->tensor_addr_ = tensor.tensor_addr();
|
||||
this->tensor_size_ = tensor.tensor_size();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool TensorMinnie::operator==(const TensorMinnie &tensor) {
|
||||
return tensor_addr_ == tensor.tensor_addr() && tensor_size_ == tensor.tensor_size();
|
||||
}
|
||||
} // namespace tensor
|
||||
} // namespace mindspore
|
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MINDSPORE_CCSRC_MINNIE_TENSOR_MINNIE_H_
|
||||
#define MINDSPORE_CCSRC_MINNIE_TENSOR_MINNIE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ir/meta_tensor.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace tensor {
|
||||
// definition of Tensor Minnie
|
||||
class TensorMinnie : public MetaTensor {
|
||||
public:
|
||||
TensorMinnie() : MetaTensor() {}
|
||||
~TensorMinnie() override = default;
|
||||
MS_DECLARE_PARENT(TensorMinnie, MetaTensor)
|
||||
|
||||
// brief Overloads operator = for TensorMinnie.
|
||||
//
|
||||
// The constructed TensorMinnie object has the same type and shape with tensor_base.
|
||||
//
|
||||
// param meta_tensor An existing TensorMinnie object.
|
||||
virtual TensorMinnie &operator=(const TensorMinnie &tensor);
|
||||
|
||||
// brief Compares two TensorMinnie objects.
|
||||
//
|
||||
// The constructed TensorMinnie object has the same type and shape with tensor_base.
|
||||
//
|
||||
// param meta_tensor The TensorMinnie object to be compared.
|
||||
// return true: If having same type and shape, return true, or return false.
|
||||
virtual bool operator==(const TensorMinnie &tensor);
|
||||
|
||||
// brief Get the tensor's size for C++
|
||||
//
|
||||
// return size_t
|
||||
size_t tensor_size() const { return tensor_size_; }
|
||||
|
||||
// brief Set Tensor data size for c++ type
|
||||
void set_tensor_size(size_t size) { tensor_size_ = size; }
|
||||
|
||||
// brief Get Tensor data pointer for c++ type
|
||||
//
|
||||
// return The pointer to the object
|
||||
void *tensor_addr() const { return tensor_addr_; }
|
||||
|
||||
// brief Set Tensor data pointer for c++ type
|
||||
void set_tensor_addr(void *addr) { tensor_addr_ = addr; }
|
||||
|
||||
protected:
|
||||
// brief Data addr of the tensor.
|
||||
void *tensor_addr_;
|
||||
|
||||
// brief Data size of the tensor.
|
||||
size_t tensor_size_;
|
||||
};
|
||||
|
||||
using TensorMinniePtr = std::shared_ptr<TensorMinnie>;
|
||||
|
||||
} // namespace tensor
|
||||
} // namespace mindspore
|
||||
|
||||
#endif // MINDSPORE_CCSRC_MINNIE_TENSOR_MINNIE_H_
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue