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

Method var_from_tensor_shape

src/core/impl/graph/helper.cpp:422–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422SymbolVar cg::var_from_tensor_shape(
423 ComputingGraph& graph, const OperatorNodeConfig& config, const char* opr_name,
424 const TensorShape& shape) {
425 auto cn = config.get_single_comp_node();
426 mgb_throw_if(
427 !cn.valid(), GraphError, "must specify comp node in %s config", opr_name);
428 DeviceTensorND dv;
429 copy_shape_to_tensor_value(dv, shape);
430 HostTensorND hv{cn};
431 hv.copy_from(dv);
432 return opr::ImmutableTensor::make(graph, hv);
433}
434
435/* =================== DepOprIter =================== */
436void cg::DepOprIter::push_stack(OperatorNodeBase* opr) {

Callers

nothing calls this directly

Calls 4

get_single_comp_nodeMethod · 0.80
makeFunction · 0.70
validMethod · 0.45
copy_fromMethod · 0.45

Tested by

no test coverage detected