text stringlengths 0 2.2M |
|---|
impl->set_storage_offset(new_storage_offset);
|
impl->set_sizes_and_strides(new_sizes, new_strides);
|
} else {
|
// Upsizing element size
|
int64_t size_ratio = new_element_size / self_element_size;
|
TORCH_CHECK(
|
(self.size(-1) % size_ratio) == 0,
|
"self.size(-1) must be divisible by ", size_ratio, " to view ",
|
self.scalar_type(), " as ", dtype, " (different element sizes), ",
|
"but got ", self.size(-1));
|
TORCH_CHECK(
|
(self.storage_offset() % size_ratio) == 0,
|
"self.storage_offset() must be divisible by ", size_ratio, " to view ",
|
self.scalar_type(), " as ", dtype, " (different element sizes), but got ",
|
self.storage_offset());
|
auto new_strides = compute_strides_for_view_dtype_upsize(
|
self.strides(), size_ratio, self.scalar_type(), dtype);
|
auto old_sizes = self.sizes();
|
DimVector new_sizes(self.dim());
|
std::copy(old_sizes.begin(), old_sizes.end(), new_sizes.begin());
|
new_sizes[self.dim() - 1] /= size_ratio;
|
auto new_storage_offset = self.storage_offset() / size_ratio;
|
impl->set_storage_offset(new_storage_offset);
|
impl->set_sizes_and_strides(new_sizes, new_strides);
|
}
|
return new_tensor;
|
}
|
}} // namespace at::native
|
/*******************************************************************************
|
* Copyright 2016-2021 Intel Corporation
|
*
|
* 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 <memory>
|
#include "oneapi/dnnl/dnnl.h"
|
#include "c_types_map.hpp"
|
#include "engine.hpp"
|
#include "memory.hpp"
|
#include "nstl.hpp"
|
#include "primitive.hpp"
|
#include "utils.hpp"
|
#if DNNL_CPU_RUNTIME != DNNL_RUNTIME_NONE
|
#include "cpu/cpu_engine.hpp"
|
#endif
|
#if DNNL_GPU_RUNTIME == DNNL_RUNTIME_OCL
|
#include "gpu/ocl/ocl_engine.hpp"
|
#endif
|
#ifdef DNNL_WITH_SYCL
|
#include "sycl/sycl_engine.hpp"
|
#endif
|
namespace dnnl {
|
namespace impl {
|
static inline std::unique_ptr<engine_factory_t> get_engine_factory(
|
engine_kind_t kind, runtime_kind_t runtime_kind) {
|
#if DNNL_CPU_RUNTIME != DNNL_RUNTIME_NONE
|
if (kind == engine_kind::cpu && is_native_runtime(runtime_kind)) {
|
return std::unique_ptr<engine_factory_t>(
|
new cpu::cpu_engine_factory_t());
|
}
|
#endif
|
#if DNNL_GPU_RUNTIME == DNNL_RUNTIME_OCL
|
if (kind == engine_kind::gpu && runtime_kind == runtime_kind::ocl) {
|
return std::unique_ptr<engine_factory_t>(
|
new gpu::ocl::ocl_engine_factory_t(kind));
|
}
|
#endif
|
#ifdef DNNL_WITH_SYCL
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.