MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / TensorValue

Function TensorValue

dnn/test/common/checker.h:435–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433
434template <typename T, typename U>
435TensorND TensorValue(
436 const TensorShape& shape, T dtype, std::initializer_list<U> values) {
437 TensorLayout layout{shape, dtype};
438 auto buf = static_cast<dt_byte*>(malloc(layout.span().dist_byte()));
439 TensorND tensor{buf, layout};
440 megdnn_assert(
441 values.size() == tensor.layout.total_nr_elems(), "%zu == %zu",
442 values.size(), tensor.layout.total_nr_elems());
443 auto ptr = tensor.ptr<typename DTypeTrait<T>::ctype>();
444 for (const auto& v : values) {
445 *ptr++ = typename DTypeTrait<T>::ctype(v);
446 }
447 return tensor;
448}
449
450template <typename T, typename U>
451TensorND TensorValueLowbit4(const TensorShape& shape, T dtype, std::vector<U> values) {

Callers 15

TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85

Calls 4

dist_byteMethod · 0.80
spanMethod · 0.80
sizeMethod · 0.45
total_nr_elemsMethod · 0.45

Tested by

no test coverage detected